From 6dd400914ee08fe122c5e28d6304d95d5cb2cffc Mon Sep 17 00:00:00 2001 From: platsch Date: Thu, 21 Dec 2017 17:39:47 +0100 Subject: [PATCH] Removed factor 4 from layer height gradation, don't apply min/max layer height limitation after gradation. Fixes #4235 (#4241) --- t/adaptive_slicing.t | 2 +- xs/src/libslic3r/PrintConfig.cpp | 2 +- xs/src/libslic3r/PrintObject.cpp | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/t/adaptive_slicing.t b/t/adaptive_slicing.t index 64c3769fc..603e5e13e 100644 --- a/t/adaptive_slicing.t +++ b/t/adaptive_slicing.t @@ -138,7 +138,7 @@ subtest 'widen to match horizontal facets' => sub { subtest 'layer height gradation' => sub { plan tests => 5; - foreach my $gradation (1/0.001*4, 1/0.01*4, 1/0.02*4, 1/0.05*4, 1/0.08*4) { + foreach my $gradation (1/0.001, 1/0.01, 1/0.02, 1/0.05, 1/0.08) { $config->set('z_steps_per_mm', $gradation); $height_gradation_test->(); } diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index f909652c2..048ce4567 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1671,7 +1671,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("z_steps_per_mm", coFloat); def->label = "Z full steps/mm"; - def->tooltip = "Set this to the number of *full* steps (not microsteps) needed for moving the Z axis by 1mm; you can calculate this by dividing the number of microsteps configured in your firmware by the microstepping amount (8, 16, 32). Slic3r will round your configured layer height to the nearest multiple of that value in order to ensure the best accuracy. This is most useful for machines with imperial leadscrews or belt-driven Z or for unusual layer heights with metric leadscrews. Set to zero to disable this experimental feature."; + def->tooltip = "Set this to the number of *full* steps (not microsteps) needed for moving the Z axis by 1mm; you can calculate this by dividing the number of microsteps configured in your firmware by the microstepping amount (8, 16, 32). Slic3r will round your configured layer height to the nearest multiple of that value in order to ensure the best accuracy. This is most useful for machines with imperial leadscrews or belt-driven Z or for unusual layer heights with metric leadscrews. If you still experience wobbling, try using 4 * full_step to achieve the same motor phase pattern for every layer (important for belt driven z-axis). Set to zero to disable this experimental feature."; def->cli = "z-steps-per-mm=f"; def->default_value = new ConfigOptionFloat(0); diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index b6848082b..8c8e76b09 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -548,7 +548,7 @@ coordf_t PrintObject::adjust_layer_height(coordf_t layer_height) const { coordf_t result = layer_height; if(this->_print->config.z_steps_per_mm > 0) { - coordf_t min_dz = 1 / this->_print->config.z_steps_per_mm * 4; + coordf_t min_dz = 1 / this->_print->config.z_steps_per_mm; result = int(layer_height / min_dz + 0.5) * min_dz; } @@ -688,9 +688,13 @@ std::vector PrintObject::generate_object_layers(coordf_t first_layer_h // push modified spline object back to model this->_model_object->layer_height_spline = this->layer_height_spline; - // apply z-gradation (this is redundant for static layer height...) - coordf_t gradation = 1 / this->_print->config.z_steps_per_mm * 4; + // apply z-gradation. + // For static layer height: the adjusted layer height is still useful + // to have the layer height a multiple of a printable z-interval. + // If we don't do this, we might get aliasing effects if a small error accumulates + // over multiple layer until we get a slightly thicker layer. if(this->_print->config.z_steps_per_mm > 0) { + coordf_t gradation = 1 / this->_print->config.z_steps_per_mm; coordf_t last_z = 0; coordf_t height; for(std::vector::iterator l = result.begin(); l != result.end(); ++l) { @@ -702,7 +706,10 @@ std::vector PrintObject::generate_object_layers(coordf_t first_layer_h }else{ // round down height = height - gradation_effect; } - height = std::min(std::max(height, min_layer_height), max_layer_height); + // limiting the height to max_ / min_layer_height can violate the gradation requirement + // we now might exceed the layer height limits a bit, but that is probably better than having + // systematic errors introduced by the steppers... + //height = std::min(std::max(height, min_layer_height), max_layer_height); *l = last_z + height; last_z = *l; }