Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2014-12-08 22:14:04 +0300
committerAlessandro Ranellucci <aar@cpan.org>2014-12-08 22:14:04 +0300
commit9a9ba02d85dbd735998fac95dba66365d4df9ef8 (patch)
tree4ceae5adcf844110d8dd31b75b486d03cc3063cc /t/combineinfill.t
parentf7026c41c5587717a6978501d8a3e645629d4358 (diff)
Bugfix: infill was not correctly generated when infill_every_layers was used along with raft_layers. Includes regression test. #2396
Diffstat (limited to 't/combineinfill.t')
-rw-r--r--t/combineinfill.t67
1 files changed, 47 insertions, 20 deletions
diff --git a/t/combineinfill.t b/t/combineinfill.t
index 62e22e6b2..5b51899ee 100644
--- a/t/combineinfill.t
+++ b/t/combineinfill.t
@@ -11,37 +11,64 @@ use List::Util qw(first);
use Slic3r;
use Slic3r::Test;
-plan tests => 2;
+plan tests => 6;
{
+ my $test = sub {
+ my ($config) = @_;
+
+ my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
+ ok my $gcode = Slic3r::Test::gcode($print), "infill_every_layers does not crash";
+
+ my $tool = undef;
+ my %layers = (); # layer_z => 1
+ my %layer_infill = (); # layer_z => has_infill
+ Slic3r::GCode::Reader->new->parse($gcode, sub {
+ my ($self, $cmd, $args, $info) = @_;
+
+ if ($cmd =~ /^T(\d+)/) {
+ $tool = $1;
+ } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0 && $tool != $config->support_material_extruder-1) {
+ $layer_infill{$self->Z} //= 0;
+ if ($tool == $config->infill_extruder-1) {
+ $layer_infill{$self->Z} = 1;
+ }
+ }
+ $layers{$args->{Z}} = 1 if $cmd eq 'G1' && $info->{dist_Z} > 0;
+ });
+
+ my $layers_with_perimeters = scalar(keys %layer_infill);
+ my $layers_with_infill = grep $_ > 0, values %layer_infill;
+ is scalar(keys %layers), $layers_with_perimeters+$config->raft_layers, 'expected number of layers';
+
+ # first infill layer is never combined, so we don't consider it
+ $layers_with_infill--;
+ $layers_with_perimeters--;
+
+ # we expect that infill is generated for half the number of combined layers
+ # plus for each single layer that was not combined (remainder)
+ is $layers_with_infill,
+ int($layers_with_perimeters/$config->infill_every_layers) + ($layers_with_perimeters % $config->infill_every_layers),
+ 'infill is only present in correct number of layers';
+ };
+
my $config = Slic3r::Config->new_from_defaults;
+ $config->set('gcode_comments', 1);
$config->set('layer_height', 0.2);
$config->set('first_layer_height', 0.2);
$config->set('nozzle_diameter', [0.5]);
$config->set('infill_every_layers', 2);
+ $config->set('perimeter_extruder', 1);
$config->set('infill_extruder', 2);
+ $config->set('support_material_extruder', 3);
+ $config->set('support_material_interface_extruder', 3);
$config->set('top_solid_layers', 0);
$config->set('bottom_solid_layers', 0);
- my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
- ok my $gcode = Slic3r::Test::gcode($print), "infill_every_layers does not crash";
+ $test->($config);
- my $tool = undef;
- my %layer_infill = (); # layer_z => has_infill
- Slic3r::GCode::Reader->new->parse($gcode, sub {
- my ($self, $cmd, $args, $info) = @_;
-
- if ($cmd =~ /^T(\d+)/) {
- $tool = $1;
- } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
- $layer_infill{$self->Z} //= 0;
- if ($tool == $config->infill_extruder-1) {
- $layer_infill{$self->Z} = 1;
- }
- }
- });
- my $layers_with_infill = grep $_, values %layer_infill;
- $layers_with_infill--; # first layer is never combined
- is $layers_with_infill, scalar(keys %layer_infill)/2, 'infill is only present in correct number of layers';
+ $config->set('skirts', 0); # prevent usage of perimeter_extruder in raft layers
+ $config->set('raft_layers', 5);
+ $test->($config);
}
# the following needs to be adapted to the new API