From ea186f565114644333d6501c75929425e73cac51 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 26 Nov 2018 09:25:15 +0100 Subject: [PATCH] Ported PrintObject::_simplify_slices() to C++ --- lib/Slic3r/Print/Object.pm | 12 ------------ xs/src/libslic3r/Print.hpp | 2 ++ xs/src/libslic3r/PrintObject.cpp | 13 +++++++++++++ xs/xsp/Print.xsp | 1 + 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index e3142e6ef..380da13f8 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -558,16 +558,4 @@ sub combine_infill { } } -# 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. -sub _simplify_slices { - my ($self, $distance) = @_; - - foreach my $layer (@{$self->layers}) { - $layer->slices->simplify($distance); - $_->slices->simplify($distance) for @{$layer->regions}; - } -} - 1; diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index e8f65dd61..e3420a5a9 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -198,6 +198,8 @@ class PrintObject /// Idempotence of this method is guaranteed by the fact that we don't remove things from /// fill_surfaces but we only turn them into VOID surfaces, thus preserving the boundaries. void clip_fill_surfaces(); + + void _simplify_slices(double distance); private: Print* _print; diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index a4f8f3bdf..aa3680e62 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -1635,4 +1635,17 @@ PrintObject::clip_fill_surfaces() } } +// 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) +{ + for (auto* layer : this->layers) { + layer->slices.simplify(distance); + for (auto* layerm : layer->regions) + layerm->slices.simplify(distance); + } +} + } diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index 7372c63c9..6c49abb3b 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -152,6 +152,7 @@ _constant() %}; void _make_perimeters(); void _infill(); + void _simplify_slices(double distance); int ptr() %code%{ RETVAL = (int)(intptr_t)THIS; %};