Ported Slic3r::ExPolygon::Collection to XS

This commit is contained in:
Alessandro Ranellucci 2013-07-14 00:38:01 +02:00
parent 7f4dc4e248
commit b1ad466189
10 changed files with 173 additions and 68 deletions

View file

@ -301,47 +301,19 @@ package Slic3r::ExPolygon::XS;
use base 'Slic3r::ExPolygon';
package Slic3r::ExPolygon::Collection;
use Moo;
use Slic3r::Geometry qw(X1 Y1);
has 'expolygons' => (is => 'ro', default => sub { [] });
sub clone {
my $self = shift;
return (ref $self)->new(
expolygons => [ map $_->clone, @{$self->expolygons} ],
);
}
sub align_to_origin {
my $self = shift;
my @bb = Slic3r::Geometry::bounding_box([ map @$_, map @$_, @{$self->expolygons} ]);
$_->translate(-$bb[X1], -$bb[Y1]) for @{$self->expolygons};
$self;
}
sub scale {
my $self = shift;
$_->scale(@_) for @{$self->expolygons};
$self;
}
sub rotate {
my $self = shift;
$_->rotate(@_) for @{$self->expolygons};
$self;
}
sub translate {
my $self = shift;
$_->translate(@_) for @{$self->expolygons};
my @bb = Slic3r::Geometry::bounding_box([ map @$_, map @$_, @$self ]);
$self->translate(-$bb[X1], -$bb[Y1]);
$self;
}
sub size {
my $self = shift;
return [ Slic3r::Geometry::size_2D([ map @$_, map @$_, @{$self->expolygons} ]) ];
return [ Slic3r::Geometry::size_2D([ map @$_, map @$_, @$self ]) ];
}
1;