From 71209711b366d59d0691ce63e4668045e11a8c40 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 23 Jul 2014 00:57:31 +0200 Subject: [PATCH] Bugfix: ignore only_retract_when_crossing_perimeters when fill_density = 0 --- lib/Slic3r/GCode.pm | 1 + t/retraction.t | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 2966000cd4..38ce4ccb8d 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -335,6 +335,7 @@ sub travel_to { # *and* in an island in the upper layer (so that the ooze will not be visible) if ($travel->length < scale $self->extruder->retract_before_travel || ($self->config->only_retract_when_crossing_perimeters + && $self->config->fill_density > 0 && (first { $_->contains_line($travel) } @{$self->_upper_layer_islands}) && (first { $_->contains_line($travel) } @{$self->_layer_islands})) || (defined $role && $role == EXTR_ROLE_SUPPORTMATERIAL && (first { $_->contains_line($travel) } @{$self->layer->support_islands})) diff --git a/t/retraction.t b/t/retraction.t index 68a71569d3..b86255dfcb 100644 --- a/t/retraction.t +++ b/t/retraction.t @@ -1,4 +1,4 @@ -use Test::More tests => 17; +use Test::More tests => 18; use strict; use warnings; @@ -155,4 +155,29 @@ use Slic3r::Test qw(_eq); is $layer_changes_with_retraction, 0, 'no retraction on layer change'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('only_retract_when_crossing_perimeters', 1); + $config->set('fill_density', 0); + + my $print = Slic3r::Test::init_print('cube_with_hole', config => $config); + my $retracted = 0; + my $traveling_without_retraction = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($info->{retracting}) { + $retracted = 1; + } elsif ($info->{extruding} && $retracted) { + $retracted = 0; + } elsif ($info->{travel} && !$retracted) { + if ($info->{dist_XY} > $config->retract_before_travel->[0]) { + $traveling_without_retraction = 1; + } + } + }); + + ok !$traveling_without_retraction, 'always retract when using only_retract_when_crossing_perimeters and fill_density = 0'; +} + __END__