Browse Source

Revert a recent change made to shells generation, causing too much solid infill. Includes regression test. #1431

Alessandro Ranellucci 11 years ago
parent
commit
39449f9245
3 changed files with 31 additions and 5 deletions
  1. 7 4
      lib/Slic3r/Print/Object.pm
  2. 0 0
      lib/Slic3r/Test.pm
  3. 24 1
      t/shells.t

+ 7 - 4
lib/Slic3r/Print/Object.pm

@@ -539,8 +539,6 @@ sub discover_horizontal_shells {
     
     Slic3r::debugf "==> DISCOVERING HORIZONTAL SHELLS\n";
     
-    my $margin = scale &Slic3r::EXTERNAL_INFILL_MARGIN;
-    
     for my $region_id (0 .. ($self->print->regions_count-1)) {
         for (my $i = 0; $i < $self->layer_count; $i++) {
             my $layerm = $self->layers->[$i]->regions->[$region_id];
@@ -557,8 +555,13 @@ sub discover_horizontal_shells {
                 # fill_surfaces though.  Using both ungrown slices and grown fill_surfaces will
                 # not work in some situations, as there won't be any grown region in the perimeter 
                 # area (this was seen in a model where the top layer had one extra perimeter, thus
-                # its fill_surfaces was thinner than the lower layer's infill)
-                my $solid = offset([ map $_->p, @{$layerm->slices->filter_by_type($type)} ], $margin);
+                # its fill_surfaces were thinner than the lower layer's infill), however it's the best
+                # solution so far. Growing the external slices by EXTERNAL_INFILL_MARGIN will put
+                # too much solid infill inside nearly-vertical slopes.
+                my $solid = [
+                    (map $_->p, @{$layerm->slices->filter_by_type($type)}),
+                    (map $_->p, @{$layerm->fill_surfaces->filter_by_type($type)}),
+                ];
                 next if !@$solid;
                 Slic3r::debugf "Layer %d has %s surfaces\n", $i, ($type == S_TYPE_TOP) ? 'top' : 'bottom';
                 

File diff suppressed because it is too large
+ 0 - 0
lib/Slic3r/Test.pm


+ 24 - 1
t/shells.t

@@ -1,4 +1,4 @@
-use Test::More tests => 11;
+use Test::More tests => 12;
 use strict;
 use warnings;
 
@@ -115,6 +115,29 @@ use Slic3r::Test;
         "shells are not propagated across perimeters of the neighbor layer";
 }
 
+{
+    my $config = Slic3r::Config->new_from_defaults;
+    $config->set('perimeters', 3);
+    $config->set('cooling', 0);                 # prevent speed alteration
+    $config->set('first_layer_speed', '100%');  # prevent speed alteration
+    $config->set('layer_height', 0.4);
+    $config->set('first_layer_height', '100%');
+    $config->set('bottom_solid_layers', 3);
+    $config->set('top_solid_layers', 3);
+    $config->set('solid_infill_speed', 99);
+    $config->set('top_solid_infill_speed', 99);
+    
+    my $print = Slic3r::Test::init_print('sloping_hole', config => $config);
+    my %solid_layers = ();  # Z => 1
+    Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
+        my ($self, $cmd, $args, $info) = @_;
+        $solid_layers{$self->Z} = 1
+            if $info->{extruding} && ($args->{F} // $self->F) == $config->solid_infill_speed*60;
+    });
+    is scalar(keys %solid_layers), $config->bottom_solid_layers + $config->top_solid_layers,
+        "no superfluous shells are generated";
+}
+
 {
     my $config = Slic3r::Config->new_from_defaults;
     $config->set('spiral_vase', 1);

Some files were not shown because too many files changed in this diff