Fix regression causing wrong number of solid shells when using fill_density = 0 (includes regression test)

This commit is contained in:
Alessandro Ranellucci 2012-12-23 20:20:17 +01:00
parent e59ed7efb7
commit 0da71dbdfa
4 changed files with 58 additions and 5 deletions

View File

@ -62,6 +62,7 @@ t/geometry.t
t/polyclip.t
t/retraction.t
t/serialize.t
t/shells.t
t/stl.t
t/vibrationlimit.t
utils/amf-to-stl.pl

View File

@ -397,11 +397,6 @@ sub prepare_fill_surfaces {
$_->surface_type(S_TYPE_INTERNAL) for grep $_->surface_type == S_TYPE_BOTTOM, @{$self->fill_surfaces};
}
# if hollow object is requested, remove internal surfaces
if ($Slic3r::Config->fill_density == 0) {
@{$self->fill_surfaces} = grep $_->surface_type != S_TYPE_INTERNAL, @{$self->fill_surfaces};
}
# turn too small internal regions into solid regions
{
my $min_area = scale scale $Slic3r::Config->solid_infill_below_area; # scaling an area requires two calls!

View File

@ -410,6 +410,15 @@ sub discover_horizontal_shells {
@{$layerm->fill_surfaces} = grep $_->expolygon->area > $area_threshold, @{$layerm->fill_surfaces};
}
for (my $i = 0; $i < $self->layer_count; $i++) {
my $layerm = $self->layers->[$i]->regions->[$region_id];
# if hollow object is requested, remove internal surfaces
if ($Slic3r::Config->fill_density == 0) {
@{$layerm->fill_surfaces} = grep $_->surface_type != S_TYPE_INTERNAL, @{$layerm->fill_surfaces};
}
}
}
}

48
t/shells.t Normal file
View File

@ -0,0 +1,48 @@
use Test::More tests => 2;
use strict;
use warnings;
BEGIN {
use FindBin;
use lib "$FindBin::Bin/../lib";
}
use List::Util qw(first);
use Slic3r;
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
$config->set('skirts', 0);
$config->set('perimeters', 0);
my $test = sub {
my ($conf) = @_;
$conf ||= $config;
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
my %layers_with_shells = (); # Z => $count
Slic3r::Test::GCodeReader->new(gcode => Slic3r::Test::gcode($print))->parse(sub {
my ($self, $cmd, $args, $info) = @_;
if ($self->Z > 0) {
$layers_with_shells{$self->Z} //= 0;
$layers_with_shells{$self->Z} = 1 if $info->{extruding} && $info->{dist_XY} > 0;
}
});
my @shells = @layers_with_shells{sort { $a <=> $b } keys %layers_with_shells};
fail "wrong number of bottom solid layers"
unless !defined(first { !$_ } @shells[0..$config->bottom_solid_layers-1]);
fail "wrong number of top solid layers"
unless !defined(first { !$_ } @shells[-$config->top_solid_layers..-1]);
1;
};
ok $test->(), "proper number of shells is applied";
$config->set('fill_density', 0);
ok $test->(), "proper number of shells is applied even when fill density is none";
}
__END__