From a712284afbdec946602c7894c0d4eb257813d9ba Mon Sep 17 00:00:00 2001
From: Alessandro Ranellucci <aar@cpan.org>
Date: Mon, 13 Jan 2014 00:06:16 +0100
Subject: [PATCH] Add a (failing) test for slicing at the same height of a
 horizontal surface attached to a volume. In this case, the loop isn't
 completed. #1672

Conflicts:

	xs/t/01_trianglemesh.t
---
 utils/dump-stl.pl      |  1 +
 xs/t/01_trianglemesh.t | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/utils/dump-stl.pl b/utils/dump-stl.pl
index 1810d9a3f..240f10b24 100644
--- a/utils/dump-stl.pl
+++ b/utils/dump-stl.pl
@@ -18,6 +18,7 @@ $ARGV[0] or usage(1);
 
 if (-e $ARGV[0]) {
     my $model = Slic3r::Format::STL->read_file($ARGV[0]);
+    $model->objects->[0]->add_instance(offset => [0,0]);
     my $mesh = $model->mesh;
     $mesh->repair;
     printf "VERTICES = %s\n", join ',', map "[$_->[0],$_->[1],$_->[2]]", @{$mesh->vertices};
diff --git a/xs/t/01_trianglemesh.t b/xs/t/01_trianglemesh.t
index 127c8c925..c80d603fa 100644
--- a/xs/t/01_trianglemesh.t
+++ b/xs/t/01_trianglemesh.t
@@ -88,4 +88,14 @@ my $cube = {
     }
 }
 
+{
+    my $m = Slic3r::TriangleMesh->new;
+    $m->ReadFromPerl(
+        [ [0,0,0],[0,0,20],[0,5,0],[0,5,20],[50,0,0],[50,0,20],[15,5,0],[35,5,0],[15,20,0],[50,5,0],[35,20,0],[15,5,10],[50,5,20],[35,5,10],[35,20,10],[15,20,10] ],
+        [ [0,1,2],[2,1,3],[1,0,4],[5,1,4],[0,2,4],[4,2,6],[7,6,8],[4,6,7],[9,4,7],[7,8,10],[2,3,6],[11,3,12],[7,12,9],[13,12,7],[6,3,11],[11,12,13],[3,1,5],[12,3,5],[5,4,9],[12,5,9],[13,7,10],[14,13,10],[8,15,10],[10,15,14],[6,11,8],[8,11,15],[15,11,13],[14,15,13] ],
+    );
+    $m->repair;
+    my $slices = $m->slice([ 5, 10 ]);
+    is $slices->[0][0]->area, $slices->[1][0]->area, 'slicing a tangent plane includes its area';
+}
 __END__