Bugfix: infill every 'n' layers was broken after recent changes

This commit is contained in:
Alessandro Ranellucci 2011-11-25 18:16:31 +01:00
parent 25c85aada5
commit f3b689d4e0

View File

@ -285,7 +285,7 @@ sub infill_every_layers {
my $layer = $self->layer($i); my $layer = $self->layer($i);
# skip layer if no internal fill surfaces # skip layer if no internal fill surfaces
next if !grep $_->surface_type eq 'internal', map @$_, @{$layer->surfaces}; next if !grep $_->surface_type eq 'internal', @{$layer->surfaces};
# for each possible depth, look for intersections with the lower layer # for each possible depth, look for intersections with the lower layer
# we do this from the greater depth to the smaller # we do this from the greater depth to the smaller
@ -295,14 +295,13 @@ sub infill_every_layers {
# select surfaces of the lower layer having the depth we're looking for # select surfaces of the lower layer having the depth we're looking for
my @lower_surfaces = grep $_->depth_layers == $d && $_->surface_type eq 'internal', my @lower_surfaces = grep $_->depth_layers == $d && $_->surface_type eq 'internal',
map @$_, @{$lower_layer->surfaces}; @{$lower_layer->surfaces};
next if !@lower_surfaces; next if !@lower_surfaces;
# process each group of surfaces separately
foreach my $surfaces (@{$layer->surfaces}) {
# calculate intersection between our surfaces and theirs # calculate intersection between our surfaces and theirs
my $intersection = intersection_ex( my $intersection = intersection_ex(
[ map $_->p, grep $_->depth_layers <= $d, @lower_surfaces ], [ map $_->p, grep $_->depth_layers <= $d, @lower_surfaces ],
[ map $_->p, grep $_->surface_type eq 'internal', @$surfaces ], [ map $_->p, grep $_->surface_type eq 'internal', @{$layer->surfaces} ],
); );
next if !@$intersection; next if !@$intersection;
my $intersection_offsetted = safety_offset([ map @$_, @$intersection ]); my $intersection_offsetted = safety_offset([ map @$_, @$intersection ]);
@ -313,7 +312,7 @@ sub infill_every_layers {
# - any internal surface not belonging to the intersection (with its original depth) # - any internal surface not belonging to the intersection (with its original depth)
{ {
my @new_surfaces = (); my @new_surfaces = ();
push @new_surfaces, grep $_->surface_type ne 'internal', @$surfaces; push @new_surfaces, grep $_->surface_type ne 'internal', @{$layer->surfaces};
push @new_surfaces, map Slic3r::Surface->cast_from_expolygon push @new_surfaces, map Slic3r::Surface->cast_from_expolygon
($_, surface_type => 'internal', depth_layers => $d + 1), @$intersection; ($_, surface_type => 'internal', depth_layers => $d + 1), @$intersection;
@ -326,18 +325,18 @@ sub infill_every_layers {
@{diff_ex( @{diff_ex(
[ [
map $_->p, grep $_->surface_type eq 'internal' && $_->depth_layers == $depth, map $_->p, grep $_->surface_type eq 'internal' && $_->depth_layers == $depth,
@$surfaces, @{$layer->surfaces},
], ],
$intersection_offsetted, $intersection_offsetted,
)}; )};
} }
@$surfaces = @new_surfaces; @{$layer->surfaces} = @new_surfaces;
} }
# now we remove the intersections from lower layer # now we remove the intersections from lower layer
foreach my $lower_surfaces (@{$lower_layer->surfaces}) { {
my @new_surfaces = (); my @new_surfaces = ();
push @new_surfaces, grep $_->surface_type ne 'internal', @$lower_surfaces; push @new_surfaces, grep $_->surface_type ne 'internal', @{$lower_layer->surfaces};
foreach my $depth (1..$Slic3r::infill_every_layers) { foreach my $depth (1..$Slic3r::infill_every_layers) {
push @new_surfaces, map Slic3r::Surface->cast_from_expolygon push @new_surfaces, map Slic3r::Surface->cast_from_expolygon
($_, surface_type => 'internal', depth_layers => $depth), ($_, surface_type => 'internal', depth_layers => $depth),
@ -347,13 +346,12 @@ sub infill_every_layers {
@{diff_ex( @{diff_ex(
[ [
map $_->p, grep $_->surface_type eq 'internal' && $_->depth_layers == $depth, map $_->p, grep $_->surface_type eq 'internal' && $_->depth_layers == $depth,
@$lower_surfaces, @{$lower_layer->surfaces},
], ],
$intersection_offsetted, $intersection_offsetted,
)}; )};
} }
@$lower_surfaces = @new_surfaces; @{$lower_layer->surfaces} = @new_surfaces;
}
} }
} }
} }