2013-12-18 15:34:31 +00:00
|
|
|
use Test::More;
|
2013-02-16 14:12:18 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin/../lib";
|
2017-08-18 07:58:50 +00:00
|
|
|
use local::lib "$FindBin::Bin/../local-lib";
|
2013-02-16 14:12:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
use List::Util qw(first);
|
|
|
|
use Slic3r;
|
2014-12-08 20:23:42 +00:00
|
|
|
use Slic3r::Surface ':types';
|
2013-02-16 14:12:18 +00:00
|
|
|
use Slic3r::Test;
|
|
|
|
|
2014-12-08 20:23:42 +00:00
|
|
|
plan tests => 8;
|
2013-12-18 15:34:31 +00:00
|
|
|
|
2013-02-16 14:12:18 +00:00
|
|
|
{
|
2014-12-08 19:14:04 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2021-09-09 10:01:31 +00:00
|
|
|
# Previously, all G-code commands had a fixed number of decimal points with means with redundant zeros after decimal points.
|
|
|
|
# We changed this behavior and got rid of these redundant padding zeros, which caused this test to fail
|
|
|
|
# because the position in Z-axis is compared as a string, and previously, G-code contained the following two commands:
|
|
|
|
# "G1 Z5 F5000 ; lift nozzle"
|
|
|
|
# "G1 Z5.000 F7800.000"
|
|
|
|
# That has a different Z-axis position from the view of string comparisons of floating-point numbers.
|
|
|
|
# To correct the computation of the number of printed layers, even in the case of string comparisons of floating-point numbers,
|
|
|
|
# we filtered out the G-code command with the commend 'lift nozzle'.
|
|
|
|
$layers{$args->{Z}} = 1 if $cmd eq 'G1' && $info->{dist_Z} && index($info->{comment}, 'lift nozzle') == -1;
|
2014-12-08 19:14:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
2021-02-24 17:48:55 +00:00
|
|
|
if ($config->raft_layers == 0) {
|
|
|
|
# first infill layer printed directly on print bed is not combined, so we don't consider it.
|
|
|
|
$layers_with_infill--;
|
|
|
|
$layers_with_perimeters--;
|
|
|
|
}
|
2014-12-08 19:14:04 +00:00
|
|
|
|
|
|
|
# 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';
|
|
|
|
};
|
|
|
|
|
2017-10-27 16:52:35 +00:00
|
|
|
my $config = Slic3r::Config::new_from_defaults;
|
2014-01-04 23:36:33 +00:00
|
|
|
$config->set('layer_height', 0.2);
|
|
|
|
$config->set('first_layer_height', 0.2);
|
2018-03-28 08:16:04 +00:00
|
|
|
$config->set('nozzle_diameter', [0.5,0.5,0.5,0.5]);
|
2014-01-04 23:36:33 +00:00
|
|
|
$config->set('infill_every_layers', 2);
|
2014-12-08 19:14:04 +00:00
|
|
|
$config->set('perimeter_extruder', 1);
|
2014-01-04 23:36:33 +00:00
|
|
|
$config->set('infill_extruder', 2);
|
2018-06-27 13:07:37 +00:00
|
|
|
$config->set('wipe_into_infill', 0);
|
2014-12-08 19:14:04 +00:00
|
|
|
$config->set('support_material_extruder', 3);
|
|
|
|
$config->set('support_material_interface_extruder', 3);
|
2014-01-04 23:36:33 +00:00
|
|
|
$config->set('top_solid_layers', 0);
|
|
|
|
$config->set('bottom_solid_layers', 0);
|
2014-12-08 19:14:04 +00:00
|
|
|
$test->($config);
|
2014-01-04 23:36:33 +00:00
|
|
|
|
2014-12-08 19:14:04 +00:00
|
|
|
$config->set('skirts', 0); # prevent usage of perimeter_extruder in raft layers
|
|
|
|
$config->set('raft_layers', 5);
|
|
|
|
$test->($config);
|
2014-01-04 23:36:33 +00:00
|
|
|
}
|
|
|
|
|
2014-12-08 20:23:42 +00:00
|
|
|
{
|
2017-10-27 16:52:35 +00:00
|
|
|
my $config = Slic3r::Config::new_from_defaults;
|
2014-12-08 20:23:42 +00:00
|
|
|
$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);
|
|
|
|
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
|
|
|
$print->process;
|
|
|
|
|
|
|
|
ok defined(first { @{$_->get_region(0)->fill_surfaces->filter_by_type(S_TYPE_INTERNALVOID)} > 0 }
|
|
|
|
@{$print->print->get_object(0)->layers}),
|
|
|
|
'infill combination produces internal void surfaces';
|
|
|
|
|
|
|
|
# we disable combination after infill has been generated
|
|
|
|
$config->set('infill_every_layers', 1);
|
2019-06-20 18:23:05 +00:00
|
|
|
$print->apply($print->print->model->clone, $config);
|
2014-12-08 20:23:42 +00:00
|
|
|
$print->process;
|
|
|
|
|
|
|
|
ok !(defined first { @{$_->get_region(0)->fill_surfaces} == 0 }
|
|
|
|
@{$print->print->get_object(0)->layers}),
|
|
|
|
'infill combination is idempotent';
|
|
|
|
}
|
|
|
|
|
2013-02-16 14:12:18 +00:00
|
|
|
__END__
|