diff --git a/src/libslic3r/EdgeGrid.hpp b/src/libslic3r/EdgeGrid.hpp index 81517a5c4..6a9f482a1 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 6c5418fd4..66167c720 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); @@ -154,7 +154,7 @@ inline Vec3d to_vec3d(const _EpecMesh::Point &v) template TriangleMesh cgal_to_triangle_mesh(const _Mesh &cgalmesh) { Pointf3s points; - std::vector facets; + std::vector facets; points.reserve(cgalmesh.num_vertices()); facets.reserve(cgalmesh.num_faces()); @@ -166,7 +166,7 @@ template TriangleMesh cgal_to_triangle_mesh(const _Mesh &cgalmesh) for (auto &face : cgalmesh.faces()) { auto vtc = cgalmesh.vertices_around_face(cgalmesh.halfedge(face)); int i = 0; - Vec3crd trface; + Vec3i trface; for (auto v : vtc) trface(i++) = static_cast(v); facets.emplace_back(trface); } diff --git a/src/libslic3r/Point.hpp b/src/libslic3r/Point.hpp index dced5c02a..e095f1c75 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 d2aac18fd..9945ed7fa 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 d385e98a2..cf6e7e020 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 ee5e96f3d..f2deb5cba 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -42,7 +42,7 @@ namespace Slic3r { -TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector& facets) : repaired(false) +TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector &facets) : repaired(false) { stl_file &stl = this->stl; stl.stats.type = inmemory; @@ -600,7 +600,7 @@ TriangleMesh TriangleMesh::convex_hull_3d() const // Let's collect results: Pointf3s dst_vertices; - std::vector facets; + std::vector facets; auto facet_list = qhull.facetList().toStdVector(); for (const orgQhull::QhullFacet& facet : facet_list) { // iterate through facets @@ -1931,22 +1931,18 @@ void TriangleMeshSlicer::cut(float z, TriangleMesh* upper, TriangleMesh* lower) // Generate the vertex list for a cube solid of arbitrary size in X/Y/Z. TriangleMesh make_cube(double x, double y, double z) { - Vec3d pv[8] = { - Vec3d(x, y, 0), Vec3d(x, 0, 0), Vec3d(0, 0, 0), - Vec3d(0, y, 0), Vec3d(x, y, z), Vec3d(0, y, z), - Vec3d(0, 0, z), Vec3d(x, 0, z) - }; - Vec3crd fv[12] = { - Vec3crd(0, 1, 2), Vec3crd(0, 2, 3), Vec3crd(4, 5, 6), - Vec3crd(4, 6, 7), Vec3crd(0, 4, 7), Vec3crd(0, 7, 1), - Vec3crd(1, 7, 6), Vec3crd(1, 6, 2), Vec3crd(2, 6, 5), - Vec3crd(2, 5, 3), Vec3crd(4, 0, 3), Vec3crd(4, 3, 5) - }; - - std::vector facets(&fv[0], &fv[0]+12); - Pointf3s vertices(&pv[0], &pv[0]+8); - - TriangleMesh mesh(vertices ,facets); + TriangleMesh mesh( + { + {x, y, 0}, {x, 0, 0}, {0, 0, 0}, + {0, y, 0}, {x, y, z}, {0, y, z}, + {0, 0, z}, {x, 0, z} + }, + { + {0, 1, 2}, {0, 2, 3}, {4, 5, 6}, + {4, 6, 7}, {0, 4, 7}, {0, 7, 1}, + {1, 7, 6}, {1, 6, 2}, {2, 6, 5}, + {2, 5, 3}, {4, 0, 3}, {4, 3, 5} + }); mesh.repair(); return mesh; } @@ -1959,8 +1955,8 @@ TriangleMesh make_cylinder(double r, double h, double fa) size_t n_steps = (size_t)ceil(2. * PI / fa); double angle_step = 2. * PI / n_steps; - Pointf3s vertices; - std::vector facets; + Pointf3s vertices; + std::vector facets; vertices.reserve(2 * n_steps + 2); facets.reserve(4 * n_steps); @@ -1980,17 +1976,17 @@ TriangleMesh make_cylinder(double r, double h, double fa) vertices.emplace_back(Vec3d(p(0), p(1), 0.)); vertices.emplace_back(Vec3d(p(0), p(1), h)); int id = (int)vertices.size() - 1; - facets.emplace_back(Vec3crd( 0, id - 1, id - 3)); // top - facets.emplace_back(Vec3crd(id, 1, id - 2)); // bottom - facets.emplace_back(Vec3crd(id, id - 2, id - 3)); // upper-right of side - facets.emplace_back(Vec3crd(id, id - 3, id - 1)); // bottom-left of side + facets.emplace_back( 0, id - 1, id - 3); // top + facets.emplace_back(id, 1, id - 2); // bottom + facets.emplace_back(id, id - 2, id - 3); // upper-right of side + facets.emplace_back(id, id - 3, id - 1); // bottom-left of side } // Connect the last set of vertices with the first. int id = (int)vertices.size() - 1; - facets.emplace_back(Vec3crd( 0, 2, id - 1)); - facets.emplace_back(Vec3crd( 3, 1, id)); - facets.emplace_back(Vec3crd(id, 2, 3)); - facets.emplace_back(Vec3crd(id, id - 1, 2)); + facets.emplace_back( 0, 2, id - 1); + facets.emplace_back( 3, 1, id); + facets.emplace_back(id, 2, 3); + facets.emplace_back(id, id - 1, 2); TriangleMesh mesh(std::move(vertices), std::move(facets)); mesh.repair(); @@ -2025,7 +2021,7 @@ TriangleMesh make_sphere(double radius, double fa) } } - std::vector facets; + std::vector facets; facets.reserve(2 * (stackCount - 1) * sectorCount); for (int i = 0; i < stackCount; ++ i) { // Beginning of current stack. @@ -2040,11 +2036,11 @@ TriangleMesh make_sphere(double radius, double fa) int k2_next = k2; if (i != 0) { k1_next = (j + 1 == sectorCount) ? k1_first : (k1 + 1); - facets.emplace_back(Vec3crd(k1, k2, k1_next)); + facets.emplace_back(k1, k2, k1_next); } if (i + 1 != stackCount) { k2_next = (j + 1 == sectorCount) ? k2_first : (k2 + 1); - facets.emplace_back(Vec3crd(k1_next, k2, k2_next)); + facets.emplace_back(k1_next, k2, k2_next); } k1 = k1_next; k2 = k2_next; diff --git a/src/libslic3r/TriangleMesh.hpp b/src/libslic3r/TriangleMesh.hpp index bd872a975..723125aaa 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); + 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 41d9ac1ff..ec67e8b0f 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/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index de56546ac..bf6f23cac 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -535,16 +535,16 @@ int GLVolumeCollection::load_wipe_tower_preview( // We'll now create the box with jagged edge. y-coordinates of the pre-generated model are shifted so that the front // edge has y=0 and centerline of the back edge has y=depth: Pointf3s points; - std::vector facets; + std::vector facets; float out_points_idx[][3] = { { 0, -depth, 0 }, { 0, 0, 0 }, { 38.453f, 0, 0 }, { 61.547f, 0, 0 }, { 100.0f, 0, 0 }, { 100.0f, -depth, 0 }, { 55.7735f, -10.0f, 0 }, { 44.2265f, 10.0f, 0 }, { 38.453f, 0, 1 }, { 0, 0, 1 }, { 0, -depth, 1 }, { 100.0f, -depth, 1 }, { 100.0f, 0, 1 }, { 61.547f, 0, 1 }, { 55.7735f, -10.0f, 1 }, { 44.2265f, 10.0f, 1 } }; int out_facets_idx[][3] = { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 5, 0 }, { 3, 5, 6 }, { 6, 2, 7 }, { 6, 0, 2 }, { 8, 9, 10 }, { 11, 12, 13 }, { 10, 11, 14 }, { 14, 11, 13 }, { 15, 8, 14 }, {8, 10, 14}, {3, 12, 4}, {3, 13, 12}, {6, 13, 3}, {6, 14, 13}, {7, 14, 6}, {7, 15, 14}, {2, 15, 7}, {2, 8, 15}, {1, 8, 2}, {1, 9, 8}, {0, 9, 1}, {0, 10, 9}, {5, 10, 0}, {5, 11, 10}, {4, 11, 5}, {4, 12, 11} }; for (int i = 0; i < 16; ++i) - points.push_back(Vec3d(out_points_idx[i][0] / (100.f / min_width), out_points_idx[i][1] + depth, out_points_idx[i][2])); + points.emplace_back(out_points_idx[i][0] / (100.f / min_width), out_points_idx[i][1] + depth, out_points_idx[i][2]); for (int i = 0; i < 28; ++i) - facets.push_back(Vec3crd(out_facets_idx[i][0], out_facets_idx[i][1], out_facets_idx[i][2])); + facets.emplace_back(out_facets_idx[i][0], out_facets_idx[i][1], out_facets_idx[i][2]); TriangleMesh tooth_mesh(points, facets); // We have the mesh ready. It has one tooth and width of min_width. We will now append several of these together until we are close to @@ -1899,7 +1899,7 @@ void GLModel::render() const bool GLArrow::on_init() { Pointf3s vertices; - std::vector triangles; + std::vector triangles; // bottom face vertices.emplace_back(0.5, 0.0, -0.1); @@ -1965,7 +1965,7 @@ GLCurvedArrow::GLCurvedArrow(unsigned int resolution) bool GLCurvedArrow::on_init() { Pointf3s vertices; - std::vector triangles; + std::vector triangles; double ext_radius = 2.5; double int_radius = 1.5; diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 0465d5df9..a02b2de69 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1955,7 +1955,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 a8b69d75a..10238c41b 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 vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) }; - std::vector facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) }; + std::vector vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} }; + std::vector facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} }; TriangleMesh cube(vertices, facets); cube.repair(); @@ -68,8 +68,8 @@ SCENARIO( "TriangleMesh: Basic mesh statistics") { } GIVEN( "A 20mm cube with one corner on the origin") { - const std::vector vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) }; - const std::vector facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) }; + const std::vector vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} }; + const std::vector facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} }; TriangleMesh cube(vertices, facets); cube.repair(); @@ -121,8 +121,8 @@ SCENARIO( "TriangleMesh: Basic mesh statistics") { SCENARIO( "TriangleMesh: Transformation functions affect mesh as expected.") { GIVEN( "A 20mm cube with one corner on the origin") { - const std::vector vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) }; - const std::vector facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) }; + const std::vector vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} }; + const std::vector facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} }; TriangleMesh cube(vertices, facets); cube.repair(); @@ -184,8 +184,8 @@ SCENARIO( "TriangleMesh: Transformation functions affect mesh as expected.") { SCENARIO( "TriangleMesh: slice behavior.") { GIVEN( "A 20mm cube with one corner on the origin") { - const std::vector vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) }; - const std::vector facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) }; + const std::vector vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} }; + const std::vector facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} }; TriangleMesh cube(vertices, facets); cube.repair(); @@ -205,8 +205,8 @@ SCENARIO( "TriangleMesh: slice behavior.") { } } GIVEN( "A STL with an irregular shape.") { - const std::vector vertices {Vec3d(0,0,0),Vec3d(0,0,20),Vec3d(0,5,0),Vec3d(0,5,20),Vec3d(50,0,0),Vec3d(50,0,20),Vec3d(15,5,0),Vec3d(35,5,0),Vec3d(15,20,0),Vec3d(50,5,0),Vec3d(35,20,0),Vec3d(15,5,10),Vec3d(50,5,20),Vec3d(35,5,10),Vec3d(35,20,10),Vec3d(15,20,10)}; - const std::vector facets {Vec3crd(0,1,2),Vec3crd(2,1,3),Vec3crd(1,0,4),Vec3crd(5,1,4),Vec3crd(0,2,4),Vec3crd(4,2,6),Vec3crd(7,6,8),Vec3crd(4,6,7),Vec3crd(9,4,7),Vec3crd(7,8,10),Vec3crd(2,3,6),Vec3crd(11,3,12),Vec3crd(7,12,9),Vec3crd(13,12,7),Vec3crd(6,3,11),Vec3crd(11,12,13),Vec3crd(3,1,5),Vec3crd(12,3,5),Vec3crd(5,4,9),Vec3crd(12,5,9),Vec3crd(13,7,10),Vec3crd(14,13,10),Vec3crd(8,15,10),Vec3crd(10,15,14),Vec3crd(6,11,8),Vec3crd(8,11,15),Vec3crd(15,11,13),Vec3crd(14,15,13)}; + const std::vector vertices {{0,0,0},{0,0,20},{0,5,0},{0,5,20},{50,0,0},{50,0,20},{15,5,0},{35,5,0},{15,20,0},{50,5,0},{35,20,0},{15,5,10},{50,5,20},{35,5,10},{35,20,10},{15,20,10}}; + const std::vector facets {{0,1,2},{2,1,3},{1,0,4},{5,1,4},{0,2,4},{4,2,6},{7,6,8},{4,6,7},{9,4,7},{7,8,10},{2,3,6},{11,3,12},{7,12,9},{13,12,7},{6,3,11},{11,12,13},{3,1,5},{12,3,5},{5,4,9},{12,5,9},{13,7,10},{14,13,10},{8,15,10},{10,15,14},{6,11,8},{8,11,15},{15,11,13},{14,15,13}}; TriangleMesh cube(vertices, facets); cube.repair(); @@ -294,8 +294,8 @@ SCENARIO( "make_xxx functions produce meshes.") { SCENARIO( "TriangleMesh: split functionality.") { GIVEN( "A 20mm cube with one corner on the origin") { - const std::vector vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) }; - const std::vector facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) }; + const std::vector vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} }; + const std::vector facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} }; TriangleMesh cube(vertices, facets); cube.repair(); @@ -308,8 +308,8 @@ SCENARIO( "TriangleMesh: split functionality.") { } } GIVEN( "Two 20mm cubes, each with one corner on the origin, merged into a single TriangleMesh") { - const std::vector vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) }; - const std::vector facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) }; + const std::vector vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} }; + const std::vector facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} }; TriangleMesh cube(vertices, facets); cube.repair(); @@ -329,8 +329,8 @@ SCENARIO( "TriangleMesh: split functionality.") { SCENARIO( "TriangleMesh: Mesh merge functions") { GIVEN( "Two 20mm cubes, each with one corner on the origin") { - const std::vector vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) }; - const std::vector facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) }; + const std::vector vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} }; + const std::vector facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} }; TriangleMesh cube(vertices, facets); cube.repair(); @@ -349,8 +349,8 @@ SCENARIO( "TriangleMesh: Mesh merge functions") { SCENARIO( "TriangleMeshSlicer: Cut behavior.") { GIVEN( "A 20mm cube with one corner on the origin") { - const std::vector vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) }; - const std::vector facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) }; + const std::vector vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} }; + const std::vector facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} }; TriangleMesh cube(vertices, facets); cube.repair(); diff --git a/tests/libslic3r/test_clipper_offset.cpp b/tests/libslic3r/test_clipper_offset.cpp index f40856a63..8209d99bf 100644 --- a/tests/libslic3r/test_clipper_offset.cpp +++ b/tests/libslic3r/test_clipper_offset.cpp @@ -15,7 +15,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { coord_t s = 1000000; GIVEN("20mm box") { ExPolygon box20mm; - box20mm.contour.points = { { 0, 0 }, { 20 * s, 0 }, { 20 * s, 20 * s}, { 0, 20 * s} }; + box20mm.contour.points = { Vec2crd{ 0, 0 }, Vec2crd{ 20 * s, 0 }, Vec2crd{ 20 * s, 20 * s}, Vec2crd{ 0, 20 * s} }; std::vector deltas_plus(box20mm.contour.points.size(), 1. * s); std::vector deltas_minus(box20mm.contour.points.size(), - 1. * s); Polygons output; @@ -87,8 +87,8 @@ SCENARIO("Constant offset", "[ClipperUtils]") { GIVEN("20mm box with 10mm hole") { ExPolygon box20mm; - box20mm.contour.points = { { 0, 0 }, { 20 * s, 0 }, { 20 * s, 20 * s}, { 0, 20 * s} }; - box20mm.holes.emplace_back(Slic3r::Polygon({ { 5 * s, 5 * s }, { 5 * s, 15 * s}, { 15 * s, 15 * s}, { 15 * s, 5 * s } })); + box20mm.contour.points = { Vec2crd{ 0, 0 }, Vec2crd{ 20 * s, 0 }, Vec2crd{ 20 * s, 20 * s}, Vec2crd{ 0, 20 * s} }; + box20mm.holes.emplace_back(Slic3r::Polygon({ Vec2crd{ 5 * s, 5 * s }, Vec2crd{ 5 * s, 15 * s}, Vec2crd{ 15 * s, 15 * s}, Vec2crd{ 15 * s, 5 * s } })); std::vector deltas_plus(box20mm.contour.points.size(), 1. * s); std::vector deltas_minus(box20mm.contour.points.size(), -1. * s); ExPolygons output; @@ -164,7 +164,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { GIVEN("20mm right angle triangle") { ExPolygon triangle20mm; - triangle20mm.contour.points = { { 0, 0 }, { 20 * s, 0 }, { 0, 20 * s} }; + triangle20mm.contour.points = { Vec2crd{ 0, 0 }, Vec2crd{ 20 * s, 0 }, Vec2crd{ 0, 20 * s } }; Polygons output; double offset = 1.; // Angle of the sharp corner bisector. diff --git a/tests/libslic3r/test_clipper_utils.cpp b/tests/libslic3r/test_clipper_utils.cpp index 69e9d0efb..a660b29cb 100644 --- a/tests/libslic3r/test_clipper_utils.cpp +++ b/tests/libslic3r/test_clipper_utils.cpp @@ -246,7 +246,7 @@ TEST_CASE("Traversing Clipper PolyTree", "[ClipperUtils]") { // Create a polygon representing unit box Polygon unitbox; const auto UNIT = coord_t(1. / SCALING_FACTOR); - unitbox.points = {{0, 0}, {UNIT, 0}, {UNIT, UNIT}, {0, UNIT}}; + unitbox.points = { Vec2crd{0, 0}, Vec2crd{UNIT, 0}, Vec2crd{UNIT, UNIT}, Vec2crd{0, UNIT}}; Polygon box_frame = unitbox; box_frame.scale(20, 10); diff --git a/tests/libslic3r/test_elephant_foot_compensation.cpp b/tests/libslic3r/test_elephant_foot_compensation.cpp index 616c0c6ad..a571e8d03 100644 --- a/tests/libslic3r/test_elephant_foot_compensation.cpp +++ b/tests/libslic3r/test_elephant_foot_compensation.cpp @@ -519,7 +519,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { // Rectangle ExPolygon expoly; coord_t scaled_w = coord_t(scale_(10)); - expoly.contour.points = { { 0, 0 }, { 0, scaled_w, }, { scaled_w, scaled_w }, { scaled_w, 0 } }; + expoly.contour.points = { Vec2crd{ 0, 0 }, Vec2crd{ 0, scaled_w, }, Vec2crd{ scaled_w, scaled_w }, Vec2crd{ scaled_w, 0 } }; // Narrow part ExPolygon expoly2; coord_t scaled_h = coord_t(scale_(0.8));