Skip to content

Commit

Permalink
Bugfix: percent first layer speed was not applied over autospeed. #2945
Browse files Browse the repository at this point in the history
  • Loading branch information
alranel committed Mar 4, 2017
1 parent f25ea9f commit 4e586b8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
53 changes: 53 additions & 0 deletions t/speed.t
Original file line number Diff line number Diff line change
@@ -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__
6 changes: 3 additions & 3 deletions xs/src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4e586b8

Please sign in to comment.