diff --git a/src/libslic3r/SLA/Pad.cpp b/src/libslic3r/SLA/Pad.cpp index 1e5de5158..b92862439 100644 --- a/src/libslic3r/SLA/Pad.cpp +++ b/src/libslic3r/SLA/Pad.cpp @@ -47,7 +47,7 @@ inline indexed_triangle_set straight_walls(const Polygon &plate, double lo_z, double hi_z) { - return walls(plate, plate, lo_z, hi_z); + return wall_strip(plate, hi_z, lo_z); //walls(plate, plate, lo_z, hi_z); } // Function to cut tiny connector cavities for a given polygon. The input poly diff --git a/src/libslic3r/SlicesToTriangleMesh.cpp b/src/libslic3r/SlicesToTriangleMesh.cpp index 3b55cf066..969fa8dac 100644 --- a/src/libslic3r/SlicesToTriangleMesh.cpp +++ b/src/libslic3r/SlicesToTriangleMesh.cpp @@ -2,7 +2,6 @@ #include "SlicesToTriangleMesh.hpp" -//#include "libslic3r/MTUtils.hpp" #include "libslic3r/Execution/ExecutionTBB.hpp" #include "libslic3r/ClipperUtils.hpp" #include "libslic3r/Tesselate.hpp" @@ -12,39 +11,6 @@ namespace Slic3r { -inline indexed_triangle_set wall_strip(const Polygon &poly, - double lower_z_mm, - double upper_z_mm) -{ - indexed_triangle_set ret; - - size_t startidx = ret.vertices.size(); - size_t offs = poly.points.size(); - - ret.vertices.reserve(ret.vertices.size() + 2 *offs); - - // The expression unscaled(p).cast().eval() is important here - // as it ensures identical conversion of 2D scaled coordinates to float 3D - // to that used by the tesselation. This way, the duplicated vertices in the - // output mesh can be found with the == operator of the points. - // its_merge_vertices will then reliably remove the duplicates. - for (const Point &p : poly.points) - ret.vertices.emplace_back(to_3d(unscaled(p).cast().eval(), float(lower_z_mm))); - - for (const Point &p : poly.points) - ret.vertices.emplace_back(to_3d(unscaled(p).cast().eval(), float(upper_z_mm))); - - for (size_t i = startidx + 1; i < startidx + offs; ++i) { - ret.indices.emplace_back(i - 1, i, i + offs - 1); - ret.indices.emplace_back(i, i + offs, i + offs - 1); - } - - ret.indices.emplace_back(startidx + offs - 1, startidx, startidx + 2 * offs - 1); - ret.indices.emplace_back(startidx, startidx + offs, startidx + 2 * offs - 1); - - return ret; -} - // Same as walls() but with identical higher and lower polygons. indexed_triangle_set inline straight_walls(const Polygon &plate, double lo_z, diff --git a/src/libslic3r/Tesselate.cpp b/src/libslic3r/Tesselate.cpp index febb3d0e7..aef512f36 100644 --- a/src/libslic3r/Tesselate.cpp +++ b/src/libslic3r/Tesselate.cpp @@ -245,4 +245,35 @@ std::vector triangulate_expolygons_2f(const ExPolygons &polys, bool flip) return out; } +indexed_triangle_set wall_strip(const Polygon &poly, double lower_z_mm, double upper_z_mm) +{ + indexed_triangle_set ret; + + size_t startidx = ret.vertices.size(); + size_t offs = poly.points.size(); + + ret.vertices.reserve(ret.vertices.size() + 2 *offs); + + // The expression unscaled(p).cast().eval() is important here + // as it ensures identical conversion of 2D scaled coordinates to float 3D + // to that used by the tesselation. This way, the duplicated vertices in the + // output mesh can be found with the == operator of the points. + // its_merge_vertices will then reliably remove the duplicates. + for (const Point &p : poly.points) + ret.vertices.emplace_back(to_3d(unscaled(p).cast().eval(), float(lower_z_mm))); + + for (const Point &p : poly.points) + ret.vertices.emplace_back(to_3d(unscaled(p).cast().eval(), float(upper_z_mm))); + + for (size_t i = startidx + 1; i < startidx + offs; ++i) { + ret.indices.emplace_back(i - 1, i, i + offs - 1); + ret.indices.emplace_back(i, i + offs, i + offs - 1); + } + + ret.indices.emplace_back(startidx + offs - 1, startidx, startidx + 2 * offs - 1); + ret.indices.emplace_back(startidx, startidx + offs, startidx + 2 * offs - 1); + + return ret; +} + } // namespace Slic3r diff --git a/src/libslic3r/Tesselate.hpp b/src/libslic3r/Tesselate.hpp index 2dbe6caa1..b164b584d 100644 --- a/src/libslic3r/Tesselate.hpp +++ b/src/libslic3r/Tesselate.hpp @@ -2,14 +2,12 @@ #define slic3r_Tesselate_hpp_ #include +#include -#include "Point.hpp" +#include "ExPolygon.hpp" namespace Slic3r { -class ExPolygon; -typedef std::vector ExPolygons; - const bool constexpr NORMALS_UP = false; const bool constexpr NORMALS_DOWN = true; @@ -20,6 +18,10 @@ extern std::vector triangulate_expolygons_2d(const ExPolygons &polys, boo extern std::vector triangulate_expolygon_2f (const ExPolygon &poly, bool flip = NORMALS_UP); extern std::vector triangulate_expolygons_2f(const ExPolygons &polys, bool flip = NORMALS_UP); +indexed_triangle_set wall_strip(const Polygon &poly, + double lower_z_mm, + double upper_z_mm); + } // namespace Slic3r #endif /* slic3r_Tesselate_hpp_ */