13_polylinecollection.t 935 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Slic3r::XS;
  5. use Test::More tests => 3;
  6. {
  7. my $collection = Slic3r::Polyline::Collection->new(
  8. Slic3r::Polyline->new([0,15], [0,18], [0,20]),
  9. Slic3r::Polyline->new([0,10], [0,8], [0,5]),
  10. );
  11. is_deeply
  12. [ map $_->y, map @$_, @{$collection->chained_path_from(Slic3r::Point->new(0,30), 0)} ],
  13. [20, 18, 15, 10, 8, 5],
  14. 'chained_path_from';
  15. is_deeply
  16. [ map $_->y, map @$_, @{$collection->chained_path(0)} ],
  17. [15, 18, 20, 10, 8, 5],
  18. 'chained_path';
  19. }
  20. {
  21. my $collection = Slic3r::Polyline::Collection->new(
  22. Slic3r::Polyline->new([15,0], [10,0], [4,0]),
  23. Slic3r::Polyline->new([10,5], [15,5], [20,5]),
  24. );
  25. is_deeply
  26. [ map $_->x, map @$_, @{$collection->chained_path_from(Slic3r::Point->new(30,0), 0)} ],
  27. [reverse 4, 10, 15, 10, 15, 20],
  28. 'chained_path_from';
  29. }
  30. __END__