From: vbd Date: Thu, 13 Sep 2007 09:10:20 +0000 (+0000) Subject: staffan : X-Git-Tag: trio_trio_coupling~41 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e60abbc6773c5f44ddbfedb018b282dc381a6131;p=tools%2Fmedcoupling.git staffan : * changed namespace of ProjectedCircularSortOrder --- diff --git a/src/INTERP_KERNEL/Interpolation3D.cxx b/src/INTERP_KERNEL/Interpolation3D.cxx index f243e979d..d91e853cd 100644 --- a/src/INTERP_KERNEL/Interpolation3D.cxx +++ b/src/INTERP_KERNEL/Interpolation3D.cxx @@ -3,6 +3,8 @@ #include "TransformedTriangle.hxx" //#include "VectorUtils.hxx" #include "IntersectorTetra.hxx" +#include "IntersectorHexa.hxx" +#include "TargetIntersector.hxx" #include "Log.hxx" @@ -175,14 +177,31 @@ namespace MEDMEM // maybe this is not ideal ... const int targetIdx = targetElement->getIndex(); - IntersectorTetra intersector(srcMesh, targetMesh, targetIdx); + + TargetIntersector* intersector; + + switch(targetElement->getType()) + { + case MED_TETRA4: + intersector = new IntersectorTetra(srcMesh, targetMesh, targetIdx); + break; + + case MED_HEXA8: + intersector = new IntersectorHexa(srcMesh, targetMesh, targetIdx); + break; + + default: + assert(false); + } + + for(vector::const_iterator iter = currNode->getSrcRegion().getBeginElements() ; iter != currNode->getSrcRegion().getEndElements() ; ++iter) { const int srcIdx = (*iter)->getIndex(); - const double vol = intersector.intersectSourceCell(srcIdx); + const double vol = intersector->intersectSourceCell(srcIdx); if(vol != 0.0) { @@ -191,6 +210,8 @@ namespace MEDMEM } } + + delete intersector; } else // recursion diff --git a/src/INTERP_KERNEL/Interpolation3D.hxx b/src/INTERP_KERNEL/Interpolation3D.hxx index 8bdf51b40..c89b36523 100644 --- a/src/INTERP_KERNEL/Interpolation3D.hxx +++ b/src/INTERP_KERNEL/Interpolation3D.hxx @@ -15,8 +15,7 @@ typedef std::vector< std::map< int, double > > IntersectionMatrix; namespace INTERP_UTILS { - class MeshElement; - class MeshRegion; + class MeshTestToolkit; }; class Interpolation3DTest; @@ -29,11 +28,8 @@ namespace MEDMEM */ class Interpolation3D : public Interpolation { - - friend class ::Interpolation3DTest; - - - public : + public: + // friend class INTERP_UTILS::MeshTestToolkit; Interpolation3D(); virtual ~Interpolation3D(); diff --git a/src/INTERP_KERNEL/Intersector.hxx b/src/INTERP_KERNEL/Intersector.hxx index bee248d85..55785eff5 100644 --- a/src/INTERP_KERNEL/Intersector.hxx +++ b/src/INTERP_KERNEL/Intersector.hxx @@ -3,10 +3,10 @@ namespace MEDMEM { - class Intersector + class TargetIntersector { public: - virtual ~Intersector() {} + virtual ~TargetIntersector() {} /** * Calculate the volume of the intersection of two cells diff --git a/src/INTERP_KERNEL/Makefile.in b/src/INTERP_KERNEL/Makefile.in index 7550eb131..1e21f76d9 100644 --- a/src/INTERP_KERNEL/Makefile.in +++ b/src/INTERP_KERNEL/Makefile.in @@ -52,10 +52,11 @@ Interpolation3DSurf.hxx\ InterpolationUtils.hxx\ BBTree.H\ MeshUtils.hxx\ -Intersector3D.hxx\ Log.hxx\ TransformedTriangle_inline.hxx\ -IntersectorTetra.hxx +IntersectorTetra.hxx\ +TargetIntersector.hxx\ +IntersectorHexa.hxx # Libraries targets @@ -72,10 +73,10 @@ RegionNode.cxx\ BoundingBox.cxx\ TetraAffineTransform.cxx\ Interpolation3D.cxx\ -Intersector3D.cxx\ Interpolation3DSurf.cxx\ Interpolation2D.cxx\ -IntersectorTetra.cxx +IntersectorTetra.cxx\ +IntersectorHexa.cxx # Executables targets BIN = @@ -83,7 +84,7 @@ BIN_SRC = BIN_SERVER_IDL = BIN_CLIENT_IDL = -TEST_PROGS = testUnitTetra +TEST_PROGS = testUnitTetra test_a_mesh LDFLAGS+= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome LDFLAGSFORBIN+= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome diff --git a/src/INTERP_KERNEL/MeshUtils.hxx b/src/INTERP_KERNEL/MeshUtils.hxx index 9677a5444..431371840 100644 --- a/src/INTERP_KERNEL/MeshUtils.hxx +++ b/src/INTERP_KERNEL/MeshUtils.hxx @@ -12,6 +12,24 @@ using namespace MED_EN; namespace INTERP_UTILS { + /** + * Returns the global number of the node of an element. + * (1 <= node <= #nodes of element) + * + * @param node the node for which the global number is sought + * @param element an element of the mesh + * @param mesh a mesh + * @return the node's global number (its coordinates in the coordinates array are at [3*globalNumber, 3*globalNumber + 2] + */ + inline int getGlobalNumberOfNode(int node, int element, const MESH& mesh) + { + assert(node >= 1); + assert(node <= mesh.getNumberOfNodes()); + const int nodeOffset = node - 1; + const int elemIdx = mesh.getConnectivityIndex(MED_NODAL, MED_CELL)[element - 1] - 1; + return mesh.getConnectivity(MED_FULL_INTERLACE, MED_NODAL, MED_CELL, MED_ALL_ELEMENTS)[elemIdx + nodeOffset] - 1; + } + /** * Returns the coordinates of a node of an element * (1 <= node <= #nodes) @@ -43,23 +61,7 @@ namespace INTERP_UTILS return static_cast(type) - 300; } - /** - * Returns the global number of the node of an element. - * (1 <= node <= #nodes of element) - * - * @param node the node for which the global number is sought - * @param element an element of the mesh - * @param mesh a mesh - * @return the node's global number (its coordinates in the coordinates array are at [3*globalNumber, 3*globalNumber + 2] - */ - inline int getGlobalNumberOfNode(int node, int element, const MESH& mesh) - { - assert(node >= 1); - assert(node <= mesh.getNumberOfNodes()); - const int nodeOffset = node - 1; - const int elemIdx = mesh.getConnectivityIndex(MED_NODAL, MED_CELL)[element - 1] - 1; - return mesh.getConnectivity(MED_FULL_INTERLACE, MED_NODAL, MED_CELL, MED_ALL_ELEMENTS)[elemIdx + nodeOffset] - 1; - } + }; diff --git a/src/INTERP_KERNEL/Test/Interpolation3DTest.cxx b/src/INTERP_KERNEL/Test/Interpolation3DTest.cxx index 6429f864f..65dc3eff1 100644 --- a/src/INTERP_KERNEL/Test/Interpolation3DTest.cxx +++ b/src/INTERP_KERNEL/Test/Interpolation3DTest.cxx @@ -59,7 +59,7 @@ void Interpolation3DTest::getVolumes(MESH& mesh, const double*& tab) const SUPPORT *sup=new SUPPORT(&mesh,"dummy",MED_CELL); FIELD* f=mesh.getVolume(sup); tab = f->getValue(); - // delete sup; + delete sup; } double Interpolation3DTest::sumVolume(const IntersectionMatrix& m) const @@ -117,6 +117,7 @@ bool Interpolation3DTest::testVolumes(const IntersectionMatrix& m, MESH& sMesh, } delete[] sVol; delete[] tVol; + return ok; } diff --git a/src/INTERP_KERNEL/Test/Interpolation3DTest.hxx b/src/INTERP_KERNEL/Test/Interpolation3DTest.hxx index b5350a315..58b9afd6b 100644 --- a/src/INTERP_KERNEL/Test/Interpolation3DTest.hxx +++ b/src/INTERP_KERNEL/Test/Interpolation3DTest.hxx @@ -1,5 +1,5 @@ -#ifndef __TU_INTERPOLATION_3D_HXX__ -#define __TU_INTERPOLATION_3D_HXX__ +#ifndef __TU_INTERPOLATION_3D_TEST_SUITE_HXX__ +#define __TU_INTERPOLATION_3D_TEST_SUITE_HXX__ #include #include "../Interpolation3D.hxx" @@ -9,247 +9,23 @@ using MEDMEM::Interpolation3D; class MEDMEM::MESH; -class Interpolation3DTest : public CppUnit::TestFixture +class Interpolation3DTestSuite : public CppUnit::TestFixture { - // single - element - CPPUNIT_TEST_SUITE( Interpolation3DTest ); - - CPPUNIT_TEST( tetraReflexiveUnit ); - CPPUNIT_TEST( tetraReflexiveGeneral ); - - CPPUNIT_TEST( tetraNudgedSimpler ); - CPPUNIT_TEST( tetraNudged ); - CPPUNIT_TEST( tetraCorner ); - CPPUNIT_TEST( tetraSimpleIncluded ); - CPPUNIT_TEST( tetraDegenEdge ); - CPPUNIT_TEST( tetraDegenFace ); - CPPUNIT_TEST( tetraDegenTranslatedInPlane ); - CPPUNIT_TEST( tetraHalfstripOnly ); - CPPUNIT_TEST( tetraHalfstripOnly2 ); - CPPUNIT_TEST( tetraSimpleHalfstripOnly ); - CPPUNIT_TEST( generalTetra ); - CPPUNIT_TEST( trickyTetra1 ); - CPPUNIT_TEST( inconsistentTetra ); - - - // multi - element - - CPPUNIT_TEST( tetraComplexIncluded ); - - CPPUNIT_TEST( dividedUnitTetraSimplerReflexive ); - CPPUNIT_TEST( dividedUnitTetraReflexive ); - - CPPUNIT_TEST( nudgedDividedUnitTetra ); - CPPUNIT_TEST( nudgedDividedUnitTetraSimpler ); - CPPUNIT_TEST( dividedGenTetra ); - CPPUNIT_TEST( boxReflexive ); - CPPUNIT_TEST( boxReflexiveModerate ); - CPPUNIT_TEST( tetraBoxes ); - CPPUNIT_TEST( moderateBoxes ); - - CPPUNIT_TEST( moderateBoxesSmaller ); - CPPUNIT_TEST( moderateBoxSmallReflexive ); - - CPPUNIT_TEST( moderateBoxEvenSmallerReflexive ); - CPPUNIT_TEST( tinyBoxReflexive ); - - CPPUNIT_TEST( simpleHexaBox ); - - CPPUNIT_TEST_SUITE_END(); - - public: - void setUp(); - - void tearDown(); - - // tests - - void tetraReflexiveUnit() - { - intersectMeshes("meshes/UnitTetra.med", "UnitTetra", "meshes/UnitTetra.med", "UnitTetra", 1.0/6.0); - } - - void tetraReflexiveGeneral() - { - intersectMeshes("meshes/GeneralTetra.med", "GeneralTetra", "meshes/GeneralTetra.med", "GeneralTetra", 0.428559); - } - - void tetraNudgedSimpler() - { - intersectMeshes("meshes/UnitTetra.med", "UnitTetra", "meshes/NudgedSimpler.med", "NudgedSimpler", 0.152112); - } - - void tetraNudged() - { - intersectMeshes("meshes/UnitTetra.med", "UnitTetra", "meshes/NudgedTetra.med", "NudgedTetra", 0.142896); - } - - void tetraCorner() - { - intersectMeshes("meshes/UnitTetra.med", "UnitTetra", "meshes/CornerTetra.med", "CornerTetra", 0.0135435); - } - - void tetraSimpleIncluded() - { - intersectMeshes("meshes/SimpleIncludedTetra.med", "SimpleIncludedTetra", "meshes/SimpleIncludingTetra.med", "SimpleIncludingTetra", 17.0156); - } - - void tetraComplexIncluded() - { - intersectMeshes("meshes/ComplexIncludedTetra.med", "ComplexIncludedTetra", "meshes/ComplexIncludingTetra.med", "ComplexIncludingTetra", 17.0156); - } - - void tetraHalfstripOnly() - { - // NB this test is not completely significant : we should also verify that - // there are triangles on the element that give a non-zero volume - intersectMeshes("meshes/HalfstripOnly.med", "HalfstripOnly", "meshes/UnitTetra.med", "UnitTetra", 0.0); - } - - void tetraHalfstripOnly2() - { - // NB this test is not completely significant : we should also verify that - // there are triangles on the element that give a non-zero volume - intersectMeshes("meshes/HalfstripOnly2.med", "HalfstripOnly2", "meshes/UnitTetra.med", "UnitTetra", 0.0); - } - - void tetraSimpleHalfstripOnly() - { - // NB this test is not completely significant : we should also verify that - // there are triangles on the element that give a non-zero volume - intersectMeshes("meshes/SimpleHalfstripOnly.med", "SimpleHalfstripOnly", "meshes/UnitTetra.med", "UnitTetra", 0.0); - } - - void generalTetra() - { - intersectMeshes("meshes/GenTetra1.med", "GenTetra1", "meshes/GenTetra2.med", "GenTetra2", 4.91393); - } - - void trickyTetra1() - { - intersectMeshes("meshes/UnitTetra.med", "UnitTetra", "meshes/TrickyTetra1.med", "TrickyTetra1", 0.0); - } - - void inconsistentTetra() - { - intersectMeshes("meshes/LargeUnitTetra.med", "LargeUnitTetra", "meshes/LargeInconsistentTetra.med", "LargeInconsistent", 7.86231e7); - } - - - void tetraDegenEdge() - { - intersectMeshes("meshes/UnitTetraDegenT.med", "UnitTetraDegenT", "meshes/DegenEdgeXY.med", "DegenEdgeXY", 0.0); - } - - void tetraDegenFace() - { - intersectMeshes("meshes/UnitTetraDegenT.med", "UnitTetraDegenT", "meshes/DegenFaceXYZ.med", "DegenFaceXYZ", 0.0); - } - - void tetraDegenTranslatedInPlane() - { - intersectMeshes("meshes/UnitTetraDegenT.med", "UnitTetraDegenT", "meshes/DegenTranslatedInPlane.med", "DegenTranslatedInPlane", 0.0571667); - } - - void dividedUnitTetraReflexive() - { - intersectMeshes("meshes/DividedUnitTetra.med", "DividedUnitTetra", "meshes/DividedUnitTetra.med", "DividedUnitTetra", 0.1666667); - } - - void dividedUnitTetraSimplerReflexive() - { - intersectMeshes("meshes/DividedUnitTetraSimpler.med", "DividedUnitTetraSimpler", "meshes/DividedUnitTetraSimpler.med", "DividedUnitTetraSimpler", 0.1666667); - } - - void nudgedDividedUnitTetra() + void setUp() { - intersectMeshes("meshes/NudgedDividedUnitTetra.med", "NudgedDividedUnitTetra", "meshes/DividedUnitTetra.med", "DividedUnitTetra", 0.150191); + _testTools = new MeshTestToolkit(); } - void nudgedDividedUnitTetraSimpler() + void tearDown() { - intersectMeshes("meshes/NudgedDividedUnitTetraSimpler.med", "NudgedDividedUnitTetraSimpler", "meshes/DividedUnitTetraSimpler.med", "DividedUnitTetraSimpler", 0.150191); + delete _testTools; } - void dividedGenTetra() - { - intersectMeshes("meshes/DividedGenTetra1.med", "DividedGenTetra1", "meshes/DividedGenTetra2.med", "DividedGenTetra2", 0.546329); - } - - void boxReflexive() - { - intersectMeshes("meshes/Box3.med", "Box3", "meshes/Box3.med", "Box3", 13.9954); - } - - void boxReflexiveModerate() - { - intersectMeshes("meshes/Box1Moderate.med", "Box1Moderate", "meshes/Box1Moderate.med", "Box1Moderate", 1.0e6); - } - - void tetraBoxes() - { - intersectMeshes("meshes/Box1.med", "Box1", "meshes/Box2.med", "Box2", 124.197); - } - - void moderateBoxes() - { - intersectMeshes("meshes/Box1Moderate.med", "Box1Moderate", "meshes/Box2Moderate.med", "Box2Moderate", 376856); - } - - void moderateBoxesSmaller() - { - intersectMeshes("meshes/BoxModSmall1.med", "BoxModSmall1", "meshes/BoxModSmall2.med", "BoxModSmall2", 321853); - } - - void moderateBoxSmallReflexive() - { - intersectMeshes("meshes/BoxModSmall1.med", "BoxModSmall1", "meshes/BoxModSmall1.med", "BoxModSmall1", 1.44018e6); - } - - void moderateBoxEvenSmallerReflexive() - { - intersectMeshes("meshes/BoxEvenSmaller1.med", "BoxEvenSmaller1", "meshes/BoxEvenSmaller1.med", "BoxEvenSmaller1", 1.44018e6); - } - - void tinyBoxReflexive() - { - intersectMeshes("meshes/TinyBox.med", "TinyBox", "meshes/TinyBox.med", "TinyBox", 979200); - } - - void simpleHexaBox() - { - intersectMeshes("meshes/BoxHexa1.med", "BoxHexa1", "meshes/BoxTetra2.med", "BoxTetra2", 65250, 1.0e-5, false); - } - -private: - - Interpolation3D* interpolator; - - double sumRow(const IntersectionMatrix& m, int i) const; - - double sumCol(const IntersectionMatrix& m, int i) const; - - void getVolumes( MEDMEM::MESH& mesh,const double*& tab) const; - - bool testVolumes(const IntersectionMatrix& m, MEDMEM::MESH& sMesh, MEDMEM::MESH& tMesh) const; - - double sumVolume(const IntersectionMatrix& m) const; - - bool areCompatitable( const IntersectionMatrix& m1, const IntersectionMatrix& m2) const; - - bool testSymmetric(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const; - - bool testDiagonal(const IntersectionMatrix& m) const; - - void dumpIntersectionMatrix(const IntersectionMatrix& m) const; - - // 1.0e-5 here is due to limited precision of "correct" volumes calculated in Salome - void intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec = 1.0e-5, bool doubleTest = true) const; - - void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const; +protected: + MeshToolkit* _testTools; }; diff --git a/src/INTERP_KERNEL/Test/Makefile.in b/src/INTERP_KERNEL/Test/Makefile.in index 8d235922d..9e8f49910 100644 --- a/src/INTERP_KERNEL/Test/Makefile.in +++ b/src/INTERP_KERNEL/Test/Makefile.in @@ -37,8 +37,13 @@ VPATH=.:@srcdir@:@top_srcdir@/idl EXPORT_HEADERS = CppUnitTest.hxx \ TransformedTriangleTest.hxx \ TransformedTriangleIntersectTest.hxx \ - Interpolation3DTest.hxx \ - TestingUtils.hxx + Interpolation3DTestSuite.hxx \ + SingleElementTetraTests.hxx \ + MultiElementTetraTests.hxx \ + HexaTests.hxx\ + MeshTestToolkit.hxx + + # Libraries targets @@ -50,10 +55,11 @@ LIB_CLIENT_IDL = # Executables targets -BIN = PerfTest TestInterpKernel +TEST_PROGS = TestInterpKernel + +BIN = PerfTest -BIN_SRC = CppUnitTest.cxx TransformedTriangleTest.cxx TransformedTriangleIntersectTest.cxx \ -Interpolation3DTest.cxx +BIN_SRC = CppUnitTest.cxx TransformedTriangleTest.cxx TransformedTriangleIntersectTest.cxx MeshTestToolkit.cxx BIN_CLIENT_IDL = diff --git a/src/INTERP_KERNEL/Test/PerfTest.cxx b/src/INTERP_KERNEL/Test/PerfTest.cxx index f72c0e883..9b3abcd1f 100644 --- a/src/INTERP_KERNEL/Test/PerfTest.cxx +++ b/src/INTERP_KERNEL/Test/PerfTest.cxx @@ -1,10 +1,57 @@ #include "Interpolation3D.hxx" -#include "TestingUtils.hxx" +#include "MeshTestToolkit.hxx" +#include "Log.hxx" + +#include "MEDMEM_Mesh.hxx" + #include #include +using namespace MEDMEM; +using namespace MED_EN; + +namespace INTERP_UTILS +{ + class PerfTestToolkit : public MeshTestToolkit + { + + public: + void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) + { + const string dataDir = getenv("DATA_DIR"); + + LOG(1, std::endl << "=== -> intersecting src = " << mesh1 << ", target = " << mesh2 ); + + LOG(5, "Loading " << mesh1 << " from " << mesh1path); + const MESH sMesh(MED_DRIVER, dataDir+mesh1path, mesh1); + const int numSrcElems = sMesh.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); + LOG(1, "Source mesh has " << numSrcElems << " elements"); + + + LOG(5, "Loading " << mesh2 << " from " << mesh2path); + const MESH tMesh(MED_DRIVER, dataDir+mesh2path, mesh2); + const int numTargetElems = tMesh.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); + + LOG(1, "Target mesh has " << numTargetElems << " elements"); + + m = _interpolator->interpol_maillages(sMesh, tMesh); + + std::pair eff = countNumberOfMatrixEntries(m); + LOG(1, eff.first << " of " << numTargetElems * numSrcElems << " intersections calculated : ratio = " + << double(eff.first) / double(numTargetElems * numSrcElems)); + LOG(1, eff.second << " non-zero elements of " << eff.first << " total : filter efficiency = " + << double(eff.second) / double(eff.first)); + + LOG(1, "Intersection calculation done. " << std::endl ); + + } + }; +} + int main(int argc, char** argv) { + using INTERP_UTILS::PerfTestToolkit; + assert(argc == 3); // load meshes @@ -16,10 +63,13 @@ int main(int argc, char** argv) IntersectionMatrix m; - calcIntersectionMatrix(mesh1path.c_str(), mesh1.c_str(), mesh2path.c_str(), mesh2.c_str(), m); + PerfTestToolkit testTools; - // dumpIntersectionMatrix(m); - + testTools.calcIntersectionMatrix(mesh1path.c_str(), mesh1.c_str(), mesh2path.c_str(), mesh2.c_str(), m); + + testTools.dumpIntersectionMatrix(m); + return 0; } + diff --git a/src/INTERP_KERNEL/Test/TestInterpKernel.cxx b/src/INTERP_KERNEL/Test/TestInterpKernel.cxx index 1d3948c66..7611f8329 100644 --- a/src/INTERP_KERNEL/Test/TestInterpKernel.cxx +++ b/src/INTERP_KERNEL/Test/TestInterpKernel.cxx @@ -21,12 +21,17 @@ #include "CppUnitTest.hxx" #include "TransformedTriangleTest.hxx" #include "TransformedTriangleIntersectTest.hxx" -#include "Interpolation3DTest.hxx" +#include "MultiElementTetraTests.hxx" +#include "SingleElementTetraTests.hxx" +#include "HexaTests.hxx" + +using namespace INTERP_UTILS; // --- Registers the fixture into the 'registry' -//CPPUNIT_TEST_SUITE_REGISTRATION( Interpolation3DTestMultiElement ); -CPPUNIT_TEST_SUITE_REGISTRATION( Interpolation3DTest ); -//CPPUNIT_TEST_SUITE_REGISTRATION( TransformedTriangleIntersectTest ); +//CPPUNIT_TEST_SUITE_REGISTRATION( HexaTests ); +//CPPUNIT_TEST_SUITE_REGISTRATION( MultiElementTetraTests ); +//CPPUNIT_TEST_SUITE_REGISTRATION( SingleElementTetraTests ); +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 index 7ac217231..6245d9fa8 100644 --- a/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx +++ b/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx @@ -3,6 +3,20 @@ #include "Log.hxx" +#ifdef OPTIMIZE +#define TEST_ZERO_DP_EDGE(seg, edge) isZero[TT::NO_DP*int(seg) + int(DoubleProduct(edge))] +#define TEST_ZERO_DP_CORNER(seg, corner) \ +isZero[DoubleProduct(TT::NO_DP*int(seg) + TT::EDGES_FOR_CORNER[3*corner] )] && \ +isZero[DoubleProduct(TT::NO_DP*int(seg) + TT::EDGES_FOR_CORNER[3*corner+1] )] && \ +isZero[DoubleProduct(TT::NO_DP*int(seg) + TT::EDGES_FOR_CORNER[3*corner+2] )] +#define TEST_ZERO_DP_RAY(seg, corner) isZero[TT::NO_DP*int(seg) + TT::DP_SEGMENT_RAY_INTERSECTION[7*(corner-1)]] +#else + +#define TEST_ZERO_DP_EDGE(seg, edge) true +#define TEST_ZERO_DP_CORNER(seg, corner) true +#define TEST_ZERO_DP_RAY(seg, corner) true +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////// // Intersection tests // Each method in this file runs all the intersection tests with some triangle. The goal is to cover all @@ -113,6 +127,19 @@ void TransformedTriangleIntersectTest::testTriangle1() // listed with yes in the tables above return true and // that the ones listed with no or not listed at all return false +#ifdef OPTIMIZE + bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; + + for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) + { + // check beforehand which double-products are zero + for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) + { + isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); + } + } +#endif + // corner in tetrahedron (3 possibilities) CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); @@ -145,42 +172,42 @@ void TransformedTriangleIntersectTest::testTriangle1() 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, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && 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, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && 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)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); // segment-halfstrip (9 possibilities) CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); @@ -196,17 +223,17 @@ void TransformedTriangleIntersectTest::testTriangle1() 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, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && 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, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && 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)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); // surface-edge (6 possibilities) CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); @@ -254,6 +281,19 @@ void TransformedTriangleIntersectTest::testTriangle2() // listed with yes in the tables above return true and // that the ones listed with no or not listed at all return false + #ifdef OPTIMIZE + bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; + + for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) + { + // check beforehand which double-products are zero + for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) + { + isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); + } + } +#endif + // corner in tetrahedron (3 possibilities) CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); @@ -286,42 +326,42 @@ void TransformedTriangleIntersectTest::testTriangle2() 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, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); + + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && 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, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && 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)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); + CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); // segment-halfstrip (9 possibilities) CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); @@ -335,18 +375,19 @@ void TransformedTriangleIntersectTest::testTriangle2() 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, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, 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)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); + + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); + CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); // surface-edge (6 possibilities) CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OX)); diff --git a/src/INTERP_KERNEL/TransformedTriangle.cxx b/src/INTERP_KERNEL/TransformedTriangle.cxx index f9e8059a5..69c5c6c88 100644 --- a/src/INTERP_KERNEL/TransformedTriangle.cxx +++ b/src/INTERP_KERNEL/TransformedTriangle.cxx @@ -569,7 +569,7 @@ namespace INTERP_UTILS { LOG(3,"--- Sorting polygon ..."); - using ::ProjectedCentralCircularSortOrder; + using INTERP_UTILS::ProjectedCentralCircularSortOrder; typedef ProjectedCentralCircularSortOrder SortOrder; // change is only necessary here and in constructor typedef SortOrder::CoordType CoordType;