From 1ab8efba7fe54c44bdee6017316f78bd4405020e Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 27 Feb 2015 21:55:02 +0100 Subject: Fixed regression causing random failures in bridge direction detection. #2636 --- xs/src/libslic3r/BridgeDetector.cpp | 12 ++++-------- xs/src/libslic3r/ExPolygonCollection.cpp | 10 ++++++++++ xs/src/libslic3r/ExPolygonCollection.hpp | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'xs/src') diff --git a/xs/src/libslic3r/BridgeDetector.cpp b/xs/src/libslic3r/BridgeDetector.cpp index dfc145422..da59a04d8 100644 --- a/xs/src/libslic3r/BridgeDetector.cpp +++ b/xs/src/libslic3r/BridgeDetector.cpp @@ -37,14 +37,10 @@ BridgeDetector::BridgeDetector(const ExPolygon &_expolygon, const ExPolygonColle Polygons grown; offset((Polygons)this->expolygon, &grown, this->extrusion_width); - // detect what edges lie on lower slices - for (ExPolygons::const_iterator lower = this->lower_slices.expolygons.begin(); - lower != this->lower_slices.expolygons.end(); - ++lower) { - /* turn bridge contour and holes into polylines and then clip them - with each lower slice's contour */ - intersection(grown, lower->contour, &this->_edges); - } + // detect what edges lie on lower slices by turning bridge contour and holes + // into polylines and then clipping them with each lower slice's contour + intersection(grown, this->lower_slices.contours(), &this->_edges); + #ifdef SLIC3R_DEBUG printf(" bridge has %zu support(s)\n", this->_edges.size()); #endif diff --git a/xs/src/libslic3r/ExPolygonCollection.cpp b/xs/src/libslic3r/ExPolygonCollection.cpp index 3b47c29b3..9ae7e8907 100644 --- a/xs/src/libslic3r/ExPolygonCollection.cpp +++ b/xs/src/libslic3r/ExPolygonCollection.cpp @@ -112,6 +112,16 @@ ExPolygonCollection::lines() const return lines; } +Polygons +ExPolygonCollection::contours() const +{ + Polygons contours; + for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it) { + contours.push_back(it->contour); + } + return contours; +} + #ifdef SLIC3RXS REGISTER_CLASS(ExPolygonCollection, "ExPolygon::Collection"); #endif diff --git a/xs/src/libslic3r/ExPolygonCollection.hpp b/xs/src/libslic3r/ExPolygonCollection.hpp index 86f77cbcb..4e6c366e2 100644 --- a/xs/src/libslic3r/ExPolygonCollection.hpp +++ b/xs/src/libslic3r/ExPolygonCollection.hpp @@ -30,6 +30,7 @@ class ExPolygonCollection void simplify(double tolerance); Polygon convex_hull() const; Lines lines() const; + Polygons contours() const; }; } -- cgit v1.2.3