Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xs
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2017-03-08 15:43:49 +0300
committerbubnikv <bubnikv@gmail.com>2017-03-08 15:43:49 +0300
commit52b76930aae8aab64251ce533c028223402f352e (patch)
tree95f0322d55f70e1d62c90da707634363188ea190 /xs
parent4331f38912cfc31f0558196502bf28cb6a8d0cec (diff)
Simplify_slices rewritten to C++, parallelized.
Added some move methods to Surface class.
Diffstat (limited to 'xs')
-rw-r--r--xs/src/libslic3r/Print.hpp1
-rw-r--r--xs/src/libslic3r/PrintObject.cpp21
-rw-r--r--xs/src/libslic3r/Surface.hpp59
-rw-r--r--xs/xsp/Print.xsp1
4 files changed, 60 insertions, 22 deletions
diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp
index a6df6dd19..6dd9a8094 100644
--- a/xs/src/libslic3r/Print.hpp
+++ b/xs/src/libslic3r/Print.hpp
@@ -169,6 +169,7 @@ public:
void _slice();
std::string _fix_slicing_errors();
+ void _simplify_slices(double distance);
bool has_support_material() const;
void detect_surfaces_type();
void process_external_surfaces();
diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp
index 20bcdf5ca..31993dfc9 100644
--- a/xs/src/libslic3r/PrintObject.cpp
+++ b/xs/src/libslic3r/PrintObject.cpp
@@ -1121,7 +1121,7 @@ void PrintObject::_slice()
}
}
- // remove last layer(s) if empty
+ BOOST_LOG_TRIVIAL(debug) << "Slicing objects - removing top empty layers";
while (! this->layers.empty()) {
const Layer *layer = this->layers.back();
for (size_t region_id = 0; region_id < this->print()->regions.size(); ++ region_id)
@@ -1284,6 +1284,25 @@ std::string PrintObject::_fix_slicing_errors()
"however you might want to check the results or repair the input file and retry.\n";
}
+// Simplify the sliced model, if "resolution" configuration parameter > 0.
+// The simplification is problematic, because it simplifies the slices independent from each other,
+// which makes the simplified discretization visible on the object surface.
+void PrintObject::_simplify_slices(double distance)
+{
+ BOOST_LOG_TRIVIAL(debug) << "Slicing objects - siplifying slices in parallel - begin";
+ tbb::parallel_for(
+ tbb::blocked_range<size_t>(0, this->layers.size()),
+ [this, distance](const tbb::blocked_range<size_t>& range) {
+ for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) {
+ Layer *layer = this->layers[layer_idx];
+ for (size_t region_idx = 0; region_idx < layer->regions.size(); ++ region_idx)
+ layer->regions[region_idx]->slices.simplify(distance);
+ layer->slices.simplify(distance);
+ }
+ });
+ BOOST_LOG_TRIVIAL(debug) << "Slicing objects - siplifying slices in parallel - end";
+}
+
void
PrintObject::_make_perimeters()
{
diff --git a/xs/src/libslic3r/Surface.hpp b/xs/src/libslic3r/Surface.hpp
index 889c3cfe4..b14247166 100644
--- a/xs/src/libslic3r/Surface.hpp
+++ b/xs/src/libslic3r/Surface.hpp
@@ -45,18 +45,34 @@ public:
{};
Surface(const Surface &other, const ExPolygon &_expolygon)
: surface_type(other.surface_type), expolygon(_expolygon),
- thickness(other.thickness), thickness_layers(other.thickness_layers), bridge_angle(other.bridge_angle), extra_perimeters(other.extra_perimeters)
+ thickness(other.thickness), thickness_layers(other.thickness_layers),
+ bridge_angle(other.bridge_angle), extra_perimeters(other.extra_perimeters)
+ {};
+ Surface(Surface &&rhs)
+ : surface_type(rhs.surface_type), expolygon(std::move(rhs.expolygon)),
+ thickness(rhs.thickness), thickness_layers(rhs.thickness_layers),
+ bridge_angle(rhs.bridge_angle), extra_perimeters(rhs.extra_perimeters)
{};
-#if SLIC3R_CPPVER >= 11
Surface(SurfaceType _surface_type, const ExPolygon &&_expolygon)
: surface_type(_surface_type), expolygon(std::move(_expolygon)),
thickness(-1), thickness_layers(1), bridge_angle(-1), extra_perimeters(0)
{};
Surface(const Surface &other, const ExPolygon &&_expolygon)
: surface_type(other.surface_type), expolygon(std::move(_expolygon)),
- thickness(other.thickness), thickness_layers(other.thickness_layers), bridge_angle(other.bridge_angle), extra_perimeters(other.extra_perimeters)
+ thickness(other.thickness), thickness_layers(other.thickness_layers),
+ bridge_angle(other.bridge_angle), extra_perimeters(other.extra_perimeters)
{};
-#endif
+
+ Surface& operator=(Surface &&rhs)
+ {
+ surface_type = rhs.surface_type;
+ expolygon = std::move(rhs.expolygon);
+ thickness = rhs.thickness;
+ thickness_layers = rhs.thickness_layers;
+ bridge_angle = rhs.bridge_angle;
+ extra_perimeters = rhs.extra_perimeters;
+ }
+
operator Polygons() const;
double area() const;
bool empty() const { return expolygon.empty(); }
@@ -79,9 +95,9 @@ inline Polygons to_polygons(const Surfaces &src)
Polygons polygons;
polygons.reserve(num);
for (Surfaces::const_iterator it = src.begin(); it != src.end(); ++it) {
- polygons.push_back(it->expolygon.contour);
+ polygons.emplace_back(it->expolygon.contour);
for (Polygons::const_iterator ith = it->expolygon.holes.begin(); ith != it->expolygon.holes.end(); ++ith)
- polygons.push_back(*ith);
+ polygons.emplace_back(*ith);
}
return polygons;
}
@@ -94,9 +110,9 @@ inline Polygons to_polygons(const SurfacesPtr &src)
Polygons polygons;
polygons.reserve(num);
for (SurfacesPtr::const_iterator it = src.begin(); it != src.end(); ++it) {
- polygons.push_back((*it)->expolygon.contour);
+ polygons.emplace_back((*it)->expolygon.contour);
for (Polygons::const_iterator ith = (*it)->expolygon.holes.begin(); ith != (*it)->expolygon.holes.end(); ++ith)
- polygons.push_back(*ith);
+ polygons.emplace_back(*ith);
}
return polygons;
}
@@ -106,7 +122,7 @@ inline ExPolygons to_expolygons(const Surfaces &src)
ExPolygons expolygons;
expolygons.reserve(src.size());
for (Surfaces::const_iterator it = src.begin(); it != src.end(); ++it)
- expolygons.push_back(it->expolygon);
+ expolygons.emplace_back(it->expolygon);
return expolygons;
}
@@ -125,7 +141,7 @@ inline ExPolygons to_expolygons(const SurfacesPtr &src)
ExPolygons expolygons;
expolygons.reserve(src.size());
for (SurfacesPtr::const_iterator it = src.begin(); it != src.end(); ++it)
- expolygons.push_back((*it)->expolygon);
+ expolygons.emplace_back((*it)->expolygon);
return expolygons;
}
@@ -151,7 +167,7 @@ inline void polygons_append(Polygons &dst, const Surfaces &src)
{
dst.reserve(dst.size() + number_polygons(src));
for (Surfaces::const_iterator it = src.begin(); it != src.end(); ++ it) {
- dst.push_back(it->expolygon.contour);
+ dst.emplace_back(it->expolygon.contour);
dst.insert(dst.end(), it->expolygon.holes.begin(), it->expolygon.holes.end());
}
}
@@ -160,7 +176,7 @@ inline void polygons_append(Polygons &dst, Surfaces &&src)
{
dst.reserve(dst.size() + number_polygons(src));
for (Surfaces::iterator it = src.begin(); it != src.end(); ++ it) {
- dst.push_back(std::move(it->expolygon.contour));
+ dst.emplace_back(std::move(it->expolygon.contour));
std::move(std::begin(it->expolygon.holes), std::end(it->expolygon.holes), std::back_inserter(dst));
it->expolygon.holes.clear();
}
@@ -171,7 +187,7 @@ inline void polygons_append(Polygons &dst, const SurfacesPtr &src)
{
dst.reserve(dst.size() + number_polygons(src));
for (SurfacesPtr::const_iterator it = src.begin(); it != src.end(); ++ it) {
- dst.push_back((*it)->expolygon.contour);
+ dst.emplace_back((*it)->expolygon.contour);
dst.insert(dst.end(), (*it)->expolygon.holes.begin(), (*it)->expolygon.holes.end());
}
}
@@ -180,7 +196,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));
+ dst.emplace_back(std::move((*it)->expolygon.contour));
std::move(std::begin((*it)->expolygon.holes), std::end((*it)->expolygon.holes), std::back_inserter(dst));
(*it)->expolygon.holes.clear();
}
@@ -190,14 +206,14 @@ inline void polygons_append(Polygons &dst, SurfacesPtr &&src)
inline void surfaces_append(Surfaces &dst, const ExPolygons &src, SurfaceType surfaceType)
{
dst.reserve(dst.size() + src.size());
- for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++ it)
- dst.push_back(Surface(surfaceType, *it));
+ for (const ExPolygon &expoly : src)
+ dst.emplace_back(Surface(surfaceType, expoly));
}
inline void surfaces_append(Surfaces &dst, const ExPolygons &src, const Surface &surfaceTempl)
{
dst.reserve(dst.size() + number_polygons(src));
- for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++ it)
- dst.push_back(Surface(surfaceTempl, *it));
+ for (const ExPolygon &expoly : src)
+ dst.emplace_back(Surface(surfaceTempl, expoly));
}
inline void surfaces_append(Surfaces &dst, const Surfaces &src)
{
@@ -207,8 +223,8 @@ inline void surfaces_append(Surfaces &dst, const Surfaces &src)
inline void surfaces_append(Surfaces &dst, ExPolygons &&src, SurfaceType surfaceType)
{
dst.reserve(dst.size() + src.size());
- for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++ it)
- dst.push_back(Surface(surfaceType, std::move(*it)));
+ for (ExPolygon &expoly : src)
+ dst.emplace_back(Surface(surfaceType, std::move(expoly)));
src.clear();
}
@@ -216,9 +232,10 @@ inline void surfaces_append(Surfaces &dst, ExPolygons &&src, const Surface &surf
{
dst.reserve(dst.size() + number_polygons(src));
for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++ it)
- dst.push_back(Surface(surfaceTempl, std::move(*it)));
+ dst.emplace_back(Surface(surfaceTempl, std::move(*it)));
src.clear();
}
+
inline void surfaces_append(Surfaces &dst, Surfaces &&src)
{
if (dst.empty()) {
diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp
index 670e4e999..70fed730f 100644
--- a/xs/xsp/Print.xsp
+++ b/xs/xsp/Print.xsp
@@ -113,6 +113,7 @@ _constant()
void _slice();
std::string _fix_slicing_errors();
+ void _simplify_slices(double distance);
void detect_surfaces_type();
void process_external_surfaces();
void discover_vertical_shells();