]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
ronnas :
authorvbd <vbd>
Mon, 9 Jul 2007 14:44:03 +0000 (14:44 +0000)
committervbd <vbd>
Mon, 9 Jul 2007 14:44:03 +0000 (14:44 +0000)
Added test class to test intersection methods of TransformedTriangle

src/INTERP_KERNEL/Test/Makefile.in
src/INTERP_KERNEL/Test/TestInterpKernel.cxx
src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx [new file with mode: 0644]
src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.hxx [new file with mode: 0644]
src/INTERP_KERNEL/Test/TransformedTriangleTest.cxx

index 82b55ddfd58a0cf5ebf2ed6fb9ebfedbaa66daeb..46c8214009d269f0fd5cc70fbbf28d41a3c409ad 100644 (file)
@@ -35,7 +35,8 @@ VPATH=.:@srcdir@:@top_srcdir@/idl
 
 # header files
 EXPORT_HEADERS = CppUnitTest.hxx \
-                TransformedTriangleTest.hxx
+                TransformedTriangleTest.hxx \
+                TransformedTriangleIntersectTest.hxx   
 
 
 # Libraries targets
@@ -49,7 +50,7 @@ LIB_CLIENT_IDL =
 
 BIN = TestInterpKernel
 
-BIN_SRC = CppUnitTest.cxx TransformedTriangleTest.cxx
+BIN_SRC = CppUnitTest.cxx TransformedTriangleTest.cxx TransformedTriangleIntersectTest.cxx
 BIN_CLIENT_IDL =
 
 
index 285e16f57218d3c9b172f69994b74a649e5f548d..a22bbf1589aaf750a3ead1d093e4ea1812a3e806 100644 (file)
 
 #include "CppUnitTest.hxx"
 #include "TransformedTriangleTest.hxx"
+#include "TransformedTriangleIntersectTest.hxx"
 
 // --- Registers the fixture into the 'registry'
 
+CPPUNIT_TEST_SUITE_REGISTRATION( TransformedTriangleIntersectTest );
 CPPUNIT_TEST_SUITE_REGISTRATION( TransformedTriangleTest );
 CPPUNIT_TEST_SUITE_REGISTRATION( TestBogusClass );
 
