Fixes, improvements and refactoring for bridges and solid surfaces.

This commit is contained in:
Alessandro Ranellucci 2011-11-23 09:49:39 +01:00
parent d13a0e2503
commit 13ef24b5eb
7 changed files with 61 additions and 51 deletions

View file

@ -22,6 +22,8 @@ has 'surface_type' => (
# this integer represents the thickness of the surface expressed in layers
has 'depth_layers' => (is => 'ro', default => sub {1});
has 'bridge_angle' => (is => 'ro');
sub cast_from_polygon {
my $class = shift;
my ($polygon, %args) = @_;
@ -47,6 +49,25 @@ sub cast_from_expolygon {
);
}
# static method to group surfaces having same surface_type and bridge_angle
sub group {
my $class = shift;
my (@surfaces) = @_;
my $unique_type = sub { $_[0]->surface_type . "_" . ($_[0]->bridge_angle || '') };
my @unique_types = ();
foreach my $surface (@surfaces) {
my $type = $unique_type->($surface);
push @unique_types, $type unless grep $_ eq $type, @unique_types;
}
my @groups = ();
foreach my $type (@unique_types) {
push @groups, [ grep { $unique_type->($_) eq $type } @surfaces ];
}
return @groups;
}
sub add_hole {
my $self = shift;
my ($hole) = @_;