2012-02-15 11:04:10 +00:00
|
|
|
use Test::More;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2013-06-14 14:48:24 +00:00
|
|
|
plan tests => 10;
|
2012-02-15 11:04:10 +00:00
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin/../lib";
|
|
|
|
}
|
|
|
|
|
|
|
|
use Slic3r;
|
2012-08-25 12:59:34 +00:00
|
|
|
use Slic3r::Geometry qw(scale X Y);
|
|
|
|
use Slic3r::Surface qw(:types);
|
2012-12-31 14:05:32 +00:00
|
|
|
use Slic3r::Test;
|
2012-02-15 11:04:10 +00:00
|
|
|
|
2012-08-25 12:59:34 +00:00
|
|
|
sub scale_points (@) { map [scale $_->[X], scale $_->[Y]], @_ }
|
2012-02-15 11:04:10 +00:00
|
|
|
|
|
|
|
{
|
2012-09-23 12:51:03 +00:00
|
|
|
my $print = Slic3r::Print->new;
|
|
|
|
$print->init_extruders;
|
2013-04-25 10:01:40 +00:00
|
|
|
my $filler = Slic3r::Fill::Rectilinear->new(
|
|
|
|
print => $print,
|
2013-06-16 10:21:25 +00:00
|
|
|
bounding_box => Slic3r::Geometry::BoundingBox->new_from_points([ [0, 0], [10, 10] ]),
|
2013-04-25 10:01:40 +00:00
|
|
|
);
|
2012-02-15 11:04:10 +00:00
|
|
|
my $surface_width = 250;
|
|
|
|
my $distance = $filler->adjust_solid_spacing(
|
|
|
|
width => $surface_width,
|
|
|
|
distance => 100,
|
|
|
|
);
|
|
|
|
is $distance, 125, 'adjusted solid distance';
|
|
|
|
is $surface_width % $distance, 0, 'adjusted solid distance';
|
|
|
|
}
|
|
|
|
|
2012-08-25 12:59:34 +00:00
|
|
|
{
|
2013-07-16 07:49:34 +00:00
|
|
|
my $expolygon = Slic3r::ExPolygon->new([ scale_points [0,0], [50,0], [50,50], [0,50] ]);
|
2013-04-25 10:01:40 +00:00
|
|
|
my $filler = Slic3r::Fill::Rectilinear->new(
|
2013-06-16 10:21:25 +00:00
|
|
|
bounding_box => $expolygon->bounding_box,
|
2013-04-25 10:01:40 +00:00
|
|
|
);
|
2012-08-25 12:59:34 +00:00
|
|
|
my $surface = Slic3r::Surface->new(
|
|
|
|
surface_type => S_TYPE_TOP,
|
2013-04-25 10:01:40 +00:00
|
|
|
expolygon => $expolygon,
|
2012-08-25 12:59:34 +00:00
|
|
|
);
|
|
|
|
foreach my $angle (0, 45) {
|
2012-09-12 14:30:44 +00:00
|
|
|
$surface->expolygon->rotate(Slic3r::Geometry::deg2rad($angle), [0,0]);
|
2012-08-25 12:59:34 +00:00
|
|
|
my ($params, @paths) = $filler->fill_surface($surface, flow_spacing => 0.69, density => 0.4);
|
|
|
|
is scalar @paths, 1, 'one continuous path';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-04 22:52:53 +00:00
|
|
|
{
|
|
|
|
my $collection = Slic3r::Polyline::Collection->new(polylines => [
|
|
|
|
Slic3r::Polyline->new([0,15], [0,18], [0,20]),
|
|
|
|
Slic3r::Polyline->new([0,10], [0,8], [0,5]),
|
|
|
|
]);
|
|
|
|
is_deeply
|
2013-02-06 09:21:23 +00:00
|
|
|
[ map $_->[Y], map @$_, $collection->chained_path(Slic3r::Point->new(0,30)) ],
|
2012-12-04 22:52:53 +00:00
|
|
|
[20, 18, 15, 10, 8, 5],
|
2013-02-06 09:21:23 +00:00
|
|
|
'chained path';
|
2012-12-04 22:52:53 +00:00
|
|
|
}
|
|
|
|
|
2012-12-20 17:10:20 +00:00
|
|
|
{
|
|
|
|
my $collection = Slic3r::Polyline::Collection->new(polylines => [
|
|
|
|
Slic3r::Polyline->new([4,0], [10,0], [15,0]),
|
|
|
|
Slic3r::Polyline->new([10,5], [15,5], [20,5]),
|
|
|
|
]);
|
|
|
|
is_deeply
|
2013-02-06 09:21:23 +00:00
|
|
|
[ map $_->[X], map @$_, $collection->chained_path(Slic3r::Point->new(30,0)) ],
|
2012-12-20 17:10:20 +00:00
|
|
|
[reverse 4, 10, 15, 10, 15, 20],
|
2013-02-06 09:21:23 +00:00
|
|
|
'chained path';
|
2012-12-20 17:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
my $collection = Slic3r::ExtrusionPath::Collection->new(paths => [
|
2013-07-16 07:49:34 +00:00
|
|
|
map Slic3r::ExtrusionPath->new(polyline => $_, role => 0),
|
2012-12-20 17:10:20 +00:00
|
|
|
Slic3r::Polyline->new([0,15], [0,18], [0,20]),
|
|
|
|
Slic3r::Polyline->new([0,10], [0,8], [0,5]),
|
|
|
|
]);
|
|
|
|
is_deeply
|
2013-07-16 07:49:34 +00:00
|
|
|
[ map $_->[Y], map @{$_->polyline}, $collection->chained_path(Slic3r::Point->new(0,30)) ],
|
2012-12-20 17:10:20 +00:00
|
|
|
[20, 18, 15, 10, 8, 5],
|
2013-02-06 09:21:23 +00:00
|
|
|
'chained path';
|
2012-12-20 17:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
my $collection = Slic3r::ExtrusionPath::Collection->new(paths => [
|
2013-07-16 07:49:34 +00:00
|
|
|
map Slic3r::ExtrusionPath->new(polyline => $_, role => 0),
|
2012-12-20 17:10:20 +00:00
|
|
|
Slic3r::Polyline->new([15,0], [10,0], [4,0]),
|
|
|
|
Slic3r::Polyline->new([10,5], [15,5], [20,5]),
|
|
|
|
]);
|
|
|
|
is_deeply
|
2013-07-16 07:49:34 +00:00
|
|
|
[ map $_->[X], map @{$_->polyline}, $collection->chained_path(Slic3r::Point->new(30,0)) ],
|
2012-12-20 17:10:20 +00:00
|
|
|
[reverse 4, 10, 15, 10, 15, 20],
|
2013-02-06 09:21:23 +00:00
|
|
|
'chained path';
|
2012-12-20 17:10:20 +00:00
|
|
|
}
|
|
|
|
|
2012-12-31 14:05:32 +00:00
|
|
|
{
|
|
|
|
my $config = Slic3r::Config->new_from_defaults;
|
|
|
|
$config->set('fill_pattern', 'hilbertcurve');
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
|
|
|
ok Slic3r::Test::gcode($print), 'successful hilbertcurve infill generation';
|
|
|
|
}
|
|
|
|
|
2013-03-26 14:47:40 +00:00
|
|
|
{
|
|
|
|
my $config = Slic3r::Config->new_from_defaults;
|
|
|
|
$config->set('skirts', 0);
|
|
|
|
$config->set('perimeters', 0);
|
|
|
|
$config->set('fill_density', 0);
|
|
|
|
$config->set('top_solid_layers', 0);
|
|
|
|
$config->set('bottom_solid_layers', 0);
|
|
|
|
$config->set('solid_infill_below_area', 20000000);
|
2013-06-14 14:48:24 +00:00
|
|
|
$config->set('solid_infill_every_layers', 2);
|
2013-03-26 14:47:40 +00:00
|
|
|
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
2013-06-14 14:48:24 +00:00
|
|
|
my %layers_with_extrusion = ();
|
2013-05-13 18:14:33 +00:00
|
|
|
Slic3r::GCode::Reader->new(gcode => Slic3r::Test::gcode($print))->parse(sub {
|
2013-03-26 14:47:40 +00:00
|
|
|
my ($self, $cmd, $args, $info) = @_;
|
2013-06-14 14:48:24 +00:00
|
|
|
$layers_with_extrusion{$self->Z} = 1 if $info->{extruding};
|
2013-03-26 14:47:40 +00:00
|
|
|
});
|
2013-06-14 14:48:24 +00:00
|
|
|
|
|
|
|
ok !%layers_with_extrusion,
|
|
|
|
"solid_infill_below_area and solid_infill_every_layers are ignored when fill_density is 0";
|
2013-03-26 14:47:40 +00:00
|
|
|
}
|
|
|
|
|
2012-02-15 11:04:10 +00:00
|
|
|
__END__
|