From 3ad9ed74ae53c96ef1a51cd85b868141ff699724 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 28 Nov 2011 19:11:26 +0100 Subject: [PATCH] New --solid-infill-feed-rate option. #68 --- lib/Slic3r.pm | 5 +++-- lib/Slic3r/Config.pm | 24 +++++++++++++++--------- lib/Slic3r/Extruder.pm | 33 +++++++++++++++++++++++---------- lib/Slic3r/ExtrusionLoop.pm | 2 +- lib/Slic3r/ExtrusionPath.pm | 2 +- lib/Slic3r/Fill.pm | 3 ++- lib/Slic3r/GUI/SkeinPanel.pm | 10 +++++++--- slic3r.pl | 9 ++++++--- 8 files changed, 58 insertions(+), 30 deletions(-) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 89adc3170..25dfb2ff7 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -47,9 +47,10 @@ our $extrusion_multiplier = 1; our $temperature = 200; # speed options -our $print_feed_rate = 60; # mm/sec -our $travel_feed_rate = 130; # mm/sec +our $travel_feed_rate = 130; # mm/sec our $perimeter_feed_rate = 30; # mm/sec +our $infill_feed_rate = 60; # mm/sec +our $solid_infill_feed_rate = 60; # mm/sec our $bridge_feed_rate = 60; # mm/sec our $bottom_layer_speed_ratio = 0.3; diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index af53a3fad..1bb5b7bcd 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -47,24 +47,29 @@ our $Options = { }, # speed options - 'print_feed_rate' => { - label => 'Print feed rate (mm/s)', - type => 'f', - }, 'travel_feed_rate' => { - label => 'Travel feed rate (mm/s)', + label => 'Travel (mm/s)', type => 'f', }, 'perimeter_feed_rate' => { - label => 'Perimeter feed rate (mm/s)', + label => 'Perimeters (mm/s)', + type => 'f', + }, + 'infill_feed_rate' => { + label => 'Infill (mm/s)', + type => 'f', + aliases => [qw(print_feed_rate)], + }, + 'solid_infill_feed_rate' => { + label => 'Solid infill (mm/s)', type => 'f', }, 'bridge_feed_rate' => { - label => 'Bridge feed rate (mm/s)', + label => 'Bridges (mm/s)', type => 'f', }, 'bottom_layer_speed_ratio' => { - label => 'Bottom layer ratio', + label => 'Bottom layer speed ratio', type => 'f', }, @@ -357,7 +362,8 @@ sub validate { if $Slic3r::skirt_height < 1; # legacy with existing config files - $Slic3r::bridge_feed_rate ||= $Slic3r::print_feed_rate; + $Slic3r::bridge_feed_rate ||= $Slic3r::infill_feed_rate; + $Slic3r::solid_infill_feed_rate ||= $Slic3r::infill_feed_rate; } 1; diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index f873ad4e3..5b2b27ef2 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -6,6 +6,7 @@ has 'shift_x' => (is => 'ro', default => sub {0} ); has 'shift_y' => (is => 'ro', default => sub {0} ); has 'z' => (is => 'rw', default => sub {0} ); has 'flow_ratio' => (is => 'rw', default => sub {1}); +has 'print_feed_rate' => (is => 'rw'); has 'extrusion_distance' => (is => 'rw', default => sub {0} ); has 'retracted' => (is => 'rw', default => sub {1} ); # this spits out some plastic at start @@ -19,14 +20,22 @@ has 'travel_feed_rate' => ( is => 'ro', default => sub { $Slic3r::travel_feed_rate * 60 }, # mm/min ); -has 'print_feed_rate' => ( - is => 'ro', - default => sub { $Slic3r::print_feed_rate * 60 }, # mm/min -); has 'perimeter_feed_rate' => ( is => 'ro', default => sub { $Slic3r::perimeter_feed_rate * 60 }, # mm/min ); +has 'infill_feed_rate' => ( + is => 'ro', + default => sub { $Slic3r::infill_feed_rate * 60 }, # mm/min +); +has 'solid_infill_feed_rate' => ( + is => 'ro', + default => sub { $Slic3r::solid_infill_feed_rate * 60 }, # mm/min +); +has 'bridge_feed_rate' => ( + is => 'ro', + default => sub { $Slic3r::bridge_feed_rate * 60 }, # mm/min +); has 'retract_speed' => ( is => 'ro', default => sub { $Slic3r::retract_speed * 60 }, # mm/min @@ -112,6 +121,13 @@ sub extrude { * $path->depth_layers; # extrude arc or line + $self->print_feed_rate( + $path->role =~ /^(perimeter|skirt)$/o ? $self->perimeter_feed_rate + : $path->role eq 'fill' ? $self->infill_feed_rate + : $path->role eq 'solid-fill' ? $self->solid_infill_feed_rate + : $path->role eq 'bridge' ? $self->bridge_feed_rate + : die "Unknown role: " . $path->role + ); if ($path->isa('Slic3r::ExtrusionPath::Arc')) { $gcode .= $self->G2_G3($path->points->[-1], $path->orientation, $path->center, $e * $path->length, $description); @@ -132,6 +148,7 @@ sub retract { && !$self->retracted; # prepare moves + $self->print_feed_rate($self->retract_speed); my $retract = [undef, undef, -$Slic3r::retract_length, "retract"]; my $lift = ($Slic3r::retract_lift == 0) ? undef @@ -181,6 +198,7 @@ sub unretract { $self->lifted(0); } + $self->print_feed_rate($self->retract_speed); $gcode .= $self->G0(undef, undef, ($Slic3r::retract_length + $Slic3r::retract_restart_extra), "compensate retraction"); @@ -250,12 +268,7 @@ sub _Gx { : 1; # determine speed - my $speed = $self->travel_feed_rate * $speed_multiplier; - if ($e) { - $speed = $self->print_feed_rate * $speed_multiplier; - $speed = $self->retract_speed if $comment =~ /retract/; - $speed = $self->perimeter_feed_rate * $speed_multiplier if $comment =~ /perimeter/; - } + my $speed = ($e ? $self->print_feed_rate : $self->travel_feed_rate) * $speed_multiplier; # output speed if it's different from last one used # (goal: reduce gcode size) diff --git a/lib/Slic3r/ExtrusionLoop.pm b/lib/Slic3r/ExtrusionLoop.pm index 50998e808..c0b408138 100644 --- a/lib/Slic3r/ExtrusionLoop.pm +++ b/lib/Slic3r/ExtrusionLoop.pm @@ -5,7 +5,7 @@ use XXX; extends 'Slic3r::Polyline::Closed'; -# perimeter/fill/bridge/skirt +# perimeter/fill/solid-fill/bridge/skirt has 'role' => (is => 'ro', required => 1); sub split_at { diff --git a/lib/Slic3r/ExtrusionPath.pm b/lib/Slic3r/ExtrusionPath.pm index 78b3b9d71..e819dcf58 100644 --- a/lib/Slic3r/ExtrusionPath.pm +++ b/lib/Slic3r/ExtrusionPath.pm @@ -7,7 +7,7 @@ extends 'Slic3r::Polyline'; # expressed in layers has 'depth_layers' => (is => 'ro', default => sub {1}); -# perimeter/fill/bridge/skirt +# perimeter/fill/solid-fill/bridge/skirt has 'role' => (is => 'ro', required => 1); use Slic3r::Geometry qw(PI X Y epsilon deg2rad rotate_points); diff --git a/lib/Slic3r/Fill.pm b/lib/Slic3r/Fill.pm index 92e6b7ff8..55abfdb05 100644 --- a/lib/Slic3r/Fill.pm +++ b/lib/Slic3r/Fill.pm @@ -81,6 +81,7 @@ sub make_fill { my $density = $Slic3r::fill_density; my $flow_width = $Slic3r::flow_width; my $is_bridge = $layer->id > 0 && $surface->surface_type eq 'bottom'; + my $is_solid = $surface->surface_type =~ /^(top|bottom)$/; # force 100% density and rectilinear fill for external surfaces if ($surface->surface_type ne 'internal') { @@ -102,7 +103,7 @@ sub make_fill { paths => [ map Slic3r::ExtrusionPath->cast( [ @$_ ], - role => ($is_bridge ? 'bridge' : 'fill'), + role => ($is_bridge ? 'bridge' : $is_solid ? 'solid-fill' : 'fill'), depth_layers => $surface->depth_layers, ), @paths, ], diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index f6547ce0d..fbf2d627f 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -23,9 +23,13 @@ sub new { title => 'Filament', options => [qw(filament_diameter extrusion_multiplier temperature)], }, + print_speed => { + title => 'Print speed', + options => [qw(perimeter_feed_rate infill_feed_rate solid_infill_feed_rate bridge_feed_rate)], + }, speed => { - title => 'Speed', - options => [qw(travel_feed_rate print_feed_rate perimeter_feed_rate bridge_feed_rate bottom_layer_speed_ratio)], + title => 'Other speed settings', + options => [qw(travel_feed_rate bottom_layer_speed_ratio)], }, accuracy => { title => 'Accuracy', @@ -79,7 +83,7 @@ sub new { my @tabs = ( $make_tab->([qw(transform accuracy skirt)], [qw(print retract)]), - $make_tab->([qw(printer filament)], [qw(speed)]), + $make_tab->([qw(printer filament)], [qw(print_speed speed)]), $make_tab->([qw(gcode)]), $make_tab->([qw(extrusion)]), ); diff --git a/slic3r.pl b/slic3r.pl index c800f4f27..a85b5c1b0 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -39,9 +39,10 @@ GetOptions( 'temperature=i' => \$Slic3r::temperature, # speed options - 'print-feed-rate=i' => \$Slic3r::print_feed_rate, 'travel-feed-rate=i' => \$Slic3r::travel_feed_rate, 'perimeter-feed-rate=i' => \$Slic3r::perimeter_feed_rate, + 'infill-feed-rate=i' => \$Slic3r::infill_feed_rate, + 'solid-infill-feed-rate=i' => \$Slic3r::solid_infill_feed_rate, 'bridge-feed-rate=i' => \$Slic3r::bridge_feed_rate, 'bottom-layer-speed-ratio=f' => \$Slic3r::bottom_layer_speed_ratio, @@ -154,10 +155,12 @@ Usage: slic3r.pl [ OPTIONS ] file.stl --temperature Extrusion temperature, set 0 to disable (default: $Slic3r::temperature) Speed options: - --print-feed-rate Speed of print moves in mm/sec (default: $Slic3r::print_feed_rate) --travel-feed-rate Speed of non-print moves in mm/sec (default: $Slic3r::travel_feed_rate) --perimeter-feed-rate - Speed of print moves for perimeters in mm/sec (default: $Slic3r::print_feed_rate) + Speed of print moves for perimeters in mm/sec (default: $Slic3r::perimeter_feed_rate) + --infill-feed-rate Speed of print moves in mm/sec (default: $Slic3r::infill_feed_rate) + --solid-infill-feed-rate + Speed of print moves for solid surfaces in mm/sec (default: $Slic3r::solid_infill_feed_rate) --bridge-feed-rate Speed of bridge print moves in mm/sec (default: $Slic3r::bridge_feed_rate) --bottom-layer-speed-ratio Factor to increase/decrease speeds on bottom