Minor cleanup of Layer::Region::_fill_gaps()

This commit is contained in:
Alessandro Ranellucci 2015-01-03 15:11:33 +01:00
parent d8be67c28b
commit 73d45dd851

View File

@ -412,6 +412,12 @@ sub _fill_gaps {
offset2([ map @$_, @$gaps ], -$max/2, +$max/2), offset2([ map @$_, @$gaps ], -$max/2, +$max/2),
1, 1,
); );
my @polylines = map @{$_->medial_axis($max, $min/2)}, @$this;
return if !@polylines;
Slic3r::debugf " %d gaps filled with extrusion width = %s\n", scalar @$this, $w
if @$this;
my $flow = $self->flow(FLOW_ROLE_SOLID_INFILL, 0, $w); my $flow = $self->flow(FLOW_ROLE_SOLID_INFILL, 0, $w);
my %path_args = ( my %path_args = (
@ -420,26 +426,23 @@ sub _fill_gaps {
width => $flow->width, width => $flow->width,
height => $self->height, height => $self->height,
); );
my @polylines = map @{$_->medial_axis($max, $min/2)}, @$this;
Slic3r::debugf " %d gaps filled with extrusion width = %s\n", scalar @$this, $w my @entities = ();
if @$this; foreach my $polyline (@polylines) {
#if ($polylines[$i]->isa('Slic3r::Polygon')) {
for my $i (0..$#polylines) { # my $loop = Slic3r::ExtrusionLoop->new;
if ($polylines[$i]->isa('Slic3r::Polygon')) { # $loop->append(Slic3r::ExtrusionPath->new(polyline => $polylines[$i]->split_at_first_point, %path_args));
my $loop = Slic3r::ExtrusionLoop->new; # $polylines[$i] = $loop;
$loop->append(Slic3r::ExtrusionPath->new(polyline => $polylines[$i]->split_at_first_point, %path_args)); if ($polyline->is_valid && $polyline->first_point->coincides_with($polyline->last_point)) {
$polylines[$i] = $loop;
} elsif ($polylines[$i]->is_valid && $polylines[$i]->first_point->coincides_with($polylines[$i]->last_point)) {
# since medial_axis() now returns only Polyline objects, detect loops here # since medial_axis() now returns only Polyline objects, detect loops here
my $loop = Slic3r::ExtrusionLoop->new; push @entities, my $loop = Slic3r::ExtrusionLoop->new;
$loop->append(Slic3r::ExtrusionPath->new(polyline => $polylines[$i], %path_args)); $loop->append(Slic3r::ExtrusionPath->new(polyline => $polyline, %path_args));
$polylines[$i] = $loop;
} else { } else {
$polylines[$i] = Slic3r::ExtrusionPath->new(polyline => $polylines[$i], %path_args); push @entities, Slic3r::ExtrusionPath->new(polyline => $polyline, %path_args);
} }
} }
return @polylines;
return @entities;
} }
sub prepare_fill_surfaces { sub prepare_fill_surfaces {