diff --git a/src/libslic3r/BridgeDetector.cpp b/src/libslic3r/BridgeDetector.cpp index ccc3505ce..ce7c960fa 100644 --- a/src/libslic3r/BridgeDetector.cpp +++ b/src/libslic3r/BridgeDetector.cpp @@ -6,9 +6,9 @@ namespace Slic3r { BridgeDetector::BridgeDetector( - ExPolygon _expolygon, - const ExPolygonCollection &_lower_slices, - coord_t _spacing) : + ExPolygon _expolygon, + const ExPolygons &_lower_slices, + coord_t _spacing) : // The original infill polygon, not inflated. expolygons(expolygons_owned), // All surfaces of the object supporting this region. @@ -20,9 +20,9 @@ BridgeDetector::BridgeDetector( } BridgeDetector::BridgeDetector( - const ExPolygons &_expolygons, - const ExPolygonCollection &_lower_slices, - coord_t _spacing) : + const ExPolygons &_expolygons, + const ExPolygons &_lower_slices, + coord_t _spacing) : // The original infill polygon, not inflated. expolygons(_expolygons), // All surfaces of the object supporting this region. @@ -46,7 +46,11 @@ void BridgeDetector::initialize() // 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. // Currently _edges are only used to set a candidate direction of the bridge (see bridge_direction_candidates()). - this->_edges = intersection_pl(to_polylines(grown), this->lower_slices.contours()); + Polygons contours; + contours.reserve(this->lower_slices.size()); + for (const ExPolygon &expoly : this->lower_slices) + contours.push_back(expoly.contour); + this->_edges = intersection_pl(to_polylines(grown), contours); #ifdef SLIC3R_DEBUG printf(" bridge has " PRINTF_ZU " support(s)\n", this->_edges.size()); @@ -54,7 +58,7 @@ void BridgeDetector::initialize() // detect anchors as intersection between our bridge expolygon and the lower slices // safety offset required to avoid Clipper from detecting empty intersection while Boost actually found some edges - this->_anchor_regions = intersection_ex(grown, to_polygons(this->lower_slices.expolygons), true); + this->_anchor_regions = intersection_ex(grown, to_polygons(this->lower_slices), true); /* if (0) { @@ -271,7 +275,7 @@ BridgeDetector::unsupported_edges(double angle, Polylines* unsupported) const if (angle == -1) angle = this->angle; if (angle == -1) return; - Polygons grown_lower = offset(this->lower_slices.expolygons, float(this->spacing)); + Polygons grown_lower = offset(this->lower_slices, float(this->spacing)); for (ExPolygons::const_iterator it_expoly = this->expolygons.begin(); it_expoly != this->expolygons.end(); ++ it_expoly) { // get unsupported bridge edges (both contour and holes) diff --git a/src/libslic3r/BridgeDetector.hpp b/src/libslic3r/BridgeDetector.hpp index 5c55276be..f876f83c7 100644 --- a/src/libslic3r/BridgeDetector.hpp +++ b/src/libslic3r/BridgeDetector.hpp @@ -3,7 +3,6 @@ #include "libslic3r.h" #include "ExPolygon.hpp" -#include "ExPolygonCollection.hpp" #include namespace Slic3r { @@ -21,7 +20,7 @@ public: // In case the caller gaves us the input polygons by a value, make a copy. ExPolygons expolygons_owned; // Lower slices, all regions. - const ExPolygonCollection &lower_slices; + const ExPolygons &lower_slices; // Scaled extrusion width of the infill. coord_t spacing; // Angle resolution for the brute force search of the best bridging angle. @@ -29,8 +28,8 @@ public: // The final optimal angle. double angle; - BridgeDetector(ExPolygon _expolygon, const ExPolygonCollection &_lower_slices, coord_t _extrusion_width); - BridgeDetector(const ExPolygons &_expolygons, const ExPolygonCollection &_lower_slices, coord_t _extrusion_width); + BridgeDetector(ExPolygon _expolygon, const ExPolygons &_lower_slices, coord_t _extrusion_width); + BridgeDetector(const ExPolygons &_expolygons, const ExPolygons &_lower_slices, coord_t _extrusion_width); // If bridge_direction_override != 0, then the angle is used instead of auto-detect. bool detect_angle(double bridge_direction_override = 0.); Polygons coverage(double angle = -1) const; diff --git a/src/libslic3r/ExPolygonCollection.cpp b/src/libslic3r/ExPolygonCollection.cpp index 6933544b6..c33df0f29 100644 --- a/src/libslic3r/ExPolygonCollection.cpp +++ b/src/libslic3r/ExPolygonCollection.cpp @@ -11,7 +11,7 @@ ExPolygonCollection::ExPolygonCollection(const ExPolygon &expolygon) ExPolygonCollection::operator Points() const { Points points; - Polygons pp = *this; + Polygons pp = (Polygons)*this; for (Polygons::const_iterator poly = pp.begin(); poly != pp.end(); ++poly) { for (Points::const_iterator point = poly->points.begin(); point != poly->points.end(); ++point) points.push_back(*point); diff --git a/src/libslic3r/ExPolygonCollection.hpp b/src/libslic3r/ExPolygonCollection.hpp index 099a6a112..35e1eef4e 100644 --- a/src/libslic3r/ExPolygonCollection.hpp +++ b/src/libslic3r/ExPolygonCollection.hpp @@ -17,11 +17,11 @@ public: ExPolygons expolygons; ExPolygonCollection() {} - ExPolygonCollection(const ExPolygon &expolygon); - ExPolygonCollection(const ExPolygons &expolygons) : expolygons(expolygons) {} - operator Points() const; - operator Polygons() const; - operator ExPolygons&(); + explicit ExPolygonCollection(const ExPolygon &expolygon); + explicit ExPolygonCollection(const ExPolygons &expolygons) : expolygons(expolygons) {} + explicit operator Points() const; + explicit operator Polygons() const; + explicit operator ExPolygons&(); void scale(double factor); void translate(double x, double y); void rotate(double angle, const Point ¢er); diff --git a/src/libslic3r/ExtrusionEntity.cpp b/src/libslic3r/ExtrusionEntity.cpp index 7f57b78af..c0d08c84b 100644 --- a/src/libslic3r/ExtrusionEntity.cpp +++ b/src/libslic3r/ExtrusionEntity.cpp @@ -14,12 +14,12 @@ namespace Slic3r { void ExtrusionPath::intersect_expolygons(const ExPolygonCollection &collection, ExtrusionEntityCollection* retval) const { - this->_inflate_collection(intersection_pl(this->polyline, collection), retval); + this->_inflate_collection(intersection_pl(this->polyline, (Polygons)collection), retval); } void ExtrusionPath::subtract_expolygons(const ExPolygonCollection &collection, ExtrusionEntityCollection* retval) const { - this->_inflate_collection(diff_pl(this->polyline, collection), retval); + this->_inflate_collection(diff_pl(this->polyline, (Polygons)collection), retval); } void ExtrusionPath::clip_end(double distance) diff --git a/src/libslic3r/MotionPlanner.cpp b/src/libslic3r/MotionPlanner.cpp index dd3443879..42bc6c2f1 100644 --- a/src/libslic3r/MotionPlanner.cpp +++ b/src/libslic3r/MotionPlanner.cpp @@ -136,11 +136,11 @@ Polyline MotionPlanner::shortest_path(const Point &from, const Point &to) if (! grown_env.contains(from)) { // delete second point while the line connecting first to third crosses the // boundaries as many times as the current first to second - while (polyline.points.size() > 2 && intersection_ln(Line(from, polyline.points[2]), grown_env).size() == 1) + while (polyline.points.size() > 2 && intersection_ln(Line(from, polyline.points[2]), (Polygons)grown_env).size() == 1) polyline.points.erase(polyline.points.begin() + 1); } if (! grown_env.contains(to)) - while (polyline.points.size() > 2 && intersection_ln(Line(*(polyline.points.end() - 3), to), grown_env).size() == 1) + while (polyline.points.size() > 2 && intersection_ln(Line(*(polyline.points.end() - 3), to), (Polygons)grown_env).size() == 1) polyline.points.erase(polyline.points.end() - 2); } diff --git a/xs/xsp/BridgeDetector.xsp b/xs/xsp/BridgeDetector.xsp index 0039d3579..eb3793cf7 100644 --- a/xs/xsp/BridgeDetector.xsp +++ b/xs/xsp/BridgeDetector.xsp @@ -25,7 +25,7 @@ BridgeDetector::new(expolygon, lower_slices, extrusion_width) ExPolygonCollection* lower_slices; int extrusion_width; CODE: - RETVAL = new BridgeDetector(*expolygon, *lower_slices, extrusion_width); + RETVAL = new BridgeDetector(*expolygon, lower_slices->expolygons, extrusion_width); OUTPUT: RETVAL @@ -35,7 +35,7 @@ BridgeDetector::new_expolygons(expolygons, lower_slices, extrusion_width) ExPolygonCollection* lower_slices; int extrusion_width; CODE: - RETVAL = new BridgeDetector(expolygons->expolygons, *lower_slices, extrusion_width); + RETVAL = new BridgeDetector(expolygons->expolygons, lower_slices->expolygons, extrusion_width); OUTPUT: RETVAL diff --git a/xs/xsp/ExPolygonCollection.xsp b/xs/xsp/ExPolygonCollection.xsp index e04d24e12..5321afb15 100644 --- a/xs/xsp/ExPolygonCollection.xsp +++ b/xs/xsp/ExPolygonCollection.xsp @@ -25,7 +25,7 @@ %code{% RETVAL = THIS->contains(*polyline); %}; void simplify(double tolerance); Polygons polygons() - %code{% RETVAL = *THIS; %}; + %code{% RETVAL = (Polygons)*THIS; %}; Clone convex_hull(); %{