diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2014-03-24 22:56:18 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2014-03-24 22:56:18 +0400 |
commit | 630004d15614f61a5e85dcd4d6449cc84c88a126 (patch) | |
tree | 944dbc7e3a5ea0c2a6bd208ab1f0b3270dae4d9a | |
parent | 2a52a318fe9ae37b0844a25a37ea03825142bc80 (diff) |
Bugfix: wrong inwards moves were calculated for 2+ copies because ExtrusionLoop objects were modified in place. Includes regression test. #1842
-rw-r--r-- | lib/Slic3r/GCode.pm | 4 | ||||
-rw-r--r-- | t/perimeters.t | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index da973186f..cbac719b4 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -175,6 +175,10 @@ sub extrude { sub extrude_loop { my ($self, $loop, $description) = @_; + # make a copy; don't modify the orientation of the original loop object otherwise + # next copies (if any) would not detect the correct orientation + $loop = $loop->clone; + # extrude all loops ccw my $was_clockwise = $loop->make_counter_clockwise; my $polygon = $loop->polygon; diff --git a/t/perimeters.t b/t/perimeters.t index eeb0b4047..8cdf24733 100644 --- a/t/perimeters.t +++ b/t/perimeters.t @@ -43,6 +43,7 @@ use Slic3r::Test; { $config->set('external_perimeter_speed', 68); + $config->set('duplicate', 2); # we test two copies to make sure ExtrusionLoop objects are not modified in-place (the second object would not detect cw loops and thus would calculate wrong inwards moves) my $print = Slic3r::Test::init_print('cube_with_hole', config => $config); my $has_cw_loops = my $has_outwards_move = 0; my $cur_loop; @@ -58,6 +59,11 @@ use Slic3r::Test; $has_cw_loops = 1 if Slic3r::Polygon->new_scale(@$cur_loop)->is_clockwise; if ($self->F == $config->external_perimeter_speed*60) { my $move_dest = Slic3r::Point->new_scale(@$info{qw(new_X new_Y)}); + + # reset counter for second object + $external_loops{$self->Z} = 0 + if defined($external_loops{$self->Z}) && $external_loops{$self->Z} == 2; + $external_loops{$self->Z}++; $has_outwards_move = 1 if !Slic3r::Polygon->new_scale(@$cur_loop)->encloses_point($move_dest) |