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
path: root/t
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2011-10-05 00:27:45 +0400
committerAlessandro Ranellucci <aar@cpan.org>2011-10-05 00:27:45 +0400
commit2da5ee744812f0a2d49d7bd63eabcec984be5537 (patch)
tree22e4cbb277f125b982c33e24d3dc005f12819322 /t
parentf1a36502e11292b44d0a433322032ede519a7509 (diff)
Bugfixes and improvements in surface detection
Diffstat (limited to 't')
-rw-r--r--t/clipper.t51
-rw-r--r--t/polyclip.t9
-rw-r--r--t/stl.t11
3 files changed, 68 insertions, 3 deletions
diff --git a/t/clipper.t b/t/clipper.t
new file mode 100644
index 000000000..f860d2e46
--- /dev/null
+++ b/t/clipper.t
@@ -0,0 +1,51 @@
+use Test::More;
+
+plan tests => 1;
+
+use Math::Clipper ':all';
+
+my $clipper = Math::Clipper->new;
+
+my $square = [ # ccw
+ [10, 10],
+ [20, 10],
+ [20, 20],
+ [10, 20],
+];
+
+my $hole_in_square = [ # cw
+ [14, 14],
+ [14, 16],
+ [16, 16],
+ [16, 14],
+];
+
+my $square = [ # ccw
+ [5, 12],
+ [25, 12],
+ [25, 18],
+ [5, 18],
+];
+
+$clipper->add_subject_polygons([ $square, $hole_in_square ]);
+$clipper->add_clip_polygons([ $square ]);
+my $intersection = $clipper->ex_execute(CT_INTERSECTION, PFT_NONZERO, PFT_NONZERO);
+
+is_deeply $intersection, [
+ {
+ holes => [
+ [
+ [14, 16],
+ [16, 16],
+ [16, 14],
+ [14, 14],
+ ],
+ ],
+ outer => [
+ [5, 18],
+ [5, 12],
+ [25, 12],
+ [25, 18],
+ ],
+ },
+], 'hole is preserved after intersection';
diff --git a/t/polyclip.t b/t/polyclip.t
index 821e7011f..605c4834b 100644
--- a/t/polyclip.t
+++ b/t/polyclip.t
@@ -1,6 +1,6 @@
use Test::More;
-plan tests => 4;
+plan tests => 9;
BEGIN {
use FindBin;
@@ -29,3 +29,10 @@ 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';
+
+is Slic3r::Geometry::point_in_segment([10, 10], [ [5, 10], [20, 10] ]), 1, 'point in horizontal segment';
+is Slic3r::Geometry::point_in_segment([30, 10], [ [5, 10], [20, 10] ]), 0, 'point not in horizontal segment';
+is Slic3r::Geometry::point_in_segment([10, 10], [ [10, 5], [10, 20] ]), 1, 'point in vertical segment';
+is Slic3r::Geometry::point_in_segment([10, 30], [ [10, 5], [10, 20] ]), 0, 'point not in vertical segment';
+is Slic3r::Geometry::point_in_segment([15, 15], [ [10, 10], [20, 20] ]), 1, 'point in diagonal segment';
+is Slic3r::Geometry::point_in_segment([20, 15], [ [10, 10], [20, 20] ]), 0, 'point not in diagonal segment';
diff --git a/t/stl.t b/t/stl.t
index 901d8c33e..84b4a27dd 100644
--- a/t/stl.t
+++ b/t/stl.t
@@ -1,6 +1,6 @@
use Test::More;
-plan tests => 7;
+plan tests => 11;
BEGIN {
use FindBin;
@@ -28,10 +28,17 @@ is_deeply lines(28, 20, 30), [ ], 'lower vertex on la
is_deeply lines(24, 10, 16), [ [ [4, 4], [2, 6] ] ], 'two edges intersect';
is_deeply lines(24, 10, 20), [ [ [4, 4], [1, 9] ] ], 'one vertex on plane and one edge intersects';
+my @lower = $stl->intersect_facet(vertices(22, 20, 20), $z, $dz);
+my @upper = $stl->intersect_facet(vertices(20, 20, 10), $z, $dz);
+isa_ok $lower[0], 'Slic3r::Line::FacetEdge', 'bottom edge on layer';
+isa_ok $upper[0], 'Slic3r::Line::FacetEdge', 'upper edge on layer';
+is $lower[0]->edge_type, 'bottom', 'lower edge is detected as bottom';
+is $upper[0]->edge_type, 'top', 'upper edge is detected as top';
+
sub vertices {
[ map [ @{$points[$_]}, $_[$_] ], 0..2 ]
}
sub lines {
- [ map [ map ref $_ eq 'Slic3r::Point' ? $_->p : [ map sprintf('%.0f', $_), @$_ ], @$_ ], $stl->intersect_facet(vertices(@_), $z, $dz) ];
+ [ map [ map ref $_ eq 'Slic3r::Point' ? $_->p : [ map sprintf('%.0f', $_), @$_ ], @$_ ], map $_->p, $stl->intersect_facet(vertices(@_), $z, $dz) ];
}