From d775c6c14c2ab2c746ef40cacc27ae4c707ef0b4 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 12 Dec 2016 15:54:37 +0100 Subject: [PATCH] Added methods set/add to SurfaceCollection. --- xs/src/libslic3r/SurfaceCollection.cpp | 13 ------------- xs/src/libslic3r/SurfaceCollection.hpp | 23 +++++++++++++++++++++-- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/xs/src/libslic3r/SurfaceCollection.cpp b/xs/src/libslic3r/SurfaceCollection.cpp index 804190548..cfeae4ccc 100644 --- a/xs/src/libslic3r/SurfaceCollection.cpp +++ b/xs/src/libslic3r/SurfaceCollection.cpp @@ -196,19 +196,6 @@ SurfaceCollection::remove_types(const SurfaceType *types, int ntypes) surfaces.erase(surfaces.begin() + j, surfaces.end()); } -void -SurfaceCollection::append(const SurfaceCollection &coll) -{ - this->surfaces.insert(this->surfaces.end(), coll.surfaces.begin(), coll.surfaces.end()); -} - -void -SurfaceCollection::append(const SurfaceType surfaceType, const Slic3r::ExPolygons &expoly) -{ - for (Slic3r::ExPolygons::const_iterator it = expoly.begin(); it != expoly.end(); ++ it) - this->surfaces.push_back(Slic3r::Surface(surfaceType, *it)); -} - void SurfaceCollection::export_to_svg(const char *path, bool show_labels) { BoundingBox bbox; diff --git a/xs/src/libslic3r/SurfaceCollection.hpp b/xs/src/libslic3r/SurfaceCollection.hpp index e013bf891..22c26936e 100644 --- a/xs/src/libslic3r/SurfaceCollection.hpp +++ b/xs/src/libslic3r/SurfaceCollection.hpp @@ -28,8 +28,27 @@ class SurfaceCollection void remove_type(const SurfaceType type); void remove_types(const SurfaceType *types, int ntypes); void filter_by_type(SurfaceType type, Polygons* polygons); - void append(const SurfaceCollection &coll); - void append(const SurfaceType surfaceType, const ExPolygons &expoly); + + void clear() { surfaces.clear(); } + bool empty() const { return surfaces.empty(); } + + void set(const SurfaceCollection &coll) { surfaces = coll.surfaces; } + void set(SurfaceCollection &&coll) { surfaces = std::move(coll.surfaces); } + void set(const ExPolygons &src, SurfaceType surfaceType) { clear(); this->append(src, surfaceType); } + void set(const ExPolygons &src, const Surface &surfaceTempl) { clear(); this->append(src, surfaceTempl); } + void set(const Surfaces &src) { clear(); this->append(src); } + void set(ExPolygons &&src, SurfaceType surfaceType) { clear(); this->append(std::move(src), surfaceType); } + void set(ExPolygons &&src, const Surface &surfaceTempl) { clear(); this->append(std::move(src), surfaceTempl); } + void set(Surfaces &&src) { clear(); this->append(std::move(src)); } + + void append(const SurfaceCollection &coll) { this->append(coll.surfaces); } + void append(SurfaceCollection &&coll) { this->append(std::move(coll.surfaces)); } + void append(const ExPolygons &src, SurfaceType surfaceType) { surfaces_append(this->surfaces, src, surfaceType); } + void append(const ExPolygons &src, const Surface &surfaceTempl) { surfaces_append(this->surfaces, src, surfaceTempl); } + void append(const Surfaces &src) { surfaces_append(this->surfaces, src); } + void append(ExPolygons &&src, SurfaceType surfaceType) { surfaces_append(this->surfaces, std::move(src), surfaceType); } + void append(ExPolygons &&src, const Surface &surfaceTempl) { surfaces_append(this->surfaces, std::move(src), surfaceTempl); } + void append(Surfaces &&src) { surfaces_append(this->surfaces, std::move(src)); } // For debugging purposes: void export_to_svg(const char *path, bool show_labels);