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/loops.t
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2012-12-30 19:27:20 +0400
committerAlessandro Ranellucci <aar@cpan.org>2012-12-30 19:27:20 +0400
commit6e6bc746367b4f50dfdac108ce067ac94ff31a30 (patch)
tree138cb3370eb5f3bd8f151b0759d6979ddb0cea79 /t/loops.t
parentde5b8b9f4d47b2913d411a54b072380882dd9e65 (diff)
Added failing test case for troubleshooting unexpected filled holes. #858
Diffstat (limited to 't/loops.t')
-rw-r--r--t/loops.t47
1 files changed, 47 insertions, 0 deletions
diff --git a/t/loops.t b/t/loops.t
new file mode 100644
index 000000000..c36505e4e
--- /dev/null
+++ b/t/loops.t
@@ -0,0 +1,47 @@
+use Test::More;
+use strict;
+use warnings;
+
+plan tests => 4;
+
+BEGIN {
+ use FindBin;
+ use lib "$FindBin::Bin/../lib";
+}
+
+use Slic3r;
+use Slic3r::Test;
+
+{
+ my (@vertices, @facets) = ();
+ Slic3r::Test::add_facet($_, \@vertices, \@facets) for
+ # external surface below the slicing Z
+ [ [0,0,0], [20,0,10], [0,0,10] ],
+ [ [20,0,0], [20,20,10], [20,0,10] ],
+ [ [20,20,0], [0,20,10], [20,20,10] ],
+ [ [0,20,0], [0,0,10], [0,20,10] ],
+
+ # external insetted surface above the slicing Z
+ [ [2,2,10], [18,2,10], [2,2,20] ],
+ [ [18,2,10], [18,18,10], [18,2,20] ],
+ [ [18,18,10], [2,18,10], [18,18,20] ],
+ [ [2,18,10], [2,2,10], [2,18,20] ],
+
+ # insetted hole below the slicing Z
+ [ [15,5,0], [5,5,10], [15,5,10] ],
+ [ [15,15,0], [15,5,10], [15,15,10] ],
+ [ [5,15,0], [15,15,10], [5,15,10] ],
+ [ [5,5,0], [5,15,10], [5,5,10] ];
+
+ my $mesh = Slic3r::TriangleMesh->new(vertices => \@vertices, facets => \@facets);
+ my @lines = map $mesh->intersect_facet($_, 10), 0..$#facets;
+ my $loops = Slic3r::TriangleMesh::make_loops(\@lines);
+ is scalar(@$loops), 3, 'correct number of loops detected';
+ is scalar(grep $_->is_counter_clockwise, @$loops), 2, 'correct number of ccw loops detected';
+
+ my @surfaces = Slic3r::Layer::Region::_merge_loops($loops);
+ is scalar(@surfaces), 1, 'one surface detected';
+ is scalar(@{$surfaces[0]->expolygon})-1, 1, 'surface has one hole';
+}
+
+__END__