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/ExPolygon.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/ExPolygon.cpp')
-rw-r--r-- | xs/src/libslic3r/ExPolygon.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/xs/src/libslic3r/ExPolygon.cpp b/xs/src/libslic3r/ExPolygon.cpp index 1d4bac50b..cd57fd7b0 100644 --- a/xs/src/libslic3r/ExPolygon.cpp +++ b/xs/src/libslic3r/ExPolygon.cpp @@ -168,52 +168,42 @@ ExPolygon::overlaps(const ExPolygon &other) const return ! other.contour.points.empty() && this->contains_b(other.contour.points.front()); } -void -ExPolygon::simplify_p(double tolerance, Polygons* polygons) const +void ExPolygon::simplify_p(double tolerance, Polygons* polygons) const { Polygons pp = this->simplify_p(tolerance); polygons->insert(polygons->end(), pp.begin(), pp.end()); } -Polygons -ExPolygon::simplify_p(double tolerance) const +Polygons ExPolygon::simplify_p(double tolerance) const { Polygons pp; pp.reserve(this->holes.size() + 1); - // contour { Polygon p = this->contour; p.points.push_back(p.points.front()); p.points = MultiPoint::_douglas_peucker(p.points, tolerance); p.points.pop_back(); - pp.push_back(p); + pp.emplace_back(std::move(p)); } - // holes - for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) { - Polygon p = *it; + for (Polygon p : this->holes) { p.points.push_back(p.points.front()); p.points = MultiPoint::_douglas_peucker(p.points, tolerance); p.points.pop_back(); - pp.push_back(p); + pp.emplace_back(std::move(p)); } - pp = simplify_polygons(pp); - return pp; + return simplify_polygons(pp); } -ExPolygons -ExPolygon::simplify(double tolerance) const +ExPolygons ExPolygon::simplify(double tolerance) const { - Polygons pp = this->simplify_p(tolerance); - return union_ex(pp); + return union_ex(this->simplify_p(tolerance)); } -void -ExPolygon::simplify(double tolerance, ExPolygons* expolygons) const +void ExPolygon::simplify(double tolerance, ExPolygons* expolygons) const { - ExPolygons ep = this->simplify(tolerance); - expolygons->insert(expolygons->end(), ep.begin(), ep.end()); + append(*expolygons, this->simplify(tolerance)); } void |