diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index aedb45d02..027a9bd58 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -16,6 +16,7 @@ has 'layer' => ( has 'region' => (is => 'ro', required => 1); has 'perimeter_flow' => (is => 'rw'); has 'infill_flow' => (is => 'rw'); +has 'infill_area_threshold' => (is => 'lazy'); has 'overhang_width' => (is => 'lazy'); # collection of spare segments generated by slicing the original geometry; @@ -71,6 +72,11 @@ sub _build_overhang_width { return scale($self->height * ((cos $threshold_rad) / (sin $threshold_rad))); } +sub _build_infill_area_threshold { + my $self = shift; + return $self->infill_flow->scaled_spacing ** 2; +} + # build polylines from lines sub make_surfaces { my $self = shift; @@ -194,7 +200,7 @@ sub make_perimeters { # this compensation only works for circular holes, while it would # overcompensate for hexagons and other shapes having straight edges. # so we require a minimum number of vertices. - next unless $circumference / @$hole >= 3 * $Slic3r::flow->scaled_width; + next unless $circumference / @$hole >= 3 * $self->perimeter_flow->scaled_width; # revert the compensation done in make_surfaces() and get the actual radius # of the hole @@ -411,7 +417,7 @@ sub _add_perimeter { my $self = shift; my ($polygon, $role) = @_; - return unless $polygon->is_printable($self->perimeter_flow->width); + return unless $polygon->is_printable($self->perimeter_flow); push @{ $self->perimeters }, Slic3r::ExtrusionLoop->pack( polygon => $polygon, role => ($role // EXTR_ROLE_PERIMETER), diff --git a/lib/Slic3r/Polygon.pm b/lib/Slic3r/Polygon.pm index 4cc51d610..da23e823a 100644 --- a/lib/Slic3r/Polygon.pm +++ b/lib/Slic3r/Polygon.pm @@ -118,7 +118,7 @@ sub subdivide { # returns false if the polyline is too tight to be printed sub is_printable { my $self = shift; - my ($flow_width) = @_; + my ($flow) = @_; # try to get an inwards offset # for a distance equal to half of the extrusion width; @@ -129,7 +129,7 @@ sub is_printable { # detect them and we would be discarding them. my $p = $self->clone; $p->make_counter_clockwise; - return $p->offset(Slic3r::Geometry::scale($flow_width || $Slic3r::flow->width) / 2) ? 1 : 0; + return $p->offset($flow->scaled_width / 2) ? 1 : 0; } sub is_valid { diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index c4a02b196..a9fc25c34 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -306,7 +306,7 @@ sub detect_surfaces_type { [ map { ref $_ eq 'ARRAY' ? $_ : ref $_ eq 'Slic3r::ExPolygon' ? @$_ : $_->p } @$clip_surfaces ], 1, ); - return grep $_->contour->is_printable($layerm->flow->width), + return grep $_->contour->is_printable($layerm->flow), map Slic3r::Surface->new(expolygon => $_, surface_type => $result_type), @$expolygons; }; @@ -430,8 +430,6 @@ sub discover_horizontal_shells { Slic3r::debugf "==> DISCOVERING HORIZONTAL SHELLS\n"; - my $area_threshold = $Slic3r::flow->scaled_spacing ** 2; - 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]; @@ -514,6 +512,7 @@ sub discover_horizontal_shells { } } + my $area_threshold = $layerm->infill_area_threshold; @{$layerm->fill_surfaces} = grep $_->expolygon->area > $area_threshold, @{$layerm->fill_surfaces}; } @@ -534,7 +533,6 @@ sub combine_infill { return unless $Slic3r::Config->infill_every_layers > 1 && $Slic3r::Config->fill_density > 0; my $every = $Slic3r::Config->infill_every_layers; - my $area_threshold = $Slic3r::flow->scaled_spacing ** 2; my $layer_count = $self->layer_count; for my $region_id (0 .. ($self->print->regions_count-1)) { @@ -559,6 +557,7 @@ sub combine_infill { ); } + my $area_threshold = $layerms[0]->infill_area_threshold; @$intersection = grep $_->area > $area_threshold, @$intersection; next if !@$intersection; Slic3r::debugf " combining %d %s regions from layers %d-%d\n",