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