Ported traverse_pt() to XS
This commit is contained in:
parent
b47b8ee34f
commit
a93c862338
9 changed files with 71 additions and 27 deletions
|
@ -4,7 +4,7 @@ use Moo;
|
|||
extends 'Slic3r::Fill::Base';
|
||||
|
||||
use Slic3r::Geometry qw(scale unscale X);
|
||||
use Slic3r::Geometry::Clipper qw(offset offset2 union_pt traverse_pt);
|
||||
use Slic3r::Geometry::Clipper qw(offset offset2 union_pt_chained);
|
||||
|
||||
sub fill_surface {
|
||||
my $self = shift;
|
||||
|
@ -37,7 +37,7 @@ sub fill_surface {
|
|||
# generate paths from the outermost to the innermost, to avoid
|
||||
# adhesion problems of the first central tiny loops
|
||||
@loops = map Slic3r::Polygon->new(@$_),
|
||||
reverse traverse_pt( union_pt(\@loops) );
|
||||
reverse @{union_pt_chained(\@loops)};
|
||||
|
||||
# order paths using a nearest neighbor search
|
||||
my @paths = ();
|
||||
|
|
|
@ -6,27 +6,8 @@ require Exporter;
|
|||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(offset offset_ex
|
||||
diff_ex diff union_ex intersection_ex xor_ex JT_ROUND JT_MITER
|
||||
JT_SQUARE is_counter_clockwise union_pt offset2 offset2_ex traverse_pt
|
||||
intersection intersection_pl diff_pl union CLIPPER_OFFSET_SCALE);
|
||||
|
||||
use Slic3r::Geometry qw(scale);
|
||||
use Slic3r::Geometry qw(chained_path);
|
||||
|
||||
sub traverse_pt {
|
||||
my ($polynodes) = @_;
|
||||
|
||||
# use a nearest neighbor search to order these children
|
||||
# TODO: supply second argument to chained_path() too?
|
||||
my @ordering_points = map { ($_->{outer} // $_->{hole})->first_point } @$polynodes;
|
||||
my @nodes = @$polynodes[ @{chained_path(\@ordering_points)} ];
|
||||
|
||||
my @polygons = ();
|
||||
foreach my $polynode (@$polynodes) {
|
||||
# traverse the next depth
|
||||
push @polygons, traverse_pt($polynode->{children});
|
||||
push @polygons, $polynode->{outer} // [ reverse @{$polynode->{hole}} ];
|
||||
}
|
||||
return @polygons;
|
||||
}
|
||||
JT_SQUARE is_counter_clockwise union_pt offset2 offset2_ex
|
||||
intersection intersection_pl diff_pl union CLIPPER_OFFSET_SCALE
|
||||
union_pt_chained);
|
||||
|
||||
1;
|
||||
|
|
|
@ -5,7 +5,7 @@ use List::Util qw(sum first);
|
|||
use Slic3r::ExtrusionPath ':roles';
|
||||
use Slic3r::Geometry qw(PI A B scale unscale chained_path points_coincide);
|
||||
use Slic3r::Geometry::Clipper qw(union_ex diff_ex intersection_ex
|
||||
offset offset2 offset2_ex union_pt traverse_pt diff intersection
|
||||
offset offset2 offset2_ex union_pt diff intersection
|
||||
union diff intersection_pl);
|
||||
use Slic3r::Surface ':types';
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use Slic3r::ExtrusionPath ':roles';
|
|||
use Slic3r::Geometry qw(X Y Z X1 Y1 X2 Y2 MIN MAX PI scale unscale move_points chained_path
|
||||
convex_hull);
|
||||
use Slic3r::Geometry::Clipper qw(diff_ex union_ex union_pt intersection_ex intersection offset
|
||||
offset2 traverse_pt JT_ROUND JT_SQUARE);
|
||||
offset2 union_pt_chained JT_ROUND JT_SQUARE);
|
||||
use Time::HiRes qw(gettimeofday tv_interval);
|
||||
|
||||
has 'config' => (is => 'rw', default => sub { Slic3r::Config->new_from_defaults }, trigger => 1);
|
||||
|
@ -678,7 +678,7 @@ sub make_brim {
|
|||
polygon => Slic3r::Polygon->new(@$_),
|
||||
role => EXTR_ROLE_SKIRT,
|
||||
flow_spacing => $flow->spacing,
|
||||
), reverse traverse_pt( union_pt(\@loops) ));
|
||||
), reverse @{union_pt_chained(\@loops)});
|
||||
}
|
||||
|
||||
sub write_gcode {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue