From bf1aba3d08d15469e55d35001f7ceb9ab608646c Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 23 Jun 2012 22:43:23 +0200 Subject: [PATCH] New --support-material-pattern and --support-material-angle options --- README.markdown | 8 +++++++- lib/Slic3r.pm | 2 ++ lib/Slic3r/Config.pm | 18 +++++++++++++++--- lib/Slic3r/Fill/Base.pm | 5 +++-- lib/Slic3r/Fill/Rectilinear.pm | 2 +- lib/Slic3r/GUI/SkeinPanel.pm | 14 +++++++++----- lib/Slic3r/Print/Object.pm | 14 ++++++-------- slic3r.pl | 8 +++++++- 8 files changed, 50 insertions(+), 21 deletions(-) diff --git a/README.markdown b/README.markdown index 4dc7a27fc..d63f2c1b0 100644 --- a/README.markdown +++ b/README.markdown @@ -159,10 +159,16 @@ The author is Alessandro Ranellucci. the default commands (turn off temperature [M104 S0], home X axis [G28 X], disable motors [M84]). --layer-gcode Load layer-change G-code from the supplied file (default: nothing). - --support-material Generate support material for overhangs --extra-perimeters Add more perimeters when needed (default: yes) --randomize-start Randomize starting point across layers (default: yes) + Support material options: + --support-material Generate support material for overhangs + --support-material-pattern + Pattern to use for support material (default: rectilinear) + --support-material-angle + Support material angle in degrees (range: 0-90, default: 0) + Retraction options: --retract-length Length of retraction in mm when pausing extrusion (default: 1) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index f61120370..f299921bf 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -123,6 +123,8 @@ our $fill_angle = 45; our $extra_perimeters = 1; our $randomize_start = 1; our $support_material = 0; +our $support_material_pattern = 'rectilinear'; +our $support_material_angle = 0; our $support_material_tool = 0; our $start_gcode = "G28 ; home all axes"; our $end_gcode = <<"END"; diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 9d1c5402c..21aa85563 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -16,8 +16,8 @@ our $Options = { cli => 'notes=s', type => 's', multiline => 1, - width => 220, - height => 130, + width => 400, + height => 100, serialize => sub { join '\n', split /\R/, $_[0] }, deserialize => sub { join "\n", split /\\n/, $_[0] }, }, @@ -284,8 +284,20 @@ our $Options = { cli => 'support-material!', type => 'bool', }, + 'support_material_pattern' => { + label => 'Pattern', + cli => 'support-material-pattern=s', + type => 'select', + values => [qw(rectilinear honeycomb)], + labels => [qw(rectilinear honeycomb)], + }, + 'support_material_angle' => { + label => 'Angle (°)', + cli => 'support-material-angle=i', + type => 'i', + }, 'support_material_tool' => { - label => 'Tool used to extrude support material', + label => 'Extruder', cli => 'support-material-tool=i', type => 'select', values => [0,1], diff --git a/lib/Slic3r/Fill/Base.pm b/lib/Slic3r/Fill/Base.pm index b104de3d5..a87ff804f 100644 --- a/lib/Slic3r/Fill/Base.pm +++ b/lib/Slic3r/Fill/Base.pm @@ -5,6 +5,7 @@ use Moo; has 'print' => (is => 'rw'); has 'layer' => (is => 'rw'); has 'max_print_dimension' => (is => 'rw'); +has 'angle' => (is => 'rw', default => sub { $Slic3r::fill_angle }); use constant PI => 4 * atan2(1, 1); @@ -16,7 +17,7 @@ sub infill_direction { # set infill angle my (@rotate, @shift); - $rotate[0] = Slic3r::Geometry::deg2rad($Slic3r::fill_angle); + $rotate[0] = Slic3r::Geometry::deg2rad($self->angle); $rotate[1] = [ $self->max_print_dimension * sqrt(2) / 2, $self->max_print_dimension * sqrt(2) / 2 ]; @shift = @{$rotate[1]}; @@ -24,7 +25,7 @@ sub infill_direction { # alternate fill direction my $layer_num = $self->layer->id / $surface->depth_layers; my $angle = $self->angles->[$layer_num % @{$self->angles}]; - $rotate[0] = Slic3r::Geometry::deg2rad($Slic3r::fill_angle) + $angle if $angle; + $rotate[0] = Slic3r::Geometry::deg2rad($self->angle) + $angle if $angle; } # use bridge angle diff --git a/lib/Slic3r/Fill/Rectilinear.pm b/lib/Slic3r/Fill/Rectilinear.pm index e8adcc6e8..ebfa316e8 100644 --- a/lib/Slic3r/Fill/Rectilinear.pm +++ b/lib/Slic3r/Fill/Rectilinear.pm @@ -69,7 +69,7 @@ sub fill_surface { ($_[X] >= ($distance_between_lines - $line_oscillation) - $tolerance) && ($_[X] <= ($distance_between_lines + $line_oscillation) + $tolerance) && $_[Y] <= $diagonal_distance } - : sub { abs($_[X]) - $distance_between_lines <= $tolerance && $_[Y] <= $diagonal_distance }; + : sub { abs($_[X] - $distance_between_lines) <= $tolerance && $_[Y] <= $diagonal_distance }; foreach my $path ($collection->shortest_path) { if (@paths) { diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 1a462f2de..f216c7d0f 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -44,7 +44,7 @@ sub new { }, print => { title => 'Print settings', - options => [qw(perimeters solid_layers fill_density fill_angle fill_pattern solid_fill_pattern randomize_start support_material)], + options => [qw(perimeters solid_layers fill_density fill_angle fill_pattern solid_fill_pattern randomize_start)], }, retract => { title => 'Retraction', @@ -53,7 +53,7 @@ sub new { cooling => { title => 'Cooling', options => [qw(cooling min_fan_speed max_fan_speed bridge_fan_speed fan_below_layer_time slowdown_below_layer_time min_print_speed disable_fan_first_layers fan_always_on)], - label_width => 300, + label_width => 450, }, skirt => { title => 'Skirt', @@ -78,12 +78,16 @@ sub new { }, other => { title => 'Other', - options => [ ($Slic3r::have_threads ? qw(threads) : ()), qw(extra_perimeters support_material_tool) ], + options => [ ($Slic3r::have_threads ? qw(threads) : ()), qw(extra_perimeters) ], }, notes => { title => 'Notes', options => [qw(notes)], }, + support_material => { + title => 'Support material', + options => [qw(support_material support_material_tool)], + }, ); $self->{panels} = \%panels; @@ -108,8 +112,8 @@ sub new { }; my @tabs = ( - $make_tab->([qw(accuracy skirt retract)], [qw(print notes)]), - $make_tab->([qw(cooling)]), + $make_tab->([qw(accuracy skirt support_material)], [qw(print retract)]), + $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)]), diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 53021ecc1..5ebcb4f9b 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -545,20 +545,18 @@ sub generate_support_material { # generate paths for the pattern that we're going to use Slic3r::debugf "Generating patterns\n"; - my $support_patterns = []; + my $support_patterns = []; # in case we want cross-hatching { my @support_material_areas = @{union_ex([ map @$_, @unsupported_expolygons ])}; my $fill = Slic3r::Fill->new(print => $params{print}); - foreach my $layer (map $self->layers->[$_], 0,1,2) { # ugly hack - $fill->filler('honeycomb')->layer($layer); + my $filler = $fill->filler($Slic3r::support_material_pattern); + $filler->angle($Slic3r::support_material_angle); + { my @patterns = (); foreach my $expolygon (@support_material_areas) { - my @paths = $fill->filler('honeycomb')->fill_surface( - Slic3r::Surface->new( - expolygon => $expolygon, - #bridge_angle => $Slic3r::fill_angle + 45 + $angle, - ), + my @paths = $filler->fill_surface( + Slic3r::Surface->new(expolygon => $expolygon), density => 0.20, flow_spacing => $Slic3r::flow->spacing, ); diff --git a/slic3r.pl b/slic3r.pl index e261a4e18..4538ac40f 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -204,10 +204,16 @@ $j the default commands (turn off temperature [M104 S0], home X axis [G28 X], disable motors [M84]). --layer-gcode Load layer-change G-code from the supplied file (default: nothing). - --support-material Generate support material for overhangs --extra-perimeters Add more perimeters when needed (default: yes) --randomize-start Randomize starting point across layers (default: yes) + Support material options: + --support-material Generate support material for overhangs + --support-material-pattern + Pattern to use for support material (default: $Slic3r::support_material_pattern) + --support-material-angle + Support material angle in degrees (range: 0-90, default: $Slic3r::support_material_angle) + Retraction options: --retract-length Length of retraction in mm when pausing extrusion (default: $Slic3r::retract_length)