From 554d10c85476ecf69eb707c09d8e945b3b472f96 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 31 Oct 2012 19:08:29 +0100 Subject: [PATCH] Only put ExtrusionPath objects in ExtrusionPath::Collection (no ExtrusionLoop objects) --- lib/Slic3r/ExtrusionLoop.pm | 8 -------- lib/Slic3r/Layer/Region.pm | 23 +++++++++-------------- lib/Slic3r/Polygon.pm | 5 +++++ 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib/Slic3r/ExtrusionLoop.pm b/lib/Slic3r/ExtrusionLoop.pm index 44a779207..325593cb5 100644 --- a/lib/Slic3r/ExtrusionLoop.pm +++ b/lib/Slic3r/ExtrusionLoop.pm @@ -60,14 +60,6 @@ sub split_at_first_point { return $self->split_at_index(0); } -# although a loop doesn't have endpoints, this method is provided to allow -# ExtrusionLoop objects to be added to an ExtrusionPath::Collection and -# sorted by the ->shortest_path() method -sub endpoints { - my $self = shift; - return ($self->polygon->[0], $self->polygon->[-1]); -} - package Slic3r::ExtrusionLoop::Packed; sub unpack { my $self = shift; diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index f2e34426f..9f88dae87 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -359,20 +359,15 @@ sub make_perimeters { } # add thin walls as perimeters - { - my @thin_paths = (); - my %properties = ( - role => EXTR_ROLE_EXTERNAL_PERIMETER, - flow_spacing => $self->perimeter_flow->spacing, - ); - for (@{ $self->thin_walls }) { - push @thin_paths, $_->isa('Slic3r::Polygon') - ? Slic3r::ExtrusionLoop->pack(polygon => $_, %properties) - : Slic3r::ExtrusionPath->pack(polyline => $_, %properties); - } - my $collection = Slic3r::ExtrusionPath::Collection->new(paths => \@thin_paths); - push @{ $self->perimeters }, $collection->shortest_path; - } + push @{ $self->perimeters }, Slic3r::ExtrusionPath::Collection->new(paths => [ + map { + Slic3r::ExtrusionPath->pack( + polyline => ($_->isa('Slic3r::Polygon') ? $_->split_at_first_point : $_), + role => EXTR_ROLE_EXTERNAL_PERIMETER, + flow_spacing => $self->perimeter_flow->spacing, + ); + } @{ $self->thin_walls } + ])->shortest_path; } sub _add_perimeter { diff --git a/lib/Slic3r/Polygon.pm b/lib/Slic3r/Polygon.pm index 18f840a45..3210e7896 100644 --- a/lib/Slic3r/Polygon.pm +++ b/lib/Slic3r/Polygon.pm @@ -146,4 +146,9 @@ sub split_at { return $self->split_at_index($i); } +sub split_at_first_point { + my $self = shift; + return $self->split_at_index(0); +} + 1; \ No newline at end of file