2013-09-18 23:29:34 +00:00
|
|
|
use Test::More tests => 1;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin/../lib";
|
|
|
|
}
|
|
|
|
|
|
|
|
use List::Util qw(first);
|
2013-09-19 08:44:29 +00:00
|
|
|
use Math::ConvexHull::MonotoneChain qw(convex_hull);
|
2013-09-18 23:29:34 +00:00
|
|
|
use Slic3r;
|
2013-11-15 14:52:11 +00:00
|
|
|
use Slic3r::Geometry qw(scale);
|
2013-09-18 23:29:34 +00:00
|
|
|
use Slic3r::Test;
|
|
|
|
|
|
|
|
{
|
|
|
|
my $config = Slic3r::Config->new_from_defaults;
|
2013-11-15 14:52:11 +00:00
|
|
|
$config->set('raft_layers', 2);
|
2013-09-18 23:29:34 +00:00
|
|
|
$config->set('infill_extruder', 2);
|
2013-11-15 14:52:11 +00:00
|
|
|
$config->set('support_material_extruder', 3);
|
2013-11-15 15:01:15 +00:00
|
|
|
$config->set('ooze_prevention', 1);
|
2013-11-15 14:52:11 +00:00
|
|
|
$config->set('extruder_offset', [ [0,0], [20,0], [0,20] ]);
|
|
|
|
$config->set('temperature', [200, 180, 170]);
|
|
|
|
$config->set('first_layer_temperature', [206, 186, 166]);
|
2013-09-18 23:29:34 +00:00
|
|
|
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
|
|
|
|
|
|
|
my $tool = undef;
|
2013-11-15 14:52:11 +00:00
|
|
|
my @tool_temp = (0,0,0);
|
2013-09-19 08:44:29 +00:00
|
|
|
my @toolchange_points = ();
|
|
|
|
my @extrusion_points = ();
|
2013-09-18 23:29:34 +00:00
|
|
|
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
|
|
|
my ($self, $cmd, $args, $info) = @_;
|
|
|
|
|
|
|
|
if ($cmd =~ /^T(\d+)/) {
|
|
|
|
if (defined $tool) {
|
|
|
|
my $expected_temp = $self->Z == ($config->get_value('first_layer_height') + $config->z_offset)
|
|
|
|
? $config->first_layer_temperature->[$tool]
|
|
|
|
: $config->temperature->[$tool];
|
|
|
|
die 'standby temperature was not set before toolchange'
|
|
|
|
if $tool_temp[$tool] != $expected_temp + $config->standby_temperature_delta;
|
|
|
|
}
|
|
|
|
$tool = $1;
|
2013-09-19 08:44:29 +00:00
|
|
|
push @toolchange_points, Slic3r::Point->new_scale($self->X, $self->Y);
|
2013-09-18 23:29:34 +00:00
|
|
|
} elsif ($cmd eq 'M104' || $cmd eq 'M109') {
|
|
|
|
my $t = $args->{T} // $tool;
|
|
|
|
if ($tool_temp[$t] == 0) {
|
|
|
|
fail 'initial temperature is not equal to first layer temperature + standby delta'
|
|
|
|
unless $args->{S} == $config->first_layer_temperature->[$t] + $config->standby_temperature_delta;
|
|
|
|
}
|
|
|
|
$tool_temp[$t] = $args->{S};
|
2013-09-19 08:44:29 +00:00
|
|
|
} elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
|
2013-11-15 14:52:11 +00:00
|
|
|
push @extrusion_points, my $point = Slic3r::Point->new_scale($args->{X}, $args->{Y});
|
|
|
|
$point->translate(map scale($_), @{ $config->extruder_offset->[$tool] });
|
2013-09-18 23:29:34 +00:00
|
|
|
}
|
|
|
|
});
|
2013-09-19 08:44:29 +00:00
|
|
|
my $convex_hull = Slic3r::Polygon->new(@{convex_hull([ map $_->pp, @extrusion_points ])});
|
2013-11-21 15:21:42 +00:00
|
|
|
ok !(first { $convex_hull->contains_point($_) } @toolchange_points), 'all toolchanges happen outside skirt';
|
2013-09-18 23:29:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__END__
|