diff --git a/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx b/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx
new file mode 100644 (file)
index 0000000..fa77029
--- /dev/null
@@ -0,0 +1,315 @@
+#include "TransformedTriangleIntersectTest.hxx"
+#include <iostream>
+
+void TransformedTriangleIntersectTest::setUp()
+{
+  double coords1[9] = 
+    {
+      0.4,-0.5, 0.5, // P
+      0.4, 2.5,-1.0, // Q
+      0.4, 2.5, 0.5  // R
+    };
+
+  tri1 = new TransformedTriangle(&coords1[0], &coords1[3], &coords1[6]);
+
+  double coords2[9] =
+    {
+     -0.5, 0.5, 0.25, // P
+      1.5, 0.5,-0.25, // Q
+     -0.5,-1.5, 0.75  // R
+    };
+  tri2 = new TransformedTriangle(&coords2[0], &coords2[3], &coords2[6]);
+  
+}
+
+void TransformedTriangleIntersectTest::tearDown()
+{
+  delete tri1;
+  delete tri2;
+}
+
+// -- Tests intersections for triangle 1
+// These are of type surface-edge (SE), segment-facet (SF), and segment-halfstrip (SHs) according to the 
+// following tables : 
+// 
+// (SE) : 
+// Edge  Intersection 
+// OX        no
+// OY        no
+// OZ        no
+// YZ        no
+// ZX        no
+// XY        yes
+//
+// (SF) : 
+// Segment / Facet  OZX   OYZ  OXY   XYZ
+// PQ               yes   no   yes   no
+// QR               no    no   no    no
+// RP               yes   no   no    yes
+//
+// (SHs) : 
+// Segment / Halfstrip    YZ  ZX  XY
+// PQ                     no  no  no
+// QR                     no  no  no
+// RP                     no  no  yes
+
+void TransformedTriangleIntersectTest::testTriangle1()
+{
+  typedef TransformedTriangle TT;
+
+  // run all intersection tests and ensure that the ones
+  // listed with yes in the tables above return true and 
+  // that the ones listed with no or not listed at all return false
+
+  // surface-edge (6 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSurfaceEdgeIntersection(TT::OX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSurfaceEdgeIntersection(TT::OY));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSurfaceEdgeIntersection(TT::OZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSurfaceEdgeIntersection(TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSurfaceEdgeIntersection(TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(true , tri1->testSurfaceEdgeIntersection(TT::XY));
+
+  // segment-facet (9 possibilities)
+  CPPUNIT_ASSERT_EQUAL(true , tri1->testSegmentFacetIntersection(TT::PQ, TT::OZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentFacetIntersection(TT::PQ, TT::OYZ));
+  CPPUNIT_ASSERT_EQUAL(true , tri1->testSegmentFacetIntersection(TT::PQ, TT::OXY));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentFacetIntersection(TT::PQ, TT::XYZ));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentFacetIntersection(TT::QR, TT::OZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentFacetIntersection(TT::QR, TT::OYZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentFacetIntersection(TT::QR, TT::OXY));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentFacetIntersection(TT::QR, TT::XYZ));
+
+  CPPUNIT_ASSERT_EQUAL(true , tri1->testSegmentFacetIntersection(TT::RP, TT::OZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentFacetIntersection(TT::RP, TT::OYZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentFacetIntersection(TT::RP, TT::OXY));
+  CPPUNIT_ASSERT_EQUAL(true , tri1->testSegmentFacetIntersection(TT::RP, TT::XYZ));
+
+  // segment-edge (18 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::PQ, TT::OX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::PQ, TT::OY));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::PQ, TT::OZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::PQ, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::PQ, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::PQ, TT::XY));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::QR, TT::OX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::QR, TT::OY));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::QR, TT::OZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::QR, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::QR, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::QR, TT::XY));
+  
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::RP, TT::OX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::RP, TT::OY));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::RP, TT::OZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::RP, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::RP, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentEdgeIntersection(TT::RP, TT::XY));
+
+  // segment - corner (12 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::PQ, TT::O));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::PQ, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::PQ, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::PQ, TT::Z));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::QR, TT::O));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::QR, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::QR, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::QR, TT::Z));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::RP, TT::O));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::RP, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::RP, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentCornerIntersection(TT::RP, TT::Z));
+
+  // surface-ray (3 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSurfaceRayIntersection(TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSurfaceRayIntersection(TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSurfaceRayIntersection(TT::Z));
+  
+  // segment-halfstrip (9 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentHalfstripIntersection(TT::PQ, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentHalfstripIntersection(TT::PQ, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentHalfstripIntersection(TT::PQ, TT::XY));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentHalfstripIntersection(TT::QR, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentHalfstripIntersection(TT::QR, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentHalfstripIntersection(TT::QR, TT::XY));
+  
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentHalfstripIntersection(TT::RP, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentHalfstripIntersection(TT::RP, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(true , tri1->testSegmentHalfstripIntersection(TT::RP, TT::XY));
+  
+  // segment-ray (9 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentRayIntersection(TT::PQ, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentRayIntersection(TT::PQ, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentRayIntersection(TT::PQ, TT::Z));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentRayIntersection(TT::QR, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentRayIntersection(TT::QR, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentRayIntersection(TT::QR, TT::Z));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentRayIntersection(TT::RP, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentRayIntersection(TT::RP, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testSegmentRayIntersection(TT::RP, TT::Z));
+
+  // corner in tetrahedron (3 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testCornerInTetrahedron(TT::P));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testCornerInTetrahedron(TT::Q));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testCornerInTetrahedron(TT::R));
+  
+  // corner on XYZ facet (3 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testCornerOnXYZFacet(TT::P));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testCornerOnXYZFacet(TT::Q));
+  CPPUNIT_ASSERT_EQUAL(false, tri1->testCornerOnXYZFacet(TT::R));
+
+}
+
+
+// -- Tests intersections for triangle 2
+// The positive tests are for intersections of type segment-edge (SgE), segment-corner (SC),
+// surface-edge (SE), and segment-facet (SF) according to the tables :
+//
+// (SgE) :
+// Segment / Edge   OX  OY  OZ  YZ  ZX  XY  
+// PQ               no  no  no  no  no  yes
+// QR               no  no  no  no  no  no 
+// RP               no  no  no  no  no  no
+//
+// (SC) : 
+// Segment / Corner O   X   Y   Z
+// PQ               no  no  no  no
+// QR               no  yes no  no
+// RP               no  no  no  no
+//
+// (SE) : 
+// Edge  Intersection 
+// OX        yes       <-- it seems this is ok according to Grandy, p. 439 (one triple product is zero)
+// OY        no
+// OZ        yes
+// YZ        no
+// ZX        yes       <-- it seems this is ok according to Grandy, p. 439 (one triple product is zero)
+// XY        no
+//
+// (SF) : 
+// Segment / Facet  OZX   OYZ  OXY   XYZ
+// PQ               no    yes  no    no
+// QR               no    no   no    no
+// RP               no    no   no    no
+//
+
+
+
+void TransformedTriangleIntersectTest::testTriangle2()
+{
+
+    typedef TransformedTriangle TT;
+
+  // run all intersection tests and ensure that the ones
+  // listed with yes in the tables above return true and 
+  // that the ones listed with no or not listed at all return false
+
+  // surface-edge (6 possibilities)
+  CPPUNIT_ASSERT_EQUAL(true , tri2->testSurfaceEdgeIntersection(TT::OX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSurfaceEdgeIntersection(TT::OY));
+  CPPUNIT_ASSERT_EQUAL(true , tri2->testSurfaceEdgeIntersection(TT::OZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSurfaceEdgeIntersection(TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(true , tri2->testSurfaceEdgeIntersection(TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSurfaceEdgeIntersection(TT::XY));
+
+  // segment-facet (9 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentFacetIntersection(TT::PQ, TT::OZX));
+  CPPUNIT_ASSERT_EQUAL(true , tri2->testSegmentFacetIntersection(TT::PQ, TT::OYZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentFacetIntersection(TT::PQ, TT::OXY));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentFacetIntersection(TT::PQ, TT::XYZ));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentFacetIntersection(TT::QR, TT::OZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentFacetIntersection(TT::QR, TT::OYZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentFacetIntersection(TT::QR, TT::OXY));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentFacetIntersection(TT::QR, TT::XYZ));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentFacetIntersection(TT::RP, TT::OZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentFacetIntersection(TT::RP, TT::OYZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentFacetIntersection(TT::RP, TT::OXY));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentFacetIntersection(TT::RP, TT::XYZ));
+
+  // segment-edge (18 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::PQ, TT::OX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::PQ, TT::OY));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::PQ, TT::OZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::PQ, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::PQ, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(true , tri2->testSegmentEdgeIntersection(TT::PQ, TT::XY));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::QR, TT::OX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::QR, TT::OY));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::QR, TT::OZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::QR, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::QR, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::QR, TT::XY));
+  
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::RP, TT::OX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::RP, TT::OY));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::RP, TT::OZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::RP, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::RP, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentEdgeIntersection(TT::RP, TT::XY));
+
+  // segment - corner (12 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentCornerIntersection(TT::PQ, TT::O));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentCornerIntersection(TT::PQ, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentCornerIntersection(TT::PQ, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentCornerIntersection(TT::PQ, TT::Z));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentCornerIntersection(TT::QR, TT::O));
+  CPPUNIT_ASSERT_EQUAL(true , tri2->testSegmentCornerIntersection(TT::QR, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentCornerIntersection(TT::QR, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentCornerIntersection(TT::QR, TT::Z));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentCornerIntersection(TT::RP, TT::O));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentCornerIntersection(TT::RP, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentCornerIntersection(TT::RP, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentCornerIntersection(TT::RP, TT::Z));
+
+  // surface-ray (3 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSurfaceRayIntersection(TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSurfaceRayIntersection(TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSurfaceRayIntersection(TT::Z));
+  
+  // segment-halfstrip (9 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentHalfstripIntersection(TT::PQ, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentHalfstripIntersection(TT::PQ, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentHalfstripIntersection(TT::PQ, TT::XY));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentHalfstripIntersection(TT::QR, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentHalfstripIntersection(TT::QR, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentHalfstripIntersection(TT::QR, TT::XY));
+  
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentHalfstripIntersection(TT::RP, TT::YZ));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentHalfstripIntersection(TT::RP, TT::ZX));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentHalfstripIntersection(TT::RP, TT::XY));
+  
+  // segment-ray (9 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentRayIntersection(TT::PQ, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentRayIntersection(TT::PQ, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentRayIntersection(TT::PQ, TT::Z));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentRayIntersection(TT::QR, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentRayIntersection(TT::QR, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentRayIntersection(TT::QR, TT::Z));
+
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentRayIntersection(TT::RP, TT::X));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentRayIntersection(TT::RP, TT::Y));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testSegmentRayIntersection(TT::RP, TT::Z));
+
+  // corner in tetrahedron (3 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testCornerInTetrahedron(TT::P));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testCornerInTetrahedron(TT::Q));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testCornerInTetrahedron(TT::R));
+  
+  // corner on XYZ facet (3 possibilities)
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testCornerOnXYZFacet(TT::P));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testCornerOnXYZFacet(TT::Q));
+  CPPUNIT_ASSERT_EQUAL(false, tri2->testCornerOnXYZFacet(TT::R));
+
+}
diff --git a/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.hxx b/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.hxx
new file mode 100644 (file)
index 0000000..8f6980c
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef __TU_TRANSFORMED_TRIANGLE_INTERSECT_HXX__
+#define __TU_TRANSFORMED_TRIANGLE_INTERSECT_HXX__
+
+#include <cppunit/extensions/HelperMacros.h>
+#include "../TransformedTriangle.hxx"
+
+#define ERR_TOL 1.0e-8
+
+using INTERP_UTILS::TransformedTriangle;
+
+class TransformedTriangleIntersectTest : public CppUnit::TestFixture
+{
+
+  CPPUNIT_TEST_SUITE( TransformedTriangleIntersectTest );
+  CPPUNIT_TEST( testTriangle1 );
+  CPPUNIT_TEST( testTriangle2 );
+  CPPUNIT_TEST_SUITE_END();
+
+  typedef INTERP_UTILS::TransformedTriangle::TriSegment TriSegment;
+  typedef INTERP_UTILS::TransformedTriangle::DoubleProduct DoubleProduct;
+
+public:
+  void setUp();
+
+  void tearDown();
+
+  void testTriangle1();
+  
+  void testTriangle2();
+
+private:
+  TransformedTriangle* tri1;
+  TransformedTriangle* tri2;
+
+};
+
+
+
+
+
+
+
+
+#endif
index 1295ef198f386507c662d79719a6ee1d22410aa5..1605bd6b9b02271522a7133d936aac8941675771 100644 (file)
@@ -20,7 +20,7 @@ void TransformedTriangleTest::setUp()
   Hq1 = 1 - q1[0] - q1[1];
   Hr1 = 1 - r1[0] - r1[1];
 
