From 3c0ea0b57fe757b656d9a635c0d4786aee5ff827 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 25 Nov 2011 10:58:13 +0100 Subject: [PATCH] New --extrusion-width-ratio option. #8 --- lib/Slic3r.pm | 3 ++- lib/Slic3r/Config.pm | 14 ++++++++++++-- lib/Slic3r/Extruder.pm | 2 +- lib/Slic3r/GUI/OptionsGroup.pm | 2 +- lib/Slic3r/GUI/SkeinPanel.pm | 20 ++++++++++++++------ slic3r.pl | 12 ++++++++---- 6 files changed, 38 insertions(+), 15 deletions(-) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 964e03f8d..5339579cb 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -57,7 +57,8 @@ our $resolution = 0.00000001; our $layer_height = 0.4; our $first_layer_height_ratio = 1; our $infill_every_layers = 1; -our $thickness_ratio = 1; +our $extrusion_width_ratio = undef; +our $flow_speed_ratio = 1.2; our $flow_width; # print options diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 8c802d0eb..ae297e071 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -68,6 +68,10 @@ our $Options = { label => 'Layer height (mm)', type => 'f', }, + 'extrusion_width_ratio' => { + label => 'Extrusion width (ratio over layer height; leave empty to calculate automatically)', + type => 'f', + }, 'first_layer_height_ratio' => { label => 'First layer height ratio', type => 'f', @@ -276,15 +280,21 @@ sub validate { die "First layer height can't be greater than --nozzle-diameter\n" if ($Slic3r::layer_height * $Slic3r::first_layer_height_ratio) > $Slic3r::nozzle_diameter; $Slic3r::flow_width = ($Slic3r::nozzle_diameter**2) - * $Slic3r::thickness_ratio * PI / (4 * $Slic3r::layer_height); + * $Slic3r::flow_speed_ratio * PI / (4 * $Slic3r::layer_height); my $max_flow_width = $Slic3r::layer_height + $Slic3r::nozzle_diameter; if ($Slic3r::flow_width > $max_flow_width) { - $Slic3r::thickness_ratio = $max_flow_width / $Slic3r::flow_width; + $Slic3r::flow_speed_ratio = $max_flow_width / $Slic3r::flow_width; $Slic3r::flow_width = $max_flow_width; } + if ($Slic3r::extrusion_width_ratio) { + my $flow_width = $Slic3r::layer_height * $Slic3r::extrusion_width_ratio; + $Slic3r::flow_speed_ratio = $flow_width / $Slic3r::flow_width; + $Slic3r::flow_width = $flow_width; + } Slic3r::debugf "Flow width = $Slic3r::flow_width\n"; + Slic3r::debugf "Flow speed ratio = $Slic3r::flow_speed_ratio\n"; # --perimeters die "Invalid value for --perimeters\n" diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index b1fc895b2..c9cd5eae8 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -101,7 +101,7 @@ sub extrude { # calculate extrusion length per distance unit my $e = $Slic3r::resolution * (($Slic3r::nozzle_diameter**2) / ($Slic3r::filament_diameter ** 2)) - * $Slic3r::thickness_ratio + * $Slic3r::flow_speed_ratio * $self->flow_ratio * $Slic3r::filament_packing_density * $path->depth_layers; diff --git a/lib/Slic3r/GUI/OptionsGroup.pm b/lib/Slic3r/GUI/OptionsGroup.pm index 3f4f9a849..877aaae7e 100644 --- a/lib/Slic3r/GUI/OptionsGroup.pm +++ b/lib/Slic3r/GUI/OptionsGroup.pm @@ -32,7 +32,7 @@ sub new { $size = Wx::Size->new($opt->{width} || -1, $opt->{height} || -1); } - $field = Wx::TextCtrl->new($parent, -1, Slic3r::Config->get($opt_key), + $field = Wx::TextCtrl->new($parent, -1, Slic3r::Config->get($opt_key) || '', Wx::wxDefaultPosition, $size, $style); EVT_TEXT($parent, $field, sub { Slic3r::Config->set($opt_key, $field->GetValue) }); push @reload_callbacks, sub { $field->SetValue(Slic3r::Config->get($opt_key)) }; diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 55459642d..f59d50316 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -51,6 +51,10 @@ sub new { title => 'Custom GCODE', options => [qw(start_gcode end_gcode)], }, + extrusion => { + title => 'Extrusion', + options => [qw(extrusion_width_ratio)], + }, ); $self->{panels} = \%panels; @@ -73,13 +77,17 @@ sub new { return $tab; }; - my $tab1 = $make_tab->([qw(transform accuracy skirt)], [qw(print retract)]); - my $tab2 = $make_tab->([qw(printer filament)], [qw(speed)]); - my $tab3 = $make_tab->([qw(gcode)]); + my @tabs = ( + $make_tab->([qw(transform accuracy skirt)], [qw(print retract)]), + $make_tab->([qw(printer filament)], [qw(speed)]), + $make_tab->([qw(gcode)]), + $make_tab->([qw(extrusion)]), + ); - $tabpanel->AddPage($tab1, "Print Settings"); - $tabpanel->AddPage($tab2, "Printer and Filament"); - $tabpanel->AddPage($tab3, "Start/End GCODE"); + $tabpanel->AddPage($tabs[0], "Print Settings"); + $tabpanel->AddPage($tabs[1], "Printer and Filament"); + $tabpanel->AddPage($tabs[2], "Start/End GCODE"); + $tabpanel->AddPage($tabs[3], "Advanced"); my $buttons_sizer; { diff --git a/slic3r.pl b/slic3r.pl index 0d9e311d1..03f374f48 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -35,7 +35,7 @@ GetOptions( # filament options 'filament-diameter=f' => \$Slic3r::filament_diameter, 'filament-packing-density=f' => \$Slic3r::filament_packing_density, - 'temperature=i' => \$Slic3r::temperature, + 'temperature=i' => \$Slic3r::temperature, # speed options 'print-feed-rate=i' => \$Slic3r::print_feed_rate, @@ -44,9 +44,10 @@ GetOptions( 'bottom-layer-speed-ratio=f' => \$Slic3r::bottom_layer_speed_ratio, # accuracy options - 'layer-height=f' => \$Slic3r::layer_height, - 'first-layer-height-ratio=f' => \$Slic3r::first_layer_height_ratio, - 'infill-every-layers=i' => \$Slic3r::infill_every_layers, + 'layer-height=f' => \$Slic3r::layer_height, + 'extrusion-width-ratio=f' => \$Slic3r::extrusion_width_ratio, + 'first-layer-height-ratio=f' => \$Slic3r::first_layer_height_ratio, + 'infill-every-layers=i' => \$Slic3r::infill_every_layers, # print options 'perimeters=i' => \$Slic3r::perimeters, @@ -165,6 +166,9 @@ Usage: slic3r.pl [ OPTIONS ] file.stl layer with (> 0, default: $Slic3r::first_layer_height_ratio) --infill-every-layers Infill every N layers (default: $Slic3r::infill_every_layers) + --extrusion-width-ratio + Calculate the extrusion width as the layer height multiplied by + this value (> 0, default: calculated automatically) Print options: --perimeters Number of perimeters/horizontal skins (range: 1+,