gaps.t 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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::Geometry::Clipper qw();
  14. use Slic3r::Surface ':types';
  15. use Slic3r::Test;
  16. {
  17. my $config = Slic3r::Config->new_from_defaults;
  18. $config->set('skirts', 0);
  19. $config->set('perimeter_speed', 66);
  20. $config->set('external_perimeter_speed', 66);
  21. $config->set('small_perimeter_speed', 66);
  22. $config->set('gap_fill_speed', 99);
  23. $config->set('perimeters', 1);
  24. $config->set('cooling', 0); # to prevent speeds from being altered
  25. $config->set('first_layer_speed', '100%'); # to prevent speeds from being altered
  26. $config->set('perimeter_extrusion_width', 0.35);
  27. $config->set('first_layer_extrusion_width', 0.35);
  28. my $print = Slic3r::Test::init_print('two_hollow_squares', config => $config);
  29. my @perimeter_points = ();
  30. my $last = ''; # perimeter | gap
  31. my $gap_fills_outside_last_perimeters = 0;
  32. Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
  33. my ($self, $cmd, $args, $info) = @_;
  34. if ($info->{extruding} && $info->{dist_XY} > 0) {
  35. my $F = $args->{F} // $self->F;
  36. my $point = Slic3r::Point->new_scale($info->{new_X}, $info->{new_Y});
  37. if ($F == $config->perimeter_speed*60) {
  38. if ($last eq 'gap') {
  39. @perimeter_points = ();
  40. }
  41. push @perimeter_points, $point;
  42. $last = 'perimeter';
  43. } elsif ($F == $config->gap_fill_speed*60) {
  44. my $convex_hull = convex_hull(\@perimeter_points);
  45. if (!$convex_hull->contains_point($point)) {
  46. $gap_fills_outside_last_perimeters++;
  47. }
  48. $last = 'gap';
  49. }
  50. }
  51. });
  52. is $gap_fills_outside_last_perimeters, 0, 'gap fills are printed before leaving islands';
  53. }
  54. __END__