From a88ce0cb5eb444ac9988dd36798b024cc00b9a8a Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 16 Sep 2013 18:42:28 +0200 Subject: [PATCH] Fix regression in start perimeters at non-overhangs. #1442 --- lib/Slic3r/ExtrusionPath.pm | 8 ++++---- lib/Slic3r/GCode.pm | 18 +++++++++--------- lib/Slic3r/Polygon.pm | 7 ++++--- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/Slic3r/ExtrusionPath.pm b/lib/Slic3r/ExtrusionPath.pm index 85ab900ed..be97e3baa 100644 --- a/lib/Slic3r/ExtrusionPath.pm +++ b/lib/Slic3r/ExtrusionPath.pm @@ -29,18 +29,18 @@ sub clip_with_expolygon { sub intersect_expolygons { my $self = shift; - my ($expolygons) = @_; + my ($expolygons_pp) = @_; return map $self->clone(polyline => Slic3r::Polyline->new(@$_)), - @{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection([ map $_->pp, @$expolygons ], [$self->pp])}; + @{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection($expolygons_pp, [$self->pp])}; } sub subtract_expolygons { my $self = shift; - my ($expolygons) = @_; + my ($expolygons_pp) = @_; return map $self->clone(polyline => Slic3r::Polyline->new(@$_)), - @{Boost::Geometry::Utils::multi_linestring_multi_polygon_difference([$self->pp], [ map $_->pp, @$expolygons ])}; + @{Boost::Geometry::Utils::multi_linestring_multi_polygon_difference([$self->pp], $expolygons_pp)}; } sub simplify { diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 53d6eabe0..c0abf1bc6 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -16,7 +16,7 @@ has 'layer_count' => (is => 'ro', required => 1 ); has 'layer' => (is => 'rw'); has '_layer_islands' => (is => 'rw'); has '_upper_layer_islands' => (is => 'rw'); -has '_layer_overhangs' => (is => 'rw'); +has '_layer_overhangs_pp' => (is => 'rw'); has 'shift_x' => (is => 'rw', default => sub {0} ); has 'shift_y' => (is => 'rw', default => sub {0} ); has 'z' => (is => 'rw'); @@ -99,10 +99,10 @@ sub change_layer { $self->_layer_islands([]); $self->_upper_layer_islands([]); } - $self->_layer_overhangs( + $self->_layer_overhangs_pp( # clone ExPolygons because they come from Surface objects but will be used outside here - $layer->id > 0 && ($layer->config->overhangs || $Slic3r::Config->start_perimeters_at_non_overhang) - ? [ map $_->expolygon->clone, grep $_->surface_type == S_TYPE_BOTTOM, map @{$_->slices}, @{$layer->regions} ] + ($layer->id > 0 && ($layer->config->overhangs || $Slic3r::Config->start_perimeters_at_non_overhang)) + ? [ map $_->expolygon->pp, grep $_->surface_type == S_TYPE_BOTTOM, map @{$_->slices}, @{$layer->regions} ] : [] ); if ($self->config->avoid_crossing_perimeters) { @@ -180,7 +180,7 @@ sub extrude_loop { } my @candidates = (); if ($Slic3r::Config->start_perimeters_at_non_overhang) { - @candidates = grep !Boost::Geometry::Utils::point_covered_by_multi_polygon($_->pp, $self->_layer_overhangs), @concave; + @candidates = grep !Boost::Geometry::Utils::point_covered_by_multi_polygon($_->pp, $self->_layer_overhangs_pp), @concave; } if (!@candidates) { # if none, look for any concave vertex @@ -188,7 +188,7 @@ sub extrude_loop { if (!@candidates) { # if none, look for any non-overhang vertex if ($Slic3r::Config->start_perimeters_at_non_overhang) { - @candidates = grep !Boost::Geometry::Utils::point_covered_by_multi_polygon($_->pp, $self->_layer_overhangs), @{$polygon}; + @candidates = grep !Boost::Geometry::Utils::point_covered_by_multi_polygon($_->pp, $self->_layer_overhangs_pp), @$polygon; } if (!@candidates) { # if none, all points are valid candidates @@ -218,15 +218,15 @@ sub extrude_loop { my @paths = (); # detect overhanging/bridging perimeters - if ($self->layer->config->overhangs && $extrusion_path->is_perimeter && @{$self->_layer_overhangs}) { + if ($self->layer->config->overhangs && $extrusion_path->is_perimeter && @{$self->_layer_overhangs_pp}) { # get non-overhang paths by subtracting overhangs from the loop push @paths, - $extrusion_path->subtract_expolygons($self->_layer_overhangs); + $extrusion_path->subtract_expolygons($self->_layer_overhangs_pp); # get overhang paths by intersecting overhangs with the loop push @paths, map { $_->role(EXTR_ROLE_OVERHANG_PERIMETER); $_ } - $extrusion_path->intersect_expolygons($self->_layer_overhangs); + $extrusion_path->intersect_expolygons($self->_layer_overhangs_pp); # reapply the nearest point search for starting point # (clone because the collection gets DESTROY'ed) diff --git a/lib/Slic3r/Polygon.pm b/lib/Slic3r/Polygon.pm index 5f6dc892a..963c13fa2 100644 --- a/lib/Slic3r/Polygon.pm +++ b/lib/Slic3r/Polygon.pm @@ -69,9 +69,10 @@ sub subdivide { sub concave_points { my $self = shift; - my @points = @{$self->pp}; - return map $self->[$_], - grep Slic3r::Geometry::angle3points(@points[$_, $_-1, $_+1]) < PI - epsilon, + my @points = @$self; + my @points_pp = @{$self->pp}; + return map $points[$_], + grep Slic3r::Geometry::angle3points(@points_pp[$_, $_-1, $_+1]) < PI - epsilon, -1 .. ($#points-1); }