2011-09-26 08:52:58 +00:00
|
|
|
package Slic3r::ExtrusionPath::Collection;
|
|
|
|
use Moo;
|
|
|
|
|
2012-07-20 12:39:07 +00:00
|
|
|
has 'paths' => (is => 'rw', default => sub { [] });
|
2011-09-26 08:52:58 +00:00
|
|
|
|
|
|
|
sub endpoints {
|
|
|
|
my $self = shift;
|
2011-12-04 15:24:46 +00:00
|
|
|
return [ map $_->endpoints, @{$self->paths} ];
|
2011-09-26 08:52:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub shortest_path {
|
|
|
|
my $self = shift;
|
|
|
|
my ($start_near) = @_;
|
|
|
|
|
2012-10-30 12:59:33 +00:00
|
|
|
my $collection = Slic3r::Polyline::Collection->new(
|
|
|
|
polylines => [ map $_->unpack->polyline, @{$self->paths} ],
|
|
|
|
);
|
2012-07-20 12:39:07 +00:00
|
|
|
|
2012-10-30 12:59:33 +00:00
|
|
|
return $collection->shortest_path($start_near, $self->paths);
|
2011-09-26 08:52:58 +00:00
|
|
|
}
|
|
|
|
|
2011-10-01 12:26:54 +00: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 16:11:59 +00:00
|
|
|
sub detect_arcs {
|
|
|
|
my $self = shift;
|
2011-11-07 13:12:07 +00:00
|
|
|
@{$self->paths} = map $_->detect_arcs(@_), @{$self->paths};
|
2011-10-20 16:11:59 +00:00
|
|
|
}
|
|
|
|
|
2011-09-26 08:52:58 +00:00
|
|
|
1;
|