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
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2015-02-01 14:43:58 +0300
committerAlessandro Ranellucci <aar@cpan.org>2015-02-01 14:43:58 +0300
commitbb3bf28e594d805f479af5ad2f1c944e7251d5f6 (patch)
treeefd07b2bf1cd4f0b0f5be0e77e65250805cda352
parent97b5d76d504243901a6d559e075bb257b7b8fd4a (diff)
Ported prepare_fill_surfaces() to XS/C++
-rw-r--r--lib/Slic3r/Layer/Region.pm24
-rw-r--r--xs/src/libslic3r/Layer.hpp1
-rw-r--r--xs/src/libslic3r/LayerRegion.cpp32
-rw-r--r--xs/xsp/Layer.xsp1
4 files changed, 34 insertions, 24 deletions
diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm
index edf56f243..f65e90129 100644
--- a/lib/Slic3r/Layer/Region.pm
+++ b/lib/Slic3r/Layer/Region.pm
@@ -53,30 +53,6 @@ sub make_perimeters {
$generator->process;
}
-sub prepare_fill_surfaces {
- my $self = shift;
-
- # Note: in order to make the psPrepareInfill step idempotent, we should never
- # alter fill_surfaces boundaries on which our idempotency relies since that's
- # the only meaningful information returned by psPerimeters.
-
- # if no solid layers are requested, turn top/bottom surfaces to internal
- if ($self->config->top_solid_layers == 0) {
- $_->surface_type(S_TYPE_INTERNAL) for @{$self->fill_surfaces->filter_by_type(S_TYPE_TOP)};
- }
- if ($self->config->bottom_solid_layers == 0) {
- $_->surface_type(S_TYPE_INTERNAL)
- for @{$self->fill_surfaces->filter_by_type(S_TYPE_BOTTOM)}, @{$self->fill_surfaces->filter_by_type(S_TYPE_BOTTOMBRIDGE)};
- }
-
- # turn too small internal regions into solid regions according to the user setting
- if ($self->config->fill_density > 0) {
- my $min_area = scale scale $self->config->solid_infill_below_area; # scaling an area requires two calls!
- $_->surface_type(S_TYPE_INTERNALSOLID)
- for grep { $_->area <= $min_area } @{$self->fill_surfaces->filter_by_type(S_TYPE_INTERNAL)};
- }
-}
-
sub process_external_surfaces {
my ($self, $lower_layer) = @_;
diff --git a/xs/src/libslic3r/Layer.hpp b/xs/src/libslic3r/Layer.hpp
index c21ffa1c8..6dd6e81a5 100644
--- a/xs/src/libslic3r/Layer.hpp
+++ b/xs/src/libslic3r/Layer.hpp
@@ -56,6 +56,7 @@ class LayerRegion
Flow flow(FlowRole role, bool bridge = false, double width = -1) const;
void merge_slices();
+ void prepare_fill_surfaces();
private:
Layer *_layer;
diff --git a/xs/src/libslic3r/LayerRegion.cpp b/xs/src/libslic3r/LayerRegion.cpp
index 7b8e77f5a..e988566a8 100644
--- a/xs/src/libslic3r/LayerRegion.cpp
+++ b/xs/src/libslic3r/LayerRegion.cpp
@@ -53,6 +53,38 @@ LayerRegion::merge_slices()
this->slices.surfaces.push_back(Surface(stInternal, *expoly));
}
+void
+LayerRegion::prepare_fill_surfaces()
+{
+ /* Note: in order to make the psPrepareInfill step idempotent, we should never
+ alter fill_surfaces boundaries on which our idempotency relies since that's
+ the only meaningful information returned by psPerimeters. */
+
+ // if no solid layers are requested, turn top/bottom surfaces to internal
+ if (this->_region->config.top_solid_layers == 0) {
+ for (Surfaces::iterator surface = this->fill_surfaces.surfaces.begin(); surface != this->fill_surfaces.surfaces.end(); ++surface) {
+ if (surface->surface_type == stTop)
+ surface->surface_type = stInternal;
+ }
+ }
+ if (this->_region->config.bottom_solid_layers == 0) {
+ for (Surfaces::iterator surface = this->fill_surfaces.surfaces.begin(); surface != this->fill_surfaces.surfaces.end(); ++surface) {
+ if (surface->surface_type == stBottom || surface->surface_type == stBottomBridge)
+ surface->surface_type = stInternal;
+ }
+ }
+
+ // turn too small internal regions into solid regions according to the user setting
+ if (this->_region->config.fill_density.value > 0) {
+ // scaling an area requires two calls!
+ double min_area = scale_(scale_(this->_region->config.solid_infill_below_area.value));
+ for (Surfaces::iterator surface = this->fill_surfaces.surfaces.begin(); surface != this->fill_surfaces.surfaces.end(); ++surface) {
+ if (surface->surface_type == stInternal && surface->area() <= min_area)
+ surface->surface_type = stInternalSolid;
+ }
+ }
+}
+
#ifdef SLIC3RXS
REGISTER_CLASS(LayerRegion, "Layer::Region");
#endif
diff --git a/xs/xsp/Layer.xsp b/xs/xsp/Layer.xsp
index a48f8d156..611e2cae9 100644
--- a/xs/xsp/Layer.xsp
+++ b/xs/xsp/Layer.xsp
@@ -29,6 +29,7 @@
Clone<Flow> flow(FlowRole role, bool bridge = false, double width = -1)
%code%{ RETVAL = THIS->flow(role, bridge, width); %};
void merge_slices();
+ void prepare_fill_surfaces();
};
%name{Slic3r::Layer} class Layer {