Bugfix: infill every 'n' layers was broken after recent changes
This commit is contained in:
parent
25c85aada5
commit
f3b689d4e0
@ -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,65 +295,63 @@ 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', @{$layer->surfaces} ],
|
||||||
[ map $_->p, grep $_->surface_type eq 'internal', @$surfaces ],
|
);
|
||||||
);
|
next if !@$intersection;
|
||||||
next if !@$intersection;
|
my $intersection_offsetted = safety_offset([ map @$_, @$intersection ]);
|
||||||
my $intersection_offsetted = safety_offset([ map @$_, @$intersection ]);
|
|
||||||
|
# new fill surfaces of the current layer are:
|
||||||
|
# - any non-internal surface
|
||||||
|
# - intersections found (with a $d + 1 depth)
|
||||||
|
# - any internal surface not belonging to the intersection (with its original depth)
|
||||||
|
{
|
||||||
|
my @new_surfaces = ();
|
||||||
|
push @new_surfaces, grep $_->surface_type ne 'internal', @{$layer->surfaces};
|
||||||
|
push @new_surfaces, map Slic3r::Surface->cast_from_expolygon
|
||||||
|
($_, surface_type => 'internal', depth_layers => $d + 1), @$intersection;
|
||||||
|
|
||||||
# new fill surfaces of the current layer are:
|
foreach my $depth (reverse $d..$Slic3r::infill_every_layers) {
|
||||||
# - any non-internal surface
|
|
||||||
# - intersections found (with a $d + 1 depth)
|
|
||||||
# - any internal surface not belonging to the intersection (with its original depth)
|
|
||||||
{
|
|
||||||
my @new_surfaces = ();
|
|
||||||
push @new_surfaces, grep $_->surface_type ne 'internal', @$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 => $depth),
|
||||||
|
|
||||||
foreach my $depth (reverse $d..$Slic3r::infill_every_layers) {
|
# difference between our internal layers with depth == $depth
|
||||||
push @new_surfaces, map Slic3r::Surface->cast_from_expolygon
|
# and the intersection found
|
||||||
($_, surface_type => 'internal', depth_layers => $depth),
|
@{diff_ex(
|
||||||
|
[
|
||||||
# difference between our internal layers with depth == $depth
|
map $_->p, grep $_->surface_type eq 'internal' && $_->depth_layers == $depth,
|
||||||
# and the intersection found
|
@{$layer->surfaces},
|
||||||
@{diff_ex(
|
],
|
||||||
[
|
$intersection_offsetted,
|
||||||
map $_->p, grep $_->surface_type eq 'internal' && $_->depth_layers == $depth,
|
)};
|
||||||
@$surfaces,
|
|
||||||
],
|
|
||||||
$intersection_offsetted,
|
|
||||||
)};
|
|
||||||
}
|
|
||||||
@$surfaces = @new_surfaces;
|
|
||||||
}
|
}
|
||||||
|
@{$layer->surfaces} = @new_surfaces;
|
||||||
# now we remove the intersections from lower layer
|
}
|
||||||
foreach my $lower_surfaces (@{$lower_layer->surfaces}) {
|
|
||||||
my @new_surfaces = ();
|
# now we remove the intersections from lower layer
|
||||||
push @new_surfaces, grep $_->surface_type ne 'internal', @$lower_surfaces;
|
{
|
||||||
foreach my $depth (1..$Slic3r::infill_every_layers) {
|
my @new_surfaces = ();
|
||||||
push @new_surfaces, map Slic3r::Surface->cast_from_expolygon
|
push @new_surfaces, grep $_->surface_type ne 'internal', @{$lower_layer->surfaces};
|
||||||
($_, surface_type => 'internal', depth_layers => $depth),
|
foreach my $depth (1..$Slic3r::infill_every_layers) {
|
||||||
|
push @new_surfaces, map Slic3r::Surface->cast_from_expolygon
|
||||||
# difference between internal layers with depth == $depth
|
($_, surface_type => 'internal', depth_layers => $depth),
|
||||||
# and the intersection found
|
|
||||||
@{diff_ex(
|
# difference between internal layers with depth == $depth
|
||||||
[
|
# and the intersection found
|
||||||
map $_->p, grep $_->surface_type eq 'internal' && $_->depth_layers == $depth,
|
@{diff_ex(
|
||||||
@$lower_surfaces,
|
[
|
||||||
],
|
map $_->p, grep $_->surface_type eq 'internal' && $_->depth_layers == $depth,
|
||||||
$intersection_offsetted,
|
@{$lower_layer->surfaces},
|
||||||
)};
|
],
|
||||||
}
|
$intersection_offsetted,
|
||||||
@$lower_surfaces = @new_surfaces;
|
)};
|
||||||
}
|
}
|
||||||
|
@{$lower_layer->surfaces} = @new_surfaces;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user