Bugfix: percent first layer speed was not applied over autospeed. #2945

This commit is contained in:
Alessandro Ranellucci 2017-03-04 14:23:03 +01:00
parent f25ea9f493
commit 4e586b8eda
2 changed files with 56 additions and 3 deletions

53
t/speed.t Normal file
View File

@ -0,0 +1,53 @@
use Test::More tests => 2;
use strict;
use warnings;
BEGIN {
use FindBin;
use lib "$FindBin::Bin/../lib";
use local::lib "$FindBin::Bin/../local-lib";
}
use List::Util qw(none);
use Slic3r;
use Slic3r::Geometry qw(epsilon);
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
my $test = sub {
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
my %speeds_by_z = (); # z => []
Slic3r::GCode::Reader->new->parse(my $gcode = Slic3r::Test::gcode($print), sub {
my ($self, $cmd, $args, $info) = @_;
if ($cmd eq 'G1' && $info->{dist_E} > 0 && $info->{dist_XY} > 0) {
$speeds_by_z{$self->Z} //= [];
push @{ $speeds_by_z{$self->Z} }, $self->F/60;
}
});
return %speeds_by_z;
};
{
$config->set('perimeter_speed', 0);
$config->set('external_perimeter_speed', 0);
$config->set('infill_speed', 0);
$config->set('support_material_speed', 0);
$config->set('solid_infill_speed', 0);
$config->set('first_layer_speed', '50%');
$config->set('first_layer_height', 0.25);
my %speeds_by_z = $test->();
ok !!(none { $_ > $config->max_print_speed/2+&epsilon } @{ $speeds_by_z{$config->first_layer_height} }),
'percent first_layer_speed is applied over autospeed';
}
{
$config->set('first_layer_speed', 33);
my %speeds_by_z = $test->();
ok !!(none { $_ > $config->first_layer_speed } @{ $speeds_by_z{$config->first_layer_height} }),
'absolute first_layer_speed overrides autospeed';
}
}
__END__

View File

@ -551,12 +551,12 @@ GCode::_extrude(ExtrusionPath path, std::string description, double speed)
CONFESS("Invalid speed");
}
}
if (this->first_layer) {
speed = this->config.get_abs_value("first_layer_speed", speed);
}
if (this->volumetric_speed != 0 && speed == 0) {
speed = this->volumetric_speed / path.mm3_per_mm;
}
if (this->first_layer) {
speed = this->config.get_abs_value("first_layer_speed", speed);
}
if (this->config.max_volumetric_speed.value > 0) {
// cap speed with max_volumetric_speed anyway (even if user is not using autospeed)
speed = std::min(