PrusaSlicer-NonPlainar/lib/Slic3r/ExtrusionPath/Collection.pm

42 lines
1.0 KiB
Perl
Raw Normal View History

2011-09-26 08:52:58 +00:00
package Slic3r::ExtrusionPath::Collection;
use Moo;
has 'paths' => (is => 'rw', default => sub { [] });
2011-09-26 08:52:58 +00:00
# no-op
sub unpack { $_[0] }
sub first_point {
2011-09-26 08:52:58 +00:00
my $self = shift;
return $self->paths->[0]->unpack->polyline->[0];
2011-09-26 08:52:58 +00:00
}
sub chained_path {
2011-09-26 08:52:58 +00:00
my $self = shift;
my ($start_near) = @_;
# make sure we pass the same path objects to the Collection constructor
# and the ->chained_path() method because the latter will reverse the
# paths in-place when needed and we need to return them that way
my @paths = map $_->unpack, @{$self->paths};
2012-10-30 12:59:33 +00:00
my $collection = Slic3r::Polyline::Collection->new(
polylines => [ map $_->polyline, @paths ],
2012-10-30 12:59:33 +00:00
);
return $collection->chained_path($start_near, \@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};
}
sub detect_arcs {
my $self = shift;
@{$self->paths} = map $_->detect_arcs(@_), @{$self->paths};
}
2011-09-26 08:52:58 +00:00
1;