From f20209ce0159e93889ddb67392476ad47c9f662a Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 18 Dec 2011 13:38:45 +0100 Subject: [PATCH] Add spacing between adjacent surfaces to avoid mini blobs --- lib/Slic3r/Fill.pm | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Fill.pm b/lib/Slic3r/Fill.pm index 6a18b3fde3..e602301a58 100644 --- a/lib/Slic3r/Fill.pm +++ b/lib/Slic3r/Fill.pm @@ -11,7 +11,7 @@ use Slic3r::Fill::OctagramSpiral; use Slic3r::Fill::PlanePath; use Slic3r::Fill::Rectilinear; use Slic3r::Fill::Rectilinear2; -use Slic3r::Geometry qw(shortest_path); +use Slic3r::Geometry qw(scale shortest_path); use Slic3r::Geometry::Clipper qw(union_ex diff_ex); use XXX; @@ -79,6 +79,36 @@ sub make_fill { } } + # add spacing between adjacent surfaces + { + my $distance = scale $Slic3r::flow_spacing / 2; + my @offsets = (); + foreach my $surface (@surfaces) { + my $expolygon = $surface->expolygon; + my $diff = diff_ex( + [ $expolygon->offset($distance) ], + $expolygon, + 1, + ); + push @offsets, map @$_, @$diff; + } + + my @new_surfaces = (); + foreach my $surface (@surfaces) { + my $diff = diff_ex( + $surface->expolygon, + [ @offsets ], + ); + + push @new_surfaces, map Slic3r::Surface->cast_from_expolygon($_, + surface_type => $surface->surface_type, + bridge_angle => $surface->bridge_angle, + depth_layers => $surface->depth_layers, + ), @$diff; + } + @surfaces = @new_surfaces; + } + # organize infill surfaces using a shortest path search @surfaces = @{shortest_path([ map [ $_->contour->points->[0], $_ ], @surfaces,