2011-09-26 10:52:58 +02:00
|
|
|
package Slic3r::ExtrusionPath::Collection;
|
|
|
|
use Moo;
|
|
|
|
|
2012-07-20 14:39:07 +02:00
|
|
|
has 'paths' => (is => 'rw', default => sub { [] });
|
2013-05-13 21:22:57 +02:00
|
|
|
has 'no_sort' => (is => 'rw');
|
2011-09-26 10:52:58 +02:00
|
|
|
|
2013-03-10 16:09:03 +01:00
|
|
|
# no-op
|
|
|
|
sub unpack { $_[0] }
|
|
|
|
|
|
|
|
sub first_point {
|
2011-09-26 10:52:58 +02:00
|
|
|
my $self = shift;
|
2013-03-10 16:09:03 +01:00
|
|
|
return $self->paths->[0]->unpack->polyline->[0];
|
2011-09-26 10:52:58 +02:00
|
|
|
}
|
|
|
|
|
2013-02-05 17:27:45 +01:00
|
|
|
sub chained_path {
|
2011-09-26 10:52:58 +02:00
|
|
|
my $self = shift;
|
2013-06-21 14:52:35 +02:00
|
|
|
my ($start_near, $no_reverse) = @_;
|
2011-09-26 10:52:58 +02:00
|
|
|
|
2013-05-13 21:22:57 +02:00
|
|
|
return @{$self->paths} if $self->no_sort;
|
|
|
|
|
2012-12-20 18:10:20 +01:00
|
|
|
# make sure we pass the same path objects to the Collection constructor
|
2013-02-05 17:27:45 +01:00
|
|
|
# and the ->chained_path() method because the latter will reverse the
|
2012-12-20 18:10:20 +01:00
|
|
|
# paths in-place when needed and we need to return them that way
|
|
|
|
my @paths = map $_->unpack, @{$self->paths};
|
2012-10-30 13:59:33 +01:00
|
|
|
my $collection = Slic3r::Polyline::Collection->new(
|
2012-12-20 18:10:20 +01:00
|
|
|
polylines => [ map $_->polyline, @paths ],
|
2012-10-30 13:59:33 +01:00
|
|
|
);
|
2012-07-20 14:39:07 +02:00
|
|
|
|
2013-06-21 14:52:35 +02:00
|
|
|
return $collection->chained_path($start_near, \@paths, $no_reverse);
|
2011-09-26 10:52:58 +02:00
|
|
|
}
|
|
|
|
|
2011-10-01 14:26:54 +02:00
|
|
|
sub cleanup {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# split paths at angles that are too acute to be printed as they will cause blobs
|
|
|
|
@{$self->paths} = map $_->split_at_acute_angles, @{$self->paths};
|
|
|
|
}
|
|
|
|
|
2011-10-20 18:11:59 +02:00
|
|
|
sub detect_arcs {
|
|
|
|
my $self = shift;
|
2011-11-07 14:12:07 +01:00
|
|
|
@{$self->paths} = map $_->detect_arcs(@_), @{$self->paths};
|
2011-10-20 18:11:59 +02:00
|
|
|
}
|
|
|
|
|
2011-09-26 10:52:58 +02:00
|
|
|
1;
|