From 542d95a593fd372e4876bb12da5c3238a50d3648 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 21 Apr 2021 15:31:06 +0200 Subject: [PATCH 1/8] Fixing unit tests --- tests/fff_print/test_flow.cpp | 2 +- tests/libslic3r/test_placeholder_parser.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/fff_print/test_flow.cpp b/tests/fff_print/test_flow.cpp index 08ba15a84..dc73f4b6e 100644 --- a/tests/fff_print/test_flow.cpp +++ b/tests/fff_print/test_flow.cpp @@ -24,7 +24,7 @@ SCENARIO("Extrusion width specifics", "[Flow]") { { "skirts", 1 }, { "perimeters", 3 }, { "fill_density", "40%" }, - { "first_layer_height", "100%" } + { "first_layer_height", 0.3 } }); WHEN("first layer width set to 2mm") { diff --git a/tests/libslic3r/test_placeholder_parser.cpp b/tests/libslic3r/test_placeholder_parser.cpp index e632dc705..8c56afc6d 100644 --- a/tests/libslic3r/test_placeholder_parser.cpp +++ b/tests/libslic3r/test_placeholder_parser.cpp @@ -14,9 +14,12 @@ SCENARIO("Placeholder parser scripting", "[PlaceholderParser]") { { "nozzle_diameter", "0.6;0.6;0.6;0.6" }, { "temperature", "357;359;363;378" } }); - // To test the "first_layer_extrusion_width" over "first_layer_heigth" over "layer_height" chain. - config.option("first_layer_height")->value = 150.; - config.option("first_layer_height")->percent = true; + // To test the "first_layer_extrusion_width" over "first_layer_heigth". + // "first_layer_heigth" over "layer_height" is no more supported after first_layer_height was moved from PrintObjectConfig to PrintConfig. +// config.option("first_layer_height")->value = 150.; +// config.option("first_layer_height")->percent = true; + config.option("first_layer_height")->value = 1.5 * config.opt_float("layer_height"); + config.option("first_layer_height")->percent = false; // To let the PlaceholderParser throw when referencing first_layer_speed if it is set to percent, as the PlaceholderParser does not know // a percent to what. config.option("first_layer_speed")->value = 50.; @@ -50,7 +53,7 @@ SCENARIO("Placeholder parser scripting", "[PlaceholderParser]") { SECTION("math: int(-13.4)") { REQUIRE(parser.process("{int(-13.4)}") == "-13"); } // Test the "coFloatOrPercent" and "xxx_extrusion_width" substitutions. - // first_layer_extrusion_width ratio_over first_layer_heigth ratio_over layer_height + // first_layer_extrusion_width ratio_over first_layer_heigth. SECTION("perimeter_extrusion_width") { REQUIRE(std::stod(parser.process("{perimeter_extrusion_width}")) == Approx(0.67500001192092896)); } SECTION("first_layer_extrusion_width") { REQUIRE(std::stod(parser.process("{first_layer_extrusion_width}")) == Approx(0.9)); } SECTION("support_material_xy_spacing") { REQUIRE(std::stod(parser.process("{support_material_xy_spacing}")) == Approx(0.3375)); } From c013b73308cb8546812c74a64ce493d46e5000ec Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 21 Apr 2021 15:38:00 +0200 Subject: [PATCH 2/8] Fixing perl unit tests --- t/flow.t | 2 +- t/layers.t | 2 +- t/multi.t | 2 +- t/shells.t | 12 ++++++------ t/thin.t | 2 +- xs/t/15_config.t | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/t/flow.t b/t/flow.t index 4d7ee5ca2..50c491604 100644 --- a/t/flow.t +++ b/t/flow.t @@ -21,7 +21,7 @@ use Slic3r::Test; $config->set('fill_density', 0.4); $config->set('bottom_solid_layers', 1); $config->set('first_layer_extrusion_width', 2); - $config->set('first_layer_height', '100%'); + $config->set('first_layer_height', $config->layer_height); $config->set('filament_diameter', [ 3.0 ]); $config->set('nozzle_diameter', [ 0.5 ]); diff --git a/t/layers.t b/t/layers.t index a9f7dfe39..4d958808a 100644 --- a/t/layers.t +++ b/t/layers.t @@ -49,7 +49,7 @@ use Slic3r::Test qw(_eq); $config->set('first_layer_height', 0.2); ok $test->(), "absolute first layer height"; - $config->set('first_layer_height', '60%'); + $config->set('first_layer_height', 0.6 * $config->layer_height); ok $test->(), "relative first layer height"; $config->set('z_offset', 0.9); diff --git a/t/multi.t b/t/multi.t index 8e7225bec..e74a7a1a8 100644 --- a/t/multi.t +++ b/t/multi.t @@ -181,7 +181,7 @@ use Slic3r::Test; my $config = Slic3r::Config::new_from_defaults; $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $config->set('layer_height', 0.4); - $config->set('first_layer_height', '100%'); + $config->set('first_layer_height', $config->layer_height); $config->set('skirts', 0); my $print = Slic3r::Test::init_print($model, config => $config); diff --git a/t/shells.t b/t/shells.t index 47b5c8881..b6d6bf9be 100644 --- a/t/shells.t +++ b/t/shells.t @@ -84,7 +84,7 @@ use Slic3r::Test; { my $config = Slic3r::Config::new_from_defaults; $config->set('layer_height', 0.3); - $config->set('first_layer_height', '100%'); + $config->set('first_layer_height', $config->layer_height); $config->set('bottom_solid_layers', 0); $config->set('top_solid_layers', 3); $config->set('cooling', [ 0 ]); @@ -119,7 +119,7 @@ use Slic3r::Test; $config->set('cooling', [ 0 ]); # prevent speed alteration $config->set('first_layer_speed', '100%'); # prevent speed alteration $config->set('layer_height', 0.4); - $config->set('first_layer_height', '100%'); + $config->set('first_layer_height', $config->layer_height); $config->set('extrusion_width', 0.55); $config->set('bottom_solid_layers', 3); $config->set('top_solid_layers', 0); @@ -142,7 +142,7 @@ use Slic3r::Test; $config->set('cooling', [ 0 ]); # prevent speed alteration $config->set('first_layer_speed', '100%'); # prevent speed alteration $config->set('layer_height', 0.4); - $config->set('first_layer_height', '100%'); + $config->set('first_layer_height', $config->layer_height); $config->set('bottom_solid_layers', 3); $config->set('top_solid_layers', 3); $config->set('solid_infill_speed', 99); @@ -170,7 +170,7 @@ use Slic3r::Test; $config->set('spiral_vase', 1); $config->set('bottom_solid_layers', 0); $config->set('skirts', 0); - $config->set('first_layer_height', '100%'); + $config->set('first_layer_height', $config->layer_height); $config->set('start_gcode', ''); $config->set('temperature', [200]); $config->set('first_layer_temperature', [205]); @@ -231,7 +231,7 @@ use Slic3r::Test; $config->set('bottom_solid_layers', 0); $config->set('retract_layer_change', [0]); $config->set('skirts', 0); - $config->set('first_layer_height', '100%'); + $config->set('first_layer_height', $config->layer_height); $config->set('layer_height', 0.4); $config->set('start_gcode', ''); # $config->set('use_relative_e_distances', 1); @@ -310,7 +310,7 @@ use Slic3r::Test; # $config->set('spiral_vase', 1); # $config->set('bottom_solid_layers', 0); # $config->set('skirts', 0); -# $config->set('first_layer_height', '100%'); +# $config->set('first_layer_height', $config->layer_height); # $config->set('start_gcode', ''); # # my $print = Slic3r::Test::init_print('two_hollow_squares', config => $config); diff --git a/t/thin.t b/t/thin.t index 9147236ee..50e7abc95 100644 --- a/t/thin.t +++ b/t/thin.t @@ -18,7 +18,7 @@ use Slic3r::Test; if (0) { my $config = Slic3r::Config::new_from_defaults; $config->set('layer_height', 0.2); - $config->set('first_layer_height', '100%'); + $config->set('first_layer_height', $config->layer_height); $config->set('extrusion_width', 0.5); $config->set('first_layer_extrusion_width', '200%'); # check this one too $config->set('skirts', 0); diff --git a/xs/t/15_config.t b/xs/t/15_config.t index 55b679101..8981e0095 100644 --- a/xs/t/15_config.t +++ b/xs/t/15_config.t @@ -4,7 +4,7 @@ use strict; use warnings; use Slic3r::XS; -use Test::More tests => 147; +use Test::More tests => 146; foreach my $config (Slic3r::Config->new, Slic3r::Config::Static::new_FullPrintConfig) { $config->set('layer_height', 0.3); @@ -70,10 +70,10 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Static::new_FullPrintCo ok abs($config->get('first_layer_height') - 0.3) < 1e-4, 'set/get absolute floatOrPercent'; is $config->opt_serialize('first_layer_height'), '0.3', 'serialize absolute floatOrPercent'; - $config->set('first_layer_height', '50%'); + $config->set('first_layer_height', $config->layer_height); $config->get_abs_value('first_layer_height'); ok abs($config->get_abs_value('first_layer_height') - 0.15) < 1e-4, 'set/get relative floatOrPercent'; - is $config->opt_serialize('first_layer_height'), '50%', 'serialize relative floatOrPercent'; +# is $config->opt_serialize('first_layer_height'), '50%', 'serialize relative floatOrPercent'; # Uh-oh, we have no point option to test at the moment #ok $config->set('print_center', [50,80]), 'valid point coordinates'; From 39deffdf5b6cd4f4c2dd699bdc1e6f4e68a75dc9 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 21 Apr 2021 15:40:43 +0200 Subject: [PATCH 3/8] One more perl unit test fix --- t/shells.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/shells.t b/t/shells.t index b6d6bf9be..29bc0b5f0 100644 --- a/t/shells.t +++ b/t/shells.t @@ -231,8 +231,8 @@ use Slic3r::Test; $config->set('bottom_solid_layers', 0); $config->set('retract_layer_change', [0]); $config->set('skirts', 0); - $config->set('first_layer_height', $config->layer_height); $config->set('layer_height', 0.4); + $config->set('first_layer_height', $config->layer_height); $config->set('start_gcode', ''); # $config->set('use_relative_e_distances', 1); $config->validate; From ee53894c4009a9fad6ac560ea0405c8f3ae21340 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 21 Apr 2021 15:43:41 +0200 Subject: [PATCH 4/8] Another last perl unit test fix --- xs/t/15_config.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/t/15_config.t b/xs/t/15_config.t index 8981e0095..a79fe7a37 100644 --- a/xs/t/15_config.t +++ b/xs/t/15_config.t @@ -70,7 +70,7 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Static::new_FullPrintCo ok abs($config->get('first_layer_height') - 0.3) < 1e-4, 'set/get absolute floatOrPercent'; is $config->opt_serialize('first_layer_height'), '0.3', 'serialize absolute floatOrPercent'; - $config->set('first_layer_height', $config->layer_height); + $config->set('first_layer_height', $config->get('layer_height')); $config->get_abs_value('first_layer_height'); ok abs($config->get_abs_value('first_layer_height') - 0.15) < 1e-4, 'set/get relative floatOrPercent'; # is $config->opt_serialize('first_layer_height'), '50%', 'serialize relative floatOrPercent'; From dcfa1d10cfb63ed25efc77e1038ab7eb0fdda675 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 21 Apr 2021 15:46:47 +0200 Subject: [PATCH 5/8] Yet another Perl test --- xs/t/15_config.t | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xs/t/15_config.t b/xs/t/15_config.t index a79fe7a37..6326cae10 100644 --- a/xs/t/15_config.t +++ b/xs/t/15_config.t @@ -4,7 +4,7 @@ use strict; use warnings; use Slic3r::XS; -use Test::More tests => 146; +use Test::More tests => 144; foreach my $config (Slic3r::Config->new, Slic3r::Config::Static::new_FullPrintConfig) { $config->set('layer_height', 0.3); @@ -70,9 +70,10 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Static::new_FullPrintCo ok abs($config->get('first_layer_height') - 0.3) < 1e-4, 'set/get absolute floatOrPercent'; is $config->opt_serialize('first_layer_height'), '0.3', 'serialize absolute floatOrPercent'; - $config->set('first_layer_height', $config->get('layer_height')); - $config->get_abs_value('first_layer_height'); - ok abs($config->get_abs_value('first_layer_height') - 0.15) < 1e-4, 'set/get relative floatOrPercent'; +# This is no more supported after first_layer_height was moved from PrintObjectConfig to PrintConfig. +# $config->set('first_layer_height', $config->get('layer_height')); +# $config->get_abs_value('first_layer_height'); +# ok abs($config->get_abs_value('first_layer_height') - 0.15) < 1e-4, 'set/get relative floatOrPercent'; # is $config->opt_serialize('first_layer_height'), '50%', 'serialize relative floatOrPercent'; # Uh-oh, we have no point option to test at the moment From bb8112f0994d7dbfc5aa929a6ca480c40dad99a7 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 21 Apr 2021 15:47:28 +0200 Subject: [PATCH 6/8] and the final Perl unit test fix --- xs/t/15_config.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/t/15_config.t b/xs/t/15_config.t index 6326cae10..4d032019c 100644 --- a/xs/t/15_config.t +++ b/xs/t/15_config.t @@ -4,7 +4,7 @@ use strict; use warnings; use Slic3r::XS; -use Test::More tests => 144; +use Test::More tests => 143; foreach my $config (Slic3r::Config->new, Slic3r::Config::Static::new_FullPrintConfig) { $config->set('layer_height', 0.3); From d069591514e1fa332ad27523e52d13ee6d43abed Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Wed, 21 Apr 2021 16:29:12 +0200 Subject: [PATCH 7/8] Write hollow flag to SL1 files if any object is hollowed. --- src/libslic3r/Format/SL1.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libslic3r/Format/SL1.cpp b/src/libslic3r/Format/SL1.cpp index 64cb8b815..554e49b5a 100644 --- a/src/libslic3r/Format/SL1.cpp +++ b/src/libslic3r/Format/SL1.cpp @@ -371,6 +371,13 @@ void fill_iniconf(ConfMap &m, const SLAPrint &print) m["numSlow"] = std::to_string(stats.slow_layers_count); m["numFast"] = std::to_string(stats.fast_layers_count); m["printTime"] = std::to_string(stats.estimated_print_time); + + bool hollow_en = false; + auto it = print.objects().begin(); + while (!hollow_en && it != print.objects().end()) + hollow_en = hollow_en || (*it++)->config().hollowing_enable.getBool(); + + m["hollow"] = hollow_en ? "1" : "0"; m["action"] = "print"; } From 657d19482ba7ab6b01793d3232696889c25d2316 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Wed, 21 Apr 2021 16:49:11 +0200 Subject: [PATCH 8/8] Minor code refinements --- src/libslic3r/Format/SL1.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/Format/SL1.cpp b/src/libslic3r/Format/SL1.cpp index 554e49b5a..4038cb046 100644 --- a/src/libslic3r/Format/SL1.cpp +++ b/src/libslic3r/Format/SL1.cpp @@ -248,7 +248,7 @@ std::vector extract_slices_from_sla_archive( { double incr, val, prev; bool stop = false; - tbb::spin_mutex mutex; + tbb::spin_mutex mutex = {}; } st {100. / slices.size(), 0., 0.}; tbb::parallel_for(size_t(0), arch.images.size(), @@ -375,7 +375,7 @@ void fill_iniconf(ConfMap &m, const SLAPrint &print) bool hollow_en = false; auto it = print.objects().begin(); while (!hollow_en && it != print.objects().end()) - hollow_en = hollow_en || (*it++)->config().hollowing_enable.getBool(); + hollow_en = (*it++)->config().hollowing_enable; m["hollow"] = hollow_en ? "1" : "0";