Browse Source

Failing test case about spurious infill in hollow objects, caused by shells being correctly generated even for hollow objects - however sometimes we don't want that

Alessandro Ranellucci 11 years ago
parent
commit
6bd4803612
4 changed files with 33 additions and 2 deletions
  1. 1 1
      lib/Slic3r/Print/Object.pm
  2. 1 0
      lib/Slic3r/Test.pm
  3. 10 0
      lib/Slic3r/TriangleMesh.pm
  4. 21 1
      t/shells.t

+ 1 - 1
lib/Slic3r/Print/Object.pm

@@ -616,7 +616,7 @@ sub discover_horizontal_shells {
                         my $margin = 3 * $layerm->solid_infill_flow->scaled_width; # require at least this size
                         my $too_narrow = diff_ex(
                             [ map @$_, @$new_internal_solid ],
-                            [ offset([ offset([ map @$_, @$new_internal_solid ], -$margin) ], +$margin) ],
+                            [ offset2([ map @$_, @$new_internal_solid ], -$margin, +$margin) ],
                             1,
                         );
                         

+ 1 - 0
lib/Slic3r/Test.pm

@@ -63,6 +63,7 @@ sub model {
         vertices    => $vertices,
         facets      => $facets,
     );
+    $mesh->scale_xyz($params{scale_xyz}) if $params{scale_xyz};
     $mesh->scale($params{scale}) if $params{scale};
     
     my $model = Slic3r::Model->new;

+ 10 - 0
lib/Slic3r/TriangleMesh.pm

@@ -301,6 +301,16 @@ sub scale {
     }
 }
 
+sub scale_xyz {
+    my $self = shift;
+    my ($versor) = @_;
+    
+    # transform vertex coordinates
+    foreach my $vertex (@{$self->vertices}) {
+        $vertex->[$_] *= $versor->[$_] for X,Y,Z;
+    }
+}
+
 sub move {
     my $self = shift;
     my (@shift) = @_;

+ 21 - 1
t/shells.t

@@ -1,4 +1,4 @@
-use Test::More tests => 3;
+use Test::More tests => 4;
 use strict;
 use warnings;
 
@@ -68,4 +68,24 @@ use Slic3r::Test;
         "correct number of top solid shells is generated in V-shaped object";
 }
 
+{
+    my $config = Slic3r::Config->new_from_defaults;
+    $config->set('perimeters', 0);
+    $config->set('fill_density', 0);
+    $config->set('cooling', 0);                 # prevent speed alteration
+    $config->set('first_layer_speed', '100%');  # prevent speed alteration
+    $config->set('extrusion_width', 0.2);
+    $config->set('bottom_solid_layers', 3);
+    $config->set('top_solid_layers', 0);
+    
+    my $print = Slic3r::Test::init_print('V', scale_xyz => [2,1,1], config => $config);
+    my %layers = ();  # Z => 1
+    Slic3r::GCode::Reader->new(gcode => Slic3r::Test::gcode($print))->parse(sub {
+        my ($self, $cmd, $args, $info) = @_;
+        $layers{$self->Z} = 1 if $info->{extruding};
+    });
+    is scalar(keys %layers), 3,
+        "shells are not extended into void if fill density is 0";
+}
+
 __END__