From 0c22250740986a702cdf3d9d19db51ca423ce1bd Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 25 Aug 2012 16:30:11 +0200 Subject: [PATCH] New option to disable retraction when moving between infill paths inside the same island. #29 --- README.markdown | 3 +++ lib/Slic3r/Config.pm | 7 +++++++ lib/Slic3r/GCode.pm | 14 ++++++-------- lib/Slic3r/GUI/Tab.pm | 2 +- slic3r.pl | 3 +++ 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/README.markdown b/README.markdown index a335f0cb..46c779a8 100644 --- a/README.markdown +++ b/README.markdown @@ -170,6 +170,9 @@ The author of the Silk icon set is Mark James. --layer-gcode Load layer-change G-code from the supplied file (default: nothing). --extra-perimeters Add more perimeters when needed (default: yes) --randomize-start Randomize starting point across layers (default: yes) + --only-retract-when-crossing-perimeters + Disable retraction when travelling between infill paths inside the same island. + (default: no) --solid-infill-below-area Force solid infill when a region has a smaller area than this threshold (mm^2, default: 70) diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 36aaa5ae..97992d5b 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -470,6 +470,13 @@ our $Options = { type => 'bool', default => 1, }, + 'only_retract_when_crossing_perimeters' => { + label => 'Only retract when crossing perimeters', + tooltip => 'Disables retraction when travelling between infill paths inside the same island.', + cli => 'only-retract-when-crossing-perimeters!', + type => 'bool', + default => 0, + }, 'support_material' => { label => 'Generate support material', tooltip => 'Enable support material generation.', diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index b5e020ac..ae6d63c6 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -132,15 +132,13 @@ sub extrude_path { my $gcode = ""; # retract if distance from previous position is greater or equal to the one - # specified by the user *and* to the maximum distance between infill lines + # specified by the user { - my $distance_from_last_pos = $self->last_pos->distance_to($path->points->[0]) * &Slic3r::SCALING_FACTOR; - my $distance_threshold = $self->extruder->retract_before_travel; - $distance_threshold = 2 * ($self->layer ? $self->layer->flow->width : $Slic3r::flow->width) / $Slic3r::Config->fill_density * sqrt(2) - if 0 && $Slic3r::Config->fill_density > 0 && $description =~ /fill/; - - if ($distance_from_last_pos >= $distance_threshold) { - $gcode .= $self->retract(travel_to => $path->points->[0]); + my $travel = Slic3r::Line->new($self->last_pos, $path->points->[0]); + if ($travel->length >= scale $self->extruder->retract_before_travel) { + if (!$Slic3r::Config->only_retract_when_crossing_perimeters || $path->role != EXTR_ROLE_FILL || !first { $_->expolygon->encloses_line($travel) } @{$self->layer->slices}) { + $gcode .= $self->retract(travel_to => $path->points->[0]); + } } } diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index cd68593a..16107b54 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -401,7 +401,7 @@ sub build { }, { title => 'Advanced', - options => [qw(infill_every_layers fill_angle solid_infill_below_area)], + options => [qw(infill_every_layers fill_angle solid_infill_below_area only_retract_when_crossing_perimeters)], }, ]); diff --git a/slic3r.pl b/slic3r.pl index 0f9baa58..2e9c8707 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -213,6 +213,9 @@ $j --layer-gcode Load layer-change G-code from the supplied file (default: nothing). --extra-perimeters Add more perimeters when needed (default: yes) --randomize-start Randomize starting point across layers (default: yes) + --only-retract-when-crossing-perimeters + Disable retraction when travelling between infill paths inside the same island. + (default: no) --solid-infill-below-area Force solid infill when a region has a smaller area than this threshold (mm^2, default: $config->{solid_infill_below_area})