2011-09-04 10:04:01 +00:00
|
|
|
package Slic3r::ExtrusionPath;
|
2011-09-06 09:50:43 +00:00
|
|
|
use Moo;
|
2011-09-04 10:04:01 +00:00
|
|
|
|
|
|
|
extends 'Slic3r::Polyline';
|
|
|
|
|
2011-09-25 21:15:45 +00:00
|
|
|
sub clip_end {
|
|
|
|
my $self = shift;
|
|
|
|
my ($distance) = @_;
|
|
|
|
|
|
|
|
while ($distance > 0) {
|
|
|
|
my $last_point = pop @{$self->points};
|
|
|
|
|
|
|
|
my $last_segment_length = $last_point->distance_to($self->points->[-1]);
|
|
|
|
if ($last_segment_length <= $distance) {
|
|
|
|
$distance -= $last_segment_length;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $new_point = Slic3r::Geometry::point_along_segment($last_point->p, $self->points->[-1]->p, $distance);
|
|
|
|
push @{$self->points}, Slic3r::Point->cast($new_point);
|
|
|
|
$distance = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-04 10:04:01 +00:00
|
|
|
1;
|