From 3edf42e98ece9b3395db9b645c484ca8aa122187 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 21 Jul 2012 15:53:38 +0200 Subject: [PATCH] Little workflow simplification --- lib/Slic3r/Layer.pm | 72 ++++++++++++++++++++++----------------------- lib/Slic3r/Print.pm | 5 ---- 2 files changed, 35 insertions(+), 42 deletions(-) diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm index 1b4ea2632..f30e09091 100644 --- a/lib/Slic3r/Layer.pm +++ b/lib/Slic3r/Layer.pm @@ -410,46 +410,44 @@ sub prepare_fill_surfaces { @surfaces = (grep($_->surface_type != S_TYPE_TOP, @surfaces), @top); } + # this will remove unprintable surfaces + # (those that are too tight for extrusion) + { + my $distance = scale $self->infill_flow->spacing / 2; + + foreach my $surface (@surfaces) { + # offset inwards + my @offsets = $surface->expolygon->offset_ex(-$distance); + + # offset the results outwards again and merge the results + @offsets = map $_->offset_ex($distance), @offsets; + @offsets = @{ union_ex([ map @$_, @offsets ], undef, 1) }; + + push @{$self->fill_surfaces}, map Slic3r::Surface->new( + expolygon => $_, + surface_type => $surface->surface_type), @offsets; + } + + Slic3r::debugf "identified %d small surfaces at layer %d\n", + (@surfaces - @{$self->fill_surfaces}), $self->id + if @{$self->fill_surfaces} != @surfaces; + + # the difference between @surfaces and $self->fill_surfaces + # is what's too small; we add it back as solid infill + if ($Slic3r::fill_density > 0) { + my $diff = diff_ex( + [ map $_->p, @surfaces ], + [ map $_->p, @{$self->fill_surfaces} ], + ); + push @{$self->fill_surfaces}, map Slic3r::Surface->new( + expolygon => $_, + surface_type => S_TYPE_INTERNALSOLID), @$diff; + } + } + $self->fill_surfaces([@surfaces]); } -sub remove_small_surfaces { - my $self = shift; - - my $distance = scale $self->infill_flow->spacing / 2; - - my @surfaces = @{$self->fill_surfaces}; - @{$self->fill_surfaces} = (); - foreach my $surface (@surfaces) { - # offset inwards - my @offsets = $surface->expolygon->offset_ex(-$distance); - - # offset the results outwards again and merge the results - @offsets = map $_->offset_ex($distance), @offsets; - @offsets = @{ union_ex([ map @$_, @offsets ], undef, 1) }; - - push @{$self->fill_surfaces}, map Slic3r::Surface->new( - expolygon => $_, - surface_type => $surface->surface_type), @offsets; - } - - Slic3r::debugf "identified %d small surfaces at layer %d\n", - (@surfaces - @{$self->fill_surfaces}), $self->id - if @{$self->fill_surfaces} != @surfaces; - - # the difference between @surfaces and $self->fill_surfaces - # is what's too small; we add it back as solid infill - if ($Slic3r::fill_density > 0) { - my $diff = diff_ex( - [ map $_->p, @surfaces ], - [ map $_->p, @{$self->fill_surfaces} ], - ); - push @{$self->fill_surfaces}, map Slic3r::Surface->new( - expolygon => $_, - surface_type => S_TYPE_INTERNALSOLID), @$diff; - } -} - # make bridges printable sub process_bridges { my $self = shift; diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index ac4a195b6..77f671091 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -241,11 +241,6 @@ sub export_gcode { $status_cb->(35, "Preparing infill surfaces"); $_->prepare_fill_surfaces for map @{$_->layers}, @{$self->objects}; - # this will remove unprintable surfaces - # (those that are too tight for extrusion) - $status_cb->(40, "Cleaning up"); - $_->remove_small_surfaces for map @{$_->layers}, @{$self->objects}; - # this will detect bridges and reverse bridges # and rearrange top/bottom/internal surfaces $status_cb->(45, "Detect bridges");