Smarter ordering of gap fill

This commit is contained in:
Alessandro Ranellucci 2013-07-26 00:03:28 +02:00
parent 2b8662cf0c
commit 8fe228fcee
2 changed files with 18 additions and 5 deletions

View File

@ -196,8 +196,10 @@ sub make_fill {
}
# add thin fill regions
push @fills, @{$layerm->thin_fills};
push @fills_ordering_points, map $_->unpack->points->[0], @{$layerm->thin_fills};
if (@{ $layerm->thin_fills }) {
push @fills, Slic3r::ExtrusionPath::Collection->new(paths => $layerm->thin_fills);
push @fills_ordering_points, $fills[-1]->first_point;
}
# organize infill paths using a nearest-neighbor search
@fills = @fills[ chained_path(\@fills_ordering_points) ];

View File

@ -348,12 +348,11 @@ sub _fill_gaps {
my @infill = map $_->offset_ex(-0.5*$flow->scaled_width), @this_width;
foreach my $expolygon (@infill) {
my @paths = $filler->fill_surface(
my ($params, @paths) = $filler->fill_surface(
Slic3r::Surface->new(expolygon => $expolygon),
density => 1,
flow_spacing => $flow->spacing,
);
my $params = shift @paths;
push @{ $self->thin_fills },
map {
@ -365,7 +364,19 @@ sub _fill_gaps {
role => EXTR_ROLE_GAPFILL,
height => $self->height,
flow_spacing => $params->{flow_spacing},
), @paths;
),
# Split polylines into lines so that the chained_path() search
# at the final stage has more freedom and will choose starting
# points closer than last positions. OTOH, this will make such
# search slower. Probably, ExtrusionPath objects should support
# splitting nearby a given position so that we can choose the right
# entry point even in the middle of the path without needing a
# complex, slow, chained_path() search on all segments. TODO.
# Such logic will also avoid all the small travel moves that this
# line-splitting causes, and it will be applicable to other things
# too.
map Slic3r::Polyline->new(@$_)->lines,
@paths;
}
}