2015-01-18 12:01:00 +00:00
|
|
|
|
use Test::More tests => 6;
|
2013-05-30 18:06:05 +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-05-30 18:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
use List::Util qw(first);
|
|
|
|
|
use Slic3r;
|
2014-08-07 23:37:39 +00:00
|
|
|
|
use Slic3r::Geometry qw(unscale convex_hull);
|
2013-05-30 18:06:05 +00:00
|
|
|
|
use Slic3r::Test;
|
|
|
|
|
|
|
|
|
|
{
|
2017-10-27 16:52:35 +00:00
|
|
|
|
my $config = Slic3r::Config::new_from_defaults;
|
2013-05-30 18:06:05 +00:00
|
|
|
|
$config->set('skirts', 1);
|
|
|
|
|
$config->set('skirt_height', 2);
|
|
|
|
|
$config->set('perimeters', 0);
|
2014-05-18 15:02:18 +00:00
|
|
|
|
$config->set('support_material_speed', 99);
|
2017-06-21 14:15:39 +00:00
|
|
|
|
$config->set('cooling', [ 0 ]); # to prevent speeds to be altered
|
2013-05-30 18:06:05 +00:00
|
|
|
|
$config->set('first_layer_speed', '100%'); # to prevent speeds to be altered
|
|
|
|
|
|
|
|
|
|
my $test = sub {
|
|
|
|
|
my ($conf) = @_;
|
|
|
|
|
$conf ||= $config;
|
|
|
|
|
|
|
|
|
|
my $print = Slic3r::Test::init_print(['20mm_cube','20mm_cube'], config => $config);
|
|
|
|
|
|
|
|
|
|
my %layers_with_skirt = (); # Z => $count
|
2013-08-28 14:51:58 +00:00
|
|
|
|
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
2013-05-30 18:06:05 +00:00
|
|
|
|
my ($self, $cmd, $args, $info) = @_;
|
|
|
|
|
|
|
|
|
|
if (defined $self->Z) {
|
|
|
|
|
$layers_with_skirt{$self->Z} //= 0;
|
|
|
|
|
$layers_with_skirt{$self->Z} = 1
|
2014-05-18 15:02:18 +00:00
|
|
|
|
if $info->{extruding} && ($args->{F} // $self->F) == $config->support_material_speed*60;
|
2013-05-30 18:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
fail "wrong number of layers with skirt"
|
|
|
|
|
unless (grep $_, values %layers_with_skirt) == $config->skirt_height;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ok $test->(), "skirt_height is honored when printing multiple objects too";
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-16 08:33:30 +00:00
|
|
|
|
{
|
2017-10-27 16:52:35 +00:00
|
|
|
|
my $config = Slic3r::Config::new_from_defaults;
|
2013-09-16 08:33:30 +00:00
|
|
|
|
$config->set('skirts', 0);
|
|
|
|
|
$config->set('perimeters', 0);
|
|
|
|
|
$config->set('top_solid_layers', 0); # to prevent solid shells and their speeds
|
|
|
|
|
$config->set('bottom_solid_layers', 0); # to prevent solid shells and their speeds
|
|
|
|
|
$config->set('brim_width', 5);
|
2014-05-18 15:02:18 +00:00
|
|
|
|
$config->set('support_material_speed', 99);
|
2017-06-21 14:15:39 +00:00
|
|
|
|
$config->set('cooling', [ 0 ]); # to prevent speeds to be altered
|
2013-09-16 08:33:30 +00:00
|
|
|
|
$config->set('first_layer_speed', '100%'); # to prevent speeds to be altered
|
|
|
|
|
|
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
|
|
|
|
|
|
|
|
|
my %layers_with_brim = (); # Z => $count
|
|
|
|
|
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
|
|
|
|
my ($self, $cmd, $args, $info) = @_;
|
|
|
|
|
|
|
|
|
|
if (defined $self->Z) {
|
|
|
|
|
$layers_with_brim{$self->Z} //= 0;
|
|
|
|
|
$layers_with_brim{$self->Z} = 1
|
|
|
|
|
if $info->{extruding} && $info->{dist_XY} > 0 && ($args->{F} // $self->F) != $config->infill_speed*60;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
is scalar(grep $_, values %layers_with_brim), 1, "brim is generated";
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 11:38:41 +00:00
|
|
|
|
{
|
2017-10-27 16:52:35 +00:00
|
|
|
|
my $config = Slic3r::Config::new_from_defaults;
|
2014-05-27 11:38:41 +00:00
|
|
|
|
$config->set('skirts', 1);
|
|
|
|
|
$config->set('brim_width', 10);
|
|
|
|
|
|
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
|
|
|
|
ok Slic3r::Test::gcode($print), 'successful G-code generation when skirt is smaller than brim width';
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-18 12:01:00 +00:00
|
|
|
|
{
|
2017-10-27 16:52:35 +00:00
|
|
|
|
my $config = Slic3r::Config::new_from_defaults;
|
2015-01-18 12:01:00 +00:00
|
|
|
|
$config->set('skirts', 1);
|
|
|
|
|
$config->set('skirt_height', 0);
|
|
|
|
|
|
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
|
|
|
|
ok Slic3r::Test::gcode($print), 'successful G-code generation when skirt_height = 0 and skirts > 0';
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-07 23:37:39 +00:00
|
|
|
|
{
|
2017-10-27 16:52:35 +00:00
|
|
|
|
my $config = Slic3r::Config::new_from_defaults;
|
2019-06-20 18:23:05 +00:00
|
|
|
|
# Define 4 extruders.
|
|
|
|
|
$config->set('nozzle_diameter', [0.4, 0.4, 0.4, 0.4]);
|
2014-08-07 23:37:39 +00:00
|
|
|
|
$config->set('layer_height', 0.4);
|
|
|
|
|
$config->set('first_layer_height', 0.4);
|
|
|
|
|
$config->set('skirts', 1);
|
|
|
|
|
$config->set('skirt_distance', 0);
|
|
|
|
|
$config->set('support_material_speed', 99);
|
|
|
|
|
$config->set('perimeter_extruder', 1);
|
|
|
|
|
$config->set('support_material_extruder', 2);
|
2017-06-21 14:15:39 +00:00
|
|
|
|
$config->set('cooling', [ 0 ]); # to prevent speeds to be altered
|
2014-08-07 23:37:39 +00:00
|
|
|
|
$config->set('first_layer_speed', '100%'); # to prevent speeds to be altered
|
|
|
|
|
|
|
|
|
|
my $print = Slic3r::Test::init_print('overhang', config => $config);
|
|
|
|
|
$print->process;
|
|
|
|
|
|
|
|
|
|
# we enable support material after skirt has been generated
|
|
|
|
|
$config->set('support_material', 1);
|
2019-06-20 18:23:05 +00:00
|
|
|
|
$print->apply($print->print->model->clone, $config);
|
2014-08-07 23:37:39 +00:00
|
|
|
|
|
|
|
|
|
my $skirt_length = 0;
|
|
|
|
|
my @extrusion_points = ();
|
|
|
|
|
my $tool = undef;
|
|
|
|
|
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
|
|
|
|
my ($self, $cmd, $args, $info) = @_;
|
|
|
|
|
|
|
|
|
|
if ($cmd =~ /^T(\d+)/) {
|
|
|
|
|
$tool = $1;
|
|
|
|
|
} elsif (defined $self->Z && $self->Z == $config->first_layer_height) {
|
|
|
|
|
# we're on first layer
|
|
|
|
|
if ($info->{extruding} && $info->{dist_XY} > 0) {
|
|
|
|
|
my $speed = ($args->{F} // $self->F) / 60;
|
|
|
|
|
if ($speed == $config->support_material_speed && $tool == $config->perimeter_extruder-1) {
|
|
|
|
|
# skirt uses support material speed but first object's extruder
|
|
|
|
|
$skirt_length += $info->{dist_XY};
|
|
|
|
|
} else {
|
|
|
|
|
push @extrusion_points, my $point = Slic3r::Point->new_scale($args->{X}, $args->{Y});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
my $convex_hull = convex_hull(\@extrusion_points);
|
|
|
|
|
my $hull_perimeter = unscale($convex_hull->split_at_first_point->length);
|
|
|
|
|
ok $skirt_length > $hull_perimeter, 'skirt lenght is large enough to contain object with support';
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-06 20:11:59 +00:00
|
|
|
|
{
|
2017-10-27 16:52:35 +00:00
|
|
|
|
my $config = Slic3r::Config::new_from_defaults;
|
2014-11-06 20:11:59 +00:00
|
|
|
|
$config->set('min_skirt_length', 20);
|
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
|
|
|
|
ok Slic3r::Test::gcode($print), 'no crash when using min_skirt_length';
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-30 18:06:05 +00:00
|
|
|
|
__END__
|