Extended arcs unit test to check whether it works with both cw and ccw arcs
This commit is contained in:
parent
98a8c64ed7
commit
28b851508e
32
t/arcs.t
32
t/arcs.t
@ -2,7 +2,7 @@ use Test::More;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
plan tests => 6;
|
||||
plan tests => 10;
|
||||
|
||||
BEGIN {
|
||||
use FindBin;
|
||||
@ -30,21 +30,35 @@ use Slic3r;
|
||||
#==========================================================
|
||||
|
||||
{
|
||||
my $path = Slic3r::ExtrusionPath->cast([
|
||||
my $path1 = Slic3r::ExtrusionPath->cast([
|
||||
[10,20], [10.7845909572784,19.9691733373313], [11.5643446504023,19.8768834059514],
|
||||
[12.3344536385591,19.7236992039768], [13.0901699437495,19.5105651629515],
|
||||
[13.8268343236509,19.2387953251129], [14.5399049973955,18.9100652418837],
|
||||
[15.2249856471595,18.5264016435409], [15.8778525229247,18.0901699437495],
|
||||
[16.4944804833018,17.6040596560003],
|
||||
], role => 'fill');
|
||||
my $collection = Slic3r::ExtrusionPath::Collection->new(paths => [$path]);
|
||||
$collection->detect_arcs(10, 1);
|
||||
my $path2 = Slic3r::ExtrusionPath->cast([ reverse @{$path1->points} ], role => 'fill');
|
||||
|
||||
is scalar(@{$collection->paths}), 1, 'path collection now contains one path';
|
||||
isa_ok $collection->paths->[0], 'Slic3r::ExtrusionPath::Arc', 'path';
|
||||
is $collection->paths->[0]->orientation, 'cw', 'orientation was correctly detected';
|
||||
my $center = [ map sprintf('%.0f', $_), @{ $collection->paths->[0]->center } ];
|
||||
is_deeply $center, [10,10], 'center was correctly detected';
|
||||
my $collection1 = Slic3r::ExtrusionPath::Collection->new(paths => [$path1]);
|
||||
my $collection2 = Slic3r::ExtrusionPath::Collection->new(paths => [$path2]);
|
||||
|
||||
$collection1->detect_arcs(10, 1);
|
||||
$collection2->detect_arcs(10, 1);
|
||||
|
||||
is scalar(@{$collection1->paths}), 1, 'path collection now contains one path';
|
||||
is scalar(@{$collection2->paths}), 1, 'path collection now contains one path';
|
||||
|
||||
isa_ok $collection1->paths->[0], 'Slic3r::ExtrusionPath::Arc', 'path';
|
||||
isa_ok $collection2->paths->[0], 'Slic3r::ExtrusionPath::Arc', 'path';
|
||||
|
||||
is $collection1->paths->[0]->orientation, 'cw', 'cw orientation was correctly detected';
|
||||
is $collection2->paths->[0]->orientation, 'ccw', 'ccw orientation was correctly detected';
|
||||
|
||||
my $center1 = [ map sprintf('%.0f', $_), @{ $collection1->paths->[0]->center } ];
|
||||
is_deeply $center1, [10,10], 'center was correctly detected';
|
||||
|
||||
my $center2 = [ map sprintf('%.0f', $_), @{ $collection2->paths->[0]->center } ];
|
||||
is_deeply $center2, [10,10], 'center was correctly detected';
|
||||
}
|
||||
|
||||
#==========================================================
|
||||
|
Loading…
Reference in New Issue
Block a user