diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index ad6157ec11..30654bed79 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -79,6 +79,7 @@ use constant OVERLAP_FACTOR => 1; use constant SMALL_PERIMETER_LENGTH => (6.5 / SCALING_FACTOR) * 2 * PI; use constant LOOP_CLIPPING_LENGTH_OVER_SPACING => 0.15; use constant INFILL_OVERLAP_OVER_SPACING => 0.45; +use constant EXTERNAL_INFILL_MARGIN => 3; our $Config; diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index d773a9d036..aa758a8626 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -416,7 +416,7 @@ sub prepare_fill_surfaces { sub process_external_surfaces { my $self = shift; - my $margin = scale 3; # TODO: ensure this is greater than the total thickness of the perimeters + my $margin = scale &Slic3r::EXTERNAL_INFILL_MARGIN; my @bottom = (); foreach my $surface (grep $_->surface_type == S_TYPE_BOTTOM, @{$self->fill_surfaces}) { diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 8431640428..99c73b4fff 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -572,6 +572,8 @@ 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]; @@ -584,9 +586,13 @@ sub discover_horizontal_shells { EXTERNAL: foreach my $type (S_TYPE_TOP, S_TYPE_BOTTOM) { # find slices of current type for current layer - # get both slices and fill_surfaces before the former contains the perimeters area - # and the latter contains the enlarged external surfaces - my $solid = [ map $_->expolygon, grep $_->surface_type == $type, @{$layerm->slices}, @{$layerm->fill_surfaces} ]; + # use slices instead of fill_surfaces because they also include the perimeter area + # which needs to be propagated in shells; we need to grow slices like we did for + # 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 = [ map $_->expolygon->offset_ex($margin), grep $_->surface_type == $type, @{$layerm->slices} ]; next if !@$solid; Slic3r::debugf "Layer %d has %s surfaces\n", $i, ($type == S_TYPE_TOP ? 'top' : 'bottom');