mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-05 21:14:01 -06:00
Ported ExtrusionPath::Collection->chained_path
This commit is contained in:
parent
ea1d138c95
commit
bd7b0e2aed
11 changed files with 170 additions and 57 deletions
|
@ -2,42 +2,6 @@ package Slic3r::ExtrusionPath::Collection;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub first_point {
|
||||
my $self = shift;
|
||||
return $self->[0]->[0];
|
||||
}
|
||||
|
||||
# (Same algorithm as Polyline::Collection)
|
||||
sub chained_path {
|
||||
my $self = shift;
|
||||
my ($start_near, $no_reverse) = @_;
|
||||
|
||||
my @my_paths = @$self;
|
||||
return @my_paths if $self->no_sort;
|
||||
|
||||
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
|
||||
? $start_near->nearest_point_index($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
|
||||
# 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;
|
||||
splice @$endpoints, $path_index*2, 2;
|
||||
$start_near = $paths[-1]->last_point;
|
||||
}
|
||||
return @paths;
|
||||
}
|
||||
|
||||
sub cleanup {
|
||||
my $self = shift;
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ sub extrude_loop {
|
|||
$extrusion_path->intersect_expolygons($self->_layer_overhangs);
|
||||
|
||||
# reapply the nearest point search for starting point
|
||||
@paths = Slic3r::ExtrusionPath::Collection->new(@paths)->chained_path($start_at, 1);
|
||||
@paths = @{Slic3r::ExtrusionPath::Collection->new(@paths)->chained_path_from($start_at, 1)};
|
||||
} else {
|
||||
push @paths, $extrusion_path;
|
||||
}
|
||||
|
|
|
@ -111,12 +111,12 @@ sub process_layer {
|
|||
if ($layer->support_interface_fills) {
|
||||
$gcode .= $self->gcodegen->set_extruder($self->extruders->[$Slic3r::Config->support_material_interface_extruder-1]);
|
||||
$gcode .= $self->gcodegen->extrude_path($_, 'support material interface')
|
||||
for $layer->support_interface_fills->chained_path($self->gcodegen->last_pos);
|
||||
for @{$layer->support_interface_fills->chained_path_from($self->gcodegen->last_pos, 0)};
|
||||
}
|
||||
if ($layer->support_fills) {
|
||||
$gcode .= $self->gcodegen->set_extruder($self->extruders->[$Slic3r::Config->support_material_extruder-1]);
|
||||
$gcode .= $self->gcodegen->extrude_path($_, 'support material')
|
||||
for $layer->support_fills->chained_path($self->gcodegen->last_pos);
|
||||
for @{$layer->support_fills->chained_path_from($self->gcodegen->last_pos, 0)};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ sub _extrude_infill {
|
|||
for my $fill (@{ $island->{fills} }) {
|
||||
if ($fill->isa('Slic3r::ExtrusionPath::Collection')) {
|
||||
$gcode .= $self->gcodegen->extrude($_, 'fill')
|
||||
for $fill->chained_path($self->gcodegen->last_pos);
|
||||
for @{$fill->chained_path_from($self->gcodegen->last_pos, 0)};
|
||||
} else {
|
||||
$gcode .= $self->gcodegen->extrude($fill, 'fill') ;
|
||||
}
|
||||
|
|
|
@ -300,15 +300,13 @@ sub make_perimeters {
|
|||
$self->perimeters->append(@loops);
|
||||
|
||||
# add thin walls as perimeters
|
||||
push @{ $self->perimeters }, Slic3r::ExtrusionPath::Collection->new(
|
||||
map {
|
||||
Slic3r::ExtrusionPath->new(
|
||||
push @{ $self->perimeters }, @{Slic3r::ExtrusionPath::Collection->new(
|
||||
map Slic3r::ExtrusionPath->new(
|
||||
polyline => ($_->isa('Slic3r::Polygon') ? $_->split_at_first_point : $_),
|
||||
role => EXTR_ROLE_EXTERNAL_PERIMETER,
|
||||
flow_spacing => $self->perimeter_flow->spacing,
|
||||
);
|
||||
} @{ $self->thin_walls }
|
||||
)->chained_path;
|
||||
), @{ $self->thin_walls }
|
||||
)->chained_path(0)};
|
||||
}
|
||||
|
||||
sub _fill_gaps {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue