Permalink
Browse files

Fix regression causing wrong number of solid shells when using fill_d…

…ensity = 0 (includes regression test)
  • Loading branch information...
1 parent e59ed7e commit 0da71dbdfa2ebdf35a34fc8354f71689e6f32b23 @alexrj committed Dec 23, 2012
Showing with 58 additions and 5 deletions.
  1. +1 −0 MANIFEST
  2. +0 −5 lib/Slic3r/Layer/Region.pm
  3. +9 −0 lib/Slic3r/Print/Object.pm
  4. +48 −0 t/shells.t
View
@@ -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
@@ -396,11 +396,6 @@ sub prepare_fill_surfaces {
if ($Slic3r::Config->bottom_solid_layers == 0) {
$_->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
{
@@ -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};
+ }
+ }
}
}
View
@@ -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__

0 comments on commit 0da71db

Please sign in to comment.