diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 25db38c30..7ed5e3dd7 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -36,6 +36,7 @@ use Encode::Locale; use Moo 1.003001; use Slic3r::XS; # import all symbols (constants etc.) before they get parsed +use Slic3r::AdaptiveSlicing; use Slic3r::Config; use Slic3r::ExPolygon; use Slic3r::Extruder; diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 65d7dad6f..c7d4c11db 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -416,6 +416,7 @@ sub build { $self->init_config_options(qw( layer_height first_layer_height + adaptive_slicing cusp_value perimeters spiral_vase top_solid_layers bottom_solid_layers extra_perimeters avoid_crossing_perimeters thin_walls overhangs @@ -458,6 +459,8 @@ sub build { my $optgroup = $page->new_optgroup('Layer height'); $optgroup->append_single_option_line('layer_height'); $optgroup->append_single_option_line('first_layer_height'); + $optgroup->append_single_option_line('adaptive_slicing'); + $optgroup->append_single_option_line('cusp_value'); } { my $optgroup = $page->new_optgroup('Vertical shells'); @@ -694,6 +697,12 @@ sub _update { my $have_perimeters = $config->perimeters > 0; $self->get_field($_)->toggle($have_perimeters) for qw(extra_perimeters thin_walls overhangs seam_position external_perimeters_first); + + my $have_adaptive_slicing = $config->adaptive_slicing; + $self->get_field($_)->toggle($have_adaptive_slicing) + for qw(cusp_value); + $self->get_field($_)->toggle(!$have_adaptive_slicing) + for qw(layer_height); my $have_infill = $config->fill_density > 0; $self->get_field($_)->toggle($have_infill) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index a1aaff307..8cd5440af 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -107,7 +107,7 @@ sub slice { $self->clear_layers; # make layers taking custom heights into account - my $print_z = my $slice_z = my $height = my $id = 0; + my $print_z = my $slice_z = my $height = my $cusp_height = my $id = 0; my $first_object_layer_height = -1; my $first_object_layer_distance = -1; @@ -134,6 +134,11 @@ sub slice { # loop until we have at least one layer and the max slice_z reaches the object height my $max_z = unscale($self->size->z); while (($slice_z - $height) <= $max_z) { + + if ($self->config->adaptive_slicing) { + #dummy + } + # assign the default height to the layer according to the general settings $height = ($id == 0) ? $self->config->get_value('first_layer_height') diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 2e9d8a6bf..567acb11d 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -6,6 +6,11 @@ t_optiondef_map PrintConfigDef::build_def() { t_optiondef_map Options; + Options["adaptive_slicing"].type = coBool; + Options["adaptive_slicing"].label = "Use adaptive slicing"; + Options["adaptive_slicing"].tooltip = "Automatically determine layer heights by the objects topology instead of using the static value."; + Options["adaptive_slicing"].cli = "adaptive-slicing!"; + Options["avoid_crossing_perimeters"].type = coBool; Options["avoid_crossing_perimeters"].label = "Avoid crossing perimeters"; Options["avoid_crossing_perimeters"].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."; @@ -78,6 +83,14 @@ PrintConfigDef::build_def() { Options["cooling"].tooltip = "This flag enables the automatic cooling logic that adjusts print speed and fan speed according to layer printing time."; Options["cooling"].cli = "cooling!"; + Options["cusp_value"].type = coFloat; + Options["cusp_value"].label = "Cusp value"; + Options["cusp_value"].tooltip = "This value determines the maximum deviaton from the objects original surface caused by the stair-stepping effect (approximation of the surface by discrete layers). Use a value between 0 (highest possible resolution) and [max_layer_height] (lowest possible resolution). Typical values are 0.1 - 0.2."; + Options["cusp_value"].sidetext = "mm"; + Options["cusp_value"].cli = "cusp_value=f"; + Options["cusp_value"].min = 0; + Options["cusp_value"].max = 1; + Options["default_acceleration"].type = coFloat; Options["default_acceleration"].label = "Default"; Options["default_acceleration"].tooltip = "This is the acceleration your printer will be reset to after the role-specific acceleration values are used (perimeter/infill). Set zero to prevent resetting acceleration at all."; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index cdc3d7173..160acd4d0 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -114,6 +114,8 @@ class StaticPrintConfig : public virtual StaticConfig class PrintObjectConfig : public virtual StaticPrintConfig { public: + ConfigOptionBool adaptive_slicing; + ConfigOptionFloat cusp_value; ConfigOptionBool dont_support_bridges; ConfigOptionFloatOrPercent extrusion_width; ConfigOptionFloatOrPercent first_layer_height; @@ -138,6 +140,8 @@ class PrintObjectConfig : public virtual StaticPrintConfig ConfigOptionFloat xy_size_compensation; PrintObjectConfig() : StaticPrintConfig() { + this->adaptive_slicing.value = false; + this->cusp_value.value = 0.15; this->dont_support_bridges.value = true; this->extrusion_width.value = 0; this->extrusion_width.percent = false; @@ -167,6 +171,8 @@ class PrintObjectConfig : public virtual StaticPrintConfig }; ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + if (opt_key == "adaptive_slicing") return &this->adaptive_slicing; + if (opt_key == "cusp_value") return &this->cusp_value; if (opt_key == "dont_support_bridges") return &this->dont_support_bridges; if (opt_key == "extrusion_width") return &this->extrusion_width; if (opt_key == "first_layer_height") return &this->first_layer_height; diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index d89686327..d561dc6aa 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -145,7 +145,9 @@ PrintObject::invalidate_state_by_config_options(const std::vector