Fixed wipe (includes regression test). #1421

This commit is contained in:
Alessandro Ranellucci 2013-09-06 19:14:06 +02:00
parent e02ae0d18a
commit 4dd12b57a1
3 changed files with 26 additions and 9 deletions

View file

@ -112,23 +112,24 @@ sub clip_start {
my $self = shift;
my ($distance) = @_;
my @points = @$self;
my $points = [ $self->[0] ];
for (my $i = 1; $distance > 0 && $i <= $#$self; $i++) {
my $point = $self->[$i];
my $segment_length = $point->distance_to($self->[$i-1]);
for (my $i = 1; $distance > 0 && $i <= $#points; $i++) {
my $point = $points[$i];
my $segment_length = $point->distance_to($points[$i-1]);
if ($segment_length <= $distance) {
$distance -= $segment_length;
push @$points, $point;
next;
}
my $new_point = Slic3r::Geometry::point_along_segment($self->[$i-1], $point, $distance);
push @$points, Slic3r::Point->new($new_point);
my $new_point = Slic3r::Geometry::point_along_segment($points[$i-1], $point, $distance);
push @$points, Slic3r::Point->new(@$new_point);
$distance = 0;
}
return __PACKAGE__->new($points);
return __PACKAGE__->new(@$points);
}
# this method returns a collection of points picked on the polygon contour