Ported diff_ex, intersection_ex, union_ex, xor_ex

This commit is contained in:
Alessandro Ranellucci 2013-07-17 00:29:09 +02:00
parent f7ada2b5db
commit bf8c799685
9 changed files with 72 additions and 48 deletions

View file

@ -57,18 +57,6 @@ sub diff {
];
}
sub union_ex {
my ($polygons, $jointype, $safety_offset) = @_;
$jointype = PFT_NONZERO unless defined $jointype;
$clipper->clear;
$polygons = $polygons->arrayref if ref $polygons eq 'Slic3r::ExPolygon';
$clipper->add_subject_polygons($safety_offset ? _convert(safety_offset($polygons)) : _convert($polygons));
return [
map Slic3r::ExPolygon->new($_->{outer}, @{$_->{holes}}),
@{ $clipper->ex_execute(CT_UNION, $jointype, $jointype) },
];
}
sub union_pt {
my ($polygons, $jointype, $safety_offset) = @_;
$jointype = PFT_NONZERO unless defined $jointype;
@ -77,18 +65,6 @@ sub union_pt {
return $clipper->pt_execute(CT_UNION, $jointype, $jointype);
}
sub intersection_ex {
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::ExPolygon->new($_->{outer}, @{$_->{holes}}),
@{ $clipper->ex_execute(CT_INTERSECTION, $jointype, $jointype) },
];
}
sub intersection {
my ($subject, $clip, $jointype, $safety_offset) = @_;
$jointype = PFT_NONZERO unless defined $jointype;
@ -101,18 +77,6 @@ sub intersection {
];
}
sub xor_ex {
my ($subject, $clip, $jointype) = @_;
$jointype = PFT_NONZERO unless defined $jointype;
$clipper->clear;
$clipper->add_subject_polygons(_convert($subject));
$clipper->add_clip_polygons(_convert($clip));
return [
map Slic3r::ExPolygon->new($_->{outer}, @{$_->{holes}}),
@{ $clipper->ex_execute(CT_XOR, $jointype, $jointype) },
];
}
sub collapse_ex {
my ($polygons, $width) = @_;
return offset2_ex($polygons, -$width/2, +$width/2);