From 80501d5b3c2ffe45e738205e3027037b2b74d383 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 28 Jun 2012 16:33:07 +0200 Subject: [PATCH] New option to customize support material extrusion width --- README.markdown | 2 ++ lib/Slic3r.pm | 2 ++ lib/Slic3r/Config.pm | 11 +++++++++-- lib/Slic3r/GUI/SkeinPanel.pm | 4 ++-- lib/Slic3r/Print/Object.pm | 10 +++++----- slic3r.pl | 2 ++ 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/README.markdown b/README.markdown index 4f253655f..6878773be 100644 --- a/README.markdown +++ b/README.markdown @@ -237,6 +237,8 @@ The author is Alessandro Ranellucci. Set a different extrusion width for perimeters --infill-extrusion-width Set a different extrusion width for infill + --support-material-extrusion-width + Set a different extrusion width for support material --bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: 1) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index ac57be635..2bc73ea0b 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -111,12 +111,14 @@ our $extrusion_width = 0; our $first_layer_extrusion_width = 0; our $perimeters_extrusion_width = 0; our $infill_extrusion_width = 0; +our $support_material_extrusion_width = 0; our $bridge_flow_ratio = 1; our $overlap_factor = 0.5; our $flow; our $first_layer_flow; our $perimeters_flow; our $infill_flow; +our $support_material_flow; # print options our $perimeters = 3; diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 893e0d659..3aa96c64b 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -245,6 +245,11 @@ our $Options = { cli => 'infill-extrusion-width=s', type => 'f', }, + 'support_material_extrusion_width' => { + label => 'Support material extrusion width (mm or % or 0 for default)', + cli => 'support-material-extrusion-width=s', + type => 'f', + }, 'bridge_flow_ratio' => { label => 'Bridge flow ratio', cli => 'bridge-flow-ratio=f', @@ -698,8 +703,10 @@ sub validate { width => $Slic3r::first_layer_extrusion_width, ); } - $Slic3r::perimeters_flow = $Slic3r::extruders->[0]->make_flow(width => $Slic3r::perimeters_extrusion_width || $Slic3r::extrusion_width); - $Slic3r::infill_flow = $Slic3r::extruders->[0]->make_flow(width => $Slic3r::infill_extrusion_width || $Slic3r::extrusion_width); + $Slic3r::perimeters_flow = $Slic3r::extruders->[0]->make_flow(width => $Slic3r::perimeters_extrusion_width || $Slic3r::extrusion_width); + $Slic3r::infill_flow = $Slic3r::extruders->[0]->make_flow(width => $Slic3r::infill_extrusion_width || $Slic3r::extrusion_width); + $Slic3r::support_material_flow = $Slic3r::extruders->[ $Slic3r::support_material_extruder ] + ->make_flow(width => $Slic3r::support_material_extrusion_width || $Slic3r::extrusion_width); Slic3r::debugf "Default flow width = %s, spacing = %s, min_spacing = %s\n", $Slic3r::flow->width, $Slic3r::flow->spacing, $Slic3r::flow->min_spacing; diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index f7a740c47..c54341d15 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -71,7 +71,7 @@ sub new { }, extrusion => { title => 'Extrusion', - options => [qw(extrusion_width first_layer_extrusion_width perimeters_extrusion_width infill_extrusion_width bridge_flow_ratio)], + options => [qw(extrusion_width first_layer_extrusion_width perimeters_extrusion_width infill_extrusion_width support_material_extrusion_width bridge_flow_ratio)], }, output => { title => 'Output', @@ -117,7 +117,7 @@ sub new { $make_tab->([qw(cooling notes)]), $make_tab->([qw(printer filament)], [qw(print_speed speed)]), $make_tab->([qw(gcode)]), - $make_tab->([qw(extrusion sequential_printing)], [qw(output other)]), + $make_tab->([qw(extrusion)], [qw(output other sequential_printing)]), ); $tabpanel->AddPage(Slic3r::GUI::Plater->new($tabpanel), "Plater"); diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index ea6a2b338..902928310 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -490,7 +490,7 @@ sub generate_support_material { my $threshold_rad = deg2rad($Slic3r::support_material_threshold + 1); # +1 makes the threshold inclusive my $overhang_width = $threshold_rad == 0 ? undef : scale $Slic3r::layer_height * ((cos $threshold_rad) / (sin $threshold_rad)); - my $distance_from_object = 1.5 * scale $Slic3r::flow->width; + my $distance_from_object = 1.5 * scale $Slic3r::support_material_flow->width; # determine support regions in each layer (for upper layers) Slic3r::debugf "Detecting regions\n"; @@ -514,7 +514,7 @@ sub generate_support_material { [ map @$_, @current_support_regions ], [ map @$_, map $_->expolygon->offset_ex($distance_from_object), @{$layer->slices} ], ); - $_->simplify(scale $layer->flow->spacing * 2) for @{$layers{$i}}; + $_->simplify(scale $layer->support_material_flow->spacing * 2) for @{$layers{$i}}; # step 2: get layer overhangs and put them into queue for adding support inside lower layers # we need an angle threshold for this @@ -536,7 +536,7 @@ sub generate_support_material { my $support_patterns = []; # in case we want cross-hatching { # 0.5 makes sure the paths don't get clipped externally when applying them to layers - my @support_material_areas = map $_->offset_ex(- 0.5 * scale $Slic3r::flow->width), + my @support_material_areas = map $_->offset_ex(- 0.5 * scale $Slic3r::support_material_flow->width), @{union_ex([ map $_->contour, map @$_, values %layers ])}; my $fill = Slic3r::Fill->new(print => $params{print}); @@ -547,8 +547,8 @@ sub generate_support_material { foreach my $expolygon (@support_material_areas) { my @paths = $filler->fill_surface( Slic3r::Surface->new(expolygon => $expolygon), - density => $Slic3r::flow->spacing / $Slic3r::support_material_spacing, - flow_spacing => $Slic3r::flow->spacing, + density => $Slic3r::support_material_flow->spacing / $Slic3r::support_material_spacing, + flow_spacing => $Slic3r::support_material_flow->spacing, ); my $params = shift @paths; diff --git a/slic3r.pl b/slic3r.pl index 979e42bf2..d532fbe66 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -282,6 +282,8 @@ $j Set a different extrusion width for perimeters --infill-extrusion-width Set a different extrusion width for infill + --support-material-extrusion-width + Set a different extrusion width for support material --bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: $Slic3r::bridge_flow_ratio) EOF