diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2014-04-29 17:25:14 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2014-04-29 17:25:14 +0400 |
commit | 913ab54a2bacf5944b2a6a3b1271fe903d1fc7bb (patch) | |
tree | 0c93430d7649141be3a4b8d57ed1115dcb450d49 /t/gaps.t | |
parent | 0b0ec7be3709892113c1ae299e9547b970b45a71 (diff) |
Bugfix: gap fill was not inserted in the correct order before leaving island. Includes regression test. #1907
Diffstat (limited to 't/gaps.t')
-rw-r--r-- | t/gaps.t | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/t/gaps.t b/t/gaps.t new file mode 100644 index 000000000..16baa0363 --- /dev/null +++ b/t/gaps.t @@ -0,0 +1,60 @@ +use Test::More tests => 1; +use strict; +use warnings; + +BEGIN { + use FindBin; + use lib "$FindBin::Bin/../lib"; +} + +use List::Util qw(first); +use Slic3r; +use Slic3r::Flow ':roles'; +use Slic3r::Geometry qw(PI scale unscale convex_hull); +use Slic3r::Geometry::Clipper qw(); +use Slic3r::Surface ':types'; +use Slic3r::Test; + +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('skirts', 0); + $config->set('perimeter_speed', 66); + $config->set('external_perimeter_speed', 66); + $config->set('small_perimeter_speed', 66); + $config->set('gap_fill_speed', 99); + $config->set('perimeters', 1); + $config->set('cooling', 0); # to prevent speeds from being altered + $config->set('first_layer_speed', '100%'); # to prevent speeds from being altered + $config->set('perimeter_extrusion_width', 0.35); + $config->set('first_layer_extrusion_width', 0.35); + + my $print = Slic3r::Test::init_print('two_hollow_squares', config => $config); + my @perimeter_points = (); + my $last = ''; # perimeter | gap + my $gap_fills_outside_last_perimeters = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($info->{extruding} && $info->{dist_XY} > 0) { + my $F = $args->{F} // $self->F; + my $point = Slic3r::Point->new_scale($info->{new_X}, $info->{new_Y}); + if ($F == $config->perimeter_speed*60) { + if ($last eq 'gap') { + @perimeter_points = (); + } + push @perimeter_points, $point; + $last = 'perimeter'; + } elsif ($F == $config->gap_fill_speed*60) { + my $convex_hull = convex_hull(\@perimeter_points); + if (!$convex_hull->contains_point($point)) { + $gap_fills_outside_last_perimeters++; + } + + $last = 'gap'; + } + } + }); + is $gap_fills_outside_last_perimeters, 0, 'gap fills are printed before leaving islands'; +} + +__END__ |