2013-07-29 18:49:54 +00:00
|
|
|
use Test::More tests => 13;
|
2013-03-29 23:21:09 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin/../lib";
|
|
|
|
}
|
|
|
|
|
2013-07-29 18:49:54 +00:00
|
|
|
use List::Util qw(first);
|
2013-03-29 23:21:09 +00:00
|
|
|
use Slic3r;
|
2013-07-29 18:49:54 +00:00
|
|
|
use Slic3r::Geometry qw(epsilon);
|
2013-03-29 23:21:09 +00:00
|
|
|
use Slic3r::Test;
|
|
|
|
|
2013-07-29 18:49:54 +00:00
|
|
|
{
|
|
|
|
my $config = Slic3r::Config->new_from_defaults;
|
2013-09-17 21:32:01 +00:00
|
|
|
$config->set('support_material', 1);
|
2013-07-29 18:49:54 +00:00
|
|
|
my @contact_z = my @top_z = ();
|
|
|
|
|
|
|
|
my $test = sub {
|
2013-09-17 21:32:01 +00:00
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
|
|
|
$print->init_extruders;
|
|
|
|
my $flow = $print->support_material_flow;
|
2013-10-26 15:56:59 +00:00
|
|
|
my $support_z = Slic3r::Print::SupportMaterial
|
|
|
|
->new(config => $config, flow => $flow)
|
|
|
|
->support_layers_z(\@contact_z, \@top_z, $config->layer_height);
|
2013-07-29 18:49:54 +00:00
|
|
|
|
2013-10-26 15:56:59 +00:00
|
|
|
is $support_z->[0], $config->first_layer_height,
|
2013-07-29 18:49:54 +00:00
|
|
|
'first layer height is honored';
|
2013-10-26 15:56:59 +00:00
|
|
|
is scalar(grep { $support_z->[$_]-$support_z->[$_-1] <= 0 } 1..$#$support_z), 0,
|
2013-07-29 18:49:54 +00:00
|
|
|
'no null or negative support layers';
|
2013-10-26 15:56:59 +00:00
|
|
|
is scalar(grep { $support_z->[$_]-$support_z->[$_-1] > $flow->nozzle_diameter + epsilon } 1..$#$support_z), 0,
|
2013-07-29 18:49:54 +00:00
|
|
|
'no layers thicker than nozzle diameter';
|
|
|
|
|
|
|
|
my $wrong_top_spacing = 0;
|
|
|
|
foreach my $top_z (@top_z) {
|
|
|
|
# find layer index of this top surface
|
2013-10-26 15:56:59 +00:00
|
|
|
my $layer_id = first { abs($support_z->[$_] - $top_z) < epsilon } 0..$#$support_z;
|
2013-07-29 18:49:54 +00:00
|
|
|
|
|
|
|
# check that first support layer above this top surface is spaced with nozzle diameter
|
|
|
|
$wrong_top_spacing = 1
|
2013-10-26 15:56:59 +00:00
|
|
|
if ($support_z->[$layer_id+1] - $support_z->[$layer_id]) != $flow->nozzle_diameter;
|
2013-07-29 18:49:54 +00:00
|
|
|
}
|
|
|
|
ok !$wrong_top_spacing, 'layers above top surfaces are spaced correctly';
|
|
|
|
};
|
|
|
|
|
|
|
|
$config->set('layer_height', 0.2);
|
|
|
|
$config->set('first_layer_height', 0.3);
|
|
|
|
@contact_z = (1.9);
|
|
|
|
@top_z = (1.1);
|
|
|
|
$test->();
|
|
|
|
|
|
|
|
$config->set('first_layer_height', 0.4);
|
|
|
|
$test->();
|
|
|
|
|
|
|
|
$config->set('layer_height', $config->nozzle_diameter->[0]);
|
|
|
|
$test->();
|
|
|
|
}
|
|
|
|
|
2013-03-29 23:21:09 +00:00
|
|
|
{
|
|
|
|
my $config = Slic3r::Config->new_from_defaults;
|
|
|
|
$config->set('raft_layers', 3);
|
|
|
|
$config->set('brim_width', 6);
|
2013-06-07 11:38:29 +00:00
|
|
|
$config->set('skirts', 0);
|
|
|
|
$config->set('support_material_extruder', 2);
|
2013-07-29 18:49:54 +00:00
|
|
|
$config->set('support_material_interface_extruder', 2);
|
2013-06-07 11:38:29 +00:00
|
|
|
$config->set('layer_height', 0.4);
|
|
|
|
$config->set('first_layer_height', '100%');
|
2013-09-17 21:51:30 +00:00
|
|
|
my $print = Slic3r::Test::init_print('overhang', config => $config);
|
2013-06-07 11:38:29 +00:00
|
|
|
ok my $gcode = Slic3r::Test::gcode($print), 'no conflict between raft/support and brim';
|
|
|
|
|
|
|
|
my $tool = 0;
|
2013-08-28 14:51:58 +00:00
|
|
|
Slic3r::GCode::Reader->new->parse($gcode, sub {
|
2013-06-07 11:38:29 +00:00
|
|
|
my ($self, $cmd, $args, $info) = @_;
|
|
|
|
|
|
|
|
if ($cmd =~ /^T(\d+)/) {
|
|
|
|
$tool = $1;
|
2013-09-17 21:51:30 +00:00
|
|
|
} elsif ($info->{extruding}) {
|
|
|
|
if ($self->Z <= ($config->raft_layers * $config->layer_height)) {
|
|
|
|
fail 'not extruding raft/brim with support material extruder'
|
|
|
|
if $tool != ($config->support_material_extruder-1);
|
|
|
|
} else {
|
|
|
|
fail 'support material exceeds raft layers'
|
|
|
|
if $tool == $config->support_material_extruder-1;
|
|
|
|
# TODO: we should test that full support is generated when we use raft too
|
|
|
|
}
|
2013-06-07 11:38:29 +00:00
|
|
|
}
|
|
|
|
});
|
2013-03-29 23:21:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__END__
|