From 4680bbdfe2625e4a6beeb0d86b54b7bb34e26968 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 30 Apr 2014 12:23:07 +0200 Subject: [PATCH] Make sure spiral vase mode is not enabled for multi-island layers. #1938 --- lib/Slic3r/GCode/Layer.pm | 2 ++ t/shells.t | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GCode/Layer.pm b/lib/Slic3r/GCode/Layer.pm index 4f453d16..957e4b6d 100644 --- a/lib/Slic3r/GCode/Layer.pm +++ b/lib/Slic3r/GCode/Layer.pm @@ -53,6 +53,8 @@ sub process_layer { ($layer->id > 0 || $self->print->config->brim_width == 0) && ($layer->id >= $self->print->config->skirt_height && $self->print->config->skirt_height != -1) && !defined(first { $_->config->bottom_solid_layers > $layer->id } @{$layer->regions}) + && !defined(first { @{$_->perimeters} > 1 } @{$layer->regions}) + && !defined(first { @{$_->fills} > 0 } @{$layer->regions}) ); } diff --git a/t/shells.t b/t/shells.t index 8fb2b9bb..914a10c7 100644 --- a/t/shells.t +++ b/t/shells.t @@ -1,4 +1,4 @@ -use Test::More tests => 10; +use Test::More tests => 17; use strict; use warnings; @@ -208,11 +208,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; @@ -224,6 +229,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) = @_; @@ -247,11 +253,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 = (); @@ -270,4 +276,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__