-  std::cout <<std::endl<< "constructing tri1..." << std::endl;
+  //  std::cout <<std::endl<< "constructing tri1..." << std::endl;
   tri1 = new TransformedTriangle(p1, q1, r1);
  
 
@@ -43,7 +43,7 @@ void TransformedTriangleTest::setUp()
   Hp2 = 1 - p2[0] - p2[1];
   Hq2 = 1 - q2[0] - q2[1];
   Hr2 = 1 - r2[0] - r2[1];
-  std::cout <<std::endl<< "constructing tri2..." << std::endl;
+  //  std::cout <<std::endl<< "constructing tri2..." << std::endl;
   tri2 = new TransformedTriangle(p2, q2, r2);
   
   
@@ -171,8 +171,8 @@ void TransformedTriangleTest::test_calcUnstableT()
       for(int row = 1 ; row < 4 ; ++row)
        {
          const double t = tri1->calcTByDevelopingRow(corner, row, false);
-         std::cout << std::endl  << " Corner = " << corner  << " Row = " << row << " got: " << t << 
-           " expected: " << correct_t_vals[corner]<< std::endl;
+         //      std::cout << std::endl  << " Corner = " << corner  << " Row = " << row << " got: " << t << 
+         //  " expected: " << correct_t_vals[corner]<< std::endl;
          CPPUNIT_ASSERT_DOUBLES_EQUAL(correct_t_vals[corner], t, ERR_TOL);       
        }
     }
