diff --git a/xs/src/libslic3r/ExPolygon.hpp b/xs/src/libslic3r/ExPolygon.hpp index 3f7774aabd5..f3a6a99eb57 100644 --- a/xs/src/libslic3r/ExPolygon.hpp +++ b/xs/src/libslic3r/ExPolygon.hpp @@ -104,12 +104,12 @@ inline void polygons_append(Polygons &dst, const ExPolygons &src) } #if SLIC3R_CPPVER >= 11 -inline void polygons_append(Polygons &dst, ExPolygons &&src) +inline void polygons_append(Polygons &dst, ExPolygons &&src) { dst.reserve(dst.size() + number_polygons(src)); - for (ExPolygons::const_iterator it = expolys.begin(); it != expolys.end(); ++ it) { + for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++ it) { dst.push_back(std::move(it->contour)); - std::move(std::begin(it->contour), std::end(it->contour), std::back_inserter(dst)); + std::move(std::begin(it->holes), std::end(it->holes), std::back_inserter(dst)); } } #endif diff --git a/xs/src/libslic3r/Fill/Fill.cpp b/xs/src/libslic3r/Fill/Fill.cpp index 568d060128d..940ff4f25bb 100644 --- a/xs/src/libslic3r/Fill/Fill.cpp +++ b/xs/src/libslic3r/Fill/Fill.cpp @@ -162,7 +162,11 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out) continue; // get filler object +#if SLIC3R_CPPVER >= 11 + std::unique_ptr f = std::unique_ptr(Fill::new_from_type(fill_pattern)); +#else std::auto_ptr f = std::auto_ptr(Fill::new_from_type(fill_pattern)); +#endif f->set_bounding_box(layerm.layer()->object()->bounding_box()); // calculate the actual flow we'll be using for this infill diff --git a/xs/src/libslic3r/PolylineCollection.cpp b/xs/src/libslic3r/PolylineCollection.cpp index d386d5ba5c7..ca46930c5b8 100644 --- a/xs/src/libslic3r/PolylineCollection.cpp +++ b/xs/src/libslic3r/PolylineCollection.cpp @@ -46,14 +46,14 @@ inline int nearest_point_index(const std::vector &pairs, const Point & return idx; } -Polylines PolylineCollection::chained_path_from( -#if SLIC3R_CPPVER >= 11 - Polylines &&src, -#else +Polylines PolylineCollection::_chained_path_from( const Polylines &src, + Point start_near, + bool no_reverse +#if SLIC3R_CPPVER >= 11 + , bool move_from_src #endif - Point start_near, - bool no_reverse) + ) { std::vector endpoints; endpoints.reserve(src.size()); @@ -70,8 +70,12 @@ Polylines PolylineCollection::chained_path_from( // find nearest point int endpoint_index = nearest_point_index(endpoints, start_near, no_reverse); assert(endpoint_index >= 0 && endpoint_index < endpoints.size() * 2); -#if SLIC3R_CPPVER >= 11 - retval.push_back(std::move(src[endpoints[endpoint_index/2].idx])); +#if SLIC3R_CPPVER > 11 + if (move_from_src) { + retval.push_back(std::move(src[endpoints[endpoint_index/2].idx])); + } else { + retval.push_back(src[endpoints[endpoint_index/2].idx]); + } #else retval.push_back(src[endpoints[endpoint_index/2].idx]); #endif @@ -86,28 +90,36 @@ Polylines PolylineCollection::chained_path_from( #if SLIC3R_CPPVER >= 11 Polylines PolylineCollection::chained_path(Polylines &&src, bool no_reverse) { - return (src.empty() || src.front().empty()) ? + return (src.empty() || src.front().points.empty()) ? Polylines() : - chained_path_from(std::move(src), src.front().first_point(), no_reverse); -} -Polylines PolylineCollection::chained_path_from(Polylines src, Point start_near, bool no_reverse) -{ - return chained_path_from(std::move(src), start_near, no_reverse); + _chained_path_from(src, src.front().first_point(), no_reverse, true); } -Polylines PolylineCollection::chained_path(Polylines src, bool no_reverse) + +Polylines PolylineCollection::chained_path_from(Polylines &&src, Point start_near, bool no_reverse) { - return (src.empty() || src.front().empty()) ? - Polylines() : - chained_path_from(std::move(src), src.front().first_point(), no_reverse); + return _chained_path_from(src, start_near, no_reverse, true); } -#else +#endif + Polylines PolylineCollection::chained_path(const Polylines &src, bool no_reverse) { return (src.empty() || src.front().points.empty()) ? Polylines() : - chained_path_from(src, src.front().first_point(), no_reverse); + _chained_path_from(src, src.front().first_point(), no_reverse +#if SLIC3R_CPPVER >= 11 + , false +#endif + ); } + +Polylines PolylineCollection::chained_path_from(const Polylines &src, Point start_near, bool no_reverse) +{ + return _chained_path_from(src, start_near, no_reverse +#if SLIC3R_CPPVER >= 11 + , false #endif + ); +} Point PolylineCollection::leftmost_point(const Polylines &polylines) { diff --git a/xs/src/libslic3r/PolylineCollection.hpp b/xs/src/libslic3r/PolylineCollection.hpp index f53e8a3a2dc..80d609410d1 100644 --- a/xs/src/libslic3r/PolylineCollection.hpp +++ b/xs/src/libslic3r/PolylineCollection.hpp @@ -8,11 +8,20 @@ namespace Slic3r { class PolylineCollection { + static Polylines _chained_path_from( + const Polylines &src, + Point start_near, + bool no_reverse +#if SLIC3R_CPPVER >= 11 + , bool move_from_src +#endif + ); + public: Polylines polylines; void chained_path(PolylineCollection* retval, bool no_reverse = false) const { retval->polylines = chained_path(this->polylines, no_reverse); } - void chained_path_from(Point start_near, PolylineCollection* retval, bool no_reverse = false) const + void chained_path_from(Point start_near, PolylineCollection* retval, bool no_reverse = false) const { retval->polylines = chained_path_from(this->polylines, start_near, no_reverse); } Point leftmost_point() const { return leftmost_point(polylines); } @@ -22,12 +31,9 @@ class PolylineCollection #if SLIC3R_CPPVER >= 11 static Polylines chained_path(Polylines &&src, bool no_reverse = false); static Polylines chained_path_from(Polylines &&src, Point start_near, bool no_reverse = false); - static Polylines chained_path(Polylines src, bool no_reverse = false); - static Polylines chained_path_from(Polylines src, Point start_near, bool no_reverse = false); -#else - static Polylines chained_path(const Polylines &src, bool no_reverse = false); - static Polylines chained_path_from(const Polylines &src, Point start_near, bool no_reverse = false); #endif + static Polylines chained_path(const Polylines &src, bool no_reverse = false); + static Polylines chained_path_from(const Polylines &src, Point start_near, bool no_reverse = false); }; } diff --git a/xs/src/libslic3r/SupportMaterial.cpp b/xs/src/libslic3r/SupportMaterial.cpp index 80b3cb1011d..701e117993b 100644 --- a/xs/src/libslic3r/SupportMaterial.cpp +++ b/xs/src/libslic3r/SupportMaterial.cpp @@ -1171,8 +1171,13 @@ void PrintObjectSupportMaterial::generate_toolpaths( infill_pattern = ipHoneycomb; break; } +#if SLIC3R_CPPVER >= 11 + std::unique_ptr filler_interface = std::unique_ptr(Fill::new_from_type(ipRectilinear)); + std::unique_ptr filler_support = std::unique_ptr(Fill::new_from_type(infill_pattern)); +#else std::auto_ptr filler_interface = std::auto_ptr(Fill::new_from_type(ipRectilinear)); std::auto_ptr filler_support = std::auto_ptr(Fill::new_from_type(infill_pattern)); +#endif { BoundingBox bbox_object = object.bounding_box(); filler_interface->set_bounding_box(bbox_object); diff --git a/xs/src/libslic3r/Surface.hpp b/xs/src/libslic3r/Surface.hpp index df6f07d3ab9..09bc3e5f506 100644 --- a/xs/src/libslic3r/Surface.hpp +++ b/xs/src/libslic3r/Surface.hpp @@ -99,11 +99,12 @@ inline Polygons to_polygons(const SurfacesPtr &src) #if SLIC3R_CPPVER >= 11 inline Polygons to_polygons(SurfacesPtr &&src) { + size_t num = 0; for (SurfacesPtr::const_iterator it = src.begin(); it != src.end(); ++it) num += (*it)->expolygon.holes.size() + 1; Polygons polygons; polygons.reserve(num); - for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++it) { + for (SurfacesPtr::const_iterator it = src.begin(); it != src.end(); ++it) { polygons.push_back(std::move((*it)->expolygon.contour)); for (Polygons::const_iterator ith = (*it)->expolygon.holes.begin(); ith != (*it)->expolygon.holes.end(); ++ith) { polygons.push_back(std::move(*ith)); @@ -146,7 +147,7 @@ inline void polygons_append(Polygons &dst, Surfaces &&src) dst.reserve(dst.size() + number_polygons(src)); for (Surfaces::const_iterator it = src.begin(); it != src.end(); ++ it) { dst.push_back(std::move(it->expolygon.contour)); - std::move(std::begin(it->expolygon.contour), std::end(it->expolygon.contour), std::back_inserter(dst)); + std::move(std::begin(it->expolygon.holes), std::end(it->expolygon.holes), std::back_inserter(dst)); } } #endif @@ -167,7 +168,7 @@ inline void polygons_append(Polygons &dst, SurfacesPtr &&src) dst.reserve(dst.size() + number_polygons(src)); for (SurfacesPtr::const_iterator it = src.begin(); it != src.end(); ++ it) { dst.push_back(std::move((*it)->expolygon.contour)); - std::move(std::begin((*it)->expolygon.contour), std::end((*it)->expolygon.contour), std::back_inserter(dst)); + std::move(std::begin((*it)->expolygon.holes), std::end((*it)->expolygon.holes), std::back_inserter(dst)); } } #endif