Fixed regression causing skirt_height to he honored incorrectly when printing more than one object. Includes regression test #1200

This commit is contained in:
Alessandro Ranellucci 2013-05-30 20:06:05 +02:00
parent 8f5a958948
commit 7baaf6bf5d
5 changed files with 56 additions and 7 deletions

View File

@ -78,6 +78,7 @@ t/retraction.t
t/serialize.t
t/shells.t
t/slice.t
t/skirt_brim.t
t/support.t
t/vibrationlimit.t
utils/amf-to-stl.pl

View File

@ -9,7 +9,7 @@ has 'gcodegen' => (is => 'ro', required => 1);
has 'shift' => (is => 'ro', required => 1);
has 'spiralvase' => (is => 'lazy');
has 'skirt_done' => (is => 'rw', default => sub {0}); # count of skirt layers done
has 'skirt_done' => (is => 'rw', default => sub { {} }); # print_z => 1
has 'brim_done' => (is => 'rw');
has 'second_layer_things_done' => (is => 'rw');
has '_last_obj_copy' => (is => 'rw');
@ -48,10 +48,10 @@ sub process_layer {
});
# extrude skirt
if ($self->skirt_done < $Slic3r::Config->skirt_height) {
if ((values %{$self->skirt_done}) < $Slic3r::Config->skirt_height && !$self->skirt_done->{$layer->print_z}) {
$self->gcodegen->set_shift(@{$self->shift});
$gcode .= $self->gcodegen->set_extruder($self->extruders->[0]); # move_z requires extruder
$gcode .= $self->gcodegen->move_z($self->gcodegen->layer->print_z);
$gcode .= $self->gcodegen->move_z($layer->print_z);
# skip skirt if we have a large brim
if ($layer->id < $Slic3r::Config->skirt_height) {
# distribute skirt loops across all extruders
@ -64,14 +64,14 @@ sub process_layer {
$gcode .= $self->gcodegen->extrude_loop($self->print->skirt->[$i], 'skirt');
}
}
$self->skirt_done($self->skirt_done + 1);
$self->skirt_done->{$layer->print_z} = 1;
$self->gcodegen->straight_once(1);
}
# extrude brim
if (!$self->brim_done) {
$gcode .= $self->gcodegen->set_extruder($self->extruders->[$Slic3r::Config->support_material_extruder-1]); # move_z requires extruder
$gcode .= $self->gcodegen->move_z($self->gcodegen->layer->print_z);
$gcode .= $self->gcodegen->move_z($layer->print_z);
$self->gcodegen->set_shift(@{$self->shift});
$gcode .= $self->gcodegen->extrude_loop($_, 'brim') for @{$self->print->brim};
$self->brim_done(1);

View File

@ -26,7 +26,7 @@ sub parse {
my ($command, @args) = split /\s+/, $line;
my %args = map { /([A-Z])(.*)/; ($1 => $2) } @args;
# check retraction
# check motion
if ($command =~ /^G[01]$/) {
foreach my $axis (@AXES) {
if (exists $args{$axis}) {

View File

@ -44,7 +44,9 @@ sub init_print {
$config->set('gcode_comments', 1) if $ENV{SLIC3R_TESTS_GCODE};
my $print = Slic3r::Print->new(config => $config);
$print->add_model(model($model_name));
$model_name = [$model_name] if ref($model_name) ne 'ARRAY';
$print->add_model(model($_)) for @$model_name;
$print->validate;
return $print;

46
t/skirt_brim.t Normal file
View File

@ -0,0 +1,46 @@
use Test::More tests => 1;
use strict;
use warnings;
BEGIN {
use FindBin;
use lib "$FindBin::Bin/../lib";
}
use List::Util qw(first);
use Slic3r;
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
$config->set('skirts', 1);
$config->set('skirt_height', 2);
$config->set('perimeters', 0);
$config->set('perimeter_speed', 99);
$config->set('cooling', 0); # to prevent speeds to be altered
$config->set('first_layer_speed', '100%'); # to prevent speeds to be altered
my $test = sub {
my ($conf) = @_;
$conf ||= $config;
my $print = Slic3r::Test::init_print(['20mm_cube','20mm_cube'], config => $config);
my %layers_with_skirt = (); # Z => $count
Slic3r::GCode::Reader->new(gcode => Slic3r::Test::gcode($print))->parse(sub {
my ($self, $cmd, $args, $info) = @_;
if (defined $self->Z) {
$layers_with_skirt{$self->Z} //= 0;
$layers_with_skirt{$self->Z} = 1
if $info->{extruding} && ($args->{F} // $self->F) == $config->perimeter_speed*60;
}
});
fail "wrong number of layers with skirt"
unless (grep $_, values %layers_with_skirt) == $config->skirt_height;
};
ok $test->(), "skirt_height is honored when printing multiple objects too";
}
__END__