Optimization of extra perimeters detection

This commit is contained in:
Alessandro Ranellucci 2013-05-31 14:30:07 +02:00
parent 917915d68e
commit c62b49d1af
2 changed files with 22 additions and 15 deletions

View file

@ -6,7 +6,8 @@ require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(safety_offset safety_offset_ex offset offset_ex collapse_ex
diff_ex diff union_ex intersection_ex xor_ex PFT_EVENODD JT_MITER JT_ROUND
JT_SQUARE is_counter_clockwise union_pt offset2 offset2_ex traverse_pt);
JT_SQUARE is_counter_clockwise union_pt offset2 offset2_ex traverse_pt
intersection);
use Math::Clipper 1.22 qw(:cliptypes :polyfilltypes :jointypes is_counter_clockwise area);
use Slic3r::Geometry qw(scale);
@ -118,6 +119,18 @@ sub intersection_ex {
];
}
sub intersection {
my ($subject, $clip, $jointype, $safety_offset) = @_;
$jointype = PFT_NONZERO unless defined $jointype;
$clipper->clear;
$clipper->add_subject_polygons($subject);
$clipper->add_clip_polygons($safety_offset ? safety_offset($clip) : $clip);
return [
map Slic3r::Polygon->new($_),
@{ $clipper->execute(CT_INTERSECTION, $jointype, $jointype) },
];
}
sub xor_ex {
my ($subject, $clip, $jointype) = @_;
$jointype = PFT_NONZERO unless defined $jointype;