From 975387d9533bb798c351129a0a538e91664a4f77 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 28 Nov 2011 18:37:53 +0100 Subject: [PATCH] New --bridge-feed-rate option. #68 --- README.markdown | 15 +++++++++++---- lib/Slic3r.pm | 1 + lib/Slic3r/Config.pm | 7 +++++++ lib/Slic3r/ExtrusionLoop.pm | 5 ++++- lib/Slic3r/ExtrusionPath.pm | 11 ++++++++++- lib/Slic3r/Fill.pm | 3 ++- lib/Slic3r/Fill/Concentric.pm | 2 +- lib/Slic3r/GUI/SkeinPanel.pm | 2 +- lib/Slic3r/Perimeter.pm | 4 ++-- lib/Slic3r/Print.pm | 2 +- slic3r.pl | 8 +++++--- t/arcs.t | 4 ++-- 12 files changed, 47 insertions(+), 17 deletions(-) diff --git a/README.markdown b/README.markdown index d75795301..17eee91d6 100644 --- a/README.markdown +++ b/README.markdown @@ -94,19 +94,23 @@ The author is Alessandro Ranellucci (me). (+/-, default: 0) --gcode-arcs Use G2/G3 commands for native arcs (experimental, not supported by all firmwares) + --g0 Use G0 commands for retraction (experimenta, not supported by all + firmwares) Filament options: --filament-diameter Diameter in mm of your raw filament (default: 3) - --filament-packing-density - Ratio of the extruded volume over volume pushed - into the extruder (default: 1) - --temperature Extrusion temperature (default: 200) + --extrusion-multiplier + Change this to alter the amount of plastic extruded. There should be + very little need to change this value, which is only useful to + compensate for filament packing (default: 1) + --temperature Extrusion temperature, set 0 to disable (default: 200) Speed options: --print-feed-rate Speed of print moves in mm/sec (default: 60) --travel-feed-rate Speed of non-print moves in mm/sec (default: 130) --perimeter-feed-rate Speed of print moves for perimeters in mm/sec (default: 60) + --bridge-feed-rate Speed of bridge print moves in mm/sec (default: 60) --bottom-layer-speed-ratio Factor to increase/decrease speeds on bottom layer by (default: 0.3) @@ -118,6 +122,9 @@ The author is Alessandro Ranellucci (me). layer with (> 0, default: 1) --infill-every-layers Infill every N layers (default: 1) + --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+, diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 10cdef933..89adc3170 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -50,6 +50,7 @@ our $temperature = 200; our $print_feed_rate = 60; # mm/sec our $travel_feed_rate = 130; # mm/sec our $perimeter_feed_rate = 30; # mm/sec +our $bridge_feed_rate = 60; # mm/sec our $bottom_layer_speed_ratio = 0.3; # accuracy options diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 05c6b4994..af53a3fad 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -59,6 +59,10 @@ our $Options = { label => 'Perimeter feed rate (mm/s)', type => 'f', }, + 'bridge_feed_rate' => { + label => 'Bridge feed rate (mm/s)', + type => 'f', + }, 'bottom_layer_speed_ratio' => { label => 'Bottom layer ratio', type => 'f', @@ -351,6 +355,9 @@ sub validate { # --skirt-height die "Invalid value for --skirt-height\n" if $Slic3r::skirt_height < 1; + + # legacy with existing config files + $Slic3r::bridge_feed_rate ||= $Slic3r::print_feed_rate; } 1; diff --git a/lib/Slic3r/ExtrusionLoop.pm b/lib/Slic3r/ExtrusionLoop.pm index 38b17a7fe..50998e808 100644 --- a/lib/Slic3r/ExtrusionLoop.pm +++ b/lib/Slic3r/ExtrusionLoop.pm @@ -5,6 +5,9 @@ use XXX; extends 'Slic3r::Polyline::Closed'; +# perimeter/fill/bridge/skirt +has 'role' => (is => 'ro', required => 1); + sub split_at { my $self = shift; my ($point) = @_; @@ -25,7 +28,7 @@ sub split_at { push @new_points, @{$self->points}[$i .. $#{$self->points}]; push @new_points, @{$self->points}[0 .. $i]; - return Slic3r::ExtrusionPath->new(points => [@new_points]); + return Slic3r::ExtrusionPath->new(points => [@new_points], role => $self->role); } 1; diff --git a/lib/Slic3r/ExtrusionPath.pm b/lib/Slic3r/ExtrusionPath.pm index 2702b20ac..78b3b9d71 100644 --- a/lib/Slic3r/ExtrusionPath.pm +++ b/lib/Slic3r/ExtrusionPath.pm @@ -7,6 +7,9 @@ extends 'Slic3r::Polyline'; # expressed in layers has 'depth_layers' => (is => 'ro', default => sub {1}); +# perimeter/fill/bridge/skirt +has 'role' => (is => 'ro', required => 1); + use Slic3r::Geometry qw(PI X Y epsilon deg2rad rotate_points); use XXX; @@ -67,7 +70,12 @@ sub split_at_acute_angles { push @p, $p3; } } - push @paths, (ref $self)->cast([@p]) if @p > 1; + push @paths, (ref $self)->cast( + [@p], + role => $self->role, + depth_layers => $self->depth_layers, + ) if @p > 1; + return @paths; } @@ -152,6 +160,7 @@ sub detect_arcs { my $arc = Slic3r::ExtrusionPath::Arc->new( points => [@arc_points], + role => $self->role, orientation => $orientation, center => $arc_center, radius => $arc_center->distance_to($points[$i]), diff --git a/lib/Slic3r/Fill.pm b/lib/Slic3r/Fill.pm index f59acc80c..92e6b7ff8 100644 --- a/lib/Slic3r/Fill.pm +++ b/lib/Slic3r/Fill.pm @@ -80,10 +80,10 @@ sub make_fill { my $filler = $Slic3r::fill_pattern; my $density = $Slic3r::fill_density; my $flow_width = $Slic3r::flow_width; + my $is_bridge = $layer->id > 0 && $surface->surface_type eq 'bottom'; # force 100% density and rectilinear fill for external surfaces if ($surface->surface_type ne 'internal') { - my $is_bridge = $layer->id > 0 && $surface->surface_type eq 'bottom'; $density = 1; $filler = $is_bridge ? 'rectilinear' : $Slic3r::solid_fill_pattern; $flow_width = $Slic3r::nozzle_diameter if $is_bridge; @@ -102,6 +102,7 @@ sub make_fill { paths => [ map Slic3r::ExtrusionPath->cast( [ @$_ ], + role => ($is_bridge ? 'bridge' : 'fill'), depth_layers => $surface->depth_layers, ), @paths, ], diff --git a/lib/Slic3r/Fill/Concentric.pm b/lib/Slic3r/Fill/Concentric.pm index 6f6910b92..bcc0cba2e 100644 --- a/lib/Slic3r/Fill/Concentric.pm +++ b/lib/Slic3r/Fill/Concentric.pm @@ -35,7 +35,7 @@ sub fill_surface { # make paths my @paths = (); my $cur_pos = Slic3r::Point->new(0,0); - foreach my $loop (map Slic3r::ExtrusionLoop->cast($_), @loops) { + foreach my $loop (map Slic3r::ExtrusionLoop->cast($_, role => 'fill'), @loops) { # find the point of the loop that is closest to the current extruder position $cur_pos = $loop->nearest_point_to($cur_pos); diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 6fb4d3675..f6547ce0d 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -25,7 +25,7 @@ sub new { }, speed => { title => 'Speed', - options => [qw(print_feed_rate travel_feed_rate perimeter_feed_rate bottom_layer_speed_ratio)], + options => [qw(travel_feed_rate print_feed_rate perimeter_feed_rate bridge_feed_rate bottom_layer_speed_ratio)], }, accuracy => { title => 'Accuracy', diff --git a/lib/Slic3r/Perimeter.pm b/lib/Slic3r/Perimeter.pm index 0e4d7c041..e4d8f1ce5 100644 --- a/lib/Slic3r/Perimeter.pm +++ b/lib/Slic3r/Perimeter.pm @@ -64,12 +64,12 @@ sub make_perimeter { foreach my $island (@perimeters) { # do holes starting from innermost one foreach my $hole (map $_->holes, map @$_, @$island) { - push @{ $layer->perimeters }, Slic3r::ExtrusionLoop->cast($hole); + push @{ $layer->perimeters }, Slic3r::ExtrusionLoop->cast($hole, role => 'perimeter'); } # do contours starting from innermost one foreach my $contour (map $_->contour, map @$_, reverse @$island) { - push @{ $layer->perimeters }, Slic3r::ExtrusionLoop->cast($contour); + push @{ $layer->perimeters }, Slic3r::ExtrusionLoop->cast($contour, role => 'perimeter'); } } } diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 7835d746c..6fac7a85c 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -273,7 +273,7 @@ sub extrude_skirt { for (my $i = $Slic3r::skirts - 1; $i >= 0; $i--) { my $distance = ($Slic3r::skirt_distance + ($Slic3r::flow_width * $i)) / $Slic3r::resolution; my $outline = offset([$convex_hull], $distance, $Slic3r::resolution * 100, JT_ROUND); - push @skirts, Slic3r::ExtrusionLoop->cast([ @{$outline->[0]} ]); + push @skirts, Slic3r::ExtrusionLoop->cast([ @{$outline->[0]} ], role => 'skirt'); } # apply skirts to all layers diff --git a/slic3r.pl b/slic3r.pl index f3306e834..c800f4f27 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -42,6 +42,7 @@ GetOptions( 'print-feed-rate=i' => \$Slic3r::print_feed_rate, 'travel-feed-rate=i' => \$Slic3r::travel_feed_rate, 'perimeter-feed-rate=i' => \$Slic3r::perimeter_feed_rate, + 'bridge-feed-rate=i' => \$Slic3r::bridge_feed_rate, 'bottom-layer-speed-ratio=f' => \$Slic3r::bottom_layer_speed_ratio, # accuracy options @@ -147,9 +148,9 @@ Usage: slic3r.pl [ OPTIONS ] file.stl Filament options: --filament-diameter Diameter in mm of your raw filament (default: $Slic3r::filament_diameter) --extrusion-multiplier - Change this to alter the amount of plastic extruded. There should be very little - need to change this value, which is only useful to compensate for - filament packing (default: $Slic3r::extrusion_multiplier) + Change this to alter the amount of plastic extruded. There should be + very little need to change this value, which is only useful to + compensate for filament packing (default: $Slic3r::extrusion_multiplier) --temperature Extrusion temperature, set 0 to disable (default: $Slic3r::temperature) Speed options: @@ -157,6 +158,7 @@ Usage: slic3r.pl [ OPTIONS ] file.stl --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) + --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 layer by (default: $Slic3r::bottom_layer_speed_ratio) diff --git a/t/arcs.t b/t/arcs.t index 2c5dead4c..4cc01260c 100644 --- a/t/arcs.t +++ b/t/arcs.t @@ -18,7 +18,7 @@ use Slic3r; [306517.1,219034.23], [286979.42,248012.49], [258001.16,267550.17], [222515.14,274714.47], [187029.11,267550.17], [158050.85,248012.49], [138513.17,219034.23], [131348.87,183548.2], [86948.77,175149.09], [119825.35,100585], - ]); + ], role => 'fill'); my $collection = Slic3r::ExtrusionPath::Collection->new(paths => [$path]); $collection->detect_arcs(30); @@ -36,7 +36,7 @@ use Slic3r; [13.8268343236509,19.2387953251129], [14.5399049973955,18.9100652418837], [15.2249856471595,18.5264016435409], [15.8778525229247,18.0901699437495], [16.4944804833018,17.6040596560003], - ]); + ], role => 'fill'); my $collection = Slic3r::ExtrusionPath::Collection->new(paths => [$path]); $collection->detect_arcs(10, 1);