mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 19:33:47 +00:00
Optimization in Polyline instantiation
This commit is contained in:
@@ -10,13 +10,8 @@ use Slic3r::Geometry::Clipper qw(JT_SQUARE);
|
||||
# the constructor accepts an array(ref) of points
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $self;
|
||||
if (@_ == 1) {
|
||||
$self = [ @{$_[0]} ];
|
||||
} else {
|
||||
$self = [ @_ ];
|
||||
}
|
||||
|
||||
my $self = [ @_ ];
|
||||
bless $self, $class;
|
||||
bless $_, 'Slic3r::Point' for @$self;
|
||||
$self;
|
||||
@@ -65,7 +60,7 @@ sub simplify {
|
||||
my $tolerance = shift || 10;
|
||||
|
||||
my $simplified = Boost::Geometry::Utils::linestring_simplify($self, $tolerance);
|
||||
return (ref $self)->new($simplified);
|
||||
return (ref $self)->new(@$simplified);
|
||||
}
|
||||
|
||||
sub reverse {
|
||||
@@ -83,9 +78,9 @@ sub grow {
|
||||
my ($distance, $scale, $joinType, $miterLimit) = @_;
|
||||
$joinType //= JT_SQUARE;
|
||||
|
||||
return map Slic3r::Polygon->new($_),
|
||||
return map Slic3r::Polygon->new(@$_),
|
||||
Slic3r::Geometry::Clipper::offset(
|
||||
[ Slic3r::Polygon->new(@$self, CORE::reverse @$self[1..($#$self-1)]) ],
|
||||
[ [ @$self, CORE::reverse @$self[1..($#$self-1)] ] ],
|
||||
$distance, $scale, $joinType, $miterLimit,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user