mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
Reorder object copies using a nearest neighbor search
This commit is contained in:
parent
cf5adca928
commit
25554a345f
2 changed files with 11 additions and 3 deletions
|
@ -134,7 +134,7 @@ sub add_model {
|
||||||
|
|
||||||
if ($object->instances) {
|
if ($object->instances) {
|
||||||
# replace the default [0,0] instance with the custom ones
|
# replace the default [0,0] instance with the custom ones
|
||||||
@{$print_object->copies} = map [ scale $_->offset->[X], scale $_->offset->[Y] ], @{$object->instances};
|
$print_object->copies([ map [ scale $_->offset->[X], scale $_->offset->[Y] ], @{$object->instances} ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use Moo;
|
||||||
|
|
||||||
use List::Util qw(min sum first);
|
use List::Util qw(min sum first);
|
||||||
use Slic3r::ExtrusionPath ':roles';
|
use Slic3r::ExtrusionPath ':roles';
|
||||||
use Slic3r::Geometry qw(Z PI scale unscale deg2rad rad2deg scaled_epsilon);
|
use Slic3r::Geometry qw(Z PI scale unscale deg2rad rad2deg scaled_epsilon chained_path_points);
|
||||||
use Slic3r::Geometry::Clipper qw(diff_ex intersection_ex union_ex offset collapse_ex);
|
use Slic3r::Geometry::Clipper qw(diff_ex intersection_ex union_ex offset collapse_ex);
|
||||||
use Slic3r::Surface ':types';
|
use Slic3r::Surface ':types';
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ has 'print' => (is => 'ro', weak_ref => 1, required => 1);
|
||||||
has 'input_file' => (is => 'rw', required => 0);
|
has 'input_file' => (is => 'rw', required => 0);
|
||||||
has 'meshes' => (is => 'rw', default => sub { [] }); # by region_id
|
has 'meshes' => (is => 'rw', default => sub { [] }); # by region_id
|
||||||
has 'size' => (is => 'rw', required => 1);
|
has 'size' => (is => 'rw', required => 1);
|
||||||
has 'copies' => (is => 'rw', default => sub {[ [0,0] ]});
|
has 'copies' => (is => 'rw', default => sub {[ [0,0] ]}, trigger => 1);
|
||||||
has 'layers' => (is => 'rw', default => sub { [] });
|
has 'layers' => (is => 'rw', default => sub { [] });
|
||||||
has 'layer_height_ranges' => (is => 'rw', default => sub { [] }); # [ z_min, z_max, layer_height ]
|
has 'layer_height_ranges' => (is => 'rw', default => sub { [] }); # [ z_min, z_max, layer_height ]
|
||||||
|
|
||||||
|
@ -50,6 +50,14 @@ sub BUILD {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _trigger_copies {
|
||||||
|
my $self = shift;
|
||||||
|
return unless @{$self->copies} > 1;
|
||||||
|
|
||||||
|
# order copies with a nearest neighbor search
|
||||||
|
@{$self->copies} = @{chained_path_points($self->copies)}
|
||||||
|
}
|
||||||
|
|
||||||
sub layer_count {
|
sub layer_count {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return scalar @{ $self->layers };
|
return scalar @{ $self->layers };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue