842, 847 slightly enlarge a clip polygon to counteract integer truncation

Geomery in referenced issues triggered Clipper problems, but also
pointed to a situation where integer truncation (as coordinates pass
into Clipper) might be shrinking a clip polygon in a way that leaves
degenerate or unwanted thin clip results. Growing the clip polygon by 2
is expected to overcome any issues caused by truncation of floats.
This commit is contained in:
Mike Sheldrake 2013-01-11 10:15:42 -08:00
parent 3d03faf0b2
commit 73aae07e74

View File

@ -227,7 +227,9 @@ sub make_perimeters {
# 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) ],
[ Slic3r::Geometry::Clipper::offset([map @$_, @offsets], +0.5*$distance) ], # +2 on the offset here makes sure that Clipper float truncation
# won't shrink the clip polygon to be smaller than intended.
[ Slic3r::Geometry::Clipper::offset([map @$_, @offsets], +0.5*$distance + 2) ],
); );
push @gaps, grep $_->area >= $gap_area_threshold, @$diff; push @gaps, grep $_->area >= $gap_area_threshold, @$diff;
} }