From 88c9ae6ca690e8661b08bf31b14dfec98af7e442 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 5 Jun 2017 12:02:26 +0200 Subject: [PATCH] Fix of https://github.com/prusa3d/Slic3r/issues/315 a crash if the max_layer_height is left to a default value of zero. --- lib/Slic3r/GUI/3DScene.pm | 17 +++++++++++++++-- xs/src/libslic3r/Slicing.cpp | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 9e35e32f7..34dd48ca8 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1471,8 +1471,21 @@ sub draw_active_object_annotations { my $max_z = unscale($print_object->size->z); my $profile = $print_object->model_object->layer_height_profile; my $layer_height = $print_object->config->get('layer_height'); - my $layer_heights_max = $print_object->print->config->get('max_layer_height'); - my $layer_height_max = my $max = max(@{$layer_heights_max}) * 1.12; + my $layer_height_max = 10000000000.; + { + # Get a maximum layer height value. + #FIXME This is a duplicate code of Slicing.cpp. + my $nozzle_diameters = $print_object->print->config->get('nozzle_diameter'); + my $layer_heights_min = $print_object->print->config->get('min_layer_height'); + my $layer_heights_max = $print_object->print->config->get('max_layer_height'); + for (my $i = 0; $i < scalar(@{$nozzle_diameters}); $i += 1) { + my $lh_min = ($layer_heights_min->[$i] == 0.) ? 0.07 : max(0.01, $layer_heights_min->[$i]); + my $lh_max = ($layer_heights_max->[$i] == 0.) ? (0.75 * $nozzle_diameters->[$i]) : $layer_heights_max->[$i]; + $layer_height_max = min($layer_height_max, max($lh_min, $lh_max)); + } + } + # Make the vertical bar a bit wider so the layer height curve does not touch the edge of the bar region. + $layer_height_max *= 1.12; # Baseline glColor3f(0., 0., 0.); glBegin(GL_LINE_STRIP); diff --git a/xs/src/libslic3r/Slicing.cpp b/xs/src/libslic3r/Slicing.cpp index 0348af0f9..27cebdd46 100644 --- a/xs/src/libslic3r/Slicing.cpp +++ b/xs/src/libslic3r/Slicing.cpp @@ -21,7 +21,7 @@ namespace Slic3r { static const coordf_t MIN_LAYER_HEIGHT = 0.01; -static const coordf_t MIN_LAYER_HEIGHT_DEFAULT = 0.05; +static const coordf_t MIN_LAYER_HEIGHT_DEFAULT = 0.07; // Minimum layer height for the variable layer height algorithm. inline coordf_t min_layer_height_from_nozzle(const PrintConfig &print_config, int idx_nozzle)