Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVojtech Bubnik <bubnikv@gmail.com>2021-04-30 12:49:57 +0300
committerVojtech Bubnik <bubnikv@gmail.com>2021-04-30 12:49:57 +0300
commit9fbba855ef42a4b870ce402930d6e6772564c7cb (patch)
tree0b5dcd92fc1fbffe1ec09be4e5865c1a03366916 /src/libslic3r/SLA
parentb327314b0265cfa14a865a44224773e50168552c (diff)
Clipper optimization:
1) Removed the already commented-out scaling / unscaling when doing "safe offsetting" 2) Removed some of the "safe offsetting" at calls where it never was used. 3) Reworked Clipper & ClipperUtils to pass Polygons / ExPolygons / Surfaces as input parameters without conversion to ClipperLib::Paths. This should save a lot of memory allocation and copying. 4) Reworked conversions from ClipperLib::Paths & PolyTree to Polygons / ExPolygons to use the move operator to avoid many unnecessary allocations. 5) Reworked some "union with safe ofsetting" to "offset_ex", which should be cheaper.
Diffstat (limited to 'src/libslic3r/SLA')
-rw-r--r--src/libslic3r/SLA/ConcaveHull.cpp17
-rw-r--r--src/libslic3r/SLA/Pad.cpp14
2 files changed, 15 insertions, 16 deletions
diff --git a/src/libslic3r/SLA/ConcaveHull.cpp b/src/libslic3r/SLA/ConcaveHull.cpp
index d3c0d1022..172408989 100644
--- a/src/libslic3r/SLA/ConcaveHull.cpp
+++ b/src/libslic3r/SLA/ConcaveHull.cpp
@@ -42,9 +42,10 @@ Point ConcaveHull::centroid(const Points &pp)
// As it shows, the current offset_ex in ClipperUtils hangs if used in jtRound
// mode
-static ClipperLib::Paths fast_offset(const ClipperLib::Paths &paths,
- coord_t delta,
- ClipperLib::JoinType jointype)
+template<typename PolygonsProvider>
+static ClipperLib::Paths fast_offset(PolygonsProvider &&paths,
+ coord_t delta,
+ ClipperLib::JoinType jointype)
{
using ClipperLib::ClipperOffset;
using ClipperLib::etClosedPolygon;
@@ -61,7 +62,7 @@ static ClipperLib::Paths fast_offset(const ClipperLib::Paths &paths,
return {};
}
- offs.AddPaths(paths, jointype, etClosedPolygon);
+ offs.AddPaths(std::forward<PolygonsProvider>(paths), jointype, etClosedPolygon);
Paths result;
offs.Execute(result, static_cast<double>(delta));
@@ -157,11 +158,9 @@ ExPolygons ConcaveHull::to_expolygons() const
ExPolygons offset_waffle_style_ex(const ConcaveHull &hull, coord_t delta)
{
- ClipperLib::Paths paths = Slic3rMultiPoints_to_ClipperPaths(hull.polygons());
- paths = fast_offset(paths, 2 * delta, ClipperLib::jtRound);
- paths = fast_offset(paths, -delta, ClipperLib::jtRound);
- ExPolygons ret = ClipperPaths_to_Slic3rExPolygons(paths);
- for (ExPolygon &p : ret) p.holes = {};
+ ExPolygons ret = ClipperPaths_to_Slic3rExPolygons(
+ fast_offset(fast_offset(ClipperUtils::PolygonsProvider(hull.polygons()), 2 * delta, ClipperLib::jtRound), -delta, ClipperLib::jtRound));
+ for (ExPolygon &p : ret) p.holes.clear();
return ret;
}
diff --git a/src/libslic3r/SLA/Pad.cpp b/src/libslic3r/SLA/Pad.cpp
index 927c32589..e11914a1c 100644
--- a/src/libslic3r/SLA/Pad.cpp
+++ b/src/libslic3r/SLA/Pad.cpp
@@ -179,10 +179,10 @@ PadSkeleton divide_blueprint(const ExPolygons &bp)
ret.outer.reserve(size_t(ptree.Total()));
for (ClipperLib::PolyTree::PolyNode *node : ptree.Childs) {
- ExPolygon poly(ClipperPath_to_Slic3rPolygon(node->Contour));
+ ExPolygon poly;
+ poly.contour.points = std::move(node->Contour);
for (ClipperLib::PolyTree::PolyNode *child : node->Childs) {
- poly.holes.emplace_back(
- ClipperPath_to_Slic3rPolygon(child->Contour));
+ poly.holes.emplace_back(std::move(child->Contour));
traverse_pt(child->Childs, &ret.inner);
}
@@ -342,18 +342,18 @@ public:
template<class...Args>
ExPolygon offset_contour_only(const ExPolygon &poly, coord_t delta, Args...args)
{
- ExPolygons tmp = offset_ex(poly.contour, float(delta), args...);
+ Polygons tmp = offset(poly.contour, float(delta), args...);
if (tmp.empty()) return {};
Polygons holes = poly.holes;
for (auto &h : holes) h.reverse();
- tmp = diff_ex(to_polygons(tmp), holes);
+ ExPolygons tmp2 = diff_ex(tmp, holes);
- if (tmp.empty()) return {};
+ if (tmp2.empty()) return {};
- return tmp.front();
+ return std::move(tmp2.front());
}
bool add_cavity(Contour3D &pad, ExPolygon &top_poly, const PadConfig3D &cfg,