From 35bd5a3423d689d22ff4e3e9ae59c15854d70a6b Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 17 Mar 2013 00:02:31 +0100 Subject: [PATCH] New --solid-infill-extrusion-width option --- README.markdown | 2 ++ lib/Slic3r/Config.pm | 10 +++++++++- lib/Slic3r/Fill.pm | 11 +++++++---- lib/Slic3r/GUI/Tab.pm | 2 +- lib/Slic3r/Layer/Region.pm | 17 +++++++++-------- lib/Slic3r/Print.pm | 5 +++-- lib/Slic3r/Print/Object.pm | 6 +++--- slic3r.pl | 2 ++ 8 files changed, 36 insertions(+), 19 deletions(-) diff --git a/README.markdown b/README.markdown index ffebd1481..95c565c98 100644 --- a/README.markdown +++ b/README.markdown @@ -300,6 +300,8 @@ The author of the Silk icon set is Mark James. Set a different extrusion width for perimeters --infill-extrusion-width Set a different extrusion width for infill + --solid-infill-extrusion-width + Set a different extrusion width for solid infill --top-infill-extrusion-width Set a different extrusion width for top infill --support-material-extrusion-width diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 1bd9657a0..b7833462f 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -446,8 +446,16 @@ our $Options = { type => 'f', default => 0, }, + 'solid_infill_extrusion_width' => { + label => 'Solid infill', + tooltip => 'Set this to a non-zero value to set a manual extrusion width for infill for solid surfaces. If expressed as percentage (for example 90%) if will be computed over layer height.', + sidetext => 'mm or % (leave 0 for default)', + cli => 'solid-infill-extrusion-width=s', + type => 'f', + default => 0, + }, 'top_infill_extrusion_width' => { - label => 'Top infill', + label => 'Top solid infill', tooltip => 'Set this to a non-zero value to set a manual extrusion width for infill for top surfaces. You may want to use thinner extrudates to fill all narrow regions and get a smoother finish. If expressed as percentage (for example 90%) if will be computed over layer height.', sidetext => 'mm or % (leave 0 for default)', cli => 'top-infill-extrusion-width=s', diff --git a/lib/Slic3r/Fill.pm b/lib/Slic3r/Fill.pm index 85c189cfe..9040c0233 100644 --- a/lib/Slic3r/Fill.pm +++ b/lib/Slic3r/Fill.pm @@ -100,7 +100,7 @@ sub make_fill { # add spacing between surfaces { - my $distance = $layerm->infill_flow->scaled_spacing / 2; + my $distance = $layerm->solid_infill_flow->scaled_spacing / 2; @surfaces = map $_->offset(-$distance), @surfaces; } @@ -109,9 +109,12 @@ sub make_fill { SURFACE: foreach my $surface (@surfaces) { my $filler = $Slic3r::Config->fill_pattern; my $density = $Slic3r::Config->fill_density; - my $flow_spacing = ($surface->surface_type == S_TYPE_TOP) - ? $layerm->top_infill_flow->spacing - : $layerm->infill_flow->spacing; + my $flow = ($surface->surface_type == S_TYPE_TOP) + ? $layerm->top_infill_flow + : $surface->is_solid + ? $layerm->solid_infill_flow + : $layerm->infill_flow; + my $flow_spacing = $flow->spacing; my $is_bridge = $layerm->id > 0 && $surface->is_bridge; my $is_solid = $surface->is_solid; diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index fa10383e5..8fdacf6f6 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -511,7 +511,7 @@ sub build { { title => 'Extrusion width', label_width => 180, - options => [qw(extrusion_width first_layer_extrusion_width perimeter_extrusion_width infill_extrusion_width top_infill_extrusion_width support_material_extrusion_width)], + options => [qw(extrusion_width first_layer_extrusion_width perimeter_extrusion_width infill_extrusion_width solid_infill_extrusion_width top_infill_extrusion_width support_material_extrusion_width)], }, { title => 'Flow', diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index 1c365dd42..fd9b187eb 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, handles => [qw(extruders)]); has 'perimeter_flow' => (is => 'rw'); has 'infill_flow' => (is => 'rw'); +has 'solid_infill_flow' => (is => 'rw'); has 'top_infill_flow' => (is => 'rw'); has 'infill_area_threshold' => (is => 'lazy'); has 'overhang_width' => (is => 'lazy'); @@ -59,15 +60,15 @@ sub _update_flows { return if !$self->region; if ($self->id == 0) { - $self->perimeter_flow - ($self->region->first_layer_flows->{perimeter} || $self->region->flows->{perimeter}); - $self->infill_flow - ($self->region->first_layer_flows->{infill} || $self->region->flows->{infill}); - $self->top_infill_flow - ($self->region->first_layer_flows->{top_infill} || $self->region->flows->{top_infill}); + for (qw(perimeter infill solid_infill top_infill)) { + my $method = "${_}_flow"; + $self->$method + ($self->region->first_layer_flows->{$_} || $self->region->flows->{$_}); + } } else { $self->perimeter_flow($self->region->flows->{perimeter}); $self->infill_flow($self->region->flows->{infill}); + $self->solid_infill_flow($self->region->flows->{solid_infill}); $self->top_infill_flow($self->region->flows->{top_infill}); } } @@ -80,7 +81,7 @@ sub _build_overhang_width { sub _build_infill_area_threshold { my $self = shift; - return $self->infill_flow->scaled_spacing ** 2; + return $self->solid_infill_flow->scaled_spacing ** 2; } # build polylines from lines @@ -160,7 +161,7 @@ sub make_perimeters { my $self = shift; my $perimeter_spacing = $self->perimeter_flow->scaled_spacing; - my $infill_spacing = $self->infill_flow->scaled_spacing; + my $infill_spacing = $self->solid_infill_flow->scaled_spacing; my $gap_area_threshold = $self->perimeter_flow->scaled_width ** 2; # this array will hold one arrayref per original surface (island); diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 0753a2768..0ee365074 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -201,8 +201,9 @@ sub init_extruders { my $region = $self->regions->[$region_id]; # per-role extruders and flows - for (qw(perimeter infill top_infill)) { - my $extruder_name = $_ eq 'top_infill' ? 'infill' : $_; + for (qw(perimeter infill solid_infill top_infill)) { + my $extruder_name = $_; + $extruder_name =~ s/^(?:solid|top)_//; $region->extruders->{$_} = ($self->regions_count > 1) ? $self->extruders->[$extruder_mapping{$region_id}] : $self->extruders->[$self->config->get("${extruder_name}_extruder")-1]; diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 6f47a7808..0431de756 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -581,7 +581,7 @@ sub discover_horizontal_shells { # make sure the new internal solid is wide enough, as it might get collapsed when # spacing is added in Fill.pm { - my $margin = 3 * $layerm->infill_flow->scaled_width; # require at least this size + 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) ], @@ -708,12 +708,12 @@ sub combine_infill { # so let's remove those areas from all layers my @intersection_with_clearance = map $_->offset( - $layerms[-1]->infill_flow->scaled_width / 2 + $layerms[-1]->solid_infill_flow->scaled_width / 2 + $layerms[-1]->perimeter_flow->scaled_width / 2 # Because fill areas for rectilinear and honeycomb are grown # later to overlap perimeters, we need to counteract that too. + (($type == S_TYPE_INTERNALSOLID || $Slic3r::Config->fill_pattern =~ /(rectilinear|honeycomb)/) - ? $layerms[-1]->infill_flow->scaled_width * &Slic3r::PERIMETER_INFILL_OVERLAP_OVER_SPACING + ? $layerms[-1]->solid_infill_flow->scaled_width * &Slic3r::PERIMETER_INFILL_OVERLAP_OVER_SPACING : 0) ), @$intersection; diff --git a/slic3r.pl b/slic3r.pl index c4cfd8487..5c5c80b16 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -353,6 +353,8 @@ $j Set a different extrusion width for perimeters --infill-extrusion-width Set a different extrusion width for infill + --solid-infill-extrusion-width + Set a different extrusion width for solid infill --top-infill-extrusion-width Set a different extrusion width for top infill --support-material-extrusion-width