Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2013-01-31 19:05:51 +0400
committerAlessandro Ranellucci <aar@cpan.org>2013-01-31 19:05:51 +0400
commit862900d9c1abde4a88e85a0fd0f4e574797a341f (patch)
tree7f17ed7761be7f86e48af56580d78933805003e5 /t/polyclip.t
parent1de016991071af13cd80b6011fce026669f41ec9 (diff)
Scale test coordinates to avoid truncation issues
Diffstat (limited to 't/polyclip.t')
-rw-r--r--t/polyclip.t68
1 files changed, 34 insertions, 34 deletions
diff --git a/t/polyclip.t b/t/polyclip.t
index 49e3be175..8877d4229 100644
--- a/t/polyclip.t
+++ b/t/polyclip.t
@@ -24,90 +24,90 @@ is Slic3r::Geometry::point_in_segment([20, 15], [ [10, 10], [20, 20] ]), 0, 'poi
#==========================================================
my $square = [ # ccw
- [10, 10],
- [20, 10],
- [20, 20],
- [10, 20],
+ [100, 100],
+ [200, 100],
+ [200, 200],
+ [100, 200],
];
-my $line = Slic3r::Line->new([5, 15], [30, 15]);
+my $line = Slic3r::Line->new([50, 150], [300, 150]);
my $intersection = Slic3r::Geometry::clip_segment_polygon($line, $square);
-is_deeply $intersection, [ [10, 15], [20, 15] ], 'line is clipped to square';
+is_deeply $intersection, [ [100, 150], [200, 150] ], 'line is clipped to square';
#==========================================================
-$intersection = Slic3r::Geometry::clip_segment_polygon([ [0, 15], [8, 15] ], $square);
+$intersection = Slic3r::Geometry::clip_segment_polygon([ [0, 150], [80, 150] ], $square);
is $intersection, undef, 'external lines are ignored 1';
#==========================================================
-$intersection = Slic3r::Geometry::clip_segment_polygon([ [30, 15], [40, 15] ], $square);
+$intersection = Slic3r::Geometry::clip_segment_polygon([ [300, 150], [400, 150] ], $square);
is $intersection, undef, 'external lines are ignored 2';
#==========================================================
-$intersection = Slic3r::Geometry::clip_segment_polygon([ [12, 12], [18, 16] ], $square);
-is_deeply $intersection, [ [12, 12], [18, 16] ], 'internal lines are preserved';
+$intersection = Slic3r::Geometry::clip_segment_polygon([ [120, 120], [180, 160] ], $square);
+is_deeply $intersection, [ [120, 120], [180, 160] ], 'internal lines are preserved';
#==========================================================
{
my $hole_in_square = [ # cw
- [14, 14],
- [14, 16],
- [16, 16],
- [16, 14],
+ [140, 140],
+ [140, 160],
+ [160, 160],
+ [160, 140],
];
my $expolygon = Slic3r::ExPolygon->new($square, $hole_in_square);
- is $expolygon->encloses_point([10, 10]), 1, 'corner point is recognized';
- is $expolygon->encloses_point([10, 18]), 1, 'point on contour is recognized';
- is $expolygon->encloses_point([14, 15]), 1, 'point on hole contour is recognized';
- is $expolygon->encloses_point([14, 14]), 1, 'point on hole corner is recognized';
+ 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';
{
- my $intersections = $expolygon->clip_line(Slic3r::Line->new([15,18], [15,15]));
+ my $intersections = $expolygon->clip_line(Slic3r::Line->new([150,180], [150,150]));
is_deeply $intersections, [
- [ [15, 18], [15, 16] ],
+ [ [150, 180], [150, 160] ],
], 'line is clipped to square with hole';
}
{
- my $intersections = $expolygon->clip_line(Slic3r::Line->new([15,15], [15,12]));
+ my $intersections = $expolygon->clip_line(Slic3r::Line->new([150,150], [150,120]));
is_deeply $intersections, [
- [ [15, 14], [15, 12] ],
+ [ [150, 140], [150, 120] ],
], 'line is clipped to square with hole';
}
{
- my $intersections = $expolygon->clip_line(Slic3r::Line->new([12,18], [18,18]));
+ my $intersections = $expolygon->clip_line(Slic3r::Line->new([120,180], [180,180]));
is_deeply $intersections, [
- [ [12,18], [18,18] ],
+ [ [120,180], [180,180] ],
], 'line is clipped to square with hole';
}
{
my $intersections = $expolygon->clip_line($line);
is_deeply $intersections, [
- [ [10, 15], [14, 15] ],
- [ [16, 15], [20, 15] ],
+ [ [100, 150], [140, 150] ],
+ [ [160, 150], [200, 150] ],
], 'line is clipped to square with hole';
}
{
my $intersections = $expolygon->clip_line(Slic3r::Line->new(reverse @$line));
is_deeply $intersections, [
- [ [20, 15], [15, 15] ],
- [ [14, 15], [10, 15] ],
+ [ [200, 150], [160, 150] ],
+ [ [140, 150], [100, 150] ],
], 'reverse line is clipped to square with hole';
}
{
- my $intersections = $expolygon->clip_line(Slic3r::Line->new([10,18], [20,18]));
+ my $intersections = $expolygon->clip_line(Slic3r::Line->new([100,180], [200,180]));
is_deeply $intersections, [
- [ [10, 18], [20, 18] ],
+ [ [100, 180], [200, 180] ],
], 'tangent line is clipped to square with hole';
}
{
- my $polyline = Slic3r::Polyline->new([ [5, 18], [25, 18], [25, 15], [15, 15], [15, 12], [12, 12], [12, 5] ]);
+ my $polyline = Slic3r::Polyline->new([ [50, 180], [250, 180], [250, 150], [150, 150], [150, 120], [120, 120], [120, 50] ]);
is_deeply [ map $_, $polyline->clip_with_expolygon($expolygon) ], [
- [ [10, 18], [20, 18] ],
- [ [20, 15], [16, 15] ],
- [ [15, 14], [15, 12], [12, 12], [12, 10] ],
+ [ [100, 180], [200, 180] ],
+ [ [200, 150], [160, 150] ],
+ [ [150, 140], [150, 120], [120, 120], [120, 100] ],
], 'polyline is clipped to square with hole';
}
}