@@ -248,7 +248,7 @@ void TransformedTriangleTest::test_calcStableC_Consistency()
              // formula : ( (Q-P) x (P - corner) )^2 / norm(Q-P)^2
            
              const double ptP[3] = { tri2->_coords[5*seg], tri2->_coords[5*seg + 1], tri2->_coords[5*seg + 2] };
-             const double ptQ[3] = { tri2->_coords[5*(seg+1 % 3)], tri2->_coords[5*(seg+1 % 3) + 1], tri2->_coords[5*(seg+1 % 3) + 2] };
+             const double ptQ[3] = { tri2->_coords[5*( (seg+1) % 3)], tri2->_coords[5*( (seg+1) % 3) + 1], tri2->_coords[5*( (seg+1) % 3) + 2] };
              const double ptCorner[3] = { 
                corner == TransformedTriangle::X ? 1.0 : 0.0,
                corner == TransformedTriangle::Y ? 1.0 : 0.0,
@@ -287,7 +287,7 @@ void TransformedTriangleTest::test_calcStableC_Consistency()
          for(int i = 0; i < 3 ; ++i) 
            {
              DoubleProduct dp = DOUBLE_PRODUCTS[3*min_corner + i];
-             std::cout << std::endl << "in test inconsistent (seg,dp) :(" << seg <<", " << dp << ")" << std::endl;
+             //              std::cout << std::endl << "in test inconsistent (seg,dp) :(" << seg <<", " << dp << ")" << std::endl;
              CPPUNIT_ASSERT_EQUAL(0.0, tri2->calcStableC(seg, dp));
              correct_c_vals[8*seg + dp] = 0.0;
            }