2013-07-15 14:21:09 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Slic3r::XS;
|
2013-07-15 21:56:01 +00:00
|
|
|
use Test::More tests => 7;
|
2013-07-15 14:21:09 +00:00
|
|
|
|
|
|
|
my $square = [
|
|
|
|
[100, 100],
|
|
|
|
[200, 100],
|
|
|
|
[200, 200],
|
|
|
|
[100, 200],
|
|
|
|
];
|
|
|
|
|
|
|
|
my $loop = Slic3r::ExtrusionLoop->new(
|
2013-07-15 20:57:22 +00:00
|
|
|
polygon => Slic3r::Polygon->new(@$square),
|
2013-07-15 14:21:09 +00:00
|
|
|
role => Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER,
|
|
|
|
);
|
2013-08-30 22:50:03 +00:00
|
|
|
isa_ok $loop->polygon, 'Slic3r::Polygon::Ref', 'loop polygon';
|
2013-07-16 07:49:34 +00:00
|
|
|
is_deeply $loop->polygon->pp, $square, 'polygon points roundtrip';
|
2013-07-15 14:21:09 +00:00
|
|
|
|
|
|
|
$loop = $loop->clone;
|
|
|
|
|
|
|
|
is $loop->role, Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER, 'role';
|
|
|
|
$loop->role(Slic3r::ExtrusionPath::EXTR_ROLE_FILL);
|
|
|
|
is $loop->role, Slic3r::ExtrusionPath::EXTR_ROLE_FILL, 'modify role';
|
|
|
|
|
2013-07-15 21:56:01 +00:00
|
|
|
{
|
|
|
|
my $path = $loop->split_at_first_point;
|
2013-07-16 15:13:01 +00:00
|
|
|
is_deeply $path->polyline->pp, [ @$square[0,1,2,3,0] ], 'split_at_first_point';
|
2013-07-15 21:56:01 +00:00
|
|
|
is $path->role, $loop->role, 'role preserved after split';
|
|
|
|
|
2013-07-16 15:13:01 +00:00
|
|
|
is_deeply $loop->split_at_index(2)->polyline->pp, [ @$square[2,3,0,1,2] ], 'split_at_index';
|
2013-07-15 21:56:01 +00:00
|
|
|
}
|
|
|
|
|
2013-07-15 14:21:09 +00:00
|
|
|
__END__
|