diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2013-07-15 22:31:43 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2013-07-15 22:31:43 +0400 |
commit | 9af2a1c007ae185ef665efe80e576b1997d2e819 (patch) | |
tree | 8317c909ec6d8334b47eccb55a86af7b0945295e /t | |
parent | d0701cdcd4b7a9677e130a3126e4575eb3b135fa (diff) |
Use XS Point everywhere
Diffstat (limited to 't')
-rw-r--r-- | t/clean_polylines.t | 7 | ||||
-rw-r--r-- | t/gcode.t | 2 | ||||
-rw-r--r-- | t/geometry.t | 6 | ||||
-rw-r--r-- | t/polyclip.t | 12 | ||||
-rw-r--r-- | t/serialize.t | 33 |
5 files changed, 13 insertions, 47 deletions
diff --git a/t/clean_polylines.t b/t/clean_polylines.t index 17c4ad6ab..092b0792d 100644 --- a/t/clean_polylines.t +++ b/t/clean_polylines.t @@ -25,16 +25,15 @@ use Slic3r; [0,0],[1,0],[2,0],[2,1],[2,2],[1,2],[0,2],[0,1],[0,0], ); $polyline = $polyline->simplify(1); - is_deeply $polyline, [ [0, 0], [2, 0], [2, 2], [0, 2], [0, 0] ], 'Douglas-Peucker'; + is_deeply $polyline->arrayref_pp, [ [0, 0], [2, 0], [2, 2], [0, 2], [0, 0] ], 'Douglas-Peucker'; } { my $polyline = Slic3r::Polyline->new( - [0,0],[0.5,0.5],[1,0],[1.25,-0.25],[1.5,.5], + [0,0], [50,50], [100,0], [125,-25], [150,50], ); - $polyline->scale(100); $polyline = $polyline->simplify(25); - is_deeply $polyline, [ [0, 0], [50, 50], [125, -25], [150, 50] ], 'Douglas-Peucker'; + is_deeply $polyline->arrayref_pp, [ [0, 0], [50, 50], [125, -25], [150, 50] ], 'Douglas-Peucker'; } { @@ -16,7 +16,7 @@ use Slic3r::Geometry qw(scale); layer_count => 1, ); $gcodegen->set_shift(10, 10); - is_deeply $gcodegen->last_pos, [scale -10, scale -10], 'last_pos is shifted correctly'; + is_deeply $gcodegen->last_pos->arrayref, [scale -10, scale -10], 'last_pos is shifted correctly'; } __END__ diff --git a/t/geometry.t b/t/geometry.t index edbe7262a..e96ec729f 100644 --- a/t/geometry.t +++ b/t/geometry.t @@ -18,7 +18,7 @@ use Slic3r::Geometry qw(PI polyline_remove_parallel_continuous_edges my $line1 = [ [5, 15], [30, 15] ]; my $line2 = [ [10, 20], [10, 10] ]; -is_deeply Slic3r::Geometry::line_intersection($line1, $line2, 1), [10, 15], 'line_intersection'; +is_deeply Slic3r::Geometry::line_intersection($line1, $line2, 1)->arrayref, [10, 15], 'line_intersection'; #========================================================== @@ -158,7 +158,7 @@ is Slic3r::Geometry::can_connect_points(@$points, $polygons), 0, 'can_connect_po { my $polyline = Slic3r::Polyline->new([0, 0], [10, 0], [20, 0]); - is_deeply [$polyline->lines], [ + is_deeply [ map $_->arrayref_pp, $polyline->lines ], [ [ [0, 0], [10, 0] ], [ [10, 0], [20, 0] ], ], 'polyline_lines'; @@ -170,7 +170,7 @@ is Slic3r::Geometry::can_connect_points(@$points, $polygons), 0, 'can_connect_po my $polyline = Slic3r::Polygon->new([0, 0], [10, 0], [5, 5]); my $result = $polyline->split_at_index(1); is ref($result), 'Slic3r::Polyline', 'split_at_index returns polyline'; - is_deeply $result, [ [10, 0], [5, 5], [0, 0], [10, 0] ], 'split_at_index'; + is_deeply $result->arrayref_pp, [ [10, 0], [5, 5], [0, 0], [10, 0] ], 'split_at_index'; } #========================================================== diff --git a/t/polyclip.t b/t/polyclip.t index 509a353d9..4882892bd 100644 --- a/t/polyclip.t +++ b/t/polyclip.t @@ -60,10 +60,10 @@ is_deeply $intersection, [ [120, 120], [180, 160] ], 'internal lines are preserv [160, 140], ]; my $expolygon = Slic3r::ExPolygon->new($square, $hole_in_square); - is $expolygon->encloses_point([100, 100]), 1, 'corner point is recognized'; - is $expolygon->encloses_point([100, 180]), 1, 'point on contour is recognized'; - is $expolygon->encloses_point([140, 150]), 1, 'point on hole contour is recognized'; - is $expolygon->encloses_point([140, 140]), 1, 'point on hole corner is recognized'; + is $expolygon->encloses_point(Slic3r::Point->new(100, 100)), 1, 'corner point is recognized'; + is $expolygon->encloses_point(Slic3r::Point->new(100, 180)), 1, 'point on contour is recognized'; + is $expolygon->encloses_point(Slic3r::Point->new(140, 150)), 1, 'point on hole contour is recognized'; + is $expolygon->encloses_point(Slic3r::Point->new(140, 140)), 1, 'point on hole corner is recognized'; { my $intersections = $expolygon->clip_line(Slic3r::Line->new([150,180], [150,150])); is_deeply $intersections, [ @@ -144,8 +144,8 @@ is_deeply $intersection, [ [120, 120], [180, 160] ], 'internal lines are preserv my $intersections = $expolygon->clip_line($line); is_deeply $intersections, [ - [ [152.742, 288.086660915295], [152.742, 215.178843238354], ], - [ [152.742, 108.087506777797], [152.742, 35.1664774739315] ], + [ [152.742, 287.908315789474], [152.742, 214.522], ], + [ [152.742, 107.478], [152.742, 35] ], ], 'line is clipped to square with hole'; } diff --git a/t/serialize.t b/t/serialize.t deleted file mode 100644 index 0d93cd52a..000000000 --- a/t/serialize.t +++ /dev/null @@ -1,33 +0,0 @@ -use Test::More; -use strict; -use warnings; - -plan tests => 2; - -BEGIN { - use FindBin; - use lib "$FindBin::Bin/../lib"; -} - -use Slic3r; -use Slic3r::Geometry qw(scale); - -#========================================================== - -{ - my $points = [ - [226,701], [260,681], [109,420], [149,397], [300,658], [308,654], - ]; - foreach my $point (@$points) { - @$point = map scale $_, @$point; - } - my $polyline = Slic3r::Polyline->new(@$points); - my $serialized = $polyline->serialize; - my $deserialized = Slic3r::Polyline->deserialize($serialized); - is scalar(@$deserialized), scalar(@$points), 'number of deserialized points'; - is_deeply $deserialized, $points, 'deserialized points coordinates'; -} - -#========================================================== - -__END__ |