From 8f32ee8f5a39262ebb96c80e34b82f3399163f3a Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 13 Nov 2011 21:46:32 +0100 Subject: [PATCH] Bugfix: recent changes broke the "Infill every N layers" feature --- lib/Slic3r/Fill.pm | 13 +++++++++++++ lib/Slic3r/Geometry/Clipper.pm | 7 +++++-- lib/Slic3r/Print.pm | 5 +++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/Slic3r/Fill.pm b/lib/Slic3r/Fill.pm index ad41cfd2..c6dc88d6 100644 --- a/lib/Slic3r/Fill.pm +++ b/lib/Slic3r/Fill.pm @@ -8,6 +8,7 @@ use Slic3r::Fill::HilbertCurve; use Slic3r::Fill::OctagramSpiral; use Slic3r::Fill::Rectilinear; use Slic3r::Fill::Rectilinear2; +use Slic3r::Geometry qw(shortest_path); use XXX; @@ -40,7 +41,19 @@ sub make_fill { } printf "Filling layer %d:\n", $layer->id; + + # organize $layer->fill_surfaces using a shortest path search + @{ $layer->fill_surfaces } = @{shortest_path([ + map [ $_->[0]->contour->points->[0], $_ ], grep @$_, @{ $layer->fill_surfaces }, + ])}; + foreach my $surfaces (@{ $layer->fill_surfaces }) { + + # organize $surfaces using a shortest path search + @$surfaces = @{shortest_path([ + map [ $_->contour->points->[0], $_ ], @$surfaces, + ])}; + SURFACE: foreach my $surface (@$surfaces) { Slic3r::debugf " Processing surface %s:\n", $surface->id; diff --git a/lib/Slic3r/Geometry/Clipper.pm b/lib/Slic3r/Geometry/Clipper.pm index aeacab66..3652d35e 100644 --- a/lib/Slic3r/Geometry/Clipper.pm +++ b/lib/Slic3r/Geometry/Clipper.pm @@ -31,11 +31,14 @@ sub diff_ex { $clipper->clear; $clipper->add_subject_polygons($subject); $clipper->add_clip_polygons($clip); - return $clipper->ex_execute(CT_DIFFERENCE, PFT_NONZERO, PFT_NONZERO); + return [ + map Slic3r::ExPolygon->new($_), + @{ $clipper->ex_execute(CT_DIFFERENCE, PFT_NONZERO, PFT_NONZERO) }, + ]; } sub diff { - return [ map { $_->{outer}, $_->{holes} } diff_ex(@_) ]; + return [ map @$_, diff_ex(@_) ]; } sub union_ex { diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 5a5b2220..6d9b3250 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -365,6 +365,7 @@ sub infill_every_layers { [ map $_->p, grep $_->surface_type eq 'internal', @$surfaces ], ); next if !@$intersection; + my $intersection_offsetted = safety_offset([ map @$_, @$intersection ]); # new fill surfaces of the current layer are: # - any non-internal surface @@ -387,7 +388,7 @@ sub infill_every_layers { map $_->p, grep $_->surface_type eq 'internal' && $_->depth_layers == $depth, @$surfaces, ], - safety_offset($intersection), + $intersection_offsetted, )}; } @$surfaces = @new_surfaces; @@ -408,7 +409,7 @@ sub infill_every_layers { map $_->p, grep $_->surface_type eq 'internal' && $_->depth_layers == $depth, @$lower_surfaces, ], - safety_offset($intersection), + $intersection_offsetted, )}; } @$lower_surfaces = @new_surfaces;