diff options
author | bubnikv <bubnikv@gmail.com> | 2018-05-18 10:52:09 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2018-05-18 10:52:09 +0300 |
commit | 3f08ef70f1db16a1971822d41a047a1cc43bb7ce (patch) | |
tree | 217450f4342c9043e08994378e057c7d025ab8bd /xs/src/libslic3r/ClipperUtils.cpp | |
parent | 651c4ab0ae9cf533d470c891a615364a0539c2de (diff) |
Fix of extraneous infill over thin walls.
Fixes https://github.com/prusa3d/Slic3r/issues/670
and some of https://github.com/prusa3d/Slic3r/issues/895
PerimeterGenerator was using an unsafe clipper offset function,
which performed offset for both a contour and its holes together.
With this commit the offsets were replaced with their safe counterparts,
though these safe counterparts may be somehow slower
(performing offset on ExPolygon or ExPolygons, piece by piece).
Also there was a bug, where if the infill & gap fill consumed
everything of the polygon, a polygon one onion shell above was still
used for infill.
Diffstat (limited to 'xs/src/libslic3r/ClipperUtils.cpp')
-rw-r--r-- | xs/src/libslic3r/ClipperUtils.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/xs/src/libslic3r/ClipperUtils.cpp b/xs/src/libslic3r/ClipperUtils.cpp index 86123b23c..31a12aa77 100644 --- a/xs/src/libslic3r/ClipperUtils.cpp +++ b/xs/src/libslic3r/ClipperUtils.cpp @@ -458,6 +458,19 @@ offset2_ex(const Polygons &polygons, const float delta1, const float delta2, return ClipperPaths_to_Slic3rExPolygons(output); } +//FIXME Vojtech: This functon may likely be optimized to avoid some of the Slic3r to Clipper +// conversions and unnecessary Clipper calls. +ExPolygons offset2_ex(const ExPolygons &expolygons, const float delta1, + const float delta2, ClipperLib::JoinType joinType, double miterLimit) +{ + Polygons polys; + for (const ExPolygon &expoly : expolygons) + append(polys, + offset(offset_ex(expoly, delta1, joinType, miterLimit), + delta2, joinType, miterLimit)); + return union_ex(polys); +} + template <class T> T _clipper_do(const ClipperLib::ClipType clipType, const Polygons &subject, @@ -650,8 +663,7 @@ union_pt_chained(const Polygons &subject, bool safety_offset_) return retval; } -void -traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval) +void traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval) { /* use a nearest neighbor search to order these children TODO: supply start_near to chained_path() too? */ @@ -677,8 +689,7 @@ traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval) } } -Polygons -simplify_polygons(const Polygons &subject, bool preserve_collinear) +Polygons simplify_polygons(const Polygons &subject, bool preserve_collinear) { // convert into Clipper polygons ClipperLib::Paths input_subject = Slic3rMultiPoints_to_ClipperPaths(subject); @@ -698,13 +709,11 @@ simplify_polygons(const Polygons &subject, bool preserve_collinear) return ClipperPaths_to_Slic3rPolygons(output); } -ExPolygons -simplify_polygons_ex(const Polygons &subject, bool preserve_collinear) +ExPolygons simplify_polygons_ex(const Polygons &subject, bool preserve_collinear) { - if (!preserve_collinear) { - return union_ex(simplify_polygons(subject, preserve_collinear)); - } - + if (! preserve_collinear) + return union_ex(simplify_polygons(subject, false)); + // convert into Clipper polygons ClipperLib::Paths input_subject = Slic3rMultiPoints_to_ClipperPaths(subject); |