Merge branch 'test-dual-retraction'

This commit is contained in:
Alessandro Ranellucci 2012-12-21 15:23:07 +01:00
commit 8cd8e8b209
4 changed files with 63 additions and 21 deletions

View file

@ -14,6 +14,7 @@ has 'id' => (is => 'rw', required => 1);
has $_ => (is => 'ro', required => 1) for @{&OPTIONS};
has 'retracted' => (is => 'rw', default => sub {0} );
has 'restart_extra' => (is => 'rw', default => sub {0} );
has 'e_per_mm3' => (is => 'lazy');
has 'retract_speed_mm_min' => (is => 'lazy');
has '_mm3_per_mm_cache' => (is => 'ro', default => sub {{}});

View file

@ -184,7 +184,7 @@ sub extrude_path {
if !points_coincide($self->last_pos, $path->points->[0]);
# compensate retraction
$gcode .= $self->unretract if $self->extruder->retracted;
$gcode .= $self->unretract;
my $area; # mm^3 of extrudate per mm of tool movement
if ($path->role == EXTR_ROLE_BRIDGE) {
@ -279,7 +279,8 @@ sub retract {
$gcode .= $self->G1(@$lift);
}
}
$self->extruder->retracted($self->extruder->retracted + $length + $restart_extra);
$self->extruder->retracted($self->extruder->retracted + $length);
$self->extruder->restart_extra($restart_extra);
$self->lifted($self->extruder->retract_lift) if $lift;
# reset extrusion distance during retracts
@ -300,9 +301,13 @@ sub unretract {
$self->lifted(0);
}
$self->speed('retract');
$gcode .= $self->G0(undef, undef, $self->extruder->retracted, "compensate retraction");
$self->extruder->retracted(0);
my $to_unretract = $self->extruder->retracted + $self->extruder->restart_extra;
if ($to_unretract) {
$self->speed('retract');
$gcode .= $self->G0(undef, undef, $to_unretract, "compensate retraction");
$self->extruder->retracted(0);
$self->extruder->restart_extra(0);
}
return $gcode;
}

View file

@ -2,6 +2,10 @@ package Slic3r::Test;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(_eq);
use IO::Scalar;
use Slic3r::Geometry qw(epsilon);
@ -30,6 +34,7 @@ sub init_print {
my $config = Slic3r::Config->new_from_defaults;
$config->apply($params{config}) if $params{config};
$config->set('gcode_comments', 1) if $ENV{SLIC3R_TESTS_GCODE};
my $print = Slic3r::Print->new(config => $config);
$print->add_model($model);
@ -48,7 +53,7 @@ sub gcode {
return $gcode;
}
sub compare {
sub _eq {
my ($a, $b) = @_;
return abs($a - $b) < epsilon;
}