Avoid overlapping regions (thanks Mike Sheldrake!). #726

This commit is contained in:
Alessandro Ranellucci 2012-10-24 16:43:41 +02:00
parent 1c50c8a401
commit f0d2b0e5ea

View File

@ -89,8 +89,12 @@ sub make_surfaces {
foreach my $surface (@surfaces) { foreach my $surface (@surfaces) {
push @{$self->slices}, map Slic3r::Surface->new push @{$self->slices}, map Slic3r::Surface->new
(expolygon => $_, surface_type => S_TYPE_INTERNAL), (expolygon => $_, surface_type => S_TYPE_INTERNAL),
map $_->offset_ex(+$distance), @{union_ex([
$surface->expolygon->offset_ex(-2*$distance); Slic3r::Geometry::Clipper::offset(
[Slic3r::Geometry::Clipper::offset($surface->expolygon, -2*$distance)],
+$distance,
),
])};
} }
# now detect thin walls by re-outgrowing offsetted surfaces and subtracting # now detect thin walls by re-outgrowing offsetted surfaces and subtracting
@ -187,14 +191,19 @@ sub make_perimeters {
# offsetting a polygon can result in one or many offset polygons # offsetting a polygon can result in one or many offset polygons
my @new_offsets = (); my @new_offsets = ();
foreach my $expolygon (@last_offsets) { foreach my $expolygon (@last_offsets) {
my @offsets = map $_->offset_ex(+0.5*$distance), $expolygon->noncollapsing_offset_ex(-1.5*$distance); my @offsets = @{union_ex([
Slic3r::Geometry::Clipper::offset(
[Slic3r::Geometry::Clipper::offset($expolygon, -1.5*$distance)],
+0.5*$distance,
),
])};
push @new_offsets, @offsets; push @new_offsets, @offsets;
# where the above check collapses the expolygon, then there's no room for an inner loop # where the above check collapses the expolygon, then there's no room for an inner loop
# and we can extract the gap for later processing # and we can extract the gap for later processing
my $diff = diff_ex( my $diff = diff_ex(
[ map @$_, $expolygon->offset_ex(-0.5*$distance) ], [ map @$_, $expolygon->offset_ex(-0.5*$distance) ],
[ map @$_, map $_->offset_ex(+0.5*$distance), @offsets ], # should these be offsetted in a single pass? [ Slic3r::Geometry::Clipper::offset([map @$_, @offsets], +0.5*$distance) ],
); );
push @gaps, grep $_->area >= $gap_area_threshold, @$diff; push @gaps, grep $_->area >= $gap_area_threshold, @$diff;
} }