Safer safety_offset() for ExPolygons

new-support
Alessandro Ranellucci 2013-03-26 13:57:37 +01:00
parent 4cb36fcbe2
commit 4c41f6c462
3 changed files with 7 additions and 15 deletions

View File

@ -85,15 +85,7 @@ sub offset_ex {
sub safety_offset {
my $self = shift;
# 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]) },
);
return Slic3r::Geometry::Clipper::safety_offset_ex($self, @_);
}
sub noncollapsing_offset_ex {

View File

@ -4,7 +4,7 @@ use warnings;
require 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
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);
}
sub safety_offset_ex {
# offset polygons and then apply holes to the right contours
return @{ union_ex([ safety_offset(@_) ]) };
}
sub offset {
my ($polygons, $distance, $scale, $joinType, $miterLimit) = @_;
$scale ||= 100000;

View File

@ -95,11 +95,6 @@ sub area {
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 {
my $self = shift;
return map Slic3r::Polygon->new($_), Slic3r::Geometry::Clipper::offset([$self], @_);