combineinfill.t 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. use Test::More tests => 3;
  2. use strict;
  3. use warnings;
  4. BEGIN {
  5. use FindBin;
  6. use lib "$FindBin::Bin/../lib";
  7. }
  8. use List::Util qw(first);
  9. use Slic3r;
  10. use Slic3r::Test;
  11. {
  12. my $config = Slic3r::Config->new_from_defaults;
  13. $config->set('skirts', 0);
  14. $config->set('solid_layers', 0);
  15. $config->set('bottom_solid_layers', 0);
  16. $config->set('top_solid_layers', 0);
  17. $config->set('infill_every_layers', 6);
  18. $config->set('layer_height', 0.06);
  19. $config->set('perimeters', 1);
  20. my $test = sub {
  21. my ($shift) = @_;
  22. my $self = Slic3r::Test::init_print('20mm_cube', config => $config);
  23. $shift /= &Slic3r::SCALING_FACTOR;
  24. my $scale = 4; # make room for fat infill lines with low layer height
  25. # Put a slope on the box's sides by shifting x and y coords by $tilt * (z / boxheight).
  26. # The test here is to put such a slight slope on the walls that it should
  27. # not trigger any extra fill on fill layers that should be empty when
  28. # combine infill is enabled.
  29. $_->[0] += $shift * ($_->[2] / (20 / &Slic3r::SCALING_FACTOR)) for @{$self->objects->[0]->meshes->[0]->vertices};
  30. $_->[1] += $shift * ($_->[2] / (20 / &Slic3r::SCALING_FACTOR)) for @{$self->objects->[0]->meshes->[0]->vertices};
  31. $_ = [$_->[0]*$scale, $_->[1]*$scale, $_->[2]] for @{$self->objects->[0]->meshes->[0]->vertices};
  32. # copy of Print::export_gcode() up to the point
  33. # after fill surfaces are combined
  34. $self->init_extruders;
  35. $_->slice for @{$self->objects};
  36. $_->make_perimeters for @{$self->objects};
  37. $_->detect_surfaces_type for @{$self->objects};
  38. $_->prepare_fill_surfaces for map @{$_->regions}, map @{$_->layers}, @{$self->objects};
  39. $_->process_external_surfaces for map @{$_->regions}, map @{$_->layers}, @{$self->objects};
  40. $_->discover_horizontal_shells for @{$self->objects};
  41. $_->combine_infill for @{$self->objects};
  42. # Only layers with id % 6 == 0 should have fill.
  43. my $spurious_infill = 0;
  44. foreach my $layer (map @{$_->layers}, @{$self->objects}) {
  45. ++$spurious_infill if ($layer->id % 6 && grep @{$_->fill_surfaces} > 0, @{$layer->regions});
  46. }
  47. $spurious_infill -= scalar(@{$self->objects->[0]->layers} - 1) % 6;
  48. fail "spurious fill surfaces found on layers that should have none (walls " . sprintf("%.4f", Slic3r::Geometry::rad2deg(atan2($shift, 20/&Slic3r::SCALING_FACTOR))) . " degrees off vertical)"
  49. unless $spurious_infill == 0;
  50. 1;
  51. };
  52. # Test with mm skew offsets for the top of the 20mm-high box
  53. for my $shift (0, 0.0001, 1) {
  54. ok $test->($shift), "no spurious fill surfaces with box walls " . sprintf("%.4f",Slic3r::Geometry::rad2deg(atan2($shift, 20))) . " degrees off of vertical";
  55. }
  56. }
  57. __END__