option to control layer height gradation for adaptive slicing

This commit is contained in:
Florens Wasserfall 2016-11-09 17:09:05 +01:00
parent 22c010791d
commit 99b830809c
5 changed files with 20 additions and 2 deletions

View File

@ -455,7 +455,7 @@ sub build {
my $self = shift; my $self = shift;
$self->init_config_options(qw( $self->init_config_options(qw(
adaptive_slicing cusp_value match_horizontal_surfaces adaptive_slicing adaptive_slicing_z_gradation cusp_value match_horizontal_surfaces
layer_height first_layer_height layer_height first_layer_height
perimeters spiral_vase perimeters spiral_vase
top_solid_layers bottom_solid_layers top_solid_layers bottom_solid_layers
@ -504,6 +504,7 @@ sub build {
$optgroup->append_single_option_line('first_layer_height'); $optgroup->append_single_option_line('first_layer_height');
$optgroup->append_single_option_line('adaptive_slicing'); $optgroup->append_single_option_line('adaptive_slicing');
$optgroup->append_single_option_line('cusp_value'); $optgroup->append_single_option_line('cusp_value');
$optgroup->append_single_option_line('adaptive_slicing_z_gradation');
$optgroup->append_single_option_line('match_horizontal_surfaces'); $optgroup->append_single_option_line('match_horizontal_surfaces');
} }
{ {
@ -790,7 +791,7 @@ sub _update {
my $have_adaptive_slicing = $config->adaptive_slicing; my $have_adaptive_slicing = $config->adaptive_slicing;
$self->get_field($_)->toggle($have_adaptive_slicing) $self->get_field($_)->toggle($have_adaptive_slicing)
for qw(cusp_value match_horizontal_surfaces); for qw(cusp_value adaptive_slicing_z_gradation match_horizontal_surfaces);
$self->get_field($_)->toggle(!$have_adaptive_slicing) $self->get_field($_)->toggle(!$have_adaptive_slicing)
for qw(layer_height); for qw(layer_height);

View File

@ -163,6 +163,12 @@ sub slice {
$height = ($id == 0) $height = ($id == 0)
? $self->config->get_value('first_layer_height') ? $self->config->get_value('first_layer_height')
: min($cusp_height, $height); : min($cusp_height, $height);
# apply z-gradation
my $gradation = $self->config->get_value('adaptive_slicing_z_gradation');
if($gradation > 0) {
$height = $height - unscale((scale($height)) % (scale($gradation)));
}
} }
}else{ }else{

View File

@ -14,6 +14,14 @@ PrintConfigDef::PrintConfigDef()
def->cli = "adaptive-slicing!"; def->cli = "adaptive-slicing!";
def->default_value = new ConfigOptionBool(false); def->default_value = new ConfigOptionBool(false);
def = this->add("adaptive_slicing_z_gradation", coFloat);
def->label = "Min layer height gradation";
def->tooltip = "Limit layer heights to a multiple of this value to avoid stepping inaccuracies at the Z-axis. Typical value for a Prusa i3, 1/16 micro-stepping is 0.004mm. Set zero do disable this option.";
def->sidetext = "mm";
def->cli = "adaptive-slicing-z-gradation=f";
def->min = 0;
def->default_value = new ConfigOptionFloat(0);
def = this->add("avoid_crossing_perimeters", coBool); def = this->add("avoid_crossing_perimeters", coBool);
def->label = "Avoid crossing perimeters"; def->label = "Avoid crossing perimeters";
def->tooltip = "Optimize travel moves in order to minimize the crossing of perimeters. This is mostly useful with Bowden extruders which suffer from oozing. This feature slows down both the print and the G-code generation."; def->tooltip = "Optimize travel moves in order to minimize the crossing of perimeters. This is mostly useful with Bowden extruders which suffer from oozing. This feature slows down both the print and the G-code generation.";

View File

@ -104,6 +104,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig
{ {
public: public:
ConfigOptionBool adaptive_slicing; ConfigOptionBool adaptive_slicing;
ConfigOptionFloat adaptive_slicing_z_gradation;
ConfigOptionFloat cusp_value; ConfigOptionFloat cusp_value;
ConfigOptionBool dont_support_bridges; ConfigOptionBool dont_support_bridges;
ConfigOptionFloatOrPercent extrusion_width; ConfigOptionFloatOrPercent extrusion_width;
@ -137,6 +138,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) { virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
OPT_PTR(adaptive_slicing); OPT_PTR(adaptive_slicing);
OPT_PTR(adaptive_slicing_z_gradation);
OPT_PTR(cusp_value); OPT_PTR(cusp_value);
OPT_PTR(dont_support_bridges); OPT_PTR(dont_support_bridges);
OPT_PTR(extrusion_width); OPT_PTR(extrusion_width);

View File

@ -228,6 +228,7 @@ PrintObject::invalidate_state_by_config_options(const std::vector<t_config_optio
|| *opt_key == "first_layer_height" || *opt_key == "first_layer_height"
|| *opt_key == "xy_size_compensation" || *opt_key == "xy_size_compensation"
|| *opt_key == "adaptive_slicing" || *opt_key == "adaptive_slicing"
|| *opt_key == "adaptive_slicing_z_gradation"
|| *opt_key == "cusp_value" || *opt_key == "cusp_value"
|| *opt_key == "match_horizontal_surfaces" || *opt_key == "match_horizontal_surfaces"
|| *opt_key == "raft_layers") { || *opt_key == "raft_layers") {