gaps.t 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. use Test::More tests => 1;
  2. use strict;
  3. use warnings;
  4. BEGIN {
  5. use FindBin;
  6. use lib "$FindBin::Bin/../lib";
  7. use local::lib "$FindBin::Bin/../local-lib";
  8. }
  9. use List::Util qw(first);
  10. use Slic3r;
  11. use Slic3r::Flow ':roles';
  12. use Slic3r::Geometry qw(PI scale unscale convex_hull);
  13. use Slic3r::Surface ':types';
  14. use Slic3r::Test;
  15. {
  16. my $config = Slic3r::Config::new_from_defaults;
  17. $config->set('skirts', 0);
  18. $config->set('perimeter_speed', 66);
  19. $config->set('external_perimeter_speed', 66);
  20. $config->set('small_perimeter_speed', 66);
  21. $config->set('gap_fill_speed', 99);
  22. $config->set('perimeters', 1);
  23. $config->set('cooling', [ 0 ]); # to prevent speeds from being altered
  24. $config->set('first_layer_speed', '100%'); # to prevent speeds from being altered
  25. $config->set('perimeter_extrusion_width', 0.35);
  26. $config->set('first_layer_extrusion_width', 0.35);
  27. my $print = Slic3r::Test::init_print('two_hollow_squares', config => $config);
  28. my @perimeter_points = ();
  29. my $last = ''; # perimeter | gap
  30. my $gap_fills_outside_last_perimeters = 0;
  31. Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
  32. my ($self, $cmd, $args, $info) = @_;
  33. if ($info->{extruding} && $info->{dist_XY} > 0) {
  34. my $F = $args->{F} // $self->F;
  35. my $point = Slic3r::Point->new_scale($info->{new_X}, $info->{new_Y});
  36. if ($F == $config->perimeter_speed*60) {
  37. if ($last eq 'gap') {
  38. @perimeter_points = ();
  39. }
  40. push @perimeter_points, $point;
  41. $last = 'perimeter';
  42. } elsif ($F == $config->gap_fill_speed*60) {
  43. my $convex_hull = convex_hull(\@perimeter_points);
  44. if (!$convex_hull->contains_point($point)) {
  45. $gap_fills_outside_last_perimeters++;
  46. }
  47. $last = 'gap';
  48. }
  49. }
  50. });
  51. is $gap_fills_outside_last_perimeters, 0, 'gap fills are printed before leaving islands';
  52. }
  53. __END__