01_trianglemesh.t 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Slic3r::XS;
  5. use Test::More tests => 5;
  6. my $cube = {
  7. vertices => [ [20,20,0], [20,0,0], [0,0,0], [0,20,0], [20,20,20], [0,20,20], [0,0,20], [20,0,20] ],
  8. facets => [ [0,1,2], [0,2,3], [4,5,6], [4,6,7], [0,4,7], [0,7,1], [1,7,6], [1,6,2], [2,6,5], [2,5,3], [4,0,3], [4,3,5] ],
  9. };
  10. {
  11. my $m = Slic3r::TriangleMesh->new;
  12. $m->ReadFromPerl($cube->{vertices}, $cube->{facets});
  13. my ($vertices, $facets) = ($m->vertices, $m->facets);
  14. is_deeply $vertices, $cube->{vertices}, 'vertices arrayref roundtrip';
  15. is_deeply $facets, $cube->{facets}, 'facets arrayref roundtrip';
  16. {
  17. my $m2 = $m->clone;
  18. is_deeply $m2->vertices, $cube->{vertices}, 'cloned vertices arrayref roundtrip';
  19. is_deeply $m2->facets, $cube->{facets}, 'cloned facets arrayref roundtrip';
  20. $m2->scale(3); # check that it does not affect $m
  21. }
  22. {
  23. my $stats = $m->stats;
  24. is $stats->{number_of_facets}, scalar(@{ $cube->{facets} }), 'stats.number_of_facets';
  25. }
  26. }
  27. __END__