Optimization of travel paths for perimeters

This commit is contained in:
Alessandro Ranellucci 2011-09-25 23:15:45 +02:00
parent 03341f3485
commit 0cd10441a1
7 changed files with 113 additions and 46 deletions

View file

@ -3,4 +3,23 @@ use Moo;
extends 'Slic3r::Polyline';
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;
}
}
1;