mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
More fixes.
This commit is contained in:
parent
34681af6ae
commit
bca3abb755
4 changed files with 43 additions and 2 deletions
32
lib/Slic3r/Geometry/Clipper.pm
Normal file
32
lib/Slic3r/Geometry/Clipper.pm
Normal file
|
@ -0,0 +1,32 @@
|
|||
package Slic3r::Geometry::Clipper;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(diff_ex diff union_ex);
|
||||
|
||||
use Math::Clipper ':all';
|
||||
our $clipper = Math::Clipper->new;
|
||||
|
||||
sub diff_ex {
|
||||
my ($subject, $clip) = @_;
|
||||
|
||||
$clipper->clear;
|
||||
$clipper->add_subject_polygons($subject);
|
||||
$clipper->add_clip_polygons($clip);
|
||||
return $clipper->ex_execute(CT_DIFFERENCE, PFT_NONZERO, PFT_NONZERO);
|
||||
}
|
||||
|
||||
sub diff {
|
||||
return [ map { $_->{outer}, $_->{holes} } diff_ex(@_) ];
|
||||
}
|
||||
|
||||
sub union_ex {
|
||||
my ($polygons) = @_;
|
||||
$clipper->clear;
|
||||
$clipper->add_subject_polygons($polygons);
|
||||
return $clipper->ex_execute(CT_UNION, PFT_NONZERO, PFT_NONZERO);
|
||||
}
|
||||
|
||||
1;
|
Loading…
Add table
Add a link
Reference in a new issue