From 73aae07e74cbe1a221e4de1acd7743f4271e21ca Mon Sep 17 00:00:00 2001 From: Mike Sheldrake Date: Fri, 11 Jan 2013 10:15:42 -0800 Subject: [PATCH] 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. --- lib/Slic3r/Layer/Region.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index 2a2736719..238a8e98e 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -227,7 +227,9 @@ sub make_perimeters { # and we can extract the gap for later processing my $diff = diff_ex( [ 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; }