combineinfill.t 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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(keep_meshes => 1) for @{$self->objects};
  36. $_->make_perimeters for @{$self->objects};
  37. foreach my $layer (map @{$_->layers}, @{$self->objects}) {
  38. $_->simplify(&Slic3r::SCALED_RESOLUTION)
  39. for @{$layer->slices}, (map $_->expolygon, map @{$_->slices}, @{$layer->regions});
  40. }
  41. $_->detect_surfaces_type for @{$self->objects};
  42. $_->prepare_fill_surfaces for map @{$_->regions}, map @{$_->layers}, @{$self->objects};
  43. $_->process_external_surfaces for map @{$_->regions}, map @{$_->layers}, @{$self->objects};
  44. $_->discover_horizontal_shells for @{$self->objects};
  45. $_->combine_infill for @{$self->objects};
  46. # Only layers with id % 6 == 0 should have fill.
  47. my $spurious_infill = 0;
  48. foreach my $layer (map @{$_->layers}, @{$self->objects}) {
  49. ++$spurious_infill if ($layer->id % 6 && grep @{$_->fill_surfaces} > 0, @{$layer->regions});
  50. }
  51. $spurious_infill -= scalar(@{$self->objects->[0]->layers} - 1) % 6;
  52. 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)"
  53. unless $spurious_infill == 0;
  54. 1;
  55. };
  56. # Test with mm skew offsets for the top of the 20mm-high box
  57. for my $shift (0, 0.0001, 1) {
  58. ok $test->($shift), "no spurious fill surfaces with box walls " . sprintf("%.4f",Slic3r::Geometry::rad2deg(atan2($shift, 20))) . " degrees off of vertical";
  59. }
  60. }
  61. __END__