diff --git a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm index beb5699a2..1b6c558e1 100644 --- a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm @@ -117,6 +117,7 @@ sub new { $self->{adaptive_quality} = $optgroup->get_value($opt_id); $self->{model_object}->config->set('adaptive_slicing_quality', $optgroup->get_value($opt_id)); $self->{object}->config->set('adaptive_slicing_quality', $optgroup->get_value($opt_id)); + $self->{object}->invalidate_step(STEP_LAYERS); # trigger re-slicing $self->_trigger_slicing; } @@ -203,7 +204,6 @@ sub _trigger_slicing { $invalidate //= 1; my $object = $self->{plater}->{print}->get_object($self->{obj_idx}); $self->{model_object}->set_layer_height_spline($self->{object}->layer_height_spline); # push modified spline object to model_object - $self->{model_object}->layer_height_spline->updateRequired; # make sure the model_object spline requires update #$self->{plater}->pause_background_process; $self->{plater}->stop_background_process; if (!$Slic3r::GUI::Settings->{_}{background_processing}) { diff --git a/lib/Slic3r/GUI/Plater/SplineControl.pm b/lib/Slic3r/GUI/Plater/SplineControl.pm index 071b0ac4c..a6034c5a0 100644 --- a/lib/Slic3r/GUI/Plater/SplineControl.pm +++ b/lib/Slic3r/GUI/Plater/SplineControl.pm @@ -228,7 +228,6 @@ sub _modification_done { $self->{interpolated_layers} = $self->{object}->layer_height_spline->getInterpolatedLayers; } $self->Refresh; - $self->{object}->layer_height_spline->suppressUpdate; $self->{on_layer_update}->(@{$self->{interpolated_layers}}); $self->{interactive_height_spline} = undef; } diff --git a/lib/Slic3r/Print/State.pm b/lib/Slic3r/Print/State.pm index d242e3760..91d4a6ef9 100644 --- a/lib/Slic3r/Print/State.pm +++ b/lib/Slic3r/Print/State.pm @@ -5,7 +5,7 @@ use warnings; require Exporter; our @ISA = qw(Exporter); -our @EXPORT_OK = qw(STEP_SLICE STEP_PERIMETERS STEP_PREPARE_INFILL +our @EXPORT_OK = qw(STEP_LAYERS STEP_SLICE STEP_PERIMETERS STEP_PREPARE_INFILL STEP_INFILL STEP_SUPPORTMATERIAL STEP_SKIRT STEP_BRIM); our %EXPORT_TAGS = (steps => \@EXPORT_OK); diff --git a/xs/src/libslic3r/LayerHeightSpline.cpp b/xs/src/libslic3r/LayerHeightSpline.cpp index 1e8da6cfe..905f4ca81 100644 --- a/xs/src/libslic3r/LayerHeightSpline.cpp +++ b/xs/src/libslic3r/LayerHeightSpline.cpp @@ -15,7 +15,6 @@ LayerHeightSpline::LayerHeightSpline() : _object_height(0) { this->_is_valid = false; - this->_update_required = true; this->_layers_updated = false; this->_layer_heights_updated = false; } @@ -32,7 +31,6 @@ LayerHeightSpline& LayerHeightSpline::operator=(const LayerHeightSpline &other) this->_internal_layers = other._internal_layers; this->_internal_layer_heights = other._internal_layer_heights; this->_is_valid = other._is_valid; - this->_update_required = other._update_required; this->_layers_updated = other._layers_updated; this->_layer_heights_updated = other._layer_heights_updated; if(this->_is_valid) { @@ -49,31 +47,6 @@ bool LayerHeightSpline::hasData() return this->_is_valid; } -/* - * Does this object expect new layer heights during the slice step or should - * we use the layer heights values provided by the spline? - * An update is required if a config option is changed which affects the layer height. - * An update is not required if the spline was modified by a user interaction. - */ -bool LayerHeightSpline::updateRequired() -{ - bool result = true; // update spline by default - if(!this->_update_required && this->_is_valid) { - result = false; - } - this->_update_required = true; // reset to default after request - return result; -} - -/* - * Don't require an update for exactly one iteration. - */ -void LayerHeightSpline::suppressUpdate() { - if (this->_is_valid) { - this->_update_required = false; - } -} - /* * Set absolute layer positions in object coordinates. * Heights (thickness of each layer) is generated from this list. diff --git a/xs/src/libslic3r/LayerHeightSpline.hpp b/xs/src/libslic3r/LayerHeightSpline.hpp index 0c46744f0..e9253d182 100644 --- a/xs/src/libslic3r/LayerHeightSpline.hpp +++ b/xs/src/libslic3r/LayerHeightSpline.hpp @@ -14,9 +14,7 @@ class LayerHeightSpline LayerHeightSpline(const LayerHeightSpline &other); LayerHeightSpline& operator=(const LayerHeightSpline &other); void setObjectHeight(coordf_t object_height) { this->_object_height = object_height; }; - bool hasData(); // indicate that we have valid data - bool updateRequired(); // indicate whether we want to generate a new spline from the layers - void suppressUpdate(); + bool hasData(); // indicate that we have valid data; bool setLayers(std::vector layers); bool updateLayerHeights(std::vector heights); bool layersUpdated() const { return this->_layers_updated; }; // true if the basis set of layers was updated (by the slicing algorithm) @@ -31,7 +29,6 @@ class LayerHeightSpline coordf_t _object_height; bool _is_valid; - bool _update_required; // this should be always true except if we want to generate new layers from this spline bool _layers_updated; bool _layer_heights_updated; std::vector _original_layers; diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 35f6e13e4..2100f638d 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -168,8 +168,9 @@ Print::invalidate_state_by_config(const PrintConfigBase &config) || opt_key == "brim_connections_width") { steps.insert(psBrim); steps.insert(psSkirt); - } else if (opt_key == "nozzle_diameter" - || opt_key == "resolution" + } else if (opt_key == "nozzle_diameter") { + osteps.insert(posLayers); + } else if (opt_key == "resolution" || opt_key == "z_steps_per_mm") { osteps.insert(posSlice); } else if (opt_key == "avoid_crossing_perimeters" diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index 7226cd390..196565b57 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -27,7 +27,7 @@ enum PrintStep { psSkirt, psBrim, }; enum PrintObjectStep { - posSlice, posPerimeters, posDetectSurfaces, + posLayers, posSlice, posPerimeters, posDetectSurfaces, posPrepareInfill, posInfill, posSupportMaterial, }; diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index 783e4a8d1..5ca3087e1 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -224,11 +224,12 @@ PrintObject::invalidate_state_by_config(const PrintConfigBase &config) for (const t_config_option_key &opt_key : diff) { if (opt_key == "layer_height" || opt_key == "first_layer_height" - || opt_key == "xy_size_compensation" - || opt_key == "raft_layers" || opt_key == "adaptive_slicing" || opt_key == "adaptive_slicing_quality" || opt_key == "match_horizontal_surfaces") { + steps.insert(posLayers); + } else if (opt_key == "xy_size_compensation" + || opt_key == "raft_layers") { steps.insert(posSlice); } else if (opt_key == "support_material_contact_distance") { steps.insert(posSlice); @@ -299,6 +300,8 @@ PrintObject::invalidate_step(PrintObjectStep step) this->invalidate_step(posPerimeters); this->invalidate_step(posDetectSurfaces); this->invalidate_step(posSupportMaterial); + }else if (step == posLayers) { + this->invalidate_step(posSlice); } else if (step == posSupportMaterial) { this->_print->invalidate_step(psSkirt); this->_print->invalidate_step(psBrim); @@ -582,11 +585,11 @@ std::vector PrintObject::generate_object_layers(coordf_t first_layer_h // Update object size at the spline object to define upper border this->layer_height_spline.setObjectHeight(unscale(this->size.z)); - if(!this->layer_height_spline.updateRequired()) { // layer heights are already generated, just update layers from spline + if (this->state.is_done(posLayers)) { + // layer heights are already generated, just update layers from spline // we don't need to respect first layer here, it's correctly provided by the spline object result = this->layer_height_spline.getInterpolatedLayers(); }else{ // create new set of layers - // create stateful objects and variables for the adaptive slicing process SlicingAdaptive as; coordf_t adaptive_quality = this->config.adaptive_slicing_quality.value; @@ -679,6 +682,8 @@ std::vector PrintObject::generate_object_layers(coordf_t first_layer_h if (this->config.adaptive_slicing.value) { // smoothing after adaptive algorithm result = this->layer_height_spline.getInterpolatedLayers(); } + + this->state.set_done(posLayers); } // push modified spline object back to model diff --git a/xs/xsp/LayerHeightSpline.xsp b/xs/xsp/LayerHeightSpline.xsp index 9ff1571aa..67d7f1e11 100644 --- a/xs/xsp/LayerHeightSpline.xsp +++ b/xs/xsp/LayerHeightSpline.xsp @@ -12,8 +12,6 @@ void setObjectHeight(coordf_t object_height); bool hasData(); - bool updateRequired(); - void suppressUpdate(); bool setLayers(std::vector layers) %code%{ RETVAL = THIS->setLayers(layers); %}; bool updateLayerHeights(std::vector heights) diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index 106bcc8b1..9397961dd 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -12,6 +12,7 @@ IV _constant() ALIAS: + STEP_LAYERS = posLayers STEP_SLICE = posSlice STEP_PERIMETERS = posPerimeters STEP_DETECT_SURFACES = posDetectSurfaces