mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 15:15:55 +08:00
Introduce new step PosLayers to split layer generation and slicing
This commit is contained in:
parent
802b631e2d
commit
2c85797c1f
@ -117,6 +117,7 @@ sub new {
|
|||||||
$self->{adaptive_quality} = $optgroup->get_value($opt_id);
|
$self->{adaptive_quality} = $optgroup->get_value($opt_id);
|
||||||
$self->{model_object}->config->set('adaptive_slicing_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}->config->set('adaptive_slicing_quality', $optgroup->get_value($opt_id));
|
||||||
|
$self->{object}->invalidate_step(STEP_LAYERS);
|
||||||
# trigger re-slicing
|
# trigger re-slicing
|
||||||
$self->_trigger_slicing;
|
$self->_trigger_slicing;
|
||||||
}
|
}
|
||||||
@ -203,7 +204,6 @@ sub _trigger_slicing {
|
|||||||
$invalidate //= 1;
|
$invalidate //= 1;
|
||||||
my $object = $self->{plater}->{print}->get_object($self->{obj_idx});
|
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}->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}->pause_background_process;
|
||||||
$self->{plater}->stop_background_process;
|
$self->{plater}->stop_background_process;
|
||||||
if (!$Slic3r::GUI::Settings->{_}{background_processing}) {
|
if (!$Slic3r::GUI::Settings->{_}{background_processing}) {
|
||||||
|
@ -228,7 +228,6 @@ sub _modification_done {
|
|||||||
$self->{interpolated_layers} = $self->{object}->layer_height_spline->getInterpolatedLayers;
|
$self->{interpolated_layers} = $self->{object}->layer_height_spline->getInterpolatedLayers;
|
||||||
}
|
}
|
||||||
$self->Refresh;
|
$self->Refresh;
|
||||||
$self->{object}->layer_height_spline->suppressUpdate;
|
|
||||||
$self->{on_layer_update}->(@{$self->{interpolated_layers}});
|
$self->{on_layer_update}->(@{$self->{interpolated_layers}});
|
||||||
$self->{interactive_height_spline} = undef;
|
$self->{interactive_height_spline} = undef;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use warnings;
|
|||||||
|
|
||||||
require Exporter;
|
require Exporter;
|
||||||
our @ISA = qw(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);
|
STEP_INFILL STEP_SUPPORTMATERIAL STEP_SKIRT STEP_BRIM);
|
||||||
our %EXPORT_TAGS = (steps => \@EXPORT_OK);
|
our %EXPORT_TAGS = (steps => \@EXPORT_OK);
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ LayerHeightSpline::LayerHeightSpline()
|
|||||||
: _object_height(0)
|
: _object_height(0)
|
||||||
{
|
{
|
||||||
this->_is_valid = false;
|
this->_is_valid = false;
|
||||||
this->_update_required = true;
|
|
||||||
this->_layers_updated = false;
|
this->_layers_updated = false;
|
||||||
this->_layer_heights_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_layers = other._internal_layers;
|
||||||
this->_internal_layer_heights = other._internal_layer_heights;
|
this->_internal_layer_heights = other._internal_layer_heights;
|
||||||
this->_is_valid = other._is_valid;
|
this->_is_valid = other._is_valid;
|
||||||
this->_update_required = other._update_required;
|
|
||||||
this->_layers_updated = other._layers_updated;
|
this->_layers_updated = other._layers_updated;
|
||||||
this->_layer_heights_updated = other._layer_heights_updated;
|
this->_layer_heights_updated = other._layer_heights_updated;
|
||||||
if(this->_is_valid) {
|
if(this->_is_valid) {
|
||||||
@ -49,31 +47,6 @@ bool LayerHeightSpline::hasData()
|
|||||||
return this->_is_valid;
|
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.
|
* Set absolute layer positions in object coordinates.
|
||||||
* Heights (thickness of each layer) is generated from this list.
|
* Heights (thickness of each layer) is generated from this list.
|
||||||
|
@ -14,9 +14,7 @@ class LayerHeightSpline
|
|||||||
LayerHeightSpline(const LayerHeightSpline &other);
|
LayerHeightSpline(const LayerHeightSpline &other);
|
||||||
LayerHeightSpline& operator=(const LayerHeightSpline &other);
|
LayerHeightSpline& operator=(const LayerHeightSpline &other);
|
||||||
void setObjectHeight(coordf_t object_height) { this->_object_height = object_height; };
|
void setObjectHeight(coordf_t object_height) { this->_object_height = object_height; };
|
||||||
bool hasData(); // indicate that we have valid data
|
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 setLayers(std::vector<coordf_t> layers);
|
bool setLayers(std::vector<coordf_t> layers);
|
||||||
bool updateLayerHeights(std::vector<coordf_t> heights);
|
bool updateLayerHeights(std::vector<coordf_t> heights);
|
||||||
bool layersUpdated() const { return this->_layers_updated; }; // true if the basis set of layers was updated (by the slicing algorithm)
|
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;
|
coordf_t _object_height;
|
||||||
bool _is_valid;
|
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 _layers_updated;
|
||||||
bool _layer_heights_updated;
|
bool _layer_heights_updated;
|
||||||
std::vector<coordf_t> _original_layers;
|
std::vector<coordf_t> _original_layers;
|
||||||
|
@ -168,8 +168,9 @@ Print::invalidate_state_by_config(const PrintConfigBase &config)
|
|||||||
|| opt_key == "brim_connections_width") {
|
|| opt_key == "brim_connections_width") {
|
||||||
steps.insert(psBrim);
|
steps.insert(psBrim);
|
||||||
steps.insert(psSkirt);
|
steps.insert(psSkirt);
|
||||||
} else if (opt_key == "nozzle_diameter"
|
} else if (opt_key == "nozzle_diameter") {
|
||||||
|| opt_key == "resolution"
|
osteps.insert(posLayers);
|
||||||
|
} else if (opt_key == "resolution"
|
||||||
|| opt_key == "z_steps_per_mm") {
|
|| opt_key == "z_steps_per_mm") {
|
||||||
osteps.insert(posSlice);
|
osteps.insert(posSlice);
|
||||||
} else if (opt_key == "avoid_crossing_perimeters"
|
} else if (opt_key == "avoid_crossing_perimeters"
|
||||||
|
@ -27,7 +27,7 @@ enum PrintStep {
|
|||||||
psSkirt, psBrim,
|
psSkirt, psBrim,
|
||||||
};
|
};
|
||||||
enum PrintObjectStep {
|
enum PrintObjectStep {
|
||||||
posSlice, posPerimeters, posDetectSurfaces,
|
posLayers, posSlice, posPerimeters, posDetectSurfaces,
|
||||||
posPrepareInfill, posInfill, posSupportMaterial,
|
posPrepareInfill, posInfill, posSupportMaterial,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -224,11 +224,12 @@ PrintObject::invalidate_state_by_config(const PrintConfigBase &config)
|
|||||||
for (const t_config_option_key &opt_key : diff) {
|
for (const t_config_option_key &opt_key : diff) {
|
||||||
if (opt_key == "layer_height"
|
if (opt_key == "layer_height"
|
||||||
|| opt_key == "first_layer_height"
|
|| opt_key == "first_layer_height"
|
||||||
|| opt_key == "xy_size_compensation"
|
|
||||||
|| opt_key == "raft_layers"
|
|
||||||
|| opt_key == "adaptive_slicing"
|
|| opt_key == "adaptive_slicing"
|
||||||
|| opt_key == "adaptive_slicing_quality"
|
|| opt_key == "adaptive_slicing_quality"
|
||||||
|| opt_key == "match_horizontal_surfaces") {
|
|| opt_key == "match_horizontal_surfaces") {
|
||||||
|
steps.insert(posLayers);
|
||||||
|
} else if (opt_key == "xy_size_compensation"
|
||||||
|
|| opt_key == "raft_layers") {
|
||||||
steps.insert(posSlice);
|
steps.insert(posSlice);
|
||||||
} else if (opt_key == "support_material_contact_distance") {
|
} else if (opt_key == "support_material_contact_distance") {
|
||||||
steps.insert(posSlice);
|
steps.insert(posSlice);
|
||||||
@ -299,6 +300,8 @@ PrintObject::invalidate_step(PrintObjectStep step)
|
|||||||
this->invalidate_step(posPerimeters);
|
this->invalidate_step(posPerimeters);
|
||||||
this->invalidate_step(posDetectSurfaces);
|
this->invalidate_step(posDetectSurfaces);
|
||||||
this->invalidate_step(posSupportMaterial);
|
this->invalidate_step(posSupportMaterial);
|
||||||
|
}else if (step == posLayers) {
|
||||||
|
this->invalidate_step(posSlice);
|
||||||
} else if (step == posSupportMaterial) {
|
} else if (step == posSupportMaterial) {
|
||||||
this->_print->invalidate_step(psSkirt);
|
this->_print->invalidate_step(psSkirt);
|
||||||
this->_print->invalidate_step(psBrim);
|
this->_print->invalidate_step(psBrim);
|
||||||
@ -582,11 +585,11 @@ std::vector<coordf_t> PrintObject::generate_object_layers(coordf_t first_layer_h
|
|||||||
|
|
||||||
// Update object size at the spline object to define upper border
|
// Update object size at the spline object to define upper border
|
||||||
this->layer_height_spline.setObjectHeight(unscale(this->size.z));
|
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
|
// we don't need to respect first layer here, it's correctly provided by the spline object
|
||||||
result = this->layer_height_spline.getInterpolatedLayers();
|
result = this->layer_height_spline.getInterpolatedLayers();
|
||||||
}else{ // create new set of layers
|
}else{ // create new set of layers
|
||||||
|
|
||||||
// create stateful objects and variables for the adaptive slicing process
|
// create stateful objects and variables for the adaptive slicing process
|
||||||
SlicingAdaptive as;
|
SlicingAdaptive as;
|
||||||
coordf_t adaptive_quality = this->config.adaptive_slicing_quality.value;
|
coordf_t adaptive_quality = this->config.adaptive_slicing_quality.value;
|
||||||
@ -679,6 +682,8 @@ std::vector<coordf_t> PrintObject::generate_object_layers(coordf_t first_layer_h
|
|||||||
if (this->config.adaptive_slicing.value) { // smoothing after adaptive algorithm
|
if (this->config.adaptive_slicing.value) { // smoothing after adaptive algorithm
|
||||||
result = this->layer_height_spline.getInterpolatedLayers();
|
result = this->layer_height_spline.getInterpolatedLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->state.set_done(posLayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
// push modified spline object back to model
|
// push modified spline object back to model
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
void setObjectHeight(coordf_t object_height);
|
void setObjectHeight(coordf_t object_height);
|
||||||
bool hasData();
|
bool hasData();
|
||||||
bool updateRequired();
|
|
||||||
void suppressUpdate();
|
|
||||||
bool setLayers(std::vector<double> layers)
|
bool setLayers(std::vector<double> layers)
|
||||||
%code%{ RETVAL = THIS->setLayers(layers); %};
|
%code%{ RETVAL = THIS->setLayers(layers); %};
|
||||||
bool updateLayerHeights(std::vector<double> heights)
|
bool updateLayerHeights(std::vector<double> heights)
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
IV
|
IV
|
||||||
_constant()
|
_constant()
|
||||||
ALIAS:
|
ALIAS:
|
||||||
|
STEP_LAYERS = posLayers
|
||||||
STEP_SLICE = posSlice
|
STEP_SLICE = posSlice
|
||||||
STEP_PERIMETERS = posPerimeters
|
STEP_PERIMETERS = posPerimeters
|
||||||
STEP_DETECT_SURFACES = posDetectSurfaces
|
STEP_DETECT_SURFACES = posDetectSurfaces
|
||||||
|
Loading…
x
Reference in New Issue
Block a user