mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-08 22:35:15 -06:00
Ported ExtrusionPath::Collection
This commit is contained in:
parent
0efea9e442
commit
c030e38908
18 changed files with 181 additions and 60 deletions
|
@ -1,25 +1,19 @@
|
|||
package Slic3r::ExtrusionPath::Collection;
|
||||
use Moo;
|
||||
|
||||
has 'paths' => (is => 'rw', default => sub { [] });
|
||||
has 'no_sort' => (is => 'rw');
|
||||
|
||||
# no-op
|
||||
sub unpack { $_[0] }
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub first_point {
|
||||
my $self = shift;
|
||||
return $self->paths->[0]->polyline->[0];
|
||||
return $self->[0]->[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};
|
||||
my @my_paths = @$self;
|
||||
return @my_paths if $self->no_sort;
|
||||
|
||||
my @paths = ();
|
||||
my $start_at;
|
||||
|
@ -34,6 +28,7 @@ sub chained_path {
|
|||
|
||||
my $path_index = int($start_index/2);
|
||||
if ($start_index % 2 && !$no_reverse) { # index is end so reverse to make it the start
|
||||
# path is reversed in place, but we got a copy from XS
|
||||
$my_paths[$path_index]->reverse;
|
||||
}
|
||||
push @paths, splice @my_paths, $path_index, 1;
|
||||
|
|
|
@ -170,29 +170,28 @@ sub make_fill {
|
|||
$params->{flow_spacing} = $layerm->extruders->{infill}->bridge_flow->width if $is_bridge;
|
||||
|
||||
# save into layer
|
||||
push @fills, Slic3r::ExtrusionPath::Collection->new(
|
||||
no_sort => $params->{no_sort},
|
||||
paths => [
|
||||
map Slic3r::ExtrusionPath->new(
|
||||
polyline => Slic3r::Polyline->new(@$_),
|
||||
role => ($surface->surface_type == S_TYPE_INTERNALBRIDGE
|
||||
? EXTR_ROLE_INTERNALBRIDGE
|
||||
: $is_bridge
|
||||
? EXTR_ROLE_BRIDGE
|
||||
: $is_solid
|
||||
? (($surface->surface_type == S_TYPE_TOP) ? EXTR_ROLE_TOPSOLIDFILL : EXTR_ROLE_SOLIDFILL)
|
||||
: EXTR_ROLE_FILL),
|
||||
height => $surface->thickness,
|
||||
flow_spacing => $params->{flow_spacing} || (warn "Warning: no flow_spacing was returned by the infill engine, please report this to the developer\n"),
|
||||
), @polylines,
|
||||
],
|
||||
push @fills, my $collection = Slic3r::ExtrusionPath::Collection->new;
|
||||
$collection->no_sort($params->{no_sort});
|
||||
$collection->append(
|
||||
map Slic3r::ExtrusionPath->new(
|
||||
polyline => Slic3r::Polyline->new(@$_),
|
||||
role => ($surface->surface_type == S_TYPE_INTERNALBRIDGE
|
||||
? EXTR_ROLE_INTERNALBRIDGE
|
||||
: $is_bridge
|
||||
? EXTR_ROLE_BRIDGE
|
||||
: $is_solid
|
||||
? (($surface->surface_type == S_TYPE_TOP) ? EXTR_ROLE_TOPSOLIDFILL : EXTR_ROLE_SOLIDFILL)
|
||||
: EXTR_ROLE_FILL),
|
||||
height => $surface->thickness,
|
||||
flow_spacing => $params->{flow_spacing} || (warn "Warning: no flow_spacing was returned by the infill engine, please report this to the developer\n"),
|
||||
), @polylines,
|
||||
);
|
||||
push @fills_ordering_points, $polylines[0][0];
|
||||
}
|
||||
|
||||
# add thin fill regions
|
||||
push @fills, @{$layerm->thin_fills};
|
||||
push @fills_ordering_points, map $_->points->[0], @{$layerm->thin_fills};
|
||||
push @fills_ordering_points, map $_->[0], @{$layerm->thin_fills};
|
||||
|
||||
# organize infill paths using a nearest-neighbor search
|
||||
@fills = @fills[ chained_path(\@fills_ordering_points) ];
|
||||
|
|
|
@ -211,9 +211,11 @@ sub extrude_loop {
|
|||
$extrusion_path->intersect_expolygons($self->_layer_overhangs);
|
||||
|
||||
# reapply the nearest point search for starting point
|
||||
@paths = Slic3r::ExtrusionPath::Collection
|
||||
->new(paths => [@paths])
|
||||
->chained_path($start_at, 1);
|
||||
{
|
||||
my $collection = Slic3r::ExtrusionPath::Collection->new;
|
||||
$collection->append(@paths);
|
||||
@paths = $collection->chained_path($start_at, 1);
|
||||
}
|
||||
} else {
|
||||
push @paths, $extrusion_path;
|
||||
}
|
||||
|
|
|
@ -281,7 +281,7 @@ sub make_perimeters {
|
|||
push @{ $self->perimeters }, @loops;
|
||||
|
||||
# add thin walls as perimeters
|
||||
push @{ $self->perimeters }, Slic3r::ExtrusionPath::Collection->new(paths => [
|
||||
push @{ $self->perimeters }, Slic3r::ExtrusionPath::Collection->new(
|
||||
map {
|
||||
Slic3r::ExtrusionPath->new(
|
||||
polyline => ($_->isa('Slic3r::Polygon') ? $_->split_at_first_point : $_),
|
||||
|
@ -289,7 +289,7 @@ sub make_perimeters {
|
|||
flow_spacing => $self->perimeter_flow->spacing,
|
||||
);
|
||||
} @{ $self->thin_walls }
|
||||
])->chained_path;
|
||||
)->chained_path;
|
||||
}
|
||||
|
||||
sub _fill_gaps {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue