mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Fix integration of XS containers
This commit is contained in:
parent
9b582a11ff
commit
9458c7db97
34 changed files with 279 additions and 152 deletions
|
@ -12,21 +12,35 @@ sub first_point {
|
|||
return $self->paths->[0]->polyline->[0];
|
||||
}
|
||||
|
||||
# Note that our paths will be reversed in place when necessary.
|
||||
# (Same algorithm as Polyline::Collection)
|
||||
sub chained_path {
|
||||
my $self = shift;
|
||||
my ($start_near, $no_reverse) = @_;
|
||||
|
||||
return @{$self->paths} if $self->no_sort;
|
||||
my @my_paths = @{$self->paths};
|
||||
|
||||
# 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 = @{$self->paths};
|
||||
my $collection = Slic3r::Polyline::Collection->new(
|
||||
polylines => [ map $_->polyline, @paths ],
|
||||
);
|
||||
|
||||
return $collection->chained_path($start_near, \@paths, $no_reverse);
|
||||
my @paths = ();
|
||||
my $start_at;
|
||||
my $endpoints = $no_reverse
|
||||
? [ map { @$_[0,0] } @my_paths ]
|
||||
: [ map { @$_[0,-1] } @my_paths ];
|
||||
while (@my_paths) {
|
||||
# find nearest point
|
||||
my $start_index = defined $start_near
|
||||
? Slic3r::Geometry::nearest_point_index($start_near, $endpoints)
|
||||
: 0;
|
||||
|
||||
my $path_index = int($start_index/2);
|
||||
if ($start_index % 2 && !$no_reverse) { # index is end so reverse to make it the start
|
||||
$my_paths[$path_index]->reverse;
|
||||
}
|
||||
push @paths, splice @my_paths, $path_index, 1;
|
||||
splice @$endpoints, $path_index*2, 2;
|
||||
$start_near = $paths[-1][-1];
|
||||
}
|
||||
return @paths;
|
||||
}
|
||||
|
||||
sub cleanup {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue