From 83435aebb4484b6da9dd8fe9586912fa2b7d73f5 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 30 Apr 2014 14:42:08 +0200 Subject: [PATCH] Make sure spiral vase mode is not enabled for multi-island layers. #1938 Conflicts: lib/Slic3r/GCode/Layer.pm t/shells.t --- lib/Slic3r/GCode/Layer.pm | 2 ++ lib/Slic3r/Test.pm | 7 +++++++ t/shells.t | 39 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GCode/Layer.pm b/lib/Slic3r/GCode/Layer.pm index 0745b070..11e31586 100644 --- a/lib/Slic3r/GCode/Layer.pm +++ b/lib/Slic3r/GCode/Layer.pm @@ -51,6 +51,8 @@ sub process_layer { ($layer->id > 0 || $Slic3r::Config->brim_width == 0) && ($layer->id >= $Slic3r::Config->skirt_height) && ($layer->id >= $Slic3r::Config->bottom_solid_layers) + && !defined(first { @{$_->perimeters} > 1 } @{$layer->regions}) + && !defined(first { @{$_->fills} > 0 } @{$layer->regions}) ); } diff --git a/lib/Slic3r/Test.pm b/lib/Slic3r/Test.pm index b7ea6171..25ba2f9e 100644 --- a/lib/Slic3r/Test.pm +++ b/lib/Slic3r/Test.pm @@ -97,6 +97,13 @@ sub model { $facets = [ [0,1,2],[0,3,4],[3,1,4],[1,3,2],[3,0,2],[4,1,0], ]; + } elsif ($model_name eq 'two_hollow_squares') { + $vertices = [ + [66.7133483886719,104.286666870117,0],[66.7133483886719,95.7133331298828,0],[65.6666870117188,94.6666717529297,0],[75.2866821289062,95.7133331298828,0],[76.3333435058594,105.333335876465,0],[76.3333435058594,94.6666717529297,0],[65.6666870117188,105.33332824707,0],[75.2866821289062,104.286666870117,0],[71.1066818237305,104.58666229248,2.79999995231628],[66.4133529663086,104.58666229248,2.79999995231628],[75.5866851806641,104.58666229248,2.79999995231628],[66.4133529663086,99.8933334350586,2.79999995231628],[66.4133529663086,95.4133377075195,2.79999995231628],[71.1066818237305,95.4133377075195,2.79999995231628],[75.5866851806641,95.4133377075195,2.79999995231628],[75.5866851806641,100.106666564941,2.79999995231628],[74.5400161743164,103.540000915527,2.79999995231628],[70.0320129394531,103.540000915527,2.79999995231628],[67.4600067138672,103.540000915527,2.79999995231628],[67.4600067138672,100.968002319336,2.79999995231628],[67.4600067138672,96.4599990844727,2.79999995231628],[74.5400161743164,99.0319976806641,2.79999995231628],[74.5400161743164,96.4599990844727,2.79999995231628],[70.0320129394531,96.4599990844727,2.79999995231628],[123.666717529297,94.6666717529297,0],[134.333312988281,94.6666717529297,0],[124.413360595703,95.4133377075195,2.79999995231628],[129.106674194336,95.4133377075195,2.79999995231628],[133.586669921875,95.4133377075195,2.79999995231628],[123.666717529297,105.33332824707,0],[124.413360595703,104.58666229248,2.79999995231628],[124.413360595703,99.8933334350586,2.79999995231628],[134.333312988281,105.33332824707,0],[129.106674194336,104.58666229248,2.79999995231628],[133.586669921875,104.58666229248,2.79999995231628],[133.586669921875,100.106666564941,2.79999995231628],[124.713317871094,104.286666870117,0],[124.713317871094,95.7133331298828,0],[133.286712646484,95.7133331298828,0],[133.286712646484,104.286666870117,0],[132.540023803711,103.540000915527,2.79999995231628],[128.032028198242,103.540008544922,2.79999995231628],[125.460006713867,103.540000915527,2.79999995231628],[125.460006713867,100.968002319336,2.79999995231628],[125.460006713867,96.4599990844727,2.79999995231628],[132.540023803711,99.0319976806641,2.79999995231628],[132.540023803711,96.4599990844727,2.79999995231628],[128.032028198242,96.4599990844727,2.79999995231628], + ]; + $facets = [ + [0,1,2],[3,4,5],[6,4,0],[6,0,2],[2,1,5],[7,4,3],[1,3,5],[0,4,7],[4,6,8],[6,9,8],[4,8,10],[6,2,9],[2,11,9],[2,12,11],[2,5,12],[5,13,12],[5,14,13],[4,10,15],[5,4,14],[4,15,14],[7,16,17],[0,7,18],[7,17,18],[1,19,20],[1,0,19],[0,18,19],[7,3,21],[3,22,21],[7,21,16],[3,23,22],[3,1,23],[1,20,23],[24,25,26],[25,27,26],[25,28,27],[29,24,30],[24,31,30],[24,26,31],[32,29,33],[29,30,33],[32,33,34],[32,34,35],[25,32,28],[32,35,28],[36,37,24],[38,32,25],[29,32,36],[29,36,24],[24,37,25],[39,32,38],[37,38,25],[36,32,39],[39,40,41],[36,39,42],[39,41,42],[37,43,44],[37,36,43],[36,42,43],[39,38,45],[38,46,45],[39,45,40],[38,47,46],[38,37,47],[37,44,47],[16,8,9],[16,10,8],[10,16,15],[15,16,21],[22,15,21],[15,22,14],[22,23,14],[23,20,14],[17,16,9],[18,17,9],[19,18,9],[19,9,11],[19,11,20],[13,14,20],[20,11,12],[13,20,12],[41,40,30],[42,41,30],[43,42,30],[43,30,31],[43,31,44],[27,28,44],[44,31,26],[27,44,26],[40,33,30],[40,34,33],[34,40,35],[35,40,45],[46,35,45],[35,46,28],[46,47,28],[47,44,28], + ]; } else { return undef; } diff --git a/t/shells.t b/t/shells.t index e967ea0e..f257f970 100644 --- a/t/shells.t +++ b/t/shells.t @@ -1,4 +1,4 @@ -use Test::More tests => 16; +use Test::More tests => 17; use strict; use warnings; @@ -205,11 +205,16 @@ use Slic3r::Test; { my $config = Slic3r::Config->new_from_defaults; $config->set('spiral_vase', 1); + $config->set('perimeters', 1); + $config->set('fill_density', 0); + $config->set('top_solid_layers', 0); $config->set('bottom_solid_layers', 0); + $config->set('retract_layer_change', [0]); $config->set('skirts', 0); $config->set('first_layer_height', '100%'); $config->set('layer_height', 0.4); $config->set('start_gcode', ''); + $config->validate; my $print = Slic3r::Test::init_print('20mm_cube', config => $config); my $z_moves = 0; @@ -221,6 +226,7 @@ use Slic3r::Test; my $sum_of_partial_z_equals_to_layer_height = 0; my $all_layer_segments_have_same_slope = 0; my $horizontal_extrusions = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { my ($self, $cmd, $args, $info) = @_; @@ -244,11 +250,11 @@ use Slic3r::Test; my $total_dist_XY = sum(map $_->[1], @this_layer); $sum_of_partial_z_equals_to_layer_height = 1 if abs(sum(map $_->[0], @this_layer) - $config->layer_height) > epsilon; - exit if $sum_of_partial_z_equals_to_layer_height; + foreach my $segment (@this_layer) { # check that segment's dist_Z is proportioned to its dist_XY $all_layer_segments_have_same_slope = 1 - if abs($segment->[0]*$total_dist_XY/$config->layer_height - $segment->[1]) > epsilon; + if abs($segment->[0]*$total_dist_XY/$config->layer_height - $segment->[1]) > 0.1; } @this_layer = (); @@ -267,4 +273,31 @@ use Slic3r::Test; ok !$horizontal_extrusions, 'no horizontal extrusions'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('perimeters', 1); + $config->set('fill_density', 0); + $config->set('top_solid_layers', 0); + $config->set('spiral_vase', 1); + $config->set('bottom_solid_layers', 0); + $config->set('skirts', 0); + $config->set('first_layer_height', '100%'); + $config->set('start_gcode', ''); + + my $print = Slic3r::Test::init_print('two_hollow_squares', config => $config); + my $diagonal_moves = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd eq 'G1') { + if ($info->{extruding} && $info->{dist_XY} > 0) { + if ($info->{dist_Z} > 0) { + $diagonal_moves++; + } + } + } + }); + is $diagonal_moves, 0, 'no spiral moves on two-island object'; +} + __END__