Very large refactoring. Ditched Slic3r::Polyline::Closed and reorganized geometric classes.

This commit is contained in:
Alessandro Ranellucci 2011-12-30 19:59:51 +01:00
parent 2def6a9787
commit 8ed91a8ec4
20 changed files with 293 additions and 349 deletions

View file

@ -3,11 +3,21 @@ use Moo;
use XXX;
extends 'Slic3r::Polyline::Closed';
# the underlying Slic3r::Polygon objects holds the geometry
has 'polygon' => (
is => 'ro',
required => 1,
handles => [qw(is_printable nearest_point_to)],
);
# perimeter/fill/solid-fill/bridge/skirt
has 'role' => (is => 'rw', required => 1);
sub BUILD {
my $self = shift;
bless $self->polygon, 'Slic3r::Polygon';
}
sub split_at {
my $self = shift;
my ($point) = @_;
@ -16,8 +26,8 @@ sub split_at {
# find index of point
my $i = -1;
for (my $n = 0; $n <= $#{$self->points}; $n++) {
if ($point->id eq $self->points->[$n]->id) {
for (my $n = 0; $n <= $#{$self->polygon}; $n++) {ZZZ "here" if ref $self->polygon->[$n] eq 'ARRAY';
if ($point->id eq $self->polygon->[$n]->id) {
$i = $n;
last;
}
@ -25,10 +35,13 @@ sub split_at {
die "Point not found" if $i == -1;
my @new_points = ();
push @new_points, @{$self->points}[$i .. $#{$self->points}];
push @new_points, @{$self->points}[0 .. $i];
push @new_points, @{$self->polygon}[$i .. $#{$self->polygon}];
push @new_points, @{$self->polygon}[0 .. $i];
return Slic3r::ExtrusionPath->new(points => [@new_points], role => $self->role);
return Slic3r::ExtrusionPath->new(
polyline => Slic3r::Polyline->new(\@new_points),
role => $self->role,
);
}
1;