diff --git a/src/libslic3r/EdgeGrid.hpp b/src/libslic3r/EdgeGrid.hpp index 81517a5c4b..6a9f482a1d 100644 --- a/src/libslic3r/EdgeGrid.hpp +++ b/src/libslic3r/EdgeGrid.hpp @@ -218,10 +218,10 @@ public: bbox.min /= m_resolution; bbox.max /= m_resolution; // Trim with the cells. - bbox.min.x() = std::max(bbox.min.x(), 0); - bbox.min.y() = std::max(bbox.min.y(), 0); - bbox.max.x() = std::min(bbox.max.x(), (coord_t)m_cols - 1); - bbox.max.y() = std::min(bbox.max.y(), (coord_t)m_rows - 1); + bbox.min.x() = std::max(bbox.min.x(), 0); + bbox.min.y() = std::max(bbox.min.y(), 0); + bbox.max.x() = std::min(bbox.max.x(), (coord_t)m_cols - 1); + bbox.max.y() = std::min(bbox.max.y(), (coord_t)m_rows - 1); for (coord_t iy = bbox.min.y(); iy <= bbox.max.y(); ++ iy) for (coord_t ix = bbox.min.x(); ix <= bbox.max.x(); ++ ix) if (! visitor(iy, ix)) diff --git a/src/libslic3r/MeshBoolean.cpp b/src/libslic3r/MeshBoolean.cpp index 6c5418fd4e..92ffdc67b8 100644 --- a/src/libslic3r/MeshBoolean.cpp +++ b/src/libslic3r/MeshBoolean.cpp @@ -29,7 +29,7 @@ TriangleMesh eigen_to_triangle_mesh(const EigenMesh &emesh) auto &VC = emesh.first; auto &FC = emesh.second; Pointf3s points(size_t(VC.rows())); - std::vector facets(size_t(FC.rows())); + std::vector facets(size_t(FC.rows())); for (Eigen::Index i = 0; i < VC.rows(); ++i) points[size_t(i)] = VC.row(i); diff --git a/src/libslic3r/Point.hpp b/src/libslic3r/Point.hpp index dced5c02a7..e095f1c757 100644 --- a/src/libslic3r/Point.hpp +++ b/src/libslic3r/Point.hpp @@ -24,7 +24,9 @@ typedef Eigen::Matrix Vec2crd; typedef Eigen::Matrix Vec3crd; typedef Eigen::Matrix Vec2i; typedef Eigen::Matrix Vec3i; +typedef Eigen::Matrix Vec2i32; typedef Eigen::Matrix Vec2i64; +typedef Eigen::Matrix Vec3i32; typedef Eigen::Matrix Vec3i64; // Vector types with a double coordinate base type. @@ -53,12 +55,12 @@ typedef Eigen::Transform Transform3d inline bool operator<(const Vec2d &lhs, const Vec2d &rhs) { return lhs(0) < rhs(0) || (lhs(0) == rhs(0) && lhs(1) < rhs(1)); } +inline int32_t cross2(const Vec2i32 &v1, const Vec2i32 &v2) { return v1(0) * v2(1) - v1(1) * v2(0); } inline int64_t cross2(const Vec2i64 &v1, const Vec2i64 &v2) { return v1(0) * v2(1) - v1(1) * v2(0); } -inline coord_t cross2(const Vec2crd &v1, const Vec2crd &v2) { return v1(0) * v2(1) - v1(1) * v2(0); } inline float cross2(const Vec2f &v1, const Vec2f &v2) { return v1(0) * v2(1) - v1(1) * v2(0); } inline double cross2(const Vec2d &v1, const Vec2d &v2) { return v1(0) * v2(1) - v1(1) * v2(0); } -inline Vec2crd to_2d(const Vec3crd &pt3) { return Vec2crd(pt3(0), pt3(1)); } +inline Vec2i32 to_2d(const Vec2i32 &pt3) { return Vec2i32(pt3(0), pt3(1)); } inline Vec2i64 to_2d(const Vec3i64 &pt3) { return Vec2i64(pt3(0), pt3(1)); } inline Vec2f to_2d(const Vec3f &pt3) { return Vec2f (pt3(0), pt3(1)); } inline Vec2d to_2d(const Vec3d &pt3) { return Vec2d (pt3(0), pt3(1)); } @@ -89,8 +91,8 @@ public: typedef coord_t coord_type; Point() : Vec2crd(0, 0) {} - Point(coord_t x, coord_t y) : Vec2crd(x, y) {} - Point(int64_t x, int64_t y) : Vec2crd(coord_t(x), coord_t(y)) {} // for Clipper + Point(int32_t x, int32_t y) : Vec2crd(coord_t(x), coord_t(y)) {} + Point(int64_t x, int64_t y) : Vec2crd(coord_t(x), coord_t(y)) {} Point(double x, double y) : Vec2crd(coord_t(lrint(x)), coord_t(lrint(y))) {} Point(const Point &rhs) { *this = rhs; } explicit Point(const Vec2d& rhs) : Vec2crd(coord_t(lrint(rhs.x())), coord_t(lrint(rhs.y()))) {} diff --git a/src/libslic3r/SLA/Common.cpp b/src/libslic3r/SLA/Common.cpp index d2aac18fda..9945ed7faf 100644 --- a/src/libslic3r/SLA/Common.cpp +++ b/src/libslic3r/SLA/Common.cpp @@ -228,7 +228,7 @@ void to_eigen_mesh(const TriangleMesh &tmesh, Eigen::MatrixXd &V, Eigen::MatrixX void to_triangle_mesh(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, TriangleMesh &out) { Pointf3s points(size_t(V.rows())); - std::vector facets(size_t(F.rows())); + std::vector facets(size_t(F.rows())); for (Eigen::Index i = 0; i < V.rows(); ++i) points[size_t(i)] = V.row(i); diff --git a/src/libslic3r/SLA/SupportTreeBuilder.cpp b/src/libslic3r/SLA/SupportTreeBuilder.cpp index d385e98a29..cf6e7e0206 100644 --- a/src/libslic3r/SLA/SupportTreeBuilder.cpp +++ b/src/libslic3r/SLA/SupportTreeBuilder.cpp @@ -48,9 +48,8 @@ Contour3D sphere(double rho, Portion portion, double fa) { vertices.emplace_back(Vec3d(b(0), b(1), z)); if (sbegin == 0) - facets.emplace_back((i == 0) ? - Vec3crd(coord_t(ring.size()), 0, 1) : - Vec3crd(id - 1, 0, id)); + (i == 0) ? facets.emplace_back(coord_t(ring.size()), 0, 1) : + facets.emplace_back(id - 1, 0, id); ++id; } @@ -66,12 +65,11 @@ Contour3D sphere(double rho, Portion portion, double fa) { auto id_ringsize = coord_t(id - int(ring.size())); if (i == 0) { // wrap around - facets.emplace_back(Vec3crd(id - 1, id, - id + coord_t(ring.size() - 1))); - facets.emplace_back(Vec3crd(id - 1, id_ringsize, id)); + facets.emplace_back(id - 1, id, id + coord_t(ring.size() - 1) ); + facets.emplace_back(id - 1, id_ringsize, id); } else { - facets.emplace_back(Vec3crd(id_ringsize - 1, id_ringsize, id)); - facets.emplace_back(Vec3crd(id - 1, id_ringsize - 1, id)); + facets.emplace_back(id_ringsize - 1, id_ringsize, id); + facets.emplace_back(id - 1, id_ringsize - 1, id); } id++; } @@ -85,10 +83,10 @@ Contour3D sphere(double rho, Portion portion, double fa) { auto id_ringsize = coord_t(id - int(ring.size())); if (i == 0) { // third vertex is on the other side of the ring. - facets.emplace_back(Vec3crd(id - 1, id_ringsize, id)); + facets.emplace_back(id - 1, id_ringsize, id); } else { auto ci = coord_t(id_ringsize + coord_t(i)); - facets.emplace_back(Vec3crd(ci - 1, ci, id)); + facets.emplace_back(ci - 1, ci, id); } } } diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp index ee5e96f3d8..651ccdd486 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -42,7 +42,9 @@ namespace Slic3r { -TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector& facets) : repaired(false) +template +TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector &facets) : + repaired(false) { stl_file &stl = this->stl; stl.stats.type = inmemory; @@ -70,6 +72,9 @@ TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector& f stl_get_size(&stl); } +template TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector &facets); +template TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector &facets); + TriangleMesh::TriangleMesh(const indexed_triangle_set &M) { stl.stats.type = inmemory; diff --git a/src/libslic3r/TriangleMesh.hpp b/src/libslic3r/TriangleMesh.hpp index bd872a975a..15b8899dab 100644 --- a/src/libslic3r/TriangleMesh.hpp +++ b/src/libslic3r/TriangleMesh.hpp @@ -22,7 +22,7 @@ class TriangleMesh { public: TriangleMesh() : repaired(false) {} - TriangleMesh(const Pointf3s &points, const std::vector &facets); + template TriangleMesh(const Pointf3s &points, const std::vector &facets); explicit TriangleMesh(const indexed_triangle_set &M); void clear() { this->stl.clear(); this->its.clear(); this->repaired = false; } bool ReadSTLFile(const char* input_file) { return stl_open(&stl, input_file); } diff --git a/src/libslic3r/libslic3r.h b/src/libslic3r/libslic3r.h index 41d9ac1ff6..ec67e8b0fd 100644 --- a/src/libslic3r/libslic3r.h +++ b/src/libslic3r/libslic3r.h @@ -21,7 +21,7 @@ #include "Technologies.hpp" #include "Semver.hpp" -typedef int32_t coord_t; +typedef int64_t coord_t; typedef double coordf_t; //FIXME This epsilon value is used for many non-related purposes: @@ -33,6 +33,7 @@ typedef double coordf_t; // This scaling generates a following fixed point representation with for a 32bit integer: // 0..4294mm with 1nm resolution // int32_t fits an interval of (-2147.48mm, +2147.48mm) +// with int64_t we don't have to worry anymore about the size of the int. #define SCALING_FACTOR 0.000001 // RESOLUTION, SCALED_RESOLUTION: Used as an error threshold for a Douglas-Peucker polyline simplification algorithm. #define RESOLUTION 0.0125 diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 1e58032d81..c1c60c9d66 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1985,7 +1985,7 @@ void GLCanvas3D::render() // we need to set the mouse's scene position here because the depth buffer // could be invalidated by the following gizmo render methods // this position is used later into on_mouse() to drag the objects - m_mouse.scene_position = _mouse_to_3d(m_mouse.position.cast()); + m_mouse.scene_position = _mouse_to_3d(m_mouse.position.cast()); _render_current_gizmo(); _render_selection_sidebar_hints(); diff --git a/src/slic3r/GUI/GLSelectionRectangle.cpp b/src/slic3r/GUI/GLSelectionRectangle.cpp index a8b69d75a1..10238c41be 100644 --- a/src/slic3r/GUI/GLSelectionRectangle.cpp +++ b/src/slic3r/GUI/GLSelectionRectangle.cpp @@ -41,7 +41,7 @@ namespace GUI { const Transform3d& projection_matrix = camera.get_projection_matrix(); // bounding box created from the rectangle corners - will take care of order of the corners - BoundingBox rectangle(Points{ Point(m_start_corner.cast()), Point(m_end_corner.cast()) }); + BoundingBox rectangle(Points{ Point(m_start_corner.cast()), Point(m_end_corner.cast()) }); // Iterate over all points and determine whether they're in the rectangle. for (unsigned int i = 0; i