From 81bae56e928a075642d598059d9ab326804ef9b8 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 3 Jun 2013 12:25:32 +0200 Subject: [PATCH] Limit only_retract_when_crossing_perimeters to travel moves that are completely enclosed in the upper layer's slices so that we avoid visible traces on top layers. #1091 --- lib/Slic3r/GCode.pm | 4 ++-- lib/Slic3r/Layer.pm | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 4519d933a..da6855210 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -283,7 +283,7 @@ sub travel_to { $travel->translate(-$self->shift_x, -$self->shift_y); if ($travel->length < scale $self->extruder->retract_before_travel - || ($self->config->only_retract_when_crossing_perimeters && first { $_->encloses_line($travel, scaled_epsilon) } @{$self->layer->slices}) + || ($self->config->only_retract_when_crossing_perimeters && first { $_->encloses_line($travel, scaled_epsilon) } @{$self->layer->upper_layer_slices}) || ($role == EXTR_ROLE_SUPPORTMATERIAL && $self->layer->support_islands_enclose_line($travel)) ) { $self->straight_once(0); @@ -326,7 +326,7 @@ sub _plan { my $need_retract = !$self->config->only_retract_when_crossing_perimeters; if (!$need_retract) { $need_retract = 1; - foreach my $slice (@{$self->layer->slices}) { + foreach my $slice (@{$self->layer->upper_layer_slices}) { # discard the island if at any line is not enclosed in it next if first { !$slice->encloses_line($_, scaled_epsilon) } @travel; # okay, this island encloses the full travel path diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm index 074baef55..ac6d8d290 100644 --- a/lib/Slic3r/Layer.pm +++ b/lib/Slic3r/Layer.pm @@ -54,6 +54,12 @@ sub support_material_contact_z { return $self->print_z - ($self->height - $self->support_material_contact_height) / &Slic3r::SCALING_FACTOR; } +sub upper_layer_slices { + my $self = shift; + + my $upper_layer = $self->object->layers->[ $self->id + 1 ] or return []; + return $upper_layer->slices; + sub region { my $self = shift; my ($region_id) = @_;