mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-05-14 19:12:38 -07:00
Ported diff() and intersection()
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user