mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-03 17:25:01 +08:00
Safer safety_offset() for ExPolygons
This commit is contained in:
parent
4cb36fcbe2
commit
4c41f6c462
@ -85,15 +85,7 @@ sub offset_ex {
|
|||||||
|
|
||||||
sub safety_offset {
|
sub safety_offset {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
return Slic3r::Geometry::Clipper::safety_offset_ex($self, @_);
|
||||||
# we're offsetting contour and holes separately
|
|
||||||
# because Clipper doesn't return polygons in the same order as
|
|
||||||
# we feed them to it
|
|
||||||
|
|
||||||
return (ref $self)->new(
|
|
||||||
$self->contour->safety_offset,
|
|
||||||
@{ Slic3r::Geometry::Clipper::safety_offset([$self->holes]) },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub noncollapsing_offset_ex {
|
sub noncollapsing_offset_ex {
|
||||||
|
@ -4,7 +4,7 @@ use warnings;
|
|||||||
|
|
||||||
require Exporter;
|
require Exporter;
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT_OK = qw(safety_offset offset offset_ex collapse_ex
|
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
|
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);
|
||||||
|
|
||||||
@ -17,6 +17,11 @@ sub safety_offset {
|
|||||||
return Math::Clipper::offset($polygons, $factor // (scale 1e-05), 100000, JT_MITER, 2);
|
return Math::Clipper::offset($polygons, $factor // (scale 1e-05), 100000, JT_MITER, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub safety_offset_ex {
|
||||||
|
# offset polygons and then apply holes to the right contours
|
||||||
|
return @{ union_ex([ safety_offset(@_) ]) };
|
||||||
|
}
|
||||||
|
|
||||||
sub offset {
|
sub offset {
|
||||||
my ($polygons, $distance, $scale, $joinType, $miterLimit) = @_;
|
my ($polygons, $distance, $scale, $joinType, $miterLimit) = @_;
|
||||||
$scale ||= 100000;
|
$scale ||= 100000;
|
||||||
|
@ -95,11 +95,6 @@ sub area {
|
|||||||
return Slic3r::Geometry::Clipper::area($self);
|
return Slic3r::Geometry::Clipper::area($self);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub safety_offset {
|
|
||||||
my $self = shift;
|
|
||||||
return (ref $self)->new(Slic3r::Geometry::Clipper::safety_offset([$self])->[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub offset {
|
sub offset {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return map Slic3r::Polygon->new($_), Slic3r::Geometry::Clipper::offset([$self], @_);
|
return map Slic3r::Polygon->new($_), Slic3r::Geometry::Clipper::offset([$self], @_);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user