Organize perimeters with a nearest point search to avoid unnecessary travel moves. #21

This commit is contained in:
Alessandro Ranellucci 2011-11-07 15:40:09 +01:00
parent e860254780
commit 279bfbb10d
3 changed files with 35 additions and 1 deletions

View file

@ -29,7 +29,9 @@ sub shortest_path {
my $start_at;
CYCLE: while (@{$self->paths}) {
# find nearest point
$start_at = Slic3r::Point->new(Slic3r::Geometry::nearest_point($start_near, [ $self->endpoints ]));
$start_at = $start_near
? Slic3r::Point->new(Slic3r::Geometry::nearest_point($start_near, [ $self->endpoints ]))
: $self->endpoints->[0];
# loop through paths to find the one that starts or ends at the point found
PATH: for (my $i = 0; $i <= $#{$self->paths}; $i++) {