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

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVojtech Bubnik <bubnikv@gmail.com>2021-01-06 13:05:22 +0300
committerVojtech Bubnik <bubnikv@gmail.com>2021-01-06 13:05:32 +0300
commit3c9f3d2b6676365cff5c5ca406145c6f999d528e (patch)
tree4653f57f111281d75ee9af9d67e5d8917b42458c /src/libslic3r/ClipperUtils.cpp
parent746729e4fa67e592420080e4c1bf390825be826a (diff)
Fixing the infill order for concentric infill to outside-in.
Relies to: Concentric Fill Start Point - New Feature Request #4948 Feature Request: Archimedean Chords - Option to define direction of travel (Inside-Out or Outside-In) #5214
Diffstat (limited to 'src/libslic3r/ClipperUtils.cpp')
-rw-r--r--src/libslic3r/ClipperUtils.cpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/src/libslic3r/ClipperUtils.cpp b/src/libslic3r/ClipperUtils.cpp
index 59872ad66..305ea134f 100644
--- a/src/libslic3r/ClipperUtils.cpp
+++ b/src/libslic3r/ClipperUtils.cpp
@@ -716,45 +716,33 @@ static void traverse_pt_noholes(const ClipperLib::PolyNodes &nodes, Polygons *ou
});
}
-static void traverse_pt_old(ClipperLib::PolyNodes &nodes, Polygons* retval)
+static void traverse_pt_outside_in(const ClipperLib::PolyNodes &nodes, Polygons *retval)
{
- /* use a nearest neighbor search to order these children
- TODO: supply start_near to chained_path() too? */
-
// collect ordering points
Points ordering_points;
ordering_points.reserve(nodes.size());
- for (ClipperLib::PolyNodes::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
- Point p((*it)->Contour.front().X, (*it)->Contour.front().Y);
- ordering_points.push_back(p);
- }
-
- // perform the ordering
- ClipperLib::PolyNodes ordered_nodes = chain_clipper_polynodes(ordering_points, nodes);
-
- // push results recursively
- for (ClipperLib::PolyNodes::iterator it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it) {
+ for (const ClipperLib::PolyNode *node : nodes)
+ ordering_points.emplace_back(node->Contour.front().X, node->Contour.front().Y);
+
+ // Perform the ordering, push results recursively.
+ //FIXME pass the last point to chain_clipper_polynodes?
+ for (const ClipperLib::PolyNode *node : chain_clipper_polynodes(ordering_points, nodes)) {
+ retval->emplace_back(ClipperPath_to_Slic3rPolygon(node->Contour));
+ if (node->IsHole())
+ // Orient a hole, which is clockwise oriented, to CCW.
+ retval->back().reverse();
// traverse the next depth
- traverse_pt_old((*it)->Childs, retval);
- retval->push_back(ClipperPath_to_Slic3rPolygon((*it)->Contour));
- if ((*it)->IsHole()) retval->back().reverse(); // ccw
+ traverse_pt_outside_in(node->Childs, retval);
}
}
-Polygons union_pt_chained(const Polygons &subject, bool safety_offset_)
+Polygons union_pt_chained_outside_in(const Polygons &subject, bool safety_offset_)
{
ClipperLib::PolyTree polytree = union_pt(subject, safety_offset_);
Polygons retval;
- traverse_pt_old(polytree.Childs, &retval);
+ traverse_pt_outside_in(polytree.Childs, &retval);
return retval;
-
-// TODO: This needs to be tested:
-// ClipperLib::PolyTree polytree = union_pt(subject, safety_offset_);
-
-// Polygons retval;
-// traverse_pt_noholes(polytree.Childs, &retval);
-// return retval;
}
Polygons simplify_polygons(const Polygons &subject, bool preserve_collinear)