Refactored Perimeter code with new Slic3r::Polygon and Slic3r::ExPolygon objects

Large refactoring. Speed gains. Removed convex hull for bridges.
This commit is contained in:
Alessandro Ranellucci 2011-10-15 11:36:05 +02:00
parent 2d784fac9b
commit 5090ae561c
11 changed files with 174 additions and 100 deletions

View file

@ -33,6 +33,10 @@ sub cast_from_expolygon {
my $class = shift;
my ($expolygon, %args) = @_;
if (ref $expolygon ne 'HASH') {
$expolygon = $expolygon->clipper_expolygon;
}
return $class->new(
contour => Slic3r::Polyline::Closed->cast($expolygon->{outer}),
holes => [
@ -79,6 +83,11 @@ sub p {
return ($self->contour->p, map $_->p, @{$self->holes});
}
sub expolygon {
my $self = shift;
return Slic3r::ExPolygon->new($self->contour->p, map $_->p, @{$self->holes});
}
sub lines {
my $self = shift;
return @{ $self->contour->lines }, map @{ $_->lines }, @{ $self->holes };