Replaced Moose with Moo => big performance boost and easier packaging

This commit is contained in:
Alessandro Ranellucci 2011-09-06 11:50:43 +02:00
parent bf5824781d
commit 26b05ab155
13 changed files with 67 additions and 75 deletions

View file

@ -1,12 +1,12 @@
package Slic3r::Layer;
use Moose;
use Moo;
use XXX;
# a sequential number of layer, starting at 0
has 'id' => (
is => 'ro',
isa => 'Int',
#isa => 'Int',
required => 1,
);
@ -16,18 +16,15 @@ has 'id' => (
has 'pointmap' => (
traits => ['Hash'],
is => 'rw',
isa => 'HashRef[Slic3r::Point]',
#isa => 'HashRef[Slic3r::Point]',
default => sub { {} },
handles => {
points => 'values',
},
);
# collection of segments generated by slicing the original geometry
# each segment is part of a closed polyline
has 'lines' => (
is => 'rw',
isa => 'ArrayRef[Slic3r::Line]',
#isa => 'ArrayRef[Slic3r::Line]',
default => sub { [] },
);
@ -35,21 +32,21 @@ has 'lines' => (
has 'surfaces' => (
traits => ['Array'],
is => 'rw',
isa => 'ArrayRef[Slic3r::Surface]',
#isa => 'ArrayRef[Slic3r::Surface]',
default => sub { [] },
);
# ordered collection of extrusion paths to build all perimeters
has 'perimeters' => (
is => 'rw',
isa => 'ArrayRef[Slic3r::ExtrusionPath]',
#isa => 'ArrayRef[Slic3r::ExtrusionPath]',
default => sub { [] },
);
# ordered collection of extrusion paths to build skirt loops
has 'skirts' => (
is => 'rw',
isa => 'ArrayRef[Slic3r::ExtrusionPath]',
#isa => 'ArrayRef[Slic3r::ExtrusionPath]',
default => sub { [] },
);
@ -58,14 +55,14 @@ has 'skirts' => (
has 'fill_surfaces' => (
traits => ['Array'],
is => 'rw',
isa => 'ArrayRef[Slic3r::Surface]',
#isa => 'ArrayRef[Slic3r::Surface]',
default => sub { [] },
);
# ordered collection of extrusion paths to fill surfaces
has 'fills' => (
is => 'rw',
isa => 'ArrayRef[Slic3r::ExtrusionPath]',
#isa => 'ArrayRef[Slic3r::ExtrusionPath]',
default => sub { [] },
);
@ -74,6 +71,11 @@ sub z {
return $self->id * $Slic3r::layer_height / $Slic3r::resolution;
}
sub points {
my $self = shift;
return values %{ $self->pointmap };
}
sub add_surface {
my $self = shift;
my (@vertices) = @_;