Bugfix: pressure regulation accumulated too much retraction and didn't discharge at the end of print. Includes regression test. #2470

This commit is contained in:
Alessandro Ranellucci 2015-01-06 00:35:39 +01:00
parent 9fd0637990
commit 0f7933c4f9
3 changed files with 38 additions and 27 deletions

View file

@ -9,7 +9,7 @@ BEGIN {
use List::Util qw();
use Slic3r;
use Slic3r::Geometry qw();
use Slic3r::Geometry qw(epsilon);
use Slic3r::Test;
{
@ -18,21 +18,18 @@ use Slic3r::Test;
$config->set('retract_length', [1]);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config, duplicate => 2);
my $retracted = 0;
my $extruding_before_full_unretract = 0;
my $retracted = $config->retract_length->[0];
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
my ($self, $cmd, $args, $info) = @_;
if ($info->{extruding} && $info->{dist_XY}) {
$extruding_before_full_unretract if $retracted != 0;
} elsif ($info->{extruding}) {
$retracted += -$info->{dist_E};
if ($info->{extruding} && !$info->{dist_XY}) {
$retracted += $info->{dist_E};
} elsif ($info->{retracting}) {
$retracted += -$info->{dist_E};
$retracted += $info->{dist_E};
}
});
ok !$extruding_before_full_unretract, 'not extruding before complete unretract';
ok abs($retracted) < epsilon, 'all retractions are compensated';
}