Fixed regression causing some bridges not to be detected correctly. #629

This commit is contained in:
Alessandro Ranellucci 2012-08-25 20:04:29 +02:00
parent fe6c8fabdb
commit 896641cb7e
5 changed files with 43 additions and 26 deletions

View file

@ -4,11 +4,11 @@ use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(explode_expolygon explode_expolygons safety_offset offset
our @EXPORT_OK = qw(explode_expolygon explode_expolygons safety_offset offset offset_ex
diff_ex diff union_ex intersection_ex xor_ex PFT_EVENODD JT_MITER JT_ROUND
JT_SQUARE is_counter_clockwise);
use Math::Clipper 1.09 ':all';
use Math::Clipper 1.09 qw(:cliptypes :polyfilltypes :jointypes is_counter_clockwise area);
use Slic3r::Geometry qw(scale);
our $clipper = Math::Clipper->new;
@ -27,6 +27,21 @@ sub safety_offset {
return Math::Clipper::offset($polygons, $factor || (scale 1e-05), 100, JT_MITER, 2);
}
sub offset {
my ($polygons, $distance, $scale, $joinType, $miterLimit) = @_;
$scale ||= &Slic3r::SCALING_FACTOR * 1000000;
$joinType = JT_MITER if !defined $joinType;
$miterLimit ||= 2;
my $offsets = Math::Clipper::offset($polygons, $distance, $scale, $joinType, $miterLimit);
return @$offsets;
}
sub offset_ex {
# offset polygons and then apply holes to the right contours
return @{ union_ex([ offset(@_) ]) };
}
sub diff_ex {
my ($subject, $clip, $safety_offset) = @_;