From 07fa87a47bdf942cfd98f0f7f31fc40a77e739a7 Mon Sep 17 00:00:00 2001 From: vbd Date: Tue, 7 Aug 2007 09:32:53 +0000 Subject: [PATCH] Staffan : Wrote more tests --- .../Test/Interpolation3DTest.cxx | 55 +- .../Test/Interpolation3DTest.hxx | 31 +- src/INTERP_KERNEL/Test/TestInterpKernel.cxx | 7 +- .../Test/TransformedTriangleIntersectTest.cxx | 2199 +++++++++++++++-- .../Test/TransformedTriangleIntersectTest.hxx | 41 +- 5 files changed, 2088 insertions(+), 245 deletions(-) diff --git a/src/INTERP_KERNEL/Test/Interpolation3DTest.cxx b/src/INTERP_KERNEL/Test/Interpolation3DTest.cxx index 3da899fd9..a1ec7bfc4 100644 --- a/src/INTERP_KERNEL/Test/Interpolation3DTest.cxx +++ b/src/INTERP_KERNEL/Test/Interpolation3DTest.cxx @@ -6,8 +6,11 @@ #include #include +#include "VectorUtils.hxx" + using namespace MEDMEM; using namespace std; +using namespace INTERP_UTILS; double Interpolation3DTest::sumVolume(IntersectionMatrix m) { @@ -22,6 +25,37 @@ double Interpolation3DTest::sumVolume(IntersectionMatrix m) return vol; } +bool Interpolation3DTest::isReflexive(IntersectionMatrix m1, IntersectionMatrix m2) +{ + int i = 0; + bool isReflexive = true; + for(IntersectionMatrix::const_iterator iter = m1.begin() ; iter != m1.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + int j = iter2->first; + const double v1 = iter2->second; + if(m2[j - 1].count(i+1) > 0) + { + const double v2 = m2[j - 1][i + 1]; + if(!epsilonEqual(v1, v2)) + { + std::cout << "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << std::endl; + isReflexive = false; + } + } + else + { + std::cout << "V2( " << iter2->first - 1 << ", " << i + 1 << ") " << " does not exist" << std::endl; + isReflexive = false; + } + } + ++i; + } + return isReflexive; +} + + //? this is not a good test bool Interpolation3DTest::isIntersectionConsistent(IntersectionMatrix m) { bool res = true; @@ -56,6 +90,7 @@ void Interpolation3DTest::dumpIntersectionMatrix(IntersectionMatrix m) } ++i; } + std::cout << "Sum of volumes = " << sumVolume(m) << std::endl << std::endl; } void Interpolation3DTest::setUp() @@ -108,7 +143,7 @@ void Interpolation3DTest::calcIntersectionMatrix(const char* mesh1path, const ch std::cout << "Intersection calculation done. " << std::endl << std::endl; } -void Interpolation3DTest::intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol) +void Interpolation3DTest::intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec) { std::cout << std::endl << std::endl << "=============================" << std::endl; @@ -122,8 +157,18 @@ void Interpolation3DTest::intersectMeshes(const char* mesh1path, const char* mes dumpIntersectionMatrix(matrix2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, sumVolume(matrix1), 1.0e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, sumVolume(matrix2), 1.0e-6); + bool reflexive = isReflexive(matrix1, matrix2); + + const double vol1 = sumVolume(matrix1); + const double vol2 = sumVolume(matrix2); + + std::cout.precision(8); + std::cout << "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol << std::endl; + + //CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, 1.0e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec); + CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec); + CPPUNIT_ASSERT_EQUAL(true, reflexive); } @@ -141,8 +186,8 @@ void Interpolation3DTest::tetraTetraScale() std::cout << std::endl << "*** target - src" << std::endl; IntersectionMatrix matrix2 = interpolator->interpol_maillages(targetMesh, srcMesh); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75, sumVolume(matrix1), 1.0e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75, sumVolume(matrix2), 1.0e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75, sumVolume(matrix1), 1.0e-6 ); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75, sumVolume(matrix2), 1.0e-6 ); } diff --git a/src/INTERP_KERNEL/Test/Interpolation3DTest.hxx b/src/INTERP_KERNEL/Test/Interpolation3DTest.hxx index 5f8b18e72..6500f12c7 100644 --- a/src/INTERP_KERNEL/Test/Interpolation3DTest.hxx +++ b/src/INTERP_KERNEL/Test/Interpolation3DTest.hxx @@ -12,17 +12,23 @@ class Interpolation3DTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( Interpolation3DTest ); - + CPPUNIT_TEST( tetraReflexiveUnit ); CPPUNIT_TEST( tetraReflexiveGeneral ); CPPUNIT_TEST( tetraNudgedSimpler ); CPPUNIT_TEST( tetraNudged ); CPPUNIT_TEST( tetraCorner ); + CPPUNIT_TEST( tetraHalfstripOnly ); CPPUNIT_TEST( tetraHalfstripOnly2 ); CPPUNIT_TEST( tetraSimpleHalfstripOnly ); + CPPUNIT_TEST( generalTetra ); + CPPUNIT_TEST( dividedUnitTetraReflexive ); +#if 0 + CPPUNIT_TEST( boxReflexive ); CPPUNIT_TEST( tetraBoxes ); +#endif //CPPUNIT_TEST( tetraTetraScale ); // CPPUNIT_TEST( box1 ); // CPPUNIT_TEST( cyl1 ); @@ -85,10 +91,27 @@ public: intersectMeshes("meshes/SimpleHalfstripOnly.med", "SimpleHalfstripOnly", "meshes/UnitTetra.med", "UnitTetra", 0.0); } + void generalTetra() + { + intersectMeshes("meshes/GenTetra1.med", "GenTetra1", "meshes/GenTetra2.med", "GenTetra2", 4.91393, 1.0e-5); + } + + void dividedUnitTetraReflexive() + { + intersectMeshes("meshes/DividedUnitTetra.med", "DividedUnitTetra", "meshes/DividedUnitTetra.med", "DividedUnitTetra", 0.1666667); + } + + void boxReflexive() + { + intersectMeshes("meshes/Box3.med", "Box3", "meshes/Box3.med", "Box3", 13.9954, 1.0e-4); + } + void tetraBoxes() { - intersectMeshes("meshes/Box1.med", "Box1", "meshes/Box2.med", "Box2", 124.197); + intersectMeshes("meshes/Box1.med", "Box1", "meshes/Box2.med", "Box2", 124.197, 1.0e-3); } + + #if 0 void tetraHalfstripOnly() @@ -182,12 +205,14 @@ private: Interpolation3D* interpolator; double sumVolume(IntersectionMatrix m); + + bool Interpolation3DTest::isReflexive(IntersectionMatrix m1, IntersectionMatrix m2); bool isIntersectionConsistent(IntersectionMatrix m); void dumpIntersectionMatrix(IntersectionMatrix m); - void intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol); + void intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec = 1.0e-6); void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m); diff --git a/src/INTERP_KERNEL/Test/TestInterpKernel.cxx b/src/INTERP_KERNEL/Test/TestInterpKernel.cxx index 44b3925aa..b3242825c 100644 --- a/src/INTERP_KERNEL/Test/TestInterpKernel.cxx +++ b/src/INTERP_KERNEL/Test/TestInterpKernel.cxx @@ -25,11 +25,10 @@ // --- Registers the fixture into the 'registry' -CPPUNIT_TEST_SUITE_REGISTRATION( Interpolation3DTest ); - +//CPPUNIT_TEST_SUITE_REGISTRATION( Interpolation3DTest ); CPPUNIT_TEST_SUITE_REGISTRATION( TransformedTriangleIntersectTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( TransformedTriangleTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( TestBogusClass ); +//CPPUNIT_TEST_SUITE_REGISTRATION( TransformedTriangleTest ); +//CPPUNIT_TEST_SUITE_REGISTRATION( TestBogusClass ); // --- generic Main program from KERNEL_SRC/src/Basics/Test diff --git a/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx b/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx index fa7702942..3b8de2139 100644 --- a/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx +++ b/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx @@ -1,315 +1,2058 @@ #include "TransformedTriangleIntersectTest.hxx" #include +//////////////////////////////////////////////////////////////////////////////////////////////////////// +// Intersection tests +// Each method in this file runs all the intersection tests with some triangle. The goal is to cover all +// the different types of intersections between a triangle and a tetrahedron. The table below gives a +// a summary of what is being tested. Before each method, there is also a summary of what how the +// triangle in the method intersects the unit tetrahedron. +// +// Since performing all tests would require a large number of triangles, we have limited our coverage to +// be such that each column and each row in the table below has at least one entry for each type of +// intersection. The intersection forumlae are totally symmetric with respect to changing the segment +// (PQ, QR, or RP) of the triangle, so they only enter in a very simple way in the code. Testing +// all these cases is therefore of low priority. +//////////////////////////////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////////// +// Intersections tested (number indicates first triangle which contains the intersection): +// ----------------------------------------------------------------------------------------------------- +// CI -> P: 3 Q: 4 R: 7 +// COH -> P: 9 Q: 8 R: 10 +// CAH -> P: 4 Q: 10 R: 9 +// ----------------------------------------------------------------------------------------------------- +// SF -> (PQ, OZX) : 1 (PQ, OYZ) : 2 (PQ, OXY) : 1 (PQ, XYZ) : 3 +// -> (QR, OZX) : 8 (QR, OYZ) : - (QR, OXY) : 4 (QR, XYZ) : 7 +// -> (RP, OZX) : 1 (RP, OYZ) : 3 (RP, OXY) : 7 (RP, XYZ) : 1 +// ----------------------------------------------------------------------------------------------------- +// SE -> (PQ, OX) : 11 (PQ, OY) : - (PQ, OZ) : 12 (PQ, XY) : 2 (PQ, ZX) : - (PQ, YZ) : 10 +// -> (QR, OX) : - (QR, OY) : - (QR, OZ) : - (QR, XY) : - (QR, ZX) : 9 (QR, YZ) : - +// -> (RP, OX) : - (RP, OY) : 12 (RP, OZ) : - (RP, XY) : - (RP, ZX) : - (RP, YZ) : - +// ----------------------------------------------------------------------------------------------------- +// SC -> (PQ, O) : - (PQ, X) : - (PQ, Y) : 8 (PQ, Z) : - +// -> (QR, O) : - (QR, X) : 2 (QR, Y) : - (QR, Z) : 13 +// -> (RP, O) : 11 (RP, X) : - (RP, Y) : - (RP, Z) : - +// ----------------------------------------------------------------------------------------------------- +// SHS -> (PQ, XY) : 3 (PQ, ZX) : - (PQ, YZ) : 13 +// -> (QR, XY) : 3 (QR, ZX) : 5 (QR, YZ) : 3 +// -> (RP, XY) : 1 (RP, ZX) : 4 (RP, YZ) : - +// ----------------------------------------------------------------------------------------------------- +// SR -> (PQ, X) : 6 (PQ, Y) : 5 (PQ, Z) : - +// -> (QR, X) : - (QR, Y) : - (QR, Z) : 6 +// -> (RP, X) : - (RP, Y) : - (RP, Z) : - +// ----------------------------------------------------------------------------------------------------- +// TE -> OX : 4 OY : 7 OZ : 8 XY : 1 ZX : 4 YZ : 3,7 +// ----------------------------------------------------------------------------------------------------- +// TR -> X : 7 Y : 6 Z : 5 +// ----------------------------------------------------------------------------------------------------- +//////////////////////////////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////////// +// Key to triangle descriptions : +// CI = Triangle corner contained in tetrahedron +// COH = Triangle corner on h = 0 face of tetrahedron +// CAH = Triangle corner above h = 0 face of tetrahedron in z-direction +// SF = Segment - facet intersection +// SE = Segment - edge intersection +// SC = Segment - corner intersection +// SHS = Segment - halfstrip intersection +// SR = Segment - ray intersection +// TE = Tetrahedron edge intersects triangle (surface - edge intersection) +// TR = Surface - ray intersection +// +// In the descriptions for each triangle, square brackets indicate superfluous but allowed intersections +// that arise as by-products of for instance segment-corner intersections. +// E.g. A segment - corner intersection can imply three surface - edge intersections +// Since these "extra" intersections arise under special circumstances, they are not counted in the +// table above +//////////////////////////////////////////////////////////////////////////////////////////////////////// -void TransformedTriangleIntersectTest::setUp() + +//////////////////////////////////////////////////////////////////////////////////////////////////////// + +// Triangle 1 has the following intersections +// CI - +// COH - +// CAH - +// SF (PQ, OXY), (PQ, OZX), (RP, XYZ), (RP, OZX) +// SE - +// SC - +// SHS (RP, XY) +// SR - +// TE XY +// TR - + +void TransformedTriangleIntersectTest::testTriangle1() { - double coords1[9] = + typedef TransformedTriangle TT; + + double coords[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]); + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + + // 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 + + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); + + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); + + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; + +} + +// Triangle 2 has the following intersections +// CI - +// COH - +// CAH - +// SF (PQ, OYZ) +// SE (PQ, XY) +// SC (QR, X) +// SHS - +// SR - +// TE [OX, OZ, ZX] +// TR - + +void TransformedTriangleIntersectTest::testTriangle2() +{ + + typedef TransformedTriangle TT; - double coords2[9] = + double coords[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]); + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + + // 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 + + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); -} + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); -void TransformedTriangleIntersectTest::tearDown() -{ - delete tri1; - delete tri2; + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); + + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; } -// -- 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 +// Triangle 3 has the following intersections +// CI P +// COH - +// CAH - +// SF (PQ, XYZ), (RP, OYZ) +// SE - +// SC - +// SHS (PQ, XY), (QR, YZ), (QR, XY) +// SR - +// TE YZ +// TR - -void TransformedTriangleIntersectTest::testTriangle1() +void TransformedTriangleIntersectTest::testTriangle3() { - typedef TransformedTriangle TT; + + typedef TransformedTriangle TT; + + double coords[9] = + { + 0.35, 0.15, 0.1, // P + 0.8, 0.8, 0.8, // Q + -0.4, 0.3, 0.9 // R + }; + + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // 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)); + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); + + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); // 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, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(true , tri->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(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, 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, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - 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)); + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, 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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, 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)); - + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, 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, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->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(true , tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->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, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; +} + +// Triangle 4 has the following intersections +// CI Q +// COH - +// CAH P +// SF (PQ, XYZ), (QR, OXY) +// SE - +// SC - +// SHS (RP, ZX) +// SR - +// TE (OX, ZX) +// TR - + +void TransformedTriangleIntersectTest::testTriangle4() +{ + + typedef TransformedTriangle TT; + + double coords[9] = + { + 0.3, 0.3, 1.8, // P + 0.75, 0.1, 0.1, // Q + 0.2, -1.3, -1.4 // R + }; - 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)); + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - 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)); + // 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 // 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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); -} + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); -// -- 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 -// + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); -void TransformedTriangleIntersectTest::testTriangle2() + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; +} + +// Triangle 5 has the following intersections +// CI - +// COH - +// CAH - +// SF - +// SE - +// SC - +// SHS (QR, ZX), (QR, XY) +// SR (PQ, Y) +// TE - +// TR Z + +void TransformedTriangleIntersectTest::testTriangle5() { typedef TransformedTriangle TT; + double coords[9] = + { + -0.5, 0.5, 2.3, // P + 0.5, 1.5, 2.8, // Q + 0.5, -2.6, 1.3 // R + }; + + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + // 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)); + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); + + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); // 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, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->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, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->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, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(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, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); // 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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; +} + +// Triangle 6 has the following intersections +// CI - +// COH - +// CAH - +// SF - +// SE - +// SC - +// SHS - +// SR (PQ, X), (QR, XY) +// TE - +// TR Y + +void TransformedTriangleIntersectTest::testTriangle6() +{ + + typedef TransformedTriangle TT; + + double coords[9] = + { + 1.5, 0.5, 1.35, // P + 0.5, -0.5, 2.1, // Q + -3.0, 3.0, -0.5 // R + }; + + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + + // 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 + + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); + + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); + + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, 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, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->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, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->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(true , tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; +} + +// Triangle 7 has the following intersections +// CI R +// COH - +// CAH - +// SF (RP, OXY),(QR,XYZ) +// SE - +// SC - +// SHS (QR, XY) +// SR - +// TE OX, ZX +// TR X + +void TransformedTriangleIntersectTest::testTriangle7() +{ + + typedef TransformedTriangle TT; + + double coords[9] = + { + -2.3, -1.5, -2.5, // P + 3.1, 0.15, 0.8, // Q + 0.3, 0.4, 0.2 // R + }; + + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - 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)); + // 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 // 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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(true , tri->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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); + + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; +} + +// Triangle 8 has the following intersections +// CI [Q] +// COH Q +// CAH - +// SF (QR, OZX), [ (QR, XYZ) ] +// SE - +// SC (PQ,Y) +// SHS - +// SR - +// TE OZ, [YZ,OY,XY] +// TR - + +void TransformedTriangleIntersectTest::testTriangle8() +{ + + typedef TransformedTriangle TT; + + double coords[9] = + { + -0.75, 3.25, -1.5, // P + 0.25, 0.25, 0.5, // Q + -0.1, -0.4, 0.9 // R + }; + + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + + // 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 + + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); + + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); + + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; +} + +// Triangle 9 has the following intersections +// CI [P] +// COH P +// CAH R +// SF (PQ, OZX), [(PQ, XYZ), (RP,XYZ)] +// SE (QR, ZX) +// SC - +// SHS - +// SR - +// TE [ZX] +// TR - + +void TransformedTriangleIntersectTest::testTriangle9() +{ + + typedef TransformedTriangle TT; + + double coords[9] = + { + 0.6, 0.2, 0.2, // P + 0.3, -0.2, 0.8, // Q + 0.1, 0.2, 0.8 // R + }; + + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + + // 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 + + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); + + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerAboveXYZFacet(TT::R)); + + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; +} + +// Triangle 10 has the following intersections +// CI [R] +// COH R +// CAH Q +// SF (RP, OYZ), [ (RP, XYZ), (QR, XYZ) ] +// SE (PQ, YZ) +// SC - +// SHS - +// SR - +// TE [YZ] +// TR - + +void TransformedTriangleIntersectTest::testTriangle10() +{ + + typedef TransformedTriangle TT; + + double coords[9] = + { + -0.1, 0.3, 0.6, // P + 0.1, 0.1, 1.0, // Q + 0.4, 0.3, 0.3 // R + }; + + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + + // 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 + + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::R)); + + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); + + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; +} + +// Triangle 11 has the following intersections +// CI Q, R +// COH - +// CAH - +// SF - +// SE (PQ, OX) +// SC (RP, O) +// SHS - +// SR - +// TE [OY] +// TR - + +void TransformedTriangleIntersectTest::testTriangle11() +{ + + typedef TransformedTriangle TT; + + double coords[9] = + { + -0.2, -0.2, -0.2, // P + 0.2, 0.1, 0.1, // Q + 0.3, 0.3, 0.3 // R + }; + + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + + // 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 + + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::R)); + + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); + + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; +} + + +// Triangle 12 has the following intersections +// CI - +// COH - +// CAH - +// SF (QR, OXY), (QR, OZX) +// SE (RP, OY), (PQ, OZ) +// SC - +// SHS - +// SR - +// TE [OY], [OZ] +// TR - + +void TransformedTriangleIntersectTest::testTriangle12() +{ + + typedef TransformedTriangle TT; + + double coords[9] = + { + -0.2, 0.2, 0.2, // P + 0.2, -0.2, 0.3, // Q + 0.6, 0.6, -0.6 // R + }; + + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + + // 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 + + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); + + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); + + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; +} + + +// Triangle 13 has the following intersections +// CI - +// COH - +// CAH - +// SF (QR, OYZ), (PQ, OXY), (PQ, XYZ) +// SE - +// SC (QR, Z) +// SHS (PQ, YZ) +// SR - +// TE [OZ, YZ, ZX] +// TR - + +void TransformedTriangleIntersectTest::testTriangle13() +{ + + typedef TransformedTriangle TT; + + double coords[9] = + { + -0.2, 0.3, 5.0, // P + 0.2, 0.1, -1.0, // Q + -0.2, -0.1, 3.0 // R + }; + + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + + // 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 + + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); + + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); + + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; +} + + + + + + + + + + +///// TEMPLATE /////////////////////////////// + + + +#if 0 +// Triangle x has the following intersections +// CI - +// COH - +// CAH - +// SF - +// SE - +// SC - +// SHS - +// SR - +// TE - +// TR - + +void TransformedTriangleIntersectTest::testTriangleX() +{ + + typedef TransformedTriangle TT; + + double coords[9] = + { + 0.0, 0.0, 0.0, // P + 0.0, 0.0, 0.0, // Q + 0.0, 0.0, 0.0 // R + }; + + TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + + // 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 + + // corner in tetrahedron (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); + + // corner on XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); + + // corner above XYZ facet (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); + CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); + + // segment-facet (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); + + // segment-edge (18 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); + + // segment - corner (12 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); + + // segment-halfstrip (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); + + // segment-ray (9 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); + + // surface-edge (6 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); + + // surface-ray (3 possibilities) + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); + delete tri; } +#endif diff --git a/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.hxx b/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.hxx index 8f6980cc9..5ade43944 100644 --- a/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.hxx +++ b/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.hxx @@ -14,24 +14,55 @@ class TransformedTriangleIntersectTest : public CppUnit::TestFixture CPPUNIT_TEST_SUITE( TransformedTriangleIntersectTest ); CPPUNIT_TEST( testTriangle1 ); CPPUNIT_TEST( testTriangle2 ); + CPPUNIT_TEST( testTriangle3 ); + CPPUNIT_TEST( testTriangle4 ); + CPPUNIT_TEST( testTriangle5 ); + CPPUNIT_TEST( testTriangle6 ); + CPPUNIT_TEST( testTriangle7 ); + CPPUNIT_TEST( testTriangle8 ); + CPPUNIT_TEST( testTriangle9 ); + CPPUNIT_TEST( testTriangle10 ); + CPPUNIT_TEST( testTriangle11 ); + CPPUNIT_TEST( testTriangle12 ); + CPPUNIT_TEST( testTriangle13 ); CPPUNIT_TEST_SUITE_END(); typedef INTERP_UTILS::TransformedTriangle::TriSegment TriSegment; typedef INTERP_UTILS::TransformedTriangle::DoubleProduct DoubleProduct; public: - void setUp(); + // void setUp(); - void tearDown(); + // void tearDown(); void testTriangle1(); void testTriangle2(); -private: - TransformedTriangle* tri1; - TransformedTriangle* tri2; + void testTriangle3(); + + void testTriangle4(); + + void testTriangle5(); + + void testTriangle6(); + + void testTriangle7(); + + void testTriangle8(); + void testTriangle9(); + + void testTriangle10(); + + void testTriangle11(); + + void testTriangle12(); + + void testTriangle13(); + +private: + }; -- 2.39.2