From 0647958a5c0681c2b0d8ded53e0804cf6b9b7af3 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 26 Jul 2013 00:32:21 +0200 Subject: [PATCH] New option for support material interface extruder. #1072 --- README.markdown | 2 ++ lib/Slic3r/Config.pm | 9 ++++++++- lib/Slic3r/GCode/Layer.pm | 9 +++++---- lib/Slic3r/GUI/Tab.pm | 2 +- lib/Slic3r/Layer.pm | 2 +- lib/Slic3r/Print.pm | 1 + lib/Slic3r/Print/Object.pm | 11 ++++++++--- lib/Slic3r/Test/SectionCut.pm | 2 +- slic3r.pl | 2 ++ t/support.t | 1 + 10 files changed, 30 insertions(+), 11 deletions(-) diff --git a/README.markdown b/README.markdown index 3d1ef284..46fbd0e6 100644 --- a/README.markdown +++ b/README.markdown @@ -322,6 +322,8 @@ The author of the Silk icon set is Mark James. --infill-extruder Extruder to use for infill (1+, default: 1) --support-material-extruder Extruder to use for support material (1+, default: 1) + --support-material-interface-extruder + Extruder to use for support material interface (1+, default: 1) If you want to change a preset file, just do diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 40dcc1dc..46c5b140 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -204,11 +204,18 @@ our $Options = { }, 'support_material_extruder' => { label => 'Support material extruder', - tooltip => 'The extruder to use when printing support material. This affects brim too.', + tooltip => 'The extruder to use when printing support material. This affects brim and raft too.', cli => 'support-material-extruder=i', type => 'i', default => 1, }, + 'support_material_interface_extruder' => { + label => 'Support material interface extruder', + tooltip => 'The extruder to use when printing support material interface. This affects raft too.', + cli => 'support-material-interface-extruder=i', + type => 'i', + default => 1, + }, # filament options 'first_layer_bed_temperature' => { diff --git a/lib/Slic3r/GCode/Layer.pm b/lib/Slic3r/GCode/Layer.pm index 50ae5ebc..b0a5f560 100644 --- a/lib/Slic3r/GCode/Layer.pm +++ b/lib/Slic3r/GCode/Layer.pm @@ -89,13 +89,14 @@ sub process_layer { # extrude support material before other things because it might use a lower Z # and also because we avoid travelling on other things when printing it if ($self->print->has_support_material && $layer->isa('Slic3r::Layer::Support')) { - $gcode .= $self->gcodegen->set_extruder($self->extruders->[$Slic3r::Config->support_material_extruder-1]); $gcode .= $self->gcodegen->move_z($layer->print_z); - if ($layer->support_contact_fills) { - $gcode .= $self->gcodegen->extrude_path($_, 'support material contact area') - for $layer->support_contact_fills->chained_path($self->gcodegen->last_pos); + if ($layer->support_interface_fills) { + $gcode .= $self->gcodegen->set_extruder($self->extruders->[$Slic3r::Config->support_material_interface_extruder-1]); + $gcode .= $self->gcodegen->extrude_path($_, 'support material interface') + for $layer->support_interface_fills->chained_path($self->gcodegen->last_pos); } if ($layer->support_fills) { + $gcode .= $self->gcodegen->set_extruder($self->extruders->[$Slic3r::Config->support_material_extruder-1]); $gcode .= $self->gcodegen->extrude_path($_, 'support material') for $layer->support_fills->chained_path($self->gcodegen->last_pos); } diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 27ff3c56..70fd3962 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -526,7 +526,7 @@ sub build { $self->add_options_page('Multiple Extruders', 'funnel.png', optgroups => [ { title => 'Extruders', - options => [qw(perimeter_extruder infill_extruder support_material_extruder)], + options => [qw(perimeter_extruder infill_extruder support_material_extruder support_material_interface_extruder)], }, ]); diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm index ce4e27dc..2bb13a31 100644 --- a/lib/Slic3r/Layer.pm +++ b/lib/Slic3r/Layer.pm @@ -70,6 +70,6 @@ extends 'Slic3r::Layer'; # ordered collection of extrusion paths to fill surfaces for support material has 'support_islands' => (is => 'rw'); has 'support_fills' => (is => 'rw'); -has 'support_contact_fills' => (is => 'rw'); +has 'support_interface_fills' => (is => 'rw'); 1; diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 38249928..ab62c108 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -257,6 +257,7 @@ sub init_extruders { } # calculate support material flow + # Note: we should calculate a different flow for support material interface if ($self->has_support_material) { my $extruder = $self->extruders->[$self->config->support_material_extruder-1]; $self->support_material_flow($extruder->make_flow( diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index d5d2e543..9d5f441c 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -1002,7 +1002,7 @@ sub generate_support_material { my $process_layer = sub { my ($layer_id) = @_; - my $result = { interface => [], support => [] }; + my $result = { contact => [], interface => [], support => [] }; $contact{$layer_id} ||= []; $interface{$layer_id} ||= []; @@ -1153,8 +1153,13 @@ sub generate_support_material { my $apply = sub { my ($layer_id, $result) = @_; my $layer = $self->support_layers->[$layer_id]; - $layer->support_contact_fills(Slic3r::ExtrusionPath::Collection->new(paths => $result->{contact})) if $result->{contact}; - $layer->support_fills(Slic3r::ExtrusionPath::Collection->new(paths => [ @{$result->{interface}}, @{$result->{support}} ])); + + my $interface_collection = Slic3r::ExtrusionPath::Collection->new(paths => [ @{$result->{contact}}, @{$result->{interface}} ]); + $layer->support_interface_fills($interface_collection) if @{$interface_collection->paths} > 0; + + my $support_collection = Slic3r::ExtrusionPath::Collection->new(paths => $result->{support}); + $layer->support_fills($support_collection) if @{$support_collection->paths} > 0; + $layer->support_islands($result->{islands}); }; Slic3r::parallelize( diff --git a/lib/Slic3r/Test/SectionCut.pm b/lib/Slic3r/Test/SectionCut.pm index 6ba799ec..05ade9be 100644 --- a/lib/Slic3r/Test/SectionCut.pm +++ b/lib/Slic3r/Test/SectionCut.pm @@ -58,7 +58,7 @@ sub export_svg { ); $group->( - filter => sub { $_[0]->isa('Slic3r::Layer::Support') ? ($_[0]->support_fills, $_[0]->support_contact_fills) : () }, + filter => sub { $_[0]->isa('Slic3r::Layer::Support') ? ($_[0]->support_fills, $_[0]->support_interface_fills) : () }, style => { 'stroke-width' => 1, 'stroke' => '#444444', diff --git a/slic3r.pl b/slic3r.pl index 4a654b31..52becfdd 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -407,6 +407,8 @@ $j --infill-extruder Extruder to use for infill (1+, default: 1) --support-material-extruder Extruder to use for support material (1+, default: 1) + --support-material-interface-extruder + Extruder to use for support material interface (1+, default: 1) EOF exit ($exit_code || 0); diff --git a/t/support.t b/t/support.t index 6ea37029..9ed16395 100644 --- a/t/support.t +++ b/t/support.t @@ -58,6 +58,7 @@ use Slic3r::Test; $config->set('brim_width', 6); $config->set('skirts', 0); $config->set('support_material_extruder', 2); + $config->set('support_material_interface_extruder', 2); $config->set('layer_height', 0.4); $config->set('first_layer_height', '100%'); my $print = Slic3r::Test::init_print('20mm_cube', config => $config);