From c0465d04343e5f2b4afae49808faa78b18b4cd32 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 26 Nov 2018 23:45:19 +0100 Subject: [PATCH] Ported PrintObject::prepare_infill() to C++ --- lib/Slic3r/Print/Object.pm | 41 -------------------------------- xs/src/libslic3r/PrintObject.cpp | 22 ++++++++--------- xs/xsp/Print.xsp | 1 + 3 files changed, 11 insertions(+), 53 deletions(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 2a50dcc46..3ac6422d0 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -34,47 +34,6 @@ sub support_layers { return [ map $self->get_support_layer($_), 0..($self->support_layer_count - 1) ]; } -sub prepare_infill { - my ($self) = @_; - - return if $self->step_done(STEP_PREPARE_INFILL); - - # This prepare_infill() is not really idempotent. - # TODO: It should clear and regenerate fill_surfaces at every run - # instead of modifying it in place. - $self->invalidate_step(STEP_PERIMETERS); - $self->make_perimeters; - - # Do this after invalidating STEP_PERIMETERS because that would re-invalidate STEP_PREPARE_INFILL - $self->set_step_started(STEP_PREPARE_INFILL); - - # prerequisites - $self->detect_surfaces_type; - - $self->print->status_cb->(30, "Preparing infill"); - - # decide what surfaces are to be filled - $_->prepare_fill_surfaces for map @{$_->regions}, @{$self->layers}; - - # this will detect bridges and reverse bridges - # and rearrange top/bottom/internal surfaces - $self->process_external_surfaces; - - # detect which fill surfaces are near external layers - # they will be split in internal and internal-solid surfaces - $self->discover_horizontal_shells; - $self->clip_fill_surfaces; - - # the following step needs to be done before combination because it may need - # to remove only half of the combined infill - $self->bridge_over_infill; - - # combine fill surfaces to honor the "infill every N layers" option - $self->combine_infill; - - $self->set_step_done(STEP_PREPARE_INFILL); -} - sub generate_support_material { my $self = shift; diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index c55f7ecf9..1faadab9b 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -1054,9 +1054,6 @@ PrintObject::slice() void PrintObject::make_perimeters() { - // prerequisites - this->slice(); - if (this->state.is_done(posPerimeters)) return; this->state.set_started(posPerimeters); @@ -1066,6 +1063,9 @@ PrintObject::make_perimeters() if (this->typed_slices) this->state.invalidate(posSlice); + // prerequisites + this->slice(); + // merge slices if they were split into types // This is not currently taking place because since merge_slices + detect_surfaces_type // are not truly idempotent we are invalidating posSlice here (see the Perl part of @@ -1209,7 +1209,8 @@ PrintObject::infill() void PrintObject::prepare_infill() { - if (this->state.is_done(posInfill)) return; + if (this->state.is_done(posPrepareInfill)) return; + // This prepare_infill() is not really idempotent. // TODO: It should clear and regenerate fill_surfaces at every run // instead of modifying it in place. @@ -1222,16 +1223,13 @@ PrintObject::prepare_infill() // prerequisites this->detect_surfaces_type(); - if (this->print()->status_cb != nullptr) - this->print()->status_cb(30, "Preparing infill"); + if (this->_print->status_cb != nullptr) + this->_print->status_cb(30, "Preparing infill"); - // decide what surfaces are to be filled - for (auto& layer : this->layers) { - for (auto& region : layer->regions) { - region->prepare_fill_surfaces(); - } - } + for (auto& layer : this->layers) + for (auto& layerm : layer->regions) + layerm->prepare_fill_surfaces(); // this will detect bridges and reverse bridges // and rearrange top/bottom/internal surfaces diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index 3cab015e0..cb1cb7d1f 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -154,6 +154,7 @@ _constant() RETVAL = (SV*)newRV_noinc((SV*)layers_av); %}; void make_perimeters(); + void prepare_infill(); void infill(); void _simplify_slices(double distance);