From f899deb6b6bbf0e15cb24c087c99b8152f57b350 Mon Sep 17 00:00:00 2001
From: Alessandro Ranellucci <aar@cpan.org>
Date: Sat, 21 Jul 2012 14:41:21 +0200
Subject: [PATCH] Prevent internal infill at all when fill density is set to
 zero. #545

---
 lib/Slic3r/Layer.pm | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm
index 43f2b264e..1b4ea2632 100644
--- a/lib/Slic3r/Layer.pm
+++ b/lib/Slic3r/Layer.pm
@@ -379,6 +379,16 @@ sub prepare_fill_surfaces {
     my $self = shift;
     
     my @surfaces = @{$self->surfaces};
+    
+    # if no solid layers are requested, turn top/bottom surfaces to internal
+    if ($Slic3r::solid_layers == 0) {
+        $_->surface_type(S_TYPE_INTERNAL) for grep $_->surface_type != S_TYPE_INTERNAL, @surfaces;
+    }
+    
+    # if hollow object is requested, remove internal surfaces
+    if ($Slic3r::fill_density == 0) {
+        @surfaces = grep $_->surface_type != S_TYPE_INTERNAL, @surfaces;
+    }
         
     # merge too small internal surfaces with their surrounding tops
     # (if they're too small, they can be treated as solid)
@@ -400,16 +410,6 @@ sub prepare_fill_surfaces {
         @surfaces = (grep($_->surface_type != S_TYPE_TOP, @surfaces), @top);
     }
     
-    # remove top/bottom surfaces
-    if ($Slic3r::solid_layers == 0) {
-        $_->surface_type(S_TYPE_INTERNAL) for grep $_->surface_type != S_TYPE_INTERNAL, @surfaces;
-    }
-    
-    # remove internal surfaces
-    if ($Slic3r::fill_density == 0) {
-        @surfaces = grep $_->surface_type != S_TYPE_INTERNAL, @surfaces;
-    }
-    
     $self->fill_surfaces([@surfaces]);
 }