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>2011-11-13 21:14:02 +0400
committerAlessandro Ranellucci <aar@cpan.org>2011-11-13 21:14:02 +0400
commit038caddcdae26a44bb0b68c952570319cd0ab42c (patch)
tree8cac8bb3336223d24bb931b376f0e1b1f5b52010 /t/polyclip.t
parent041e9877a3838e8441618901dc20e89311de428c (diff)
New fill types (hilbertcurve, archimedeanchords, octagramspiral) and ability to use different patterns for solid layers. #20
Diffstat (limited to 't/polyclip.t')
-rw-r--r--t/polyclip.t67
1 files changed, 58 insertions, 9 deletions
diff --git a/t/polyclip.t b/t/polyclip.t
index b7d4d58f6..205f036c8 100644
--- a/t/polyclip.t
+++ b/t/polyclip.t
@@ -2,7 +2,7 @@ use Test::More;
use strict;
use warnings;
-plan tests => 14;
+plan tests => 24;
BEGIN {
use FindBin;
@@ -59,11 +59,57 @@ is_deeply $intersection, [ [12, 12], [18, 16] ], 'internal lines are preserved';
[16, 16],
[16, 14],
];
- my $intersections = Slic3r::Geometry::clip_segment_complex_polygon($line, [ $square, $hole_in_square ]);
- is_deeply $intersections, [
- [ [10, 15], [14, 15] ],
- [ [16, 15], [20, 15] ],
- ], 'line is clipped to square with hole';
+ 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';
+ {
+ my $intersections = $expolygon->clip_line([ [15,18], [15,15] ]);
+ is_deeply $intersections, [
+ [ [15, 18], [15, 16] ],
+ ], 'line is clipped to square with hole';
+ }
+ {
+ my $intersections = $expolygon->clip_line([ [15,15], [15,12] ]);
+ is_deeply $intersections, [
+ [ [15, 14], [15, 12] ],
+ ], 'line is clipped to square with hole';
+ }
+ {
+ my $intersections = $expolygon->clip_line([ [12,18], [18,18] ]);
+ is_deeply $intersections, [
+ [ [12,18], [18,18] ],
+ ], 'line is clipped to square with hole';
+ }
+ {
+ my $intersections = $expolygon->clip_line($line);
+ is_deeply $intersections, [
+ [ [10, 15], [14, 15] ],
+ [ [16, 15], [20, 15] ],
+ ], 'line is clipped to square with hole';
+ }
+ {
+ my $intersections = $expolygon->clip_line([ reverse @$line ]);
+ is_deeply $intersections, [
+ [ [20, 15], [16, 15] ],
+ [ [14, 15], [10, 15] ],
+ ], 'reverse line is clipped to square with hole';
+ }
+ {
+ my $intersections = $expolygon->clip_line([ [10,18], [20,18] ]);
+ is_deeply $intersections, [
+ [ [10, 18], [20, 18] ],
+ ], 'tangent line is clipped to square with hole';
+ }
+ {
+ my $polyline = Slic3r::Polyline->cast([ [5, 18], [25, 18], [25, 15], [15, 15], [15, 12], [12, 12], [12, 5] ]);
+ is_deeply [ map $_->p, $polyline->clip_with_expolygon($expolygon) ], [
+ [ [10, 18], [20, 18] ],
+ [ [20, 15], [16, 15] ],
+ [ [15, 14], [15, 12], [12, 12], [12, 10] ],
+ ], 'polyline is clipped to square with hole';
+ }
}
#==========================================================
@@ -93,11 +139,14 @@ is_deeply $intersection, [ [12, 12], [18, 16] ], 'internal lines are preserved';
];
is is_counter_clockwise($small_circle), 0, "hole is clockwise";
+ my $expolygon = Slic3r::ExPolygon->new($large_circle, $small_circle);
$line = [ [152.741724,288.086671142818], [152.741724,34.166466971035] ];
- my $intersections = Slic3r::Geometry::clip_segment_complex_polygon($line, [ $large_circle, $small_circle ]);
+ my $intersections = $expolygon->clip_line($line);
is_deeply $intersections, [
- [ [152.741724, 35.166466971035], [152.741724, 108.087543109156] ],
- [ [152.741724, 215.178806915206], [152.741724, 288.086671142818] ],
+ [ [152.741724, 288.086671142818], [152.741724, 215.178806915206], ],
+ [ [152.741724, 108.087543109156], [152.741724, 35.166466971035] ],
], 'line is clipped to square with hole';
}
+
+#==========================================================