mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-08 14:34:04 -06:00
Merge branch 'better-brim'
Conflicts: lib/Slic3r/Geometry/Clipper.pm lib/Slic3r/Print.pm
This commit is contained in:
commit
7953dcfb12
5 changed files with 73 additions and 29 deletions
|
@ -6,9 +6,9 @@ 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);
|
||||
JT_SQUARE is_counter_clockwise union_pt offset2 offset2_ex);
|
||||
|
||||
use Math::Clipper 1.17 qw(:cliptypes :polyfilltypes :jointypes is_counter_clockwise area);
|
||||
use Math::Clipper 1.21 qw(:cliptypes :polyfilltypes :jointypes is_counter_clockwise area);
|
||||
use Slic3r::Geometry qw(scale);
|
||||
our $clipper = Math::Clipper->new;
|
||||
|
||||
|
@ -33,6 +33,16 @@ sub offset {
|
|||
return @$offsets;
|
||||
}
|
||||
|
||||
sub offset2 {
|
||||
my ($polygons, $distance1, $distance2, $scale, $joinType, $miterLimit) = @_;
|
||||
$scale ||= 100000;
|
||||
$joinType //= JT_MITER;
|
||||
$miterLimit //= 3;
|
||||
|
||||
my $offsets = Math::Clipper::int_offset2($polygons, $distance1, $distance2, $scale, $joinType, $miterLimit);
|
||||
return @$offsets;
|
||||
}
|
||||
|
||||
sub offset_ex {
|
||||
my ($polygons, $distance, $scale, $joinType, $miterLimit) = @_;
|
||||
$scale ||= 100000;
|
||||
|
@ -43,6 +53,16 @@ sub offset_ex {
|
|||
return map Slic3r::ExPolygon->new($_), @$offsets;
|
||||
}
|
||||
|
||||
sub offset2_ex {
|
||||
my ($polygons, $delta1, $delta2, $scale, $joinType, $miterLimit) = @_;
|
||||
$scale ||= 100000;
|
||||
$joinType //= JT_MITER;
|
||||
$miterLimit //= 3;
|
||||
|
||||
my $offsets = Math::Clipper::ex_int_offset2($polygons, $delta1, $delta2, $scale, $joinType, $miterLimit);
|
||||
return map Slic3r::ExPolygon->new($_), @$offsets;
|
||||
}
|
||||
|
||||
sub diff_ex {
|
||||
my ($subject, $clip, $safety_offset) = @_;
|
||||
|
||||
|
@ -78,6 +98,14 @@ sub union_ex {
|
|||
];
|
||||
}
|
||||
|
||||
sub union_pt {
|
||||
my ($polygons, $jointype, $safety_offset) = @_;
|
||||
$jointype = PFT_NONZERO unless defined $jointype;
|
||||
$clipper->clear;
|
||||
$clipper->add_subject_polygons($safety_offset ? safety_offset($polygons) : $polygons);
|
||||
return $clipper->pt_execute(CT_UNION, $jointype, $jointype);
|
||||
}
|
||||
|
||||
sub intersection_ex {
|
||||
my ($subject, $clip, $jointype, $safety_offset) = @_;
|
||||
$jointype = PFT_NONZERO unless defined $jointype;
|
||||
|
@ -102,19 +130,9 @@ sub xor_ex {
|
|||
];
|
||||
}
|
||||
|
||||
sub ex_int_offset2 {
|
||||
my ($polygons, $delta1, $delta2, $scale, $joinType, $miterLimit) = @_;
|
||||
$scale ||= 100000;
|
||||
$joinType //= JT_MITER;
|
||||
$miterLimit //= 3;
|
||||
|
||||
my $offsets = Math::Clipper::ex_int_offset2($polygons, $delta1, $delta2, $scale, $joinType, $miterLimit);
|
||||
return map Slic3r::ExPolygon->new($_), @$offsets;
|
||||
}
|
||||
|
||||
sub collapse_ex {
|
||||
my ($polygons, $width) = @_;
|
||||
return [ ex_int_offset2($polygons, -$width/2, +$width/2) ];
|
||||
return [ offset2_ex($polygons, -$width/2, +$width/2) ];
|
||||
}
|
||||
|
||||
sub simplify_polygon {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue