From 133f3a0495ed293c8dfbfbd61347921711fa28b5 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 1 Dec 2011 19:40:45 +0100 Subject: [PATCH] Bugfix: Clipper error occurred under certain circumstances --- lib/Slic3r/ExPolygon.pm | 8 +++++++- lib/Slic3r/Layer.pm | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Slic3r/ExPolygon.pm b/lib/Slic3r/ExPolygon.pm index ba46f7095..6fc391a41 100644 --- a/lib/Slic3r/ExPolygon.pm +++ b/lib/Slic3r/ExPolygon.pm @@ -55,8 +55,14 @@ sub offset { sub safety_offset { my $self = shift; + + # we're offsetting contour and holes separately + # because Clipper doesn't return polygons in the same order as + # we feed them to it + return (ref $self)->new( - @{ Slic3r::Geometry::Clipper::safety_offset([@$self]) }, + $self->contour->safety_offset, + @{ Slic3r::Geometry::Clipper::safety_offset([$self->holes]) }, ); } diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm index 9ae5d090b..6c6511986 100644 --- a/lib/Slic3r/Layer.pm +++ b/lib/Slic3r/Layer.pm @@ -2,7 +2,7 @@ package Slic3r::Layer; use Moo; use Math::Clipper ':all'; -use Slic3r::Geometry qw(collinear X Y A B PI); +use Slic3r::Geometry qw(scale collinear X Y A B PI); use Slic3r::Geometry::Clipper qw(union_ex diff_ex intersection_ex PFT_EVENODD); use XXX; @@ -278,8 +278,8 @@ sub process_bridges { # now, extend our bridge by taking a portion of supporting surfaces { # offset the bridge by the specified amount of mm (minimum 3) - my $bridge_overlap = 3 / $Slic3r::resolution; - my ($bridge_offset) = $expolygon->contour->offset($bridge_overlap, $Slic3r::resolution * 100, JT_MITER, 2); + my $bridge_overlap = scale 3; + my ($bridge_offset) = $expolygon->contour->offset($bridge_overlap); # calculate the new bridge my $intersection = intersection_ex(