Ported diff() and intersection()

This commit is contained in:
Alessandro Ranellucci 2013-07-17 01:21:30 +02:00
parent c7b6818ccf
commit 0efea9e442
4 changed files with 72 additions and 43 deletions

View file

@ -25,18 +25,6 @@ sub safety_offset_ex {
@{Math::Clipper::ex_int_offset(_convert($polygons), $factor // (scale 1e-05), 100000, JT_MITER, 2)};
}
sub diff {
my ($subject, $clip, $safety_offset) = @_;
$clipper->clear;
$clipper->add_subject_polygons(_convert($subject));
$clipper->add_clip_polygons($safety_offset ? _convert(safety_offset($clip)) : _convert($clip));
return [
map Slic3r::Polygon->new(@$_),
@{ $clipper->execute(CT_DIFFERENCE, PFT_NONZERO, PFT_NONZERO) },
];
}
sub union_pt {
my ($polygons, $jointype, $safety_offset) = @_;
$jointype = PFT_NONZERO unless defined $jointype;
@ -45,18 +33,6 @@ sub union_pt {
return $clipper->pt_execute(CT_UNION, $jointype, $jointype);
}
sub intersection {
my ($subject, $clip, $jointype, $safety_offset) = @_;
$jointype = PFT_NONZERO unless defined $jointype;
$clipper->clear;
$clipper->add_subject_polygons(_convert($subject));
$clipper->add_clip_polygons($safety_offset ? _convert(safety_offset($clip)) : _convert($clip));
return [
map Slic3r::Polygon->new(@$_),
@{ $clipper->execute(CT_INTERSECTION, $jointype, $jointype) },
];
}
sub collapse_ex {
my ($polygons, $width) = @_;
return offset2_ex($polygons, -$width/2, +$width/2);