Support larger printer sizes by using 64-bit.

SuperSlicer is referenced for some changes.

Co-authored-by: Merill <merill@free.fr>
This commit is contained in:
SoftFever
2024-05-10 23:47:08 +08:00
co-authored by Merill
parent 5bceebdd9d
commit 9b2c2bff1d
87 changed files with 380 additions and 362 deletions
+3 -3
View File
@@ -44,7 +44,7 @@ void BedShape::append_option_line(ConfigOptionsGroupShp optgroup, Parameter para
def.type = coPoints;
def.set_default_value(new ConfigOptionPoints{ Vec2d(200, 200) });
def.min = 0;
def.max = 2147;
def.max = 214700;
def.label = get_option_label(param);
def.tooltip = L("Size in X and Y of the rectangular plate.");
key = "rect_size";
@@ -52,8 +52,8 @@ void BedShape::append_option_line(ConfigOptionsGroupShp optgroup, Parameter para
case Parameter::RectOrigin:
def.type = coPoints;
def.set_default_value(new ConfigOptionPoints{ Vec2d(0, 0) });
def.min = -1073.5;
def.max = 1073.5;
def.min = -107350;
def.max = 107350;
def.label = get_option_label(param);
def.tooltip = L("Distance of the 0,0 G-code coordinate from the front left corner of the rectangle.");
key = "rect_origin";
+3 -3
View File
@@ -11,7 +11,7 @@ using namespace GUI;
Points CameraUtils::project(const Camera & camera,
const std::vector<Vec3d> &points)
{
Vec4i viewport(camera.get_viewport().data());
Vec4i32 viewport(camera.get_viewport().data());
// Convert our std::vector to Eigen dynamic matrix.
Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::DontAlign>
@@ -100,7 +100,7 @@ void CameraUtils::ray_from_ortho_screen_pos(const Camera &camera, const Vec2d &p
assert(camera.get_type() == Camera::EType::Ortho);
Matrix4d modelview = camera.get_view_matrix().matrix();
Matrix4d projection = camera.get_projection_matrix().matrix();
Vec4i viewport(camera.get_viewport().data());
Vec4i32 viewport(camera.get_viewport().data());
igl::unproject(screen_point(camera,position), modelview, projection, viewport, point);
direction = camera.get_dir_forward();
}
@@ -109,7 +109,7 @@ void CameraUtils::ray_from_persp_screen_pos(const Camera &camera, const Vec2d &p
assert(camera.get_type() == Camera::EType::Perspective);
Matrix4d modelview = camera.get_view_matrix().matrix();
Matrix4d projection = camera.get_projection_matrix().matrix();
Vec4i viewport(camera.get_viewport().data());
Vec4i32 viewport(camera.get_viewport().data());
igl::unproject(screen_point(camera, position), modelview, projection, viewport, point);
direction = point - camera.get_position();
}
+1 -1
View File
@@ -8721,7 +8721,7 @@ Vec3d GLCanvas3D::_mouse_to_3d(const Point& mouse_pos, float* z)
}
else {
const Camera& camera = wxGetApp().plater()->get_camera();
const Vec4i viewport(camera.get_viewport().data());
const Vec4i32 viewport(camera.get_viewport().data());
Vec3d out;
igl::unproject(Vec3d(mouse_pos.x(), viewport[3] - mouse_pos.y(), *z), camera.get_view_matrix().matrix(), camera.get_projection_matrix().matrix(), viewport, out);
return out;
+1 -1
View File
@@ -274,7 +274,7 @@ std::string GLGizmoCut3D::get_tooltip() const
bool GLGizmoCut3D::on_mouse(const wxMouseEvent &mouse_event)
{
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2d mouse_pos = mouse_coord.cast<double>();
if (mouse_event.ShiftDown() && mouse_event.LeftDown())
+5 -5
View File
@@ -264,7 +264,7 @@ struct GuiCfg
float max_tooltip_width = 0.f;
// maximal width and height of style image
Vec2i max_style_image_size = Vec2i(0, 0);
Vec2i32 max_style_image_size = Vec2i32(0, 0);
float indent = 0.f;
float input_offset = 0.f;
@@ -274,7 +274,7 @@ struct GuiCfg
ImVec2 text_size;
// maximal size of face name image
Vec2i face_name_size = Vec2i(0, 0);
Vec2i32 face_name_size = Vec2i32(0, 0);
float face_name_texture_offset_x = 0.f;
// maximal texture generate jobs running at once
@@ -1567,7 +1567,7 @@ void GLGizmoEmboss::init_font_name_texture() {
glsafe(::glBindTexture(target, id));
glsafe(::glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
glsafe(::glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
const Vec2i &size = m_gui_cfg->face_name_size;
const Vec2i32 &size = m_gui_cfg->face_name_size;
GLint w = size.x(), h = m_face_names->count_cached_textures * size.y();
std::vector<unsigned char> data(4*w * h, {0});
const GLenum format = GL_RGBA, type = GL_UNSIGNED_BYTE;
@@ -3698,8 +3698,8 @@ GuiCfg create_gui_configuration()
int max_style_image_width = static_cast<int>(std::round(cfg.max_style_name_width/2 - 2 * style.FramePadding.x));
int max_style_image_height = static_cast<int>(std::round(input_height));
cfg.max_style_image_size = Vec2i(max_style_image_width, line_height);
cfg.face_name_size = Vec2i(cfg.input_width, line_height_with_spacing);
cfg.max_style_image_size = Vec2i32(max_style_image_width, line_height);
cfg.face_name_size = Vec2i32(cfg.input_width, line_height_with_spacing);
cfg.face_name_texture_offset_x = cfg.face_name_size.x() + space;
cfg.max_tooltip_width = ImGui::GetFontSize() * 20.0f;
+2 -2
View File
@@ -176,7 +176,7 @@ void GLGizmoFlatten::update_planes()
// This part is still performed in mesh coordinate system.
const int num_of_facets = ch.facets_count();
const std::vector<Vec3f> face_normals = its_face_normals(ch.its);
const std::vector<Vec3i> face_neighbors = its_face_neighbors(ch.its);
const std::vector<Vec3i32> face_neighbors = its_face_neighbors(ch.its);
std::vector<int> facet_queue(num_of_facets, 0);
std::vector<bool> facet_visited(num_of_facets, false);
int facet_queue_cnt = 0;
@@ -199,7 +199,7 @@ void GLGizmoFlatten::update_planes()
int facet_idx = facet_queue[-- facet_queue_cnt];
const stl_normal& this_normal = face_normals[facet_idx];
if (std::abs(this_normal(0) - (*normal_ptr)(0)) < 0.001 && std::abs(this_normal(1) - (*normal_ptr)(1)) < 0.001 && std::abs(this_normal(2) - (*normal_ptr)(2)) < 0.001) {
const Vec3i face = ch.its.indices[facet_idx];
const Vec3i32 face = ch.its.indices[facet_idx];
for (int j=0; j<3; ++j)
m_planes.back().vertices.emplace_back(ch.its.vertices[face[j]].cast<double>());
+1 -1
View File
@@ -87,7 +87,7 @@ bool GLGizmoMeshBoolean::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
bool GLGizmoMeshBoolean::on_mouse(const wxMouseEvent &mouse_event)
{
// wxCoord == int --> wx/types.h
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2d mouse_pos = mouse_coord.cast<double>();
// when control is down we allow scene pan and rotation even when clicking
+5 -5
View File
@@ -910,7 +910,7 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
bool GLGizmoPainterBase::on_mouse(const wxMouseEvent &mouse_event)
{
// wxCoord == int --> wx/types.h
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2d mouse_pos = mouse_coord.cast<double>();
if (mouse_event.Moving()) {
@@ -1365,11 +1365,11 @@ void TriangleSelectorPatch::update_triangles_per_patch()
bool using_wireframe = (m_need_wireframe && wxGetApp().plater()->is_wireframe_enabled() && wxGetApp().plater()->is_show_wireframe()) ? true : false;
auto get_all_touching_triangles = [this](int facet_idx, const Vec3i& neighbors, const Vec3i& neighbors_propagated) -> std::vector<int> {
auto get_all_touching_triangles = [this](int facet_idx, const Vec3i32& neighbors, const Vec3i32& neighbors_propagated) -> std::vector<int> {
assert(facet_idx != -1 && facet_idx < int(m_triangles.size()));
assert(this->verify_triangle_neighbors(m_triangles[facet_idx], neighbors));
std::vector<int> touching_triangles;
Vec3i vertices = { m_triangles[facet_idx].verts_idxs[0], m_triangles[facet_idx].verts_idxs[1], m_triangles[facet_idx].verts_idxs[2] };
Vec3i32 vertices = { m_triangles[facet_idx].verts_idxs[0], m_triangles[facet_idx].verts_idxs[1], m_triangles[facet_idx].verts_idxs[2] };
append_touching_subtriangles(neighbors(0), vertices(1), vertices(0), touching_triangles);
append_touching_subtriangles(neighbors(1), vertices(2), vertices(1), touching_triangles);
append_touching_subtriangles(neighbors(2), vertices(0), vertices(2), touching_triangles);
@@ -1745,14 +1745,14 @@ void TriangleSelectorGUI::update_paint_contour()
m_paint_contour.reset();
GLModel::Geometry init_data;
const std::vector<Vec2i> contour_edges = this->get_seed_fill_contour();
const std::vector<Vec2i32> contour_edges = this->get_seed_fill_contour();
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(2 * contour_edges.size());
init_data.reserve_indices(2 * contour_edges.size());
init_data.color = ColorRGBA::WHITE();
// vertices + indices
unsigned int vertices_count = 0;
for (const Vec2i& edge : contour_edges) {
for (const Vec2i32& edge : contour_edges) {
init_data.add_vertex(m_vertices[edge(0)].v);
init_data.add_vertex(m_vertices[edge(1)].v);
vertices_count += 2;
+1 -1
View File
@@ -360,7 +360,7 @@ private:
mutable float m_cursor_z{0};
mutable double m_height_start_z_in_imgui{0};
mutable bool m_is_set_height_start_z_by_imgui{false};
mutable Vec2i m_height_start_pos{0, 0};
mutable Vec2i32 m_height_start_pos{0, 0};
mutable bool m_is_cursor_in_imgui{false};
BoundingBoxf3 bounding_box() const;
void update_contours(int i, const TriangleMesh& vol_mesh, float cursor_z, float max_z, float min_z) const;
+1 -1
View File
@@ -447,7 +447,7 @@ bool GLGizmoText::gizmo_event(SLAGizmoEventType action, const Vec2d &mouse_posit
bool GLGizmoText::on_mouse(const wxMouseEvent &mouse_event)
{
// wxCoord == int --> wx/types.h
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2d mouse_pos = mouse_coord.cast<double>();
bool control_down = mouse_event.CmdDown();
+1 -1
View File
@@ -571,7 +571,7 @@ bool GLGizmosManager::gizmos_toolbar_on_mouse(const wxMouseEvent &mouse_event) {
static MouseCapture mc;
// wxCoord == int --> wx/types.h
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2d mouse_pos = mouse_coord.cast<double>();
EType gizmo = get_gizmo_from_mouse(mouse_pos);
+3 -3
View File
@@ -2217,7 +2217,7 @@ ImVec2 ImGuiWrapper::suggest_location(const ImVec2 &dialog_size,
offseted_center.y() + diff_norm.y() * move_size.y());
// move offset close to center
Points window_polygon = {offset.cast<int>(),
Points window_polygon = {offset.cast<coord_t>(),
Point(offset.x(), offset.y() + dialog_size.y),
Point(offset.x() + dialog_size.x,
offset.y() + dialog_size.y),
@@ -2227,12 +2227,12 @@ ImVec2 ImGuiWrapper::suggest_location(const ImVec2 &dialog_size,
double allowed_space = 10; // in px
double allowed_space_sq = allowed_space * allowed_space;
Vec2d move_vec = (center - (offset.cast<int>() + half_dialog_size))
Vec2d move_vec = (center - (offset.cast<coord_t>() + half_dialog_size))
.cast<double>();
Vec2d result_move(0, 0);
do {
move_vec = move_vec / 2.;
Point move_point = (move_vec + result_move).cast<int>();
Point move_point = (move_vec + result_move).cast<coord_t>();
Points moved_polygon = window_polygon; // copy
for (Point &p : moved_polygon) p += move_point;
if (Slic3r::intersection(interest, Polygon(moved_polygon)).empty())
@@ -11,7 +11,7 @@
#include <wx/string.h>
#include <wx/fontenc.h>
#include "Job.hpp"
#include "libslic3r/Point.hpp" // Vec2i
#include "libslic3r/Point.hpp" // Vec2i32
namespace Slic3r::GUI {
@@ -32,7 +32,7 @@ struct FontImageData
size_t index;
// Height of each text
// And Limit for width
Vec2i size; // in px
Vec2i32 size; // in px
// bigger value create darker image
// divide value 255
+6 -5
View File
@@ -14,6 +14,7 @@
#include <libslic3r/BuildVolume.hpp> // create object
#include <libslic3r/SLA/ReprojectPointsOnMesh.hpp>
#include "libslic3r/libslic3r.h"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/NotificationManager.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"
@@ -322,9 +323,9 @@ void CreateObjectJob::process(Ctl &ctl)
Points bed_shape_;
bed_shape_.reserve(m_input.bed_shape.size());
for (const Vec2d &p : m_input.bed_shape)
bed_shape_.emplace_back(p.cast<int>());
bed_shape_.emplace_back(p.cast<coord_t>());
Slic3r::Polygon bed(bed_shape_);
if (!bed.contains(bed_coor.cast<int>()))
if (!bed.contains(bed_coor.cast<coord_t>()))
// mouse pose is out of build plate so create object in center of plate
bed_coor = bed.centroid().cast<double>();
@@ -836,7 +837,7 @@ std::vector<BoundingBoxes> create_line_bounds(const ExPolygonsWithIds &shapes, s
template<typename Fnc> TriangleMesh create_mesh_per_glyph(DataBase &input, Fnc was_canceled)
{
// method use square of coord stored into int64_t
static_assert(std::is_same<Point::coord_type, int32_t>());
// static_assert(std::is_same<Point::coord_type, int32_t>());
const EmbossShape &shape = input.create_shape();
if (shape.shapes_with_ids.empty())
return {};
@@ -853,7 +854,7 @@ template<typename Fnc> TriangleMesh create_mesh_per_glyph(DataBase &input, Fnc w
// half of font em size for direction of letter emboss
// double em_2_mm = prop.size_in_mm / 2.; // TODO: fix it
double em_2_mm = 5.;
int32_t em_2_polygon = static_cast<int32_t>(std::round(scale_(em_2_mm)));
coord_t em_2_polygon = static_cast<coord_t>(std::round(scale_(em_2_mm)));
size_t s_i_offset = 0; // shape index offset(for next lines)
indexed_triangle_set result;
@@ -1277,7 +1278,7 @@ indexed_triangle_set cut_surface_to_its(const ExPolygons &shapes, const Transfor
if (is_text_reflected) {
for (SurfaceCut::Contour &c : cut.contours)
std::reverse(c.begin(), c.end());
for (Vec3i &t : cut.indices)
for (Vec3i32 &t : cut.indices)
std::swap(t[0], t[1]);
}
+1 -1
View File
@@ -84,7 +84,7 @@ public:
return Sel(std::min(int(Sel::modelOnly), std::max(0, sel)));
}
Vec2i get_marchsq_windowsize() const override
Vec2i32 get_marchsq_windowsize() const override
{
enum { Accurate, Balanced, Fast };
+1 -1
View File
@@ -27,7 +27,7 @@ public:
indexed_triangle_set mesh;
DynamicPrintConfig profile;
wxString path;
Vec2i win = {2, 2};
Vec2i32 win = {2, 2};
std::string err;
ConfigSubstitutions config_substitutions;
+1 -1
View File
@@ -18,7 +18,7 @@ public:
virtual ~SLAImportJobView() = default;
virtual Sel get_selection() const = 0;
virtual Vec2i get_marchsq_windowsize() const = 0;
virtual Vec2i32 get_marchsq_windowsize() const = 0;
virtual std::string get_path() const = 0;
};
+3 -2
View File
@@ -11,6 +11,7 @@
#include "libslic3r/Model.hpp"
#include "libslic3r/CSGMesh/SliceCSGMesh.hpp"
#include "libslic3r/libslic3r.h"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/Camera.hpp"
@@ -355,8 +356,8 @@ void MeshClipper::recalculate_triangles()
// To prevent overflow after scaling, downscale the input if needed:
double extra_scale = 1.;
int32_t limit = int32_t(std::min(std::numeric_limits<coord_t>::max() / (2. * std::max(1., scale_x)), std::numeric_limits<coord_t>::max() / (2. * std::max(1., scale_y))));
int32_t max_coord = 0;
coord_t limit = coord_t(std::min(std::numeric_limits<coord_t>::max() / (2. * std::max(1., scale_x)), std::numeric_limits<coord_t>::max() / (2. * std::max(1., scale_y))));
coord_t max_coord = 0;
for (const Point& pt : exp.contour)
max_coord = std::max(max_coord, std::max(std::abs(pt.x()), std::abs(pt.y())));
if (max_coord + m_contour_width >= limit)
+2 -2
View File
@@ -488,7 +488,7 @@ namespace {
Vec2d mouse_position(const wxMouseEvent &mouse_event){
// wxCoord == int --> wx/types.h
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
return mouse_coord.cast<double>();
}
@@ -542,7 +542,7 @@ bool start_dragging(const Vec2d &mouse_pos,
// zero point of volume in world coordinate system
Vec3d volume_center = to_world.translation();
// screen coordinate of volume center
Vec2i coor = CameraUtils::project(camera, volume_center);
auto coor = CameraUtils::project(camera, volume_center);
Vec2d mouse_offset = coor.cast<double>() - mouse_pos;
Vec2d mouse_offset_without_sla_shift = mouse_offset;
if (double sla_shift = gl_volume.get_sla_shift_z(); !is_approx(sla_shift, 0.)) {
+2 -2
View File
@@ -209,10 +209,10 @@ GLModel::Geometry create_geometry(const TextLines &lines, float radius, bool is_
if (is_mirrored) {
// change order of indices
for (Vec3i t : its.indices)
for (Vec3i32 t : its.indices)
geometry.add_triangle(t[0], t[2], t[1]);
} else {
for (Vec3i t : its.indices)
for (Vec3i32 t : its.indices)
geometry.add_triangle(t[0], t[1], t[2]);
}
return geometry;
+1 -1
View File
@@ -976,7 +976,7 @@ bool CalibUtils::process_and_store_3mf(Model *model, const DynamicPrintConfig &f
double print_height = full_config.opt_float("printable_height");
double current_width = bedfs[2].x() - bedfs[0].x();
double current_depth = bedfs[2].y() - bedfs[0].y();
Vec3i plate_size;
Vec3i32 plate_size;
plate_size[0] = bedfs[2].x() - bedfs[0].x();
plate_size[1] = bedfs[2].y() - bedfs[0].y();
plate_size[2] = print_height;
+1 -1
View File
@@ -351,7 +351,7 @@ void StyleManager::init_trunc_names(float max_width) {
#include "slic3r/GUI/MainFrame.hpp"
#include "slic3r/GUI/Gizmos/GizmoObjectManipulation.hpp"
void StyleManager::init_style_images(const Vec2i &max_size,
void StyleManager::init_style_images(const Vec2i32 &max_size,
const std::string &text)
{
// check already initialized
+2 -2
View File
@@ -170,7 +170,7 @@ public:
/// </summary>
/// <param name="max_size">Maximal width and height of one style texture</param>
/// <param name="text">Text to render by style</param>
void init_style_images(const Vec2i& max_size, const std::string &text);
void init_style_images(const Vec2i32& max_size, const std::string &text);
void free_style_images();
// access to all managed font styles
@@ -295,7 +295,7 @@ private:
// Keep styles to render
Items styles;
// Maximal width and height in pixels of image
Vec2i max_size;
Vec2i32 max_size;
// Text to render
std::string text;
+1 -1
View File
@@ -151,7 +151,7 @@ std::optional<RaycastManager::Hit> RaycastManager::first_hit(const Vec3d& point,
// Calculate normal from transformed triangle
// NOTE: Anisotropic transformation of normal is not perpendiculat to triangle
const Vec3i tri = hit_mesh->indices(hit_face);
const Vec3i32 tri = hit_mesh->indices(hit_face);
std::array<Vec3d,3> pts;
auto tr = hit_tramsformation->linear();
for (int i = 0; i < 3; ++i)