2013-12-07 13:52:59 +00:00
|
|
|
use Test::More tests => 6;
|
2013-01-27 12:06:45 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin/../lib";
|
|
|
|
}
|
|
|
|
|
2013-10-13 15:04:47 +00:00
|
|
|
use List::Util qw(first);
|
2013-01-27 12:06:45 +00:00
|
|
|
use Slic3r;
|
|
|
|
use Slic3r::Geometry qw(scale);
|
2013-09-06 17:14:06 +00:00
|
|
|
use Slic3r::Test;
|
2013-01-27 12:06:45 +00:00
|
|
|
|
|
|
|
{
|
2013-05-31 09:19:36 +00:00
|
|
|
my $gcodegen = Slic3r::GCode->new(
|
|
|
|
config => Slic3r::Config->new_from_defaults,
|
|
|
|
layer_count => 1,
|
2013-09-03 17:26:58 +00:00
|
|
|
extruders => [],
|
2013-05-31 09:19:36 +00:00
|
|
|
);
|
2013-01-27 12:06:45 +00:00
|
|
|
$gcodegen->set_shift(10, 10);
|
2013-07-15 18:31:43 +00:00
|
|
|
is_deeply $gcodegen->last_pos->arrayref, [scale -10, scale -10], 'last_pos is shifted correctly';
|
2013-01-27 12:06:45 +00:00
|
|
|
}
|
|
|
|
|
2013-09-06 17:14:06 +00:00
|
|
|
{
|
|
|
|
my $config = Slic3r::Config->new_from_defaults;
|
|
|
|
$config->set('wipe', [1]);
|
|
|
|
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
|
|
|
my $have_wipe = 0;
|
2013-10-13 15:04:47 +00:00
|
|
|
my @retract_speeds = ();
|
2013-09-06 17:14:06 +00:00
|
|
|
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
|
|
|
my ($self, $cmd, $args, $info) = @_;
|
2013-10-13 15:04:47 +00:00
|
|
|
if ($info->{retracting} && $info->{dist_XY} > 0) {
|
|
|
|
$have_wipe = 1;
|
|
|
|
my $move_time = $info->{dist_XY} / ($args->{F} // $self->F);
|
|
|
|
push @retract_speeds, abs($info->{dist_E}) / $move_time;
|
|
|
|
}
|
2013-09-06 17:14:06 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
ok $have_wipe, "wipe";
|
2013-10-13 15:04:47 +00:00
|
|
|
ok !defined (first { abs($_ - $config->retract_speed->[0]*60) < 5 } @retract_speeds), 'wipe moves don\'t retract faster than configured speed';
|
2013-09-06 17:14:06 +00:00
|
|
|
}
|
|
|
|
|
2013-11-02 13:44:30 +00:00
|
|
|
{
|
2013-12-07 13:52:59 +00:00
|
|
|
# This tests the following behavior:
|
|
|
|
# - complete objects does not crash
|
|
|
|
# - no hard-coded "E" are generated
|
|
|
|
# - Z moves are correctly generated for both objects
|
2013-11-02 13:44:30 +00:00
|
|
|
my $config = Slic3r::Config->new_from_defaults;
|
2013-12-24 00:13:02 +00:00
|
|
|
$config->set('gcode_comments', 1);
|
2013-11-02 13:44:30 +00:00
|
|
|
$config->set('complete_objects', 1);
|
2013-11-24 11:37:36 +00:00
|
|
|
$config->set('extrusion_axis', 'A');
|
2013-12-07 13:52:59 +00:00
|
|
|
$config->set('start_gcode', ''); # prevent any default extra Z move
|
|
|
|
$config->set('layer_height', 0.4);
|
|
|
|
$config->set('first_layer_height', 0.4);
|
2013-12-24 00:13:02 +00:00
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config, duplicate => 2);
|
2013-11-24 11:37:36 +00:00
|
|
|
ok my $gcode = Slic3r::Test::gcode($print), "complete_objects";
|
2013-12-07 13:52:59 +00:00
|
|
|
my @z_moves = ();
|
2013-11-24 11:37:36 +00:00
|
|
|
Slic3r::GCode::Reader->new->parse($gcode, sub {
|
|
|
|
my ($self, $cmd, $args, $info) = @_;
|
|
|
|
fail 'unexpected E argument' if defined $args->{E};
|
2013-12-07 13:52:59 +00:00
|
|
|
if (defined $args->{Z}) {
|
|
|
|
push @z_moves, $args->{Z};
|
|
|
|
}
|
2013-11-24 11:37:36 +00:00
|
|
|
});
|
2013-12-07 13:52:59 +00:00
|
|
|
my $layer_count = 20/0.4; # cube is 20mm tall
|
|
|
|
is scalar(@z_moves), 2*$layer_count, 'complete_objects generates the correct number of Z moves';
|
|
|
|
is_deeply [ @z_moves[0..($layer_count-1)] ], [ @z_moves[$layer_count..$#z_moves] ], 'complete_objects generates the correct Z moves';
|
2013-11-02 13:44:30 +00:00
|
|
|
}
|
|
|
|
|
2013-01-27 12:06:45 +00:00
|
|
|
__END__
|