From 5e78f8a0b07f01dea96d9e570626d1e3999af321 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 15 Nov 2013 15:52:11 +0100 Subject: [PATCH] Make sure all extruders are outside skirt at toolchange when standby_temperature is enabled --- lib/Slic3r/Print.pm | 8 +++++++- t/multi.t | 14 +++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 99ed37248..660cb8f7f 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -803,7 +803,13 @@ sub write_gcode { # calculate wiping points if needed if ($self->config->standby_temperature) { my $outer_skirt = Slic3r::Polygon->new(@{convex_hull([ map $_->pp, map @$_, @{$self->skirt} ])}); - $gcodegen->standby_points([ map $_->clone, map @$_, map $_->subdivide(scale 10), @{offset([$outer_skirt], scale 3)} ]); + my @skirts = (); + foreach my $extruder (@{$self->extruders}) { + push @skirts, my $s = $outer_skirt->clone; + $s->translate(map scale($_), @{$extruder->extruder_offset}); + } + my $convex_hull = Slic3r::Polygon->new(@{convex_hull([ map @$_, map $_->pp, @skirts ])}); + $gcodegen->standby_points([ map $_->clone, map @$_, map $_->subdivide(scale 10), @{offset([$convex_hull], scale 3)} ]); } # prepare the layer processor diff --git a/t/multi.t b/t/multi.t index 01f64d235..1423499ee 100644 --- a/t/multi.t +++ b/t/multi.t @@ -10,19 +10,23 @@ BEGIN { use List::Util qw(first); use Math::ConvexHull::MonotoneChain qw(convex_hull); use Slic3r; +use Slic3r::Geometry qw(scale); use Slic3r::Test; { my $config = Slic3r::Config->new_from_defaults; + $config->set('raft_layers', 2); $config->set('infill_extruder', 2); + $config->set('support_material_extruder', 3); $config->set('standby_temperature', 1); - $config->set('temperature', [200, 180]); - $config->set('first_layer_temperature', [206, 186]); + $config->set('extruder_offset', [ [0,0], [20,0], [0,20] ]); + $config->set('temperature', [200, 180, 170]); + $config->set('first_layer_temperature', [206, 186, 166]); my $print = Slic3r::Test::init_print('20mm_cube', config => $config); my $tool = undef; - my @tool_temp = (0,0); + my @tool_temp = (0,0,0); my @toolchange_points = (); my @extrusion_points = (); Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { @@ -46,9 +50,9 @@ use Slic3r::Test; } $tool_temp[$t] = $args->{S}; } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) { - push @extrusion_points, Slic3r::Point->new_scale($args->{X}, $args->{Y}); + push @extrusion_points, my $point = Slic3r::Point->new_scale($args->{X}, $args->{Y}); + $point->translate(map scale($_), @{ $config->extruder_offset->[$tool] }); } - # TODO: check that toolchanges retraction and restart happen outside skirt }); my $convex_hull = Slic3r::Polygon->new(@{convex_hull([ map $_->pp, @extrusion_points ])}); ok !(first { $convex_hull->encloses_point($_) } @toolchange_points), 'all toolchanges happen outside skirt';