From: ageay Date: Fri, 13 Feb 2009 19:44:19 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: EndIntegAG1302^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=938834e85dfefa404d31c1290e8e0be78c423c1a;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/INTERP_KERNEL/Test/BBTreeTest.cxx b/src/INTERP_KERNEL/Test/BBTreeTest.cxx deleted file mode 100644 index 85661913f..000000000 --- a/src/INTERP_KERNEL/Test/BBTreeTest.cxx +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "BBTreeTest.hxx" -#include -#include -namespace INTERP_TEST -{ - - - void BBTreeTest::setUp() - { - } - - - void BBTreeTest::tearDown() - { - } - - /** - * Test that creates a tree in 2D and check that - * the results are correct in three - * cases : - * a non matching search - * a standard case - * a bbox overlapping the bboxes of the tree - */ - void BBTreeTest::test_BBTree() { - //bbox tree creation - const int N=10; - double* bbox=new double[4*N*N]; - for (int i=0; i tree(bbox,0,0,N*N); - std::vector elems; - - //box outside the tree - double bbox1[4]={-2.0, -1.0, 0.0, 1.0}; - tree.getIntersectingElems(bbox1,elems); - CPPUNIT_ASSERT_EQUAL(0,(int)elems.size()); - elems.clear(); - - //box intersecting 4 tree elems - double bbox2[4]={2.5, 3.5, 0.5, 1.5}; - tree.getIntersectingElems(bbox2,elems); - CPPUNIT_ASSERT_EQUAL(4,(int)elems.size()); - elems.clear(); - - //box exactly superimposed to two tree elems - double bbox3[4]={5.0,6.0,7.0,9.0}; - tree.getIntersectingElems(bbox3,elems); - CPPUNIT_ASSERT_EQUAL(2,(int)elems.size()); - elems.clear(); - - double xx[2]={1.0,1.0}; - tree.getElementsAroundPoint(xx,elems); - CPPUNIT_ASSERT_EQUAL(4,(int)elems.size()); - - delete[] bbox; - } - - -} diff --git a/src/INTERP_KERNEL/Test/BBTreeTest.hxx b/src/INTERP_KERNEL/Test/BBTreeTest.hxx deleted file mode 100644 index 8007e0ba8..000000000 --- a/src/INTERP_KERNEL/Test/BBTreeTest.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __TU_BB_TREE_HXX__ -#define __TU_BB_TREE_HXX__ - -#include -#include "../BBTree.txx" - -namespace INTERP_TEST -{ - - /** - * \brief Test suite testing some of the low level methods of TransformedTriangle. - * - */ - class BBTreeTest : public CppUnit::TestFixture - { - - CPPUNIT_TEST_SUITE( BBTreeTest ); - CPPUNIT_TEST( test_BBTree ); - CPPUNIT_TEST_SUITE_END(); - - - public: - void setUp(); - - void tearDown(); - - // tests - void test_BBTree(); - - }; - - - - -} - - - -#endif diff --git a/src/INTERP_KERNEL/Test/BasicMainTest.hxx b/src/INTERP_KERNEL/Test/BasicMainTest.hxx deleted file mode 100644 index 8220e33a0..000000000 --- a/src/INTERP_KERNEL/Test/BasicMainTest.hxx +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _BASICMAINTEST_HXX_ -#define _BASICMAINTEST_HXX_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// ============================================================================ -/*! - * Main program source for Unit Tests with cppunit package does not depend - * on actual tests, so we use the same for all partial unit tests. - */ -// ============================================================================ - -int main(int argc, char* argv[]) -{ - // --- Create the event manager and test controller - CPPUNIT_NS::TestResult controller; - - // --- Add a listener that colllects test result - CPPUNIT_NS::TestResultCollector result; - controller.addListener( &result ); - - // --- Add a listener that print dots as test run. -#ifdef WIN32 - CPPUNIT_NS::TextTestProgressListener progress; -#else - CPPUNIT_NS::BriefTestProgressListener progress; -#endif - controller.addListener( &progress ); - - // --- Get the top level suite from the registry - - CPPUNIT_NS::Test *suite = - CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); - - // --- Adds the test to the list of test to run - - CPPUNIT_NS::TestRunner runner; - runner.addTest( suite ); - runner.run( controller); - - // --- Print test in a compiler compatible format. - - std::ofstream testFile; - testFile.open("UnitTestsResult", std::ios::out | std::ios::trunc); - //CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr ); - CPPUNIT_NS::CompilerOutputter outputter( &result, testFile ); - outputter.write(); - - // --- Run the tests. - - bool wasSucessful = result.wasSuccessful(); - testFile.close(); - - // --- Return error code 1 if the one of test failed. - - return wasSucessful ? 0 : 1; -} - -#endif diff --git a/src/INTERP_KERNEL/Test/CppUnitTest.cxx b/src/INTERP_KERNEL/Test/CppUnitTest.cxx deleted file mode 100644 index cb37e28cf..000000000 --- a/src/INTERP_KERNEL/Test/CppUnitTest.cxx +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "CppUnitTest.hxx" diff --git a/src/INTERP_KERNEL/Test/CppUnitTest.hxx b/src/INTERP_KERNEL/Test/CppUnitTest.hxx deleted file mode 100644 index 6ebb88e5b..000000000 --- a/src/INTERP_KERNEL/Test/CppUnitTest.hxx +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __TU_TEST_CPPUNIT_HXX__ -#define __TU_TEST_CPPUNIT_HXX__ - -#include - -/** - * \brief Class tested by TestBogusClass : not very useful - */ -class BogusClass { - friend class TestBogusClass; - -public: - BogusClass(double _x) : x(_x) {;} - - double getX() { return x; } - -private: - double x; -}; - -/** - * \brief Class used to figure out CppUnit : not very useful - * - */ -class TestBogusClass : public CppUnit::TestFixture -{ - - CPPUNIT_TEST_SUITE( TestBogusClass ); - CPPUNIT_TEST( test1 ); - CPPUNIT_TEST( test2 ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() { - obj = new BogusClass(3.14); - } - - void tearDown() { - delete obj; - } - - void test1() { - // test something - CPPUNIT_ASSERT(obj->x == 3.14); - CPPUNIT_ASSERT(obj->getX() == obj->x); - } - - void test2() { - // test something else - obj->x += 2.6; - CPPUNIT_ASSERT(obj->getX() > 3.14); - } - -private: - BogusClass* obj; - -}; - - - - - - - - -#endif diff --git a/src/INTERP_KERNEL/Test/HexaTests.hxx b/src/INTERP_KERNEL/Test/HexaTests.hxx deleted file mode 100644 index a7f0adf1e..000000000 --- a/src/INTERP_KERNEL/Test/HexaTests.hxx +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __HEXA_TESTS_HXX_ -#define __HEXA_TESTS_HXX_ - -#include "InterpolationTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class performing intersection tests on meshes with hexahedral elements. - * - */ - class HexaTests : public InterpolationTestSuite<3,3> - { - CPPUNIT_TEST_SUITE( HexaTests ); - - CPPUNIT_TEST( simpleHexaBox ); - //VB : slightly inaccurate so that it triggers a failure of the test - // should be investigated in the future - // CPPUNIT_TEST( reflexiveHexaBox ); - CPPUNIT_TEST( hexaBoxes ); - CPPUNIT_TEST( hexaBoxesMoved ); - - CPPUNIT_TEST_SUITE_END(); - - public: - - /// Intersection between two boxes, aligned with the axes.One has 60 hexahedral elements and the other has 39 tetrahedral elements - /// \brief Status : pass - void simpleHexaBox() - { - _testTools->intersectMeshes("BoxHexa1", "BoxTetra2", 65250, 1.0e-5); - } - - /// Intersection of a box with 60 hexahedral elements with itself - /// \brief Status : pass - void reflexiveHexaBox() - { - _testTools->intersectMeshes("BoxHexa1", "BoxHexa1", 204000); - } - - /// Intersection between two boxes, aligned with the axes.Both have hexahedral elements : one 36, the other 60 - /// \brief Status : pass - void hexaBoxes() - { - _testTools->intersectMeshes("BoxHexa1", "BoxHexa2", 65250); - } - - /// Intersection between two boxes in general position with hexahedral elements. One has 200 elements and the other 420. - /// \brief Status : fails - reason unknown. The matrix does not fulfil the transpose requirement : that W_AB = W_BA^T - void hexaBoxesMoved() - { - _testTools->intersectMeshes("MovedHexaBox1", "MovedHexaBox2", 65250); - } - - }; -} -#endif diff --git a/src/INTERP_KERNEL/Test/Interpolation3DTest.cxx b/src/INTERP_KERNEL/Test/Interpolation3DTest.cxx deleted file mode 100644 index a538c6fdb..000000000 --- a/src/INTERP_KERNEL/Test/Interpolation3DTest.cxx +++ /dev/null @@ -1,348 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "Interpolation3DTest.hxx" -#include "MEDMEM_Mesh.hxx" - -#include -#include -#include -#include -#include - -#include "VectorUtils.hxx" - -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Support.hxx" - -// levels : -// 1 - titles and volume results -// 2 - symmetry / diagonal results and intersection matrix output -// 3 - empty -// 4 - empty -// 5 - misc -#include "Log.hxx" - - -//#define VOL_PREC 1.0e-6 - -using namespace MEDMEM; -using namespace std; -using namespace INTERP_KERNEL; -using namespace MED_EN; - -double Interpolation3DTest::sumRow(const IntersectionMatrix& m, int i) const -{ - double vol = 0.0; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - if(iter->count(i) != 0.0) - { - map::const_iterator iter2 = iter->find(i); - vol += iter2->second; - } - } - return vol; -} - -double Interpolation3DTest::sumCol(const IntersectionMatrix& m, int i) const -{ - double vol = 0.0; - const std::map& col = m[i]; - for(map::const_iterator iter = col.begin() ; iter != col.end() ; ++iter) - { - vol += std::fabs(iter->second); - } - return vol; -} - - -void Interpolation3DTest::getVolumes(MESH& mesh, double* tab) const -{ - SUPPORT *sup=new SUPPORT(&mesh,"dummy",MED_CELL); - FIELD* f=mesh.getVolume(sup); - const double *tabS=f->getValue(); - std::copy(tabS,tabS+mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS),tab) - delete sup; -} - -double Interpolation3DTest::sumVolume(const IntersectionMatrix& m) const -{ - - vector volumes; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - volumes.push_back(iter2->second); - // vol += std::abs(iter2->second); - } - } - - // sum in ascending order to avoid rounding errors - - sort(volumes.begin(), volumes.end()); - const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); - - return vol; -} - -bool Interpolation3DTest::testVolumes(const IntersectionMatrix& m, MESH& sMesh, MESH& tMesh) const -{ - bool ok = true; - - // source elements - double* sVol = new double[sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)]; - getVolumes(sMesh, sVol); - - for(int i = 0; i < sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); ++i) - { - const double sum_row = sumRow(m, i+1); - if(!epsilonEqualRelative(sum_row, sVol[i], VOL_PREC)) - { - LOG(1, "Source volume inconsistent : vol of cell " << i << " = " << sVol[i] << " but the row sum is " << sum_row ); - ok = false; - } - LOG(1, "diff = " <::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) - // { - map theMap = m2.at(j-1); - const double v2 = theMap[i + 1]; - if(v1 != v2) - { - LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 ); - if(!epsilonEqualRelative(v1, v2, VOL_PREC)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isSymmetric = false; - } - } - } - ++i; - } - if(!isSymmetric) - { - LOG(1, "*** matrices are not symmetric"); - } - return isSymmetric; -} - -bool Interpolation3DTest::testDiagonal(const IntersectionMatrix& m) const -{ - LOG(1, "Checking if matrix is diagonal" ); - int i = 1; - bool isDiagonal = true; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - const double vol = iter2->second; - if(vol != 0.0 && (i != j)) - { - LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" ); - if(!epsilonEqual(vol, 0.0, VOL_PREC)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isDiagonal = false; - } - } - } - ++i; - } - if(!isDiagonal) - { - LOG(1, "*** matrix is not diagonal"); - } - return isDiagonal; -} - -void Interpolation3DTest::dumpIntersectionMatrix(const IntersectionMatrix& m) const -{ - int i = 0; - std::cout << "Intersection matrix is " << endl; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - - std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << endl; - - } - ++i; - } - std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; -} - -void Interpolation3DTest::setUp() -{ - interpolator = new Interpolation3D(); -} - -void Interpolation3DTest::tearDown() -{ - delete interpolator; -} - -void Interpolation3DTest::calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const -{ - const string dataBaseDir = getenv("MED_ROOT_DIR"); - const string dataDir = dataBaseDir + "/share/salome/resources/med/"; - - LOG(1, std::endl << "=== -> intersecting src = " << mesh1 << ", target = " << mesh2 ); - - LOG(5, "Loading " << mesh1 << " from " << mesh1path); - MESH sMesh(MED_DRIVER, dataDir+mesh1path, mesh1); - - LOG(5, "Loading " << mesh2 << " from " << mesh2path); - MESH tMesh(MED_DRIVER, dataDir+mesh2path, mesh2); - - m = interpolator->interpolateMeshes(sMesh, tMesh); - - // if reflexive, check volumes - if(strcmp(mesh1path,mesh2path) == 0) - { - const bool row_and_col_sums_ok = testVolumes(m, sMesh, tMesh); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Row or column sums incorrect", true, row_and_col_sums_ok); - } - - LOG(1, "Intersection calculation done. " << std::endl ); - -} - -void Interpolation3DTest::intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const -{ - LOG(1, std::endl << std::endl << "=============================" ); - - using std::string; - const string path1 = string(mesh1path) + string(mesh1); - const string path2 = string(mesh2path) + string(mesh2); - - const bool isTestReflexive = (path1.compare(path2) == 0); - - IntersectionMatrix matrix1; - calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix1); -#endif - - std::cout.precision(16); - - const double vol1 = sumVolume(matrix1); - - if(!doubleTest) - { - LOG(1, "vol = " << vol1 <<" correctVol = " << correctVol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(correctVol, vol1)); - - if(isTestReflexive) - { - CPPUNIT_ASSERT_EQUAL_MESSAGE("Reflexive test failed", true, testDiagonal(matrix1)); - } - } - else - { - - IntersectionMatrix matrix2; - calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix2); -#endif - - const double vol2 = sumVolume(matrix2); - - LOG(1, "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol ); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(vol1, correctVol)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec * std::max(vol2, correctVol)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, prec * std::max(vol1, vol2)); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Symmetry test failed", true, testSymmetric(matrix1, matrix2)); - } - -} - - - diff --git a/src/INTERP_KERNEL/Test/Interpolation3DTest.hxx b/src/INTERP_KERNEL/Test/Interpolation3DTest.hxx deleted file mode 100644 index 77984859e..000000000 --- a/src/INTERP_KERNEL/Test/Interpolation3DTest.hxx +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __TU_INTERPOLATION_3D_TEST_HXX__ -#define __TU_INTERPOLATION_3D_TEST_HXX__ - -#include -#include "../Interpolation3D.hxx" - -#define ERR_TOL 1.0e-8 - -using MEDMEM::Interpolation3D; -class MEDMEM::MESH; - -/// \brief OBSOLETE - renamed Interpolation3DTestSuite -class Interpolation3DTest : public CppUnit::TestFixture -{ - -public: - void setUp() - { - _testTools = new MeshTestToolkit(); - } - - void tearDown() - { - delete _testTools; - } - -protected: - - MeshToolkit* _testTools; - -}; - -#endif diff --git a/src/INTERP_KERNEL/Test/InterpolationOptionsTest.cxx b/src/INTERP_KERNEL/Test/InterpolationOptionsTest.cxx deleted file mode 100644 index 6bafcb137..000000000 --- a/src/INTERP_KERNEL/Test/InterpolationOptionsTest.cxx +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "InterpolationOptionsTest.hxx" -#include "MEDNormalizedUnstructuredMesh.hxx" -#include "Interpolation2D.hxx" -#include -#include - -namespace INTERP_TEST -{ - - - void InterpolationOptionsTest::setUp() - { - } - - - void InterpolationOptionsTest::tearDown() - { - } - - /** - * Test that creates a tree in 2D and check that - * the results are correct in three - * cases : - * a non matching search - * a standard case - * a bbox overlapping the bboxes of the tree - */ - void InterpolationOptionsTest::test_InterpolationOptions() { - string sourcename=getenv("MED_ROOT_DIR"); - sourcename +="/share/salome/resources/med/square1.med"; - MEDMEM::MESH source_mesh (MED_DRIVER,sourcename,"Mesh_2"); - - string targetname=getenv("MED_ROOT_DIR"); - targetname +="/share/salome/resources/med/square2.med"; - MEDMEM::MESH target_mesh (MED_DRIVER,targetname,"Mesh_3"); - - MEDMEM::SUPPORT source_support(&source_mesh,"on All support"); - MEDMEM::FIELD source_field(&source_support,1); - double* value=const_cast(source_field.getValue()); - for (int i=0; i target_field(&target_support,1); - double* targetvalue=const_cast(target_field.getValue()); - for (int i=0; i wrap_source_mesh(&source_mesh); - MEDNormalizedUnstructuredMesh<2,2> wrap_target_mesh(&target_mesh); - // Go for interpolation... - INTERP_KERNEL::Interpolation2D myInterpolator; - //optionnal call to parametrize your interpolation. First precision, tracelevel, intersector wanted. - myInterpolator.setPrecision(1e-7); - myInterpolator.setPrintLevel(1); - } - - -} diff --git a/src/INTERP_KERNEL/Test/InterpolationOptionsTest.hxx b/src/INTERP_KERNEL/Test/InterpolationOptionsTest.hxx deleted file mode 100644 index 1507f81e1..000000000 --- a/src/INTERP_KERNEL/Test/InterpolationOptionsTest.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __TU_INTERPOLATIONOPTIONS_HXX__ -#define __TU_INTERPOLATIONOPTIONS_HXX__ - -#include -#include "../InterpolationOptions.hxx" -#include "MEDMEM_Field.hxx" - -namespace INTERP_TEST -{ - - /** - * \brief Test suite testing some of the low level methods of TransformedTriangle. - * - */ - class InterpolationOptionsTest : public CppUnit::TestFixture - { - - CPPUNIT_TEST_SUITE( InterpolationOptionsTest ); - CPPUNIT_TEST( test_InterpolationOptions ); - CPPUNIT_TEST_SUITE_END(); - - - public: - void setUp(); - - void tearDown(); - - // tests - void test_InterpolationOptions(); - - private: - - }; - - - - -} - - - -#endif diff --git a/src/INTERP_KERNEL/Test/InterpolationPlanarTestSuite.hxx b/src/INTERP_KERNEL/Test/InterpolationPlanarTestSuite.hxx deleted file mode 100755 index 729061e46..000000000 --- a/src/INTERP_KERNEL/Test/InterpolationPlanarTestSuite.hxx +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __TU_INTERPOLATION_PLANAR_TEST_SUITE_HXX__ -#define __TU_INTERPOLATION_PLANAR_TEST_SUITE_HXX__ - -#include -#include -#include -#include - -using namespace std; - -namespace INTERP_TEST -{ - - /** - * \brief Base class for planar mesh intersection test suites. - * - */ - class InterpolationPlanarTestSuite : public CppUnit::TestFixture - { - - public: - double _Epsilon; - double _Precision; - - /** - * Sets up the test suite. - * - */ - void setUp() - { - _Epsilon = 1.e-6; - _Precision = 1.e-6; - } - void tearDown() {} - - // bool checkDequesEqual(std::deque< double > deque1, std::deque< double > deque2, double epsilon); - // bool checkVectorsEqual(std::vector< double > Vect1, std::vector< double > Vect2, double epsilon); - // void dequePrintOut(std::deque< double > deque1); - // void vectPrintOut(std::vector< double > vect); - // void tabPrintOut( const double * tab, int size); - - bool checkDequesEqual(std::deque< double > deque1, - std::deque< double > deque2, double epsilon) - { - int size1 = deque1.size(); - int size2 = deque2.size(); - bool are_equal = size1 == size2; - - if(are_equal) - for(int i = 0; i < size1 && are_equal; i++) - are_equal = fabs(deque1[i] - deque2[i]) < epsilon; - - return are_equal; - } - bool checkVectorsEqual(std::vector< double > vect1, - std::vector< double > vect2, double epsilon) - { - int size1 = vect1.size(); - int size2 = vect2.size(); - bool are_equal = size1 == size2; - - if(are_equal) - for(int i = 0; i < size1 && are_equal; i++) - are_equal = fabs(vect1[i] - vect2[i]) < epsilon; - - return are_equal; - } - void dequePrintOut(std::deque< double > deque1) - { - for(int i = 0; i< (int)deque1.size(); i++) - { - std::cerr << deque1[i] << " "; - } - std::cerr<< endl; - } - void vectPrintOut(std::vector< double > vect) - { - for(int i = 0; i< (int)vect.size(); i++) - { - std::cerr << vect[i] << " "; - } - std::cerr<< endl; - } - void tabPrintOut( const double * tab,int size) - { - for(int i = 0; i< size; i++) - { - std::cerr << tab[i] << " "; - } - std::cerr<< endl; - } - - /** - * Cleans up after the test suite. - * Liberates the MeshTestToolkit object used by the tests. - */ - // void tearDown() - // { - // delete _testTools; - // } - - - - // protected: - // /// MeshTestToolkit object to which the tests are delegated - // MeshTestToolkit* _testTools; - - }; -} -#endif diff --git a/src/INTERP_KERNEL/Test/InterpolationTestSuite.hxx b/src/INTERP_KERNEL/Test/InterpolationTestSuite.hxx deleted file mode 100644 index a1151c754..000000000 --- a/src/INTERP_KERNEL/Test/InterpolationTestSuite.hxx +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __TU_INTERPOLATION_TEST_SUITE_HXX__ -#define __TU_INTERPOLATION_TEST_SUITE_HXX__ - -#include "MeshTestToolkit.txx" - -#include - -namespace INTERP_TEST -{ - - /** - * \brief Base class for mesh intersection test suites. - * - */ - template - class InterpolationTestSuite : public CppUnit::TestFixture - { - - public: - /** - * Sets up the test suite. - * Creates the MeshTestToolkit object used by the tests. - * - */ - void setUp() - { - _testTools = new MeshTestToolkit(); - } - - /** - * Cleans up after the test suite. - * Liberates the MeshTestToolkit object used by the tests. - */ - void tearDown() - { - delete _testTools; - } - - - - protected: - /// MeshTestToolkit object to which the tests are delegated - MeshTestToolkit* _testTools; - - }; -} -#endif diff --git a/src/INTERP_KERNEL/Test/MEDMeshMaker.cxx b/src/INTERP_KERNEL/Test/MEDMeshMaker.cxx deleted file mode 100644 index 18fd7e873..000000000 --- a/src/INTERP_KERNEL/Test/MEDMeshMaker.cxx +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Meshing.hxx" - -MEDMEM::MESH* MEDMeshMaker(int dim, int nbedge, MED_EN::medGeometryElement type) -{ - MEDMEM::MESHING* mesh=new MEDMEM::MESHING(); - mesh->setSpaceDimension(dim); - int nbnodes; - int nbelems; - switch (dim) - { - case 2: - nbnodes=(nbedge+1)*(nbedge+1); - if(type==MED_EN::MED_QUAD4) - nbelems=(nbedge*nbedge); - else - throw MEDMEM::MEDEXCEPTION("MEDMeshMaker: type not impletmented"); - break; - case 3: - nbnodes=(nbedge+1)*(nbedge+1)*(nbedge+1); - if (type==MED_EN::MED_HEXA8) - nbelems= nbedge*nbedge*nbedge; - else - throw MEDMEM::MEDEXCEPTION("MEDMeshMaker: type not impletmented"); - break; - } - double* coords = new double[dim*nbnodes]; - int nz; - if (dim==2) nz =1; else nz=nbedge+1; - { - for (int ix=0; ix < nbedge+1; ix++) - for (int iy=0; iysetCoordinates(dim, nbnodes,coords,"CARTESIAN",MED_EN::MED_FULL_INTERLACE); - delete [] coords; - mesh->setNumberOfTypes(1,MED_EN::MED_CELL); - mesh->setTypes(&type,MED_EN::MED_CELL); - mesh->setNumberOfElements(&nbelems,MED_EN::MED_CELL); - - int* conn = new int [nbelems*(type%100)]; - if (dim==2) - { - for (int ix=0; ixsetConnectivity(conn, MED_EN::MED_CELL,type); - delete [] conn; - mesh->setMeshDimension(dim); - return mesh; -} diff --git a/src/INTERP_KERNEL/Test/MEDMeshMaker.hxx b/src/INTERP_KERNEL/Test/MEDMeshMaker.hxx deleted file mode 100644 index d06aefd10..000000000 --- a/src/INTERP_KERNEL/Test/MEDMeshMaker.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_define.hxx" -namespace MEDMEM -{ - class MESH; -} - -MEDMEM::MESH* MEDMeshMaker(int dim, int nbedge, MED_EN::medGeometryElement type); diff --git a/src/INTERP_KERNEL/Test/Makefile.am b/src/INTERP_KERNEL/Test/Makefile.am deleted file mode 100644 index 2d4c50b33..000000000 --- a/src/INTERP_KERNEL/Test/Makefile.am +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -lib_LTLIBRARIES = libInterpKernelTest.la - -salomeinclude_HEADERS = CppUnitTest.hxx \ - TransformedTriangleTest.hxx \ - TransformedTriangleIntersectTest.hxx \ - InterpolationTestSuite.hxx \ - SingleElementTetraTests.hxx \ - MultiElementTetraTests.hxx \ - HexaTests.hxx \ - MeshTestToolkit.hxx \ - MeshTestToolkit.txx \ - BBTreeTest.hxx \ - RemapperTest.hxx \ - SingleElementPlanarTests.hxx \ - MultiElement2DTests.hxx \ - InterpolationPlanarTestSuite.hxx \ - UnitTetraIntersectionBaryTest.hxx \ - PointLocatorTest.hxx \ - MEDMeshMaker.hxx \ - QuadraticPlanarInterpTest.hxx - -EXTRA_DIST += \ - BasicMainTest.hxx \ - Interpolation3DTest.cxx \ - Interpolation3DTest.hxx \ - MultiElement3DSurfTests.hxx \ - TestingUtils.hxx \ - perf_test.sh - -CLEANFILES = \ - UnitTestsResult - -dist_libInterpKernelTest_la_SOURCES= \ - CppUnitTest.cxx \ - TransformedTriangleTest.cxx \ - UnitTetraIntersectionBaryTest.cxx \ - TransformedTriangleIntersectTest.cxx \ - BBTreeTest.cxx \ - RemapperTest.cxx \ - SingleElementPlanarTests.cxx \ - PointLocatorTest.cxx \ - MEDMeshMaker.cxx \ - InterpolationOptionsTest.hxx \ - InterpolationOptionsTest.cxx \ - QuadraticPlanarInterpTest.cxx \ - QuadraticPlanarInterpTest2.cxx \ - QuadraticPlanarInterpTest3.cxx \ - QuadraticPlanarInterpTest4.cxx \ - QuadraticPlanarInterpTest5.cxx - -libInterpKernelTest_la_CPPFLAGS = @CPPUNIT_INCLUDES@ $(MED2_INCLUDES) $(HDF5_INCLUDES) \ - -I$(srcdir)/.. -I$(srcdir)/../MEDWrapper/V2_1/Core -I$(srcdir)/../MEDMEM \ - -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Geometric2D \ - -I$(srcdir)/../INTERP_KERNEL/Bases -DOPTIMIZE -DLOG_LEVEL=0 - -libInterpKernelTest_la_LDFLAGS = @CPPUNIT_LIBS@ ../MEDWrapper/V2_1/Core/libmed_V2_1.la \ - ../INTERP_KERNEL/libinterpkernel.la ../INTERP_KERNEL/Geometric2D/libInterpGeometric2DAlg.la \ - ../MEDMEM/libmedmem.la -lm - -if MED_ENABLE_KERNEL - libInterpKernelTest_la_CPPFLAGS += ${KERNEL_CXXFLAGS} - libInterpKernelTest_la_LDFLAGS += ${KERNEL_LDFLAGS} -lSALOMELocalTrace -endif - -# Executables targets -bin_PROGRAMS = TestINTERP_KERNEL \ - PerfTest - -dist_TestINTERP_KERNEL_SOURCES = TestInterpKernel.cxx -dist_PerfTest_SOURCES = PerfTest.cxx - -LDADD = $(MED2_LIBS) $(libInterpKernelTest_la_LDFLAGS) \ - libInterpKernelTest.la -if MED_ENABLE_KERNEL - LDADD += -lSALOMEBasics -endif -AM_CPPFLAGS = $(libInterpKernelTest_la_CPPFLAGS) - -UNIT_TEST_PROG = TestInterpKernel - -check : tests \ No newline at end of file diff --git a/src/INTERP_KERNEL/Test/MeshTestToolkit.hxx b/src/INTERP_KERNEL/Test/MeshTestToolkit.hxx deleted file mode 100644 index 5f6b54a4d..000000000 --- a/src/INTERP_KERNEL/Test/MeshTestToolkit.hxx +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __TU_MESH_TEST_TOOLKIT_HXX__ -#define __TU_MESH_TEST_TOOLKIT_HXX__ - -#include "../Interpolation3D.hxx" -#include "../Interpolation3D.txx" -#include "../InterpolationPlanar.hxx" - -#include -#include - -#define ERR_TOL 1.0e-8 - -typedef std::vector > IntersectionMatrix; - -namespace INTERP_KERNEL -{ - class Interpolation3D; -} - - -namespace MEDMEM { - class MESH; -}; - -namespace INTERP_TEST -{ - /** - * \brief Class providing services for mesh intersection tests. - * - */ - template - class MeshTestToolkit - { - - public: - double _precision; - INTERP_KERNEL::IntersectionType _intersectionType;//Used only in the case MESHDIM==2 (planar intersections) - - MeshTestToolkit():_precision(1.e-6),_intersectionType(INTERP_KERNEL::Triangulation) {} - - ~MeshTestToolkit() {} - - void intersectMeshes(const char* mesh1, const char* mesh2, const double correctVol, const double prec = 1.0e-5, bool doubleTest = true) 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 dumpIntersectionMatrix(const IntersectionMatrix& m) const; - - double sumRow(const IntersectionMatrix& m, int i) const; - - double sumCol(const IntersectionMatrix& m, int i) const; - - void getVolumes( MEDMEM::MESH& mesh, 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 testTranspose(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const; - - bool testDiagonal(const IntersectionMatrix& m) const; - - void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const; - - }; -} -#endif diff --git a/src/INTERP_KERNEL/Test/MeshTestToolkit.txx b/src/INTERP_KERNEL/Test/MeshTestToolkit.txx deleted file mode 100644 index 84bb2df8e..000000000 --- a/src/INTERP_KERNEL/Test/MeshTestToolkit.txx +++ /dev/null @@ -1,509 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDNormalizedUnstructuredMesh.hxx" -#include "MEDNormalizedUnstructuredMesh.txx" - -#include "MeshTestToolkit.hxx" -#include "MEDMEM_Mesh.hxx" - -#include "Interpolation3DSurf.txx" -#include "Interpolation2D.txx" -#include "Interpolation3D.txx" - -#include -#include -#include -#include -#include - -//#include "VectorUtils.hxx" - -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Support.hxx" - -// levels : -// 1 - titles and volume results -// 2 - symmetry / diagonal results and intersection matrix output -// 3 - empty -// 4 - empty -// 5 - misc -#include "Log.hxx" - -#include - -//#define VOL_PREC 1.0e-6 - -using namespace MEDMEM; -using namespace std; -using namespace MED_EN; -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - - /** - * Calculates the sum of a row of an intersection matrix - * - * @param m an intersection matrix - * @param i the index of the row (1 <= i <= no. rows) - * @return the sum of the values of row i - * - */ - template - double MeshTestToolkit::sumRow(const IntersectionMatrix& m, int i) const - { - double vol = 0.0; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - if(iter->count(i) != 0.0) - { - map::const_iterator iter2 = iter->find(i); - vol += fabs(iter2->second); - } - } - return vol; - } - - /** - * Calculates the sum of a column of an intersection matrix - * - * @param m an intersection matrix - * @param i the index of the column (0 <= i <= no. rows - 1) - * @return the sum of the values of column i - * - */ - template - double MeshTestToolkit::sumCol(const IntersectionMatrix& m, int i) const - { - double vol = 0.0; - const std::map& col = m[i]; - for(map::const_iterator iter = col.begin() ; iter != col.end() ; ++iter) - { - vol += fabs(iter->second); - } - return vol; - } - - /** - * Gets the volumes of the elements in a mesh. - * - * @param mesh the mesh - * @param tab pointer to double[no. elements of mesh] array in which to store the volumes - */ - template - void MeshTestToolkit::getVolumes(MEDMEM::MESH& mesh, double* tab) const - { - SUPPORT *sup=new SUPPORT(&mesh,"dummy",MED_CELL); - FIELD* f; - switch (MESHDIM) - { - case 2: - f=mesh.getArea(sup); - break; - case 3: - f=mesh.getVolume(sup); - break; - } - const double *tabS = f->getValue(); - std::copy(tabS,tabS+mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS),tab); - delete sup; - delete f; - } - - /** - * Sums all the elements (volumes) of an intersection matrix - * - * @param m the intersection matrix - * @return the sum of the elements of m - */ - - template - double MeshTestToolkit::sumVolume(const IntersectionMatrix& m) const - { - - vector volumes; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - volumes.push_back(fabs(iter2->second)); - } - } - - // sum in ascending order to avoid rounding errors - - sort(volumes.begin(), volumes.end()); - const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); - - return vol; - } - - /** - * Verifies if for a given intersection matrix the sum of each row is equal to the volumes - * of the corresponding source elements and the sum of each column is equal to the volumes - * of the corresponding target elements. This will be true as long as the meshes correspond - * to the same geometry. The equalities are in the "epsilon-sense", making sure the relative - * error is small enough. - * - * @param m the intersection matrix - * @param sMesh the source mesh - * @param tMesh the target mesh - * @return true if the condition is verified, false if not. - */ - template - bool MeshTestToolkit::testVolumes(const IntersectionMatrix& m, MEDMEM::MESH& sMesh, MEDMEM::MESH& tMesh) const - { - bool ok = true; - - // source elements - double* sVol = new double[sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)]; - getVolumes(sMesh, sVol); - - for(int i = 0; i < sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); ++i) - { - const double sum_row = sumRow(m, i+1); - if(!epsilonEqualRelative(sum_row, fabs(sVol[i]), _precision)) - { - LOG(1, "Source volume inconsistent : vol of cell " << i << " = " << sVol[i] << " but the row sum is " << sum_row ); - ok = false; - } - LOG(1, "diff = " < - bool MeshTestToolkit::testTranspose(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const - { - - int i = 0; - bool isSymmetric = true; - - LOG(1, "Checking symmetry src - target" ); - isSymmetric = isSymmetric & areCompatitable(m1, m2) ; - LOG(1, "Checking symmetry target - src" ); - isSymmetric = isSymmetric & areCompatitable(m2, m1); - - 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 = fabs(iter2->second); - //if(m2[j - 1].count(i+1) > 0) - // { - map theMap = m2.at(j-1); - const double v2 = fabs(theMap[i + 1]); - if(v1 != v2) - { - LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 ); - if(!epsilonEqualRelative(v1, v2, _precision)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isSymmetric = false; - } - } - } - ++i; - } - if(!isSymmetric) - { - LOG(1, "*** matrices are not symmetric"); - } - return isSymmetric; - } - - /** - * Tests if an intersection matrix is diagonal. - * - * @param m the intersection matrix - * @return true if m is diagonal; false if not - * - */ - template - bool MeshTestToolkit::testDiagonal(const IntersectionMatrix& m) const - { - LOG(1, "Checking if matrix is diagonal" ); - int i = 1; - bool isDiagonal = true; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - const double vol = iter2->second; - if(vol != 0.0 && (i != j)) - { - LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" ); - if(!epsilonEqual(vol, 0.0, _precision)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isDiagonal = false; - } - } - } - ++i; - } - if(!isDiagonal) - { - LOG(1, "*** matrix is not diagonal"); - } - return isDiagonal; - } - - /** - * Outputs the intersection matrix as a list of all its elements to std::cout. - * - * @param m the intersection matrix to output - */ - template - void MeshTestToolkit::dumpIntersectionMatrix(const IntersectionMatrix& m) const - { - int i = 0; - std::cout << "Intersection matrix is " << endl; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - - std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << endl; - - } - ++i; - } - std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; - } - - /** - * Calculates the intersection matrix for two meshes. - * If the source and target meshes are the same, a CppUnit assertion raised if testVolumes() returns false. - * - * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh1 the name of the source mesh - * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh2 the name of the target mesh - * @param m intersection matrix in which to store the result of the intersection - */ - template - void MeshTestToolkit::calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const - { - const string dataBaseDir = getenv("MED_ROOT_DIR"); - const string dataDir = dataBaseDir + string("/share/salome/resources/med/"); - - LOG(1, std::endl << "=== -> intersecting src = " << mesh1path << ", target = " << mesh2path ); - - LOG(5, "Loading " << mesh1 << " from " << mesh1path); - MESH sMesh(MED_DRIVER, dataDir+mesh1path, mesh1); - - LOG(5, "Loading " << mesh2 << " from " << mesh2path); - MESH tMesh(MED_DRIVER, dataDir+mesh2path, mesh2); - - MEDNormalizedUnstructuredMesh sMesh_wrapper(&sMesh); - MEDNormalizedUnstructuredMesh tMesh_wrapper(&tMesh); - - if (SPACEDIM==2 && MESHDIM==2) - { - Interpolation2D interpolator; - interpolator.setOptions(_precision, LOG_LEVEL, _intersectionType,1); - interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); - } - else if (SPACEDIM==3 && MESHDIM==2) - { - Interpolation3DSurf interpolator; - interpolator.setOptions(_precision,LOG_LEVEL, 0.5,_intersectionType,false,1); - interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); - } - else if (SPACEDIM==3 && MESHDIM==3) - { - Interpolation3D interpolator; - interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); - } - else - { - throw MEDEXCEPTION("Wrong dimensions"); - } - // if reflexive, check volumes - if(strcmp(mesh1path,mesh2path) == 0) - { - const bool row_and_col_sums_ok = testVolumes(m, sMesh, tMesh); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Row or column sums incorrect", true, row_and_col_sums_ok); - const bool is_diagonal =testDiagonal(m); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Self intersection matrix is not diagonal", true, is_diagonal); - } - - LOG(1, "Intersection calculation done. " << std::endl ); - - } - - /** - * Tests the intersection algorithm for two meshes. - * Depending on the nature of the meshes, different tests will be performed. The sum of the elements will - * be compared to the given total volume of the intersection in all cases. If the two meshes are the same, then - * it will be confirmed that the intersection matrix is diagonal, otherwise the intersection matrices will be - * calculated once which each mesh as source mesh, and it will be verified that the they are each others' transpose. - * - * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh1 the name of the source mesh - * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh2 the name of the target mesh - * @param correctVol the total volume of the intersection of the two meshes - * @param prec maximum relative error to be tolerated in volume comparisions - * @param doubleTest if false, only the test with mesh 1 as the source mesh and mesh 2 as the target mesh will be performed - * - */ - template - void MeshTestToolkit::intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const - { - LOG(1, std::endl << std::endl << "=============================" ); - - using std::string; - const string path1 = string(mesh1path) + string(mesh1); - const string path2 = string(mesh2path) + string(mesh2); - - const bool isTestReflexive = (path1.compare(path2) == 0); - - IntersectionMatrix matrix1; - calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix1); -#endif - - std::cout.precision(16); - - const double vol1 = sumVolume(matrix1); - - if(!doubleTest) - { - LOG(1, "vol = " << vol1 <<" correctVol = " << correctVol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(correctVol, vol1)); - - if(isTestReflexive) - { - CPPUNIT_ASSERT_EQUAL_MESSAGE("Reflexive test failed", true, testDiagonal(matrix1)); - } - } - else - { - - IntersectionMatrix matrix2; - calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix2); -#endif - - const double vol2 = sumVolume(matrix2); - - LOG(1, "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol ); - - CPPUNIT_ASSERT_EQUAL_MESSAGE("Symmetry test failed", true, testTranspose(matrix1, matrix2)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(vol1, correctVol)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec * std::max(vol2, correctVol)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, prec * std::max(vol1, vol2)); - } - - } - - /** - * Utility method used to facilitate the call to intersect meshes. - * It calls intersectMeshes, using "mesh1.med" as file name for the mesh with name "mesh1" and - * "mesh2.med" as file name for the mesh with name "mesh2". The rest of the arguments are passed - * along as they are. - * - * @param mesh1 the name of the source mesh - * @param mesh2 the name of the target mesh - * @param correctVol the total volume of the intersection of the two meshes - * @param prec maximum relative error to be tolerated in volume comparisions - * @param doubleTest if false, only the test with mesh 1 as the source mesh and mesh 2 as the target mesh will be performed - * - */ - template - void MeshTestToolkit::intersectMeshes(const char* mesh1, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const - { - const string path1 = string(mesh1) + string(".med"); - std::cout << "here :" << path1 << std::endl; - const string path2 = string(mesh2) + string(".med"); - - intersectMeshes(path1.c_str(), mesh1, path2.c_str(), mesh2, correctVol, prec, doubleTest); - } - - -} diff --git a/src/INTERP_KERNEL/Test/MultiElement2DTests.hxx b/src/INTERP_KERNEL/Test/MultiElement2DTests.hxx deleted file mode 100644 index 2a9ae1153..000000000 --- a/src/INTERP_KERNEL/Test/MultiElement2DTests.hxx +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __MULTI_ELEMENT_2D_TESTS_HXX_ -#define __MULTI_ELEMENT_2D_TESTS_HXX_ - -#include "InterpolationTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class testing algorithm by intersecting meshes of several - * polygonal elements - up to a few thousand. This serves to check the - * filtering methods and the matrix assemblage, as well as verifying - * that computation errors do not become unmanageable. It uses mehes of - * different geometries : triangle, quadrilateral. - * - */ - class MultiElement2DTests : public InterpolationTestSuite<2,2> - { - CPPUNIT_TEST_SUITE( MultiElement2DTests ); - - CPPUNIT_TEST(SymetryTranspose2DTest); - CPPUNIT_TEST(SelfIntersection2DTest); - - CPPUNIT_TEST_SUITE_END(); - - public: - void SymetryTranspose2DTest() - { - _testTools->_intersectionType=INTERP_KERNEL::Triangulation; - _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); - _testTools->_intersectionType=INTERP_KERNEL::Convex; - _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); - } - void SelfIntersection2DTest() - { - IntersectionMatrix m; - _testTools->_intersectionType=INTERP_KERNEL::Triangulation; - _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); - _testTools->_intersectionType=INTERP_KERNEL::Convex; - _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); - } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Test/MultiElement3DSurfTests.hxx b/src/INTERP_KERNEL/Test/MultiElement3DSurfTests.hxx deleted file mode 100644 index 0543d73d1..000000000 --- a/src/INTERP_KERNEL/Test/MultiElement3DSurfTests.hxx +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __MULTI_ELEMENT_3DSurf_TESTS_HXX_ -#define __MULTI_ELEMENT_3DSurf_TESTS_HXX_ - -#include "InterpolationTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class testing algorithm by intersecting meshes of several - * polygonal elements - up to a few thousand. This serves to check the - * filtering methods and the matrix assemblage, as well as verifying - * that computation errors do not become unmanageable. It uses mehes of - * different geometries : triangle, quadrilateral. - * - */ - class MultiElement2DTests : public InterpolationTestSuite<3,2> - { - CPPUNIT_TEST_SUITE( MultiElement3DSurfTests ); - - CPPUNIT_TEST(SymetryTranspose3DSurfTest); - CPPUNIT_TEST(SelfIntersection3DSurfTest); - - CPPUNIT_TEST_SUITE_END(); - - public: - void SymetryTranspose3DSurfTest() - { - _testTools->_intersectionType=INTERP_KERNEL::Triangulation; - _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); - _testTools->_intersectionType=INTERP_KERNEL::Convex; - _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); - } - void SelfIntersection3DSurfTest() - { - IntersectionMatrix m; - _testTools->_intersectionType=INTERP_KERNEL::Triangulation; - _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); - _testTools->_intersectionType=INTERP_KERNEL::Convex; - _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); - } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Test/MultiElementTetraTests.hxx b/src/INTERP_KERNEL/Test/MultiElementTetraTests.hxx deleted file mode 100644 index d8610688e..000000000 --- a/src/INTERP_KERNEL/Test/MultiElementTetraTests.hxx +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __MULTI_ELEMENT_TETRA_TESTS_HXX_ -#define __MULTI_ELEMENT_TETRA_TESTS_HXX_ - -#include "InterpolationTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class testing algorithm by intersecting meshes of several - * elements (all tetrahedra) - up to a few thousand. This serves to check the - * filtering methods and the matrix assemblage, as well as verifying - * that computation errors do not become unmanageable. It uses mehes of - * different geometries : tetrahedra, boxes and cylinders. - * - */ - class MultiElementTetraTests : public InterpolationTestSuite<3,3> - { - CPPUNIT_TEST_SUITE( MultiElementTetraTests ); - - CPPUNIT_TEST( tetraComplexIncluded ); - CPPUNIT_TEST( dividedUnitTetraSimplerReflexive ); - CPPUNIT_TEST( dividedUnitTetraReflexive ); - CPPUNIT_TEST( nudgedDividedUnitTetraSimpler ); - CPPUNIT_TEST( nudgedDividedUnitTetra ); - CPPUNIT_TEST( dividedGenTetra ); - CPPUNIT_TEST( tinyBoxReflexive ); - CPPUNIT_TEST( moderateBoxEvenSmallerReflexive ); - CPPUNIT_TEST( moderateBoxSmallReflexive ); - CPPUNIT_TEST( boxReflexive ); - CPPUNIT_TEST( boxReflexiveModerate ); - CPPUNIT_TEST( tetraBoxes ); - CPPUNIT_TEST( moderateBoxesSmaller ); - CPPUNIT_TEST( moderateBoxes ); - - CPPUNIT_TEST_SUITE_END(); - - public: - - /// Tetrahedron situated totally inside another - /// \brief Status : pass - void tetraComplexIncluded() - { - _testTools->intersectMeshes("ComplexIncludedTetra", "ComplexIncludingTetra", 17.0156); - } - - /// Unit tetrahedron divided in 4 elements intersecting itself. - /// \brief Status : pass - void dividedUnitTetraSimplerReflexive() - { - _testTools->intersectMeshes("DividedUnitTetraSimpler", "DividedUnitTetraSimpler", 0.1666667); - } - - /// Unit tetrahedron divided in 14 elements intersecting itself. - /// \brief Status : pass - void dividedUnitTetraReflexive() - { - _testTools->intersectMeshes("DividedUnitTetra", "DividedUnitTetra", 0.1666667); - } - - /// Unit tetrahedron divided in 4 elements intersecting slightly displaced version of itself. - /// \brief Status : pass - void nudgedDividedUnitTetraSimpler() - { - _testTools->intersectMeshes("NudgedDividedUnitTetraSimpler", "DividedUnitTetraSimpler", 0.150191); - } - - /// Unit tetrahedron divided in 14 elements intersecting slightly displaced version of itself. - /// \brief Status : pass - void nudgedDividedUnitTetra() - { - _testTools->intersectMeshes("NudgedDividedUnitTetra", "DividedUnitTetra", 0.150191); - } - - /// Two intersecting tetrahedra in general position, one with 23 elements, the other with 643 elements - /// \brief Status : pass - void dividedGenTetra() - { - _testTools->intersectMeshes("DividedGenTetra1", "DividedGenTetra2", 0.546329); - } - - /// Large box in general position with 12 elements intersecting itself - /// \brief Status : pass - void tinyBoxReflexive() - { - _testTools->intersectMeshes("TinyBox", "TinyBox", 979200); - } - - /// Small box in general position with 33 elements intersecting itself - /// \brief Status : pass - void boxReflexive() - { - _testTools->intersectMeshes("Box3", "Box3", 13.9954); - } - - /// Box in general position with 67 elements intersecting itself - /// \brief Status : pass - void moderateBoxEvenSmallerReflexive() - { - _testTools->intersectMeshes("BoxEvenSmaller1", "BoxEvenSmaller1", 1.44018e6); - } - - /// Box in general position with 544 elements intersecting itself - /// \brief Status : pass - void moderateBoxSmallReflexive() - { - _testTools->intersectMeshes("BoxModSmall1", "BoxModSmall1", 1.44018e6); - } - - /// Large box in general position with 2943 elements intersecting itself - /// \brief Status : pass - void boxReflexiveModerate() - { - _testTools->intersectMeshes("Box1Moderate", "Box1Moderate", 1.0e6); - } - - /// Two intersecting boxes in general position with 12 and 18 elements - /// \brief Status : pass - void tetraBoxes() - { - _testTools->intersectMeshes("Box1", "Box2", 124.197); - } - - /// Two intersecting boxes in general position with 430 and 544 elements - /// \brief Status : pass - void moderateBoxesSmaller() - { - _testTools->intersectMeshes("BoxModSmall1", "BoxModSmall2", 321853); - } - - /// Two intersecting boxes in general position with 2943 and 3068 elements - /// \brief Status : pass - void moderateBoxes() - { - _testTools->intersectMeshes("Box1Moderate", "Box2Moderate", 376856); - } - - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Test/PerfTest.cxx b/src/INTERP_KERNEL/Test/PerfTest.cxx deleted file mode 100644 index 847aa31b1..000000000 --- a/src/INTERP_KERNEL/Test/PerfTest.cxx +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "Interpolation3D.hxx" -#include "Interpolation3D.txx" -#include "MeshTestToolkit.txx" -#include "Log.hxx" -#include "VectorUtils.hxx" - -#include "MEDMEM_Mesh.hxx" -#include "MEDNormalizedUnstructuredMesh.hxx" - -#include -#include - -using namespace MEDMEM; -using namespace MED_EN; - -/** - * \file PerfTest.cxx - * Test program which takes two meshes and calculates their intersection matrix. - * - * USAGE : PerfTest mesh1 mesh2 - * where mesh1 and mesh2 are the names of two meshes located in - * the files mesh1.med, mesh2.med in {$MED_ROOT_DIR}/share/salome/resources/med/ - * - */ - -namespace INTERP_TEST -{ - /** - * \brief Specialization of MeshTestToolkit for the purposes of performance testing. - * - */ - class PerfTestToolkit : public MeshTestToolkit<3,3> - { - - public: - - /** - * Calculates the intersection matrix for two meshes. - * Outputs the names of the meshes intersected, the number of elements in each mesh, - * the number of matrix elements and the number of non-zero matrix elements, etc. - * These values help to determine how well the filtering algorithm is working. - * - * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh1 the name of the source mesh - * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh2 the name of the target mesh - * @param m intersection matrix in which to store the result of the intersection - */ - void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) - { - const string dataBaseDir = getenv("MED_ROOT_DIR"); - const string dataDir = dataBaseDir + "/share/salome/resources/med/"; - - LOG(1, std::endl << "=== -> intersecting src = " << mesh1 << ", target = " << mesh2 ); - - LOG(5, "Loading " << mesh1 << " from " << mesh1path); - const MESH sMesh(MED_DRIVER, dataDir+mesh1path, mesh1); - - - LOG(5, "Loading " << mesh2 << " from " << mesh2path); - const MESH tMesh(MED_DRIVER, dataDir+mesh2path, mesh2); - - MEDNormalizedUnstructuredMesh<3,3> sMesh_wrapper(&sMesh); - MEDNormalizedUnstructuredMesh<3,3> tMesh_wrapper(&tMesh); - - Interpolation3D interpolator; - interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); - - 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 ); - - } - - /** - * Counts the number of elements in an intersection matrix, and the number of these which are non-zero. - * - * @param m the intersection matrix - * @return pair containing as its first element the number of elements in m and as its second element the - * number these which are non-zero - */ - std::pair countNumberOfMatrixEntries(const IntersectionMatrix& m) - { - - int numElems = 0; - int numNonZero = 0; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - numElems += iter->size(); - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - if(!INTERP_KERNEL::epsilonEqual(iter2->second, 0.0, VOL_PREC)) - { - ++numNonZero; - } - } - } - return std::make_pair(numElems, numNonZero); - } - - }; -} - -/** - * Main method of the program. - * Intersects the meshes and outputs some information about the calculation as well as the - * intersection matrix on std::cout. - * - * @param argc number of arguments given to the program (should be 3, the user giving 2 mesh names) - * @param argv vector to the arguments as strings. - */ -int main(int argc, char** argv) -{ - using INTERP_TEST::PerfTestToolkit; - - assert(argc == 3); - - // load meshes - const string mesh1 = argv[1]; - const string mesh2 = argv[2]; - - const string mesh1path = mesh1 + ".med"; - const string mesh2path = mesh2 + ".med"; - - IntersectionMatrix m; - - PerfTestToolkit testTools; - - 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/PointLocatorTest.cxx b/src/INTERP_KERNEL/Test/PointLocatorTest.cxx deleted file mode 100644 index 02629b4a6..000000000 --- a/src/INTERP_KERNEL/Test/PointLocatorTest.cxx +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "PointLocatorTest.hxx" -#include "PointLocator.hxx" -#include "MEDMeshMaker.hxx" - -#include -#include - -namespace INTERP_TEST -{ - - - void PointLocatorTest::setUp() - { - } - - - void PointLocatorTest::tearDown() - { - } - - /** - * Test that creates a tree in 2D and check that - * the results are correct in three - * cases : - * a non matching search - * a standard case - * a bbox overlapping the bboxes of the tree - */ - void PointLocatorTest::test_PointLocator() { - MEDMEM::MESH* mesh2D= MEDMeshMaker(2,2,MED_EN::MED_QUAD4); - INTERP_KERNEL::PointLocator pl(*mesh2D) ; - double x[2]={0.0,0.0}; - std::list elems = pl.locate(x); - CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)(*(elems.begin()))); - elems.clear(); - - double x2[2]={0.25,0.25}; - elems = pl.locate(x2); - CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)(*(elems.begin()))); - elems.clear(); - - double x3[2]={0.5,0.5}; - elems = pl.locate(x3); - CPPUNIT_ASSERT_EQUAL(4,(int)elems.size()); - elems.clear(); - - double x4[2]={-1.0,0.0}; - elems = pl.locate(x4); - CPPUNIT_ASSERT_EQUAL(0,(int)elems.size()); - elems.clear(); - delete mesh2D; - - MEDMEM::MESH* mesh3D= MEDMeshMaker(3,2,MED_EN::MED_HEXA8); - INTERP_KERNEL::PointLocator pl3(*mesh3D); - double xx[3]={0.0,0.0,0.0}; - elems = pl3.locate(xx); - CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)*(elems.begin())); - elems.clear(); - - double xx2[3]={0.25,0.25,0.25}; - elems = pl3.locate(xx2); - CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)*(elems.begin())); - elems.clear(); - - double xx3[3]={0.5,0.5,0.5}; - elems = pl3.locate(xx3); - CPPUNIT_ASSERT_EQUAL(8,(int)elems.size()); - elems.clear(); - - double xx4[3]={-1.0,0.0,0.0}; - elems = pl3.locate(x4); - CPPUNIT_ASSERT_EQUAL(0,(int)elems.size()); - elems.clear(); - delete mesh3D; - - } - - -} diff --git a/src/INTERP_KERNEL/Test/PointLocatorTest.hxx b/src/INTERP_KERNEL/Test/PointLocatorTest.hxx deleted file mode 100644 index 84c576e47..000000000 --- a/src/INTERP_KERNEL/Test/PointLocatorTest.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __TU_POINTLOCATOR_HXX__ -#define __TU_POINTLOCATOR_HXX__ - -#include -#include "PointLocator.hxx" - -namespace INTERP_TEST -{ - - /** - * \brief Test suite testing some of the low level methods of TransformedTriangle. - * - */ - class PointLocatorTest : public CppUnit::TestFixture - { - - CPPUNIT_TEST_SUITE( PointLocatorTest ); - CPPUNIT_TEST( test_PointLocator ); - CPPUNIT_TEST_SUITE_END(); - - - public: - void setUp(); - - void tearDown(); - - // tests - void test_PointLocator(); - - }; - - - - -} - - - -#endif diff --git a/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest.cxx b/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest.cxx deleted file mode 100644 index f556f3a4c..000000000 --- a/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest.cxx +++ /dev/null @@ -1,1023 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "QuadraticPlanarInterpTest.hxx" -#include "QuadraticPolygon.hxx" -#include "EdgeArcCircle.hxx" -#include "ElementaryEdge.hxx" -#include "ComposedEdge.hxx" -#include "EdgeLin.hxx" - -#include -#include - -using namespace std; -using namespace INTERP_KERNEL; - -static const double ADMISSIBLE_ERROR = 1.e-14; - -void QuadraticPlanarInterpTest::setUp() -{ -} - -void QuadraticPlanarInterpTest::tearDown() -{ -} - -void QuadraticPlanarInterpTest::cleanUp() -{ -} - -void QuadraticPlanarInterpTest::ReadWriteInXfigElementary() -{ - //Testing bounds calculation. For Seg2 - istringstream stream("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4700"); - EdgeLin *e1=new EdgeLin(stream); - Bounds bound=e1->getBounds(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.32,bound[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.45,bound[1],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.34,bound[2],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.47,bound[3],ADMISSIBLE_ERROR); - e1->decrRef(); - istringstream stream2("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n4500 4700 3200 3400"); - e1=new EdgeLin(stream2); - bound=e1->getBounds(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.32,bound[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.45,bound[1],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.34,bound[2],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.47,bound[3],ADMISSIBLE_ERROR); - e1->decrRef(); - //Testing bounds calculation For Arc of circle. - -} - -void QuadraticPlanarInterpTest::ReadWriteInXfigGlobal() -{ - string dataBaseDir(getenv("MED_ROOT_DIR")); - dataBaseDir+="/share/salome/resources/med/"; - string tmp; - tmp=dataBaseDir; tmp+="Pol1.fig"; - QuadraticPolygon pol1(tmp.c_str()); - pol1.dumpInXfigFile("Pol1_gen.fig"); - tmp=dataBaseDir; tmp+="Pol2.fig"; - QuadraticPolygon pol2(tmp.c_str()); - pol2.dumpInXfigFile("Pol2_gen.fig"); - tmp=dataBaseDir; tmp+="Pol3.fig"; - QuadraticPolygon pol3(tmp.c_str()); - pol3.dumpInXfigFile("Pol3_gen.fig"); - tmp=dataBaseDir; tmp+="Pol4.fig"; - QuadraticPolygon pol4(tmp.c_str()); - CPPUNIT_ASSERT_EQUAL(1,pol4.size()); - ElementaryEdge *edge1=dynamic_cast(pol4[0]); - CPPUNIT_ASSERT(edge1); - Edge *edge2=edge1->getPtr(); - EdgeArcCircle *edge=dynamic_cast(edge2); - CPPUNIT_ASSERT(edge); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.24375,edge->getRadius(),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.7857653289925404,edge->getAngle(),ADMISSIBLE_ERROR); - double center[2]; - edge->getCenter(center); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48,center[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48375,center[1],ADMISSIBLE_ERROR); - const double *start=*edge->getStartNode(); - Node *n1=new Node(start[0]+2*(center[0]-start[0]),start[1]+2*(center[1]-start[1])); - edge->changeMiddle(n1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.24375,edge->getRadius(),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.7857653289925404,edge->getAngle(),ADMISSIBLE_ERROR); - n1->decrRef(); - n1=new Node(center[0],center[1]+0.24375); - edge->changeMiddle(n1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.24375,edge->getRadius(),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.49741997818704586,edge->getAngle(),ADMISSIBLE_ERROR);//5.7857653289925404 + 2*PI - n1->decrRef(); - //A half circle. - EdgeArcCircle *e=new EdgeArcCircle(0.84,0.54,0.78,0.6,0.84,0.66); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.06,e->getRadius(),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.1415925921507317,e->getAngle(),1e-5); - e->decrRef(); - e=new EdgeArcCircle(0.84,0.54,0.9,0.6,0.84,0.66); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.06,e->getRadius(),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415925921507317,e->getAngle(),1e-5); - e->decrRef(); -} - -void QuadraticPlanarInterpTest::BasicGeometricTools() -{ - Node *n1=new Node(1.,1.); - Node *n2=new Node(4.,2.); - EdgeLin *e1=new EdgeLin(n1,n2); - double tmp[2]; - e1->getNormalVector(tmp); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.94868329805051377,tmp[1],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.31622776601683794,tmp[0],ADMISSIBLE_ERROR); - e1->decrRef(); - n1->decrRef(); n2->decrRef(); - n1=new Node(1.,1.); - n2=new Node(0.,4.); - e1=new EdgeLin(n1,n2); - double tmp2[2]; - e1->getNormalVector(tmp2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,Node::dot(tmp,tmp2),1e-10); - tmp[0]=0.5; tmp[1]=2.5; - CPPUNIT_ASSERT(e1->isNodeLyingOn(tmp)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,e1->getDistanceToPoint(tmp),1e-12); - tmp[1]=2.55; CPPUNIT_ASSERT(!e1->isNodeLyingOn(tmp)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0158113883008418,e1->getDistanceToPoint(tmp),1e-12); - tmp[0]=0.; tmp[1]=5.; - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,e1->getDistanceToPoint(tmp),1e-12); - EdgeArcCircle *e=new EdgeArcCircle(4.,3.,0.,5.,-5.,0.); - tmp[0]=-4.; tmp[1]=3.; - CPPUNIT_ASSERT(e->isNodeLyingOn(tmp)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,e->getDistanceToPoint(tmp),1e-12); - tmp[1]=3.1; CPPUNIT_ASSERT(!e->isNodeLyingOn(tmp)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(6.0632371551998077e-2,e->getDistanceToPoint(tmp),1e-12); - tmp[0]=-4.; tmp[1]=-3.; - CPPUNIT_ASSERT(!e->isNodeLyingOn(tmp)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1622776601683795,e->getDistanceToPoint(tmp),1e-12); - e->decrRef(); - e1->decrRef(); - n1->decrRef(); n2->decrRef(); -} - -void QuadraticPlanarInterpTest::IntersectionBasics() -{ - //Testing intersection of Bounds. - istringstream stream1("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4800"); - EdgeLin *e1=new EdgeLin(stream1); - istringstream stream2("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4800"); - EdgeLin *e2=new EdgeLin(stream2); - Bounds *bound=e1->getBounds().amIIntersectingWith(e2->getBounds()); CPPUNIT_ASSERT(bound); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.32,(*bound)[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.45,(*bound)[1],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.34,(*bound)[2],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48,(*bound)[3],ADMISSIBLE_ERROR); - delete bound; - e2->decrRef(); e1->decrRef(); - // - istringstream stream3("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3000 7200 6000 3700"); - EdgeLin *e3=new EdgeLin(stream3); - istringstream stream4("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n4800 6600 7200 4200"); - EdgeLin *e4=new EdgeLin(stream4); - bound=e3->getBounds().amIIntersectingWith(e4->getBounds()); CPPUNIT_ASSERT(bound); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48,(*bound)[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.6,(*bound)[1],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.42,(*bound)[2],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.66,(*bound)[3],ADMISSIBLE_ERROR); - delete bound; - e3->decrRef(); e4->decrRef(); -} - -void QuadraticPlanarInterpTest::EdgeLinUnitary() -{ - EdgeLin *e1=new EdgeLin(0.5,0.5,3.7,4.1); - Node *n=new Node(2.1,2.3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),0.5,1e-8); - n->decrRef(); - n=new Node(3.7,4.1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),1.,1e-8); - n->decrRef(); - n=new Node(0.5,0.5); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),0.,1e-8); - n->decrRef(); - n=new Node(-1.1,-1.3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),-0.5,1e-8); - n->decrRef(); - n=new Node(5.3,5.9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),1.5,1e-8); - n->decrRef(); e1->decrRef(); -} - -/*! - * Here two things are tested. - * 1 ) One the overlapping calculation capability of edge/edge intersector. - * 2 ) Then the capability to handle the case where 2 segs (whatever their type) are overlapped. - * All the configuration of full or part overlapping have been tested. - */ -void QuadraticPlanarInterpTest::IntersectionEdgeOverlapUnitarySegSeg() -{ - ComposedEdge& v1=*(new ComposedEdge); - ComposedEdge& v2=*(new ComposedEdge); - MergePoints v3; - //Testing merge of geometric equals seg2. - Edge *e1=new EdgeLin(0.5,0.5,1.,1.); Edge *e2=new EdgeLin(0.5,0.5,1.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - v1.clear(); v2.clear(); v3.clear(); - // - testing by adding some noise - e1->decrRef(); e1=new EdgeLin(0.5+5.e-15,0.5-5.e-15,1.,1.+7.e-15); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Testing merge of geometric equals seg2 but now with opposite direction - e1=new EdgeLin(0.5,0.5,0.7,0.7); e2=new EdgeLin(0.7+6.e-15,0.7-2.e-15,0.5+3.e-15,0.5-4.e-15); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && !v2[0]->getDirection());//compared 8 lines above !v2[0]->getDirection() - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 0 - //Test 1 - OUT_AFTER - OUT_AFTER | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.5,0.,2.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 2 - INSIDE - OUT_AFTER | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.5,0.,1.5,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresicEqualDirSensitive(v2[0])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 2 - INSIDE - OUT_AFTER | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.5,0.,1.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresicEqualDirSensitive(v2[0])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 2 - INSIDE - OUT_AFTER | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.5,0.5,1.5,1.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresicEqualDirSensitive(v2[0])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 2 - INSIDE - OUT_AFTER | opp. dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.5,1.5,0.5,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(!v1[1]->intresicEqualDirSensitive(v2[1]) && v1[1]->intresicEqual(v2[1])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3 - INSIDE - INSIDE | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.25,0.,0.75,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3 - INSIDE - INSIDE | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.25,0.,0.75); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3 - INSIDE - INSIDE | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.25,0.25,0.75,0.75); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3 - INSIDE - INSIDE | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.75,0.75,0.25,0.25); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && !v1[1]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3bis - INSIDE - INSIDE - Bis | opp dir. - double center[2]={0.,0.}; - double radius=1.; - e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-2*M_PI/3.+2*M_PI,-M_PI/3.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(v1[0]->getDirection()); CPPUNIT_ASSERT(!v2[0]->getDirection()); - CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(v1[2]->getDirection()); CPPUNIT_ASSERT(!v2[2]->getDirection()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3bis - INSIDE - INSIDE - Bis | same dir. - e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-M_PI/3.,-2*M_PI/3.+2*M_PI); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(v1[0]->getDirection()); CPPUNIT_ASSERT(v2[2]->getDirection()); - CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(v1[2]->getDirection()); CPPUNIT_ASSERT(v2[0]->getDirection()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getStartNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3bis - INSIDE - INSIDE - Bis | opp dir. | e1<->e2 to test symetry - e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-2*M_PI/3.+2*M_PI,-M_PI/3.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. - CPPUNIT_ASSERT(e2->intersectWith(e1,v3,v2,v1)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(!v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->getDirection()); - CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(!v1[2]->getDirection()); CPPUNIT_ASSERT(v2[2]->getDirection()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-5); // << not maximal precision because node switching - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3bis - INSIDE - INSIDE - Bis | same dir. | e1<->e2 to test symetry - e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-M_PI/3.,-2*M_PI/3.+2*M_PI); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. - CPPUNIT_ASSERT(e2->intersectWith(e1,v3,v2,v1)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(v1[0]->getDirection()); CPPUNIT_ASSERT(v2[2]->getDirection()); - CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(v1[2]->getDirection()); CPPUNIT_ASSERT(v2[0]->getDirection()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-5); // << not maximal precision because node switching - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getStartNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 4 - OUT_BEFORE - OUT_BEFORE | same dir. - 0 ° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-1.,0.,-0.5,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 5 - OUT_BEFORE - INSIDE | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,0.5,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresicEqualDirSensitive(v2[1])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 5 - OUT_BEFORE - INSIDE | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0,-0.5,0.,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresicEqualDirSensitive(v2[1])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 5 - OUT_BEFORE - INSIDE | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(-0.5,-0.5,0.5,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresicEqualDirSensitive(v2[1])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 5 - OUT_BEFORE - INSIDE | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.5,0.5,-0.5,-0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(!v1[0]->intresicEqualDirSensitive(v2[0]) && v1[0]->intresicEqual(v2[0]) ); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 6 - OUT_BEFORE - OUT_AFTER | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,1.5,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 6 - OUT_BEFORE - OUT_AFTER | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,-0.5,0.,1.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 6 - OUT_BEFORE - OUT_AFTER | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(-0.5,-0.5,1.5,1.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 6 - OUT_BEFORE - OUT_AFTER | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.5,1.5,-0.5,-0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && !v2[1]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 7 - END - OUT_AFTER | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.,0.,1.5,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 7 - END - OUT_AFTER | opp dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.5,0.,1.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); - CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 8 - START - END | same dir. - 0° - e1=new EdgeLin(0.,0.,0.7,0.); e2=new EdgeLin(0.,0.,0.7,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 8 - START - END | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,0.7); e2=new EdgeLin(0.,0.,0.,0.7); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 8 - START - END | same dir. - 45° - e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(0.,0.,0.7,0.7); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 8 - START - END | opp. dir. - 45° - e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(0.7,0.7,0.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && !v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 9 - OUT_BEFORE - START | same dir. - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,0.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); - CPPUNIT_ASSERT(e2->getEndNode()==e1->getStartNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 10 - START - OUT_AFTER | same dir. - 0° - e1=new EdgeLin(0.,0.,0.7,0.); e2=new EdgeLin(0.,0.,1.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 10 - START - OUT_AFTER | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,0.7); e2=new EdgeLin(0.,0.,0.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 10 - START - OUT_AFTER | same dir. - 45° - e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(0.,0.,1.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 10 - START - OUT_AFTER | opp dir. - 45° - e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(1.,1.,0.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && !v2[1]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 11 - INSIDE - END | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.7,0.,1.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 11 - INSIDE - END | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.7,0.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 11 - INSIDE - END | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.7,0.7,1.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 11 - INSIDE - END | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.,1.,0.7,0.7); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getStartNode()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && !v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 12 - OUT_BEFORE - END | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,1.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 12 - OUT_BEFORE - END | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,-0.5,0.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 12 - OUT_BEFORE - END | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(-0.5,-0.5,1.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 12 - OUT_BEFORE - END | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.,1.,-0.5,-0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && !v2[0]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 13 - START - INSIDE | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.,0.,0.5,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 13 - START - INSIDE | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.,0.,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 13 - START - INSIDE | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.,0.,0.5,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 13 - START - INSIDE | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.5,0.5,0.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && !v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e2->getEndNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 14 - INSIDE - START | same dir. - e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,M_PI/3.,-M_PI); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresicEqual(v2[0])); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2*M_PI/3.,v1[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v2[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 14 - INSIDE - START | opp dir. - e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,-M_PI,M_PI/3.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(v2[1]->getPtr()) && !v2[1]->getDirection() && v1[1]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2*M_PI/3.,v1[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v2[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[0]->getCurveLength(),1.e-12); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 15 - END - INSIDE | same dir. - e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,0.,-4.*M_PI/3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresicEqual(v2[1])); - CPPUNIT_ASSERT(v2[0]->getEndNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getStartNode()==e1->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.*M_PI/3.,v1[1]->getCurveLength(),1.e-12); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 15 - END - INSIDE | opp dir. - e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,-4.*M_PI/3,0.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[0]->getPtr()) && !v2[0]->getDirection() && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.*M_PI/3.,v1[1]->getCurveLength(),1.e-12); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - // - ComposedEdge::Delete(&v1); - ComposedEdge::Delete(&v2); -} - -/*! - * Here there is test of cases where between 2 edges intersects only in points not on edge. - */ -void QuadraticPlanarInterpTest::IntersectionPointOnlyUnitarySegSeg() -{ - // 0° - classical - EdgeLin *e1=new EdgeLin(0.,0.,1.,0.); - EdgeLin *e2=new EdgeLin(0.3,0.3,0.5,-0.3); - ComposedEdge& v1=*(new ComposedEdge); - ComposedEdge& v2=*(new ComposedEdge); MergePoints v3; - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4,(*v1[0]->getEndNode())[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,(*v1[0]->getEndNode())[1],ADMISSIBLE_ERROR); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - // 90° - classical - e1=new EdgeLin(0.,0.,0.,1.); - e2=new EdgeLin(-0.3,0.3,0.3,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,(*v1[0]->getEndNode())[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4,(*v1[0]->getEndNode())[1],ADMISSIBLE_ERROR); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 1 - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.,0.,0.,1.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 1 - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.,1.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 1 - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.,0.,1.,-1.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 2 - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.,1.,1.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isEnd1(0)); CPPUNIT_ASSERT(v3.isEnd2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3 - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.,0.,1.,1.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isEnd1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 4 - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.,-1.,0.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isEnd2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Intersection extremity of one edge and inside of other edge. 2 End. - e1=new EdgeLin(0.,0.,1.,0.); - e2=new EdgeLin(0.5,1.,0.5,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode() && v1[0]->getEndNode()==e2->getEndNode() && v1[1]->getStartNode()==e2->getEndNode() && v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getDirection() && v1[1]->getDirection()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Intersection extremity of one edge and inside of other edge. 2 Start. - e1=new EdgeLin(0.,0.,1.,0.); - e2=new EdgeLin(0.5,0.,0.5,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode() && v1[0]->getEndNode()==e2->getStartNode() && v1[1]->getStartNode()==e2->getStartNode() && v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getDirection() && v1[1]->getDirection()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Intersection extremity of one edge and inside of other edge. 1 Start. - e1=new EdgeLin(0.5,0.,0.5,1.); - e2=new EdgeLin(0.,0.,1.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getStartNode()==e2->getStartNode() && v2[0]->getEndNode()==e1->getStartNode() && v2[1]->getStartNode()==e1->getStartNode() && v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getDirection() && v2[1]->getDirection()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Intersection extremity of one edge and inside of other edge. 1 End. - e1=new EdgeLin(0.5,1.,0.5,0.); - e2=new EdgeLin(0.,0.,1.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getStartNode()==e2->getStartNode() && v2[0]->getEndNode()==e1->getEndNode() && v2[1]->getStartNode()==e1->getEndNode() && v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getDirection() && v2[1]->getDirection()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - ComposedEdge::Delete(&v2); - ComposedEdge::Delete(&v1); -} diff --git a/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest.hxx b/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest.hxx deleted file mode 100644 index da60159a8..000000000 --- a/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest.hxx +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _QUADRATICPLANARINTERPTEST_HXX_ -#define _QUADRATICPLANARINTERPTEST_HXX_ - -#include - -namespace INTERP_KERNEL -{ - class Node; - class EdgeArcCircle; - class QuadraticPolygon; - - class QuadraticPlanarInterpTest : public CppUnit::TestFixture - { - CPPUNIT_TEST_SUITE( QuadraticPlanarInterpTest ); - CPPUNIT_TEST( ReadWriteInXfigElementary ); - CPPUNIT_TEST( ReadWriteInXfigGlobal ); - CPPUNIT_TEST( BasicGeometricTools ); - CPPUNIT_TEST( IntersectionBasics ); - CPPUNIT_TEST( EdgeLinUnitary ); - CPPUNIT_TEST( IntersectionEdgeOverlapUnitarySegSeg ); - CPPUNIT_TEST( IntersectionPointOnlyUnitarySegSeg ); - CPPUNIT_TEST( IntersectArcCircleBase ); - CPPUNIT_TEST( IntersectArcCircleFull ); - CPPUNIT_TEST( IntersectArcCircleSegumentBase ); - CPPUNIT_TEST( checkInOutDetection ); - CPPUNIT_TEST( checkAssemblingBases1 ); - CPPUNIT_TEST( checkAssemblingBases2 ); - CPPUNIT_TEST( checkPolygonsIntersection1 ); - CPPUNIT_TEST( checkPolygonsIntersection2 ); - CPPUNIT_TEST( checkAreasCalculations ); - CPPUNIT_TEST( checkBarycenterCalculations ); - CPPUNIT_TEST( checkHighLevelFunctionTest1 ); - CPPUNIT_TEST( check1DInterpLin ); - CPPUNIT_TEST( checkEpsilonCoherency1 ); - CPPUNIT_TEST( checkNonRegression1 ); - CPPUNIT_TEST( checkNonRegression2 ); - CPPUNIT_TEST( checkNonRegression3 ); - CPPUNIT_TEST( checkNonRegression4 ); - CPPUNIT_TEST( checkNonRegression5 ); - CPPUNIT_TEST( checkNonRegression6 ); - CPPUNIT_TEST( checkNonRegression7 ); - CPPUNIT_TEST( checkNonRegression8 ); - CPPUNIT_TEST( checkNonRegression9 ); - CPPUNIT_TEST( checkNonRegression10 ); - CPPUNIT_TEST( checkNonRegression11 ); - CPPUNIT_TEST( checkNonRegression12 ); - CPPUNIT_TEST ( checkNonRegression13 ); - CPPUNIT_TEST ( checkNonRegression14 ); - CPPUNIT_TEST ( checkNonRegression15 ); - CPPUNIT_TEST ( checkNonRegression16 ); - CPPUNIT_TEST ( checkNonRegression17 ); - // - CPPUNIT_TEST ( checkNonRegressionOmar0000 ); - CPPUNIT_TEST ( checkNonRegressionOmar0001 ); - CPPUNIT_TEST ( checkNonRegressionOmar0002 ); - CPPUNIT_TEST ( checkNonRegressionOmar0003 ); - CPPUNIT_TEST ( checkNonRegressionOmar0004 ); - CPPUNIT_TEST ( checkNonRegressionOmar0005 ); - CPPUNIT_TEST ( checkNonRegressionOmar0006 ); - CPPUNIT_TEST ( checkNonRegressionOmar0007 ); - CPPUNIT_TEST ( checkNonRegressionOmar0008 ); - CPPUNIT_TEST ( checkNonRegressionOmar0009 ); - CPPUNIT_TEST ( checkNonRegressionOmar0010 ); - CPPUNIT_TEST ( checkNonRegressionOmar0011 ); - CPPUNIT_TEST ( checkNonRegressionOmar2511 ); - CPPUNIT_TEST ( checkNonRegressionOmar0012 ); - CPPUNIT_TEST ( checkNonRegressionOmar0013 ); - CPPUNIT_TEST ( checkNonRegressionOmar0014 ); - CPPUNIT_TEST ( checkNonRegressionOmar0015 ); - CPPUNIT_TEST ( checkNonRegressionOmar0016 ); - CPPUNIT_TEST ( checkNonRegressionOmar0017 ); - CPPUNIT_TEST ( checkNonRegressionOmar0018 ); - CPPUNIT_TEST ( checkNonRegressionOmar0019 ); - CPPUNIT_TEST ( checkNonRegressionOmar0020 ); - CPPUNIT_TEST ( checkNonRegressionOmar0021 ); - CPPUNIT_TEST ( checkNonRegressionOmar0022 ); - CPPUNIT_TEST ( checkNonRegressionOmar0023 ); - CPPUNIT_TEST ( checkNonRegressionOmar0024 ); - CPPUNIT_TEST ( checkNonRegressionOmar2524 ); - CPPUNIT_TEST ( checkNonRegressionOmar0025 ); - CPPUNIT_TEST ( checkNonRegressionOmar0026 ); - CPPUNIT_TEST ( checkNonRegressionOmar0027 ); - CPPUNIT_TEST ( checkNonRegressionOmar0028 ); - CPPUNIT_TEST ( checkNonRegressionOmar0029 ); - CPPUNIT_TEST ( checkNonRegressionOmar0030 ); - // - CPPUNIT_TEST( checkNormalize ); - CPPUNIT_TEST_SUITE_END(); - public: - void setUp(); - void tearDown(); - void cleanUp(); - // - void ReadWriteInXfigElementary(); - void ReadWriteInXfigGlobal(); - void BasicGeometricTools(); - void IntersectionBasics(); - void EdgeLinUnitary(); - void IntersectionEdgeOverlapUnitarySegSeg(); - void IntersectionPointOnlyUnitarySegSeg(); - // - void IntersectArcCircleBase(); - void IntersectArcCircleFull(); - void IntersectArcCircleSegumentBase(); - // - void checkInOutDetection(); - // - void checkAssemblingBases1(); - void checkAssemblingBases2(); - // - void checkPolygonsIntersection1(); - void checkPolygonsIntersection2(); - void checkAreasCalculations(); - void checkBarycenterCalculations(); - // - void checkHighLevelFunctionTest1(); - // - void check1DInterpLin(); - // - void checkEpsilonCoherency1(); - // - void checkNonRegression1(); - void checkNonRegression2(); - void checkNonRegression3(); - void checkNonRegression4(); - void checkNonRegression5(); - void checkNonRegression6(); - void checkNonRegression7(); - void checkNonRegression8(); - void checkNonRegression9(); - void checkNonRegression10(); - void checkNonRegression11(); - void checkNonRegression12(); - void checkNonRegression13(); - void checkNonRegression14(); - void checkNonRegression15(); - void checkNonRegression16(); - void checkNonRegression17(); - // - void checkNonRegressionOmar0000(); - void checkNonRegressionOmar0001(); - void checkNonRegressionOmar0002(); - void checkNonRegressionOmar0003(); - void checkNonRegressionOmar0004(); - void checkNonRegressionOmar0005(); - void checkNonRegressionOmar0006(); - void checkNonRegressionOmar0007(); - void checkNonRegressionOmar0008(); - void checkNonRegressionOmar0009(); - void checkNonRegressionOmar0010(); - void checkNonRegressionOmar0011(); - void checkNonRegressionOmar2511(); - void checkNonRegressionOmar0012(); - void checkNonRegressionOmar0013(); - void checkNonRegressionOmar0014(); - void checkNonRegressionOmar0015(); - void checkNonRegressionOmar0016(); - void checkNonRegressionOmar0017(); - void checkNonRegressionOmar0018(); - void checkNonRegressionOmar0019(); - void checkNonRegressionOmar0020(); - void checkNonRegressionOmar0021(); - void checkNonRegressionOmar0022(); - void checkNonRegressionOmar0023(); - void checkNonRegressionOmar0024(); - void checkNonRegressionOmar2524(); - void checkNonRegressionOmar0025(); - void checkNonRegressionOmar0026(); - void checkNonRegressionOmar0027(); - void checkNonRegressionOmar0028(); - void checkNonRegressionOmar0029(); - void checkNonRegressionOmar0030(); - // - void checkNormalize(); - private: - QuadraticPolygon *buildQuadraticPolygonCoarseInfo(const double *coords, const int *conn, int lgth); - EdgeArcCircle *buildArcOfCircle(const double *center, double radius, double alphaStart, double alphaEnd); - double btw2NodesAndACenter(const Node& n1, const Node& n2, const double *center); - void checkBasicsOfPolygons(QuadraticPolygon& pol1, QuadraticPolygon& pol2, bool checkDirection); - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest2.cxx b/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest2.cxx deleted file mode 100644 index 026ce84ea..000000000 --- a/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest2.cxx +++ /dev/null @@ -1,669 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "QuadraticPlanarInterpTest.hxx" -#include "QuadraticPolygon.hxx" -#include "EdgeArcCircle.hxx" -#include "EdgeLin.hxx" - -#include -#include -#include - -using namespace std; -using namespace INTERP_KERNEL; - -static const double ADMISSIBLE_ERROR = 1.e-14; - -void QuadraticPlanarInterpTest::IntersectArcCircleBase() -{ - double center[2]={0.5,0.5}; - double radius=0.3; - EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI/3),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/3),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,M_PI/3.,M_PI/2.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI/2),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(M_PI/3),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(M_PI/3),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/2),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,M_PI/3.,3.*M_PI/4.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(3*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(M_PI/3),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(3*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/2),ADMISSIBLE_ERROR);//<< - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,3*M_PI/4,7*M_PI/8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(7*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(3*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(7*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(3*M_PI/4),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,7.*M_PI/8.,9.*M_PI/8.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI),ADMISSIBLE_ERROR);//<< - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(7*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(9*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(7*M_PI/8),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,9.*M_PI/8.,11.*M_PI/8.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(9*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(11*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(11*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(9*M_PI/8),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,11.*M_PI/8.,7.*M_PI/4.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(11*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(7*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(3*M_PI/2),ADMISSIBLE_ERROR);//<< - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(7*M_PI/4),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,7.*M_PI/4.,15.*M_PI/8.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(7*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(15*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(7*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(15*M_PI/8),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,-M_PI/8.,M_PI/4.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(0.),ADMISSIBLE_ERROR); //<< - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(15*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/4),ADMISSIBLE_ERROR); - e1->decrRef(); - // - // ArcCArcCIntersector - // - TypeOfLocInEdge where1,where2; - vector v4; - MergePoints v3; - EdgeArcCircle *e2; - ArcCArcCIntersector *intersector=0; - for(unsigned k=0;k<8;k++) - { - e1=buildArcOfCircle(center,radius,M_PI/4.+k*M_PI/4.,M_PI/3.+k*M_PI/4.); - e2=buildArcOfCircle(center,radius,M_PI/4.+k*M_PI/4.,M_PI/3.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==START && where2==END); - delete intersector; v3.clear(); e2->decrRef(); - // - e2=buildArcOfCircle(center,radius,7*M_PI/24.+k*M_PI/4.,M_PI/3.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==INSIDE && where2==END); - delete intersector; v3.clear(); e2->decrRef(); - // - e2=buildArcOfCircle(center,radius,M_PI/4.+k*M_PI/4.,7*M_PI/24.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==START && where2==INSIDE); - delete intersector; v3.clear(); e2->decrRef(); - // - e2=buildArcOfCircle(center,radius,13.*M_PI/48.+k*M_PI/4.,15*M_PI/48.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==INSIDE && where2==INSIDE); - delete intersector; v3.clear(); e2->decrRef(); - // - e2=buildArcOfCircle(center,radius,-M_PI/4.+k*M_PI/4.,M_PI/6.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==OUT_BEFORE && where2==OUT_BEFORE); - delete intersector; v3.clear(); e2->decrRef(); - // - e2=buildArcOfCircle(center,radius,0+k*M_PI/4.,5*M_PI/6.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==OUT_BEFORE && where2==OUT_AFTER); - delete intersector; v3.clear(); e2->decrRef(); - e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 > R2 ; dist(circle1,circle2)>R1; Opposite order. - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,(k-1)*M_PI/4.,(k+1)*M_PI/4.); - e2=buildArcOfCircle(center2,1.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.35587863972199624,1e-10); - for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 > R2 ; dist(circle1,circle2)>R1; Same order. - for(unsigned k=0;k<7;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,(k-1)*M_PI/4.,(k+1)*M_PI/4.); - e2=buildArcOfCircle(center2,1.,M_PI+(k+1)*M_PI/4.,M_PI+(k-1)*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.35587863972199624,1e-10); - for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // 2 intersections R1>R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.6793851523346941,1e-10); - for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // 2 intersections R1>R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.6793851523346941,1e-10); - for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)>R2; Opposite order. - for(unsigned k=0;k<1;k++) - { - double center2[2]; center[0]=0.; center[1]=0.; - center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,1.,(k-1)*M_PI/4.,(k+1)*M_PI/4.); - e2=buildArcOfCircle(center2,3.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.1195732971845034,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)>R2; same order. - for(unsigned k=0;k<8;k++) - { - double center2[2]; center[0]=0.; center[1]=0.; - center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,1.,(k+1)*M_PI/4.,(k-1)*M_PI/4.); - e2=buildArcOfCircle(center2,3.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.1195732971845034,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.0844420190512074,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.0844420190512074,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Tangent intersection - QUADRATIC_PLANAR::setPrecision(1e-5); - for(unsigned k=0;k<8;k++) - { - double center2[2]; center[0]=0.; center[1]=0.; - center2[0]=4.*cos(k*M_PI/4.); center2[1]=4.*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,1.,(k+1)*M_PI/4.,(k-1)*M_PI/4.); - e2=buildArcOfCircle(center2,3.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); // order has no sence here because v4.size() expected to 1 but for valgrind serenity test. - CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v4.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - QUADRATIC_PLANAR::setPrecision(1e-14); - // Extremities # 1 - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.-0.55978664859225125,M_PI+k*M_PI/4.+0.55978664859225125); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(!intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT_EQUAL(0,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getStartNode()==e1->getEndNode()); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.55978664859225125,M_PI+k*M_PI/4.-0.55978664859225125); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(!intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT_EQUAL(0,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==e1->getEndNode()); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Extremities # 2 - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.55978664859225125,M_PI+k*M_PI/4.-0.7); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); - CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v4[0]); - v4[0]->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Extremities # 3 - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.7,M_PI+k*M_PI/4.-0.7); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==v4[0]); CPPUNIT_ASSERT(e1->getEndNode()==v4[1]); - v4[0]->decrRef(); v4[1]->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Extremities # 4 - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - Node *nodeS=new Node(center[0]+3.*cos(k*M_PI/4.-0.17793931986099812),center[1]+3.*sin(k*M_PI/4.-0.17793931986099812)); - Node *nodeE=new Node(center[0]+3.*cos(k*M_PI/4.),center[1]+3.*sin(k*M_PI/4.)); - double angle=k*M_PI/4.-0.17793931986099812; - angle=angle>M_PI?angle-2.*M_PI:angle; - e1=new EdgeArcCircle(nodeS,nodeE,//Problem of precision 1e-14 to easily reached. - center,3.,angle,0.17793931986099812); - nodeS->decrRef(); nodeE->decrRef(); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.7,M_PI+k*M_PI/4.-0.7); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==v4[0]); - v4[0]->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - //Extremities # 5 - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - Node *nodeS=new Node(center[0]+3.*cos(k*M_PI/4.-0.17793931986099812),center[1]+3.*sin(k*M_PI/4.-0.17793931986099812)); - Node *nodeE=new Node(center[0]+3.*cos(k*M_PI/4.)+0.5,center[1]+3.*sin(k*M_PI/4.)); - double angle=k*M_PI/4.-0.17793931986099812; - angle=angle>M_PI?angle-2.*M_PI:angle; - e1=new EdgeArcCircle(nodeS,nodeE,//Problem of precision 1e-14 to easily reached. - center,3.,angle,0.67793931986099812); - nodeS->decrRef(); nodeE->decrRef(); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.7,M_PI+k*M_PI/4.-0.7); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==v4[0]); - v4[0]->decrRef(); v4[1]->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } -} - -void QuadraticPlanarInterpTest::IntersectArcCircleFull() -{ - double center1[2]; center1[0]=0.; center1[1]=0.; double radius1=3.; - double center2[2]; center2[0]=0.75; center2[1]=-2.6; double radius2=1.; - EdgeArcCircle *e1=buildArcOfCircle(center1,radius1,-M_PI/3.,4.*M_PI/3.); - EdgeArcCircle *e2=buildArcOfCircle(center2,radius2,0.,M_PI/2.); - MergePoints commonNode; - QuadraticPolygon pol1; QuadraticPolygon pol2; - QuadraticPolygon pol3; QuadraticPolygon pol4; - pol3.pushBack(e1); pol4.pushBack(e2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol3.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol4.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(19.6648305849,pol3.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol4.getArea(),1e-6); - CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol1,pol2)); - CPPUNIT_ASSERT_EQUAL(2,pol1.size()); - CPPUNIT_ASSERT_EQUAL(2,pol2.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(19.6648305849,pol1.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol2.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol1.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol2.getPerimeter(),1e-6); - // - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,0.,M_PI/2.); - commonNode.clear(); - QuadraticPolygon pol5; QuadraticPolygon pol6; - QuadraticPolygon pol7; QuadraticPolygon pol8; - pol7.pushBack(e1); pol8.pushBack(e2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol7.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol8.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol7.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol8.getArea(),1e-6); - CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol5,pol6)); - CPPUNIT_ASSERT_EQUAL(2,pol5.size()); - CPPUNIT_ASSERT_EQUAL(2,pol6.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol5.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol6.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol5.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol6.getPerimeter(),1e-6); - // - center2[0]=3.5; center2[1]=0.; - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,M_PI/2.,3*M_PI/2.); - commonNode.clear(); - QuadraticPolygon pol9; QuadraticPolygon pol10; - QuadraticPolygon pol11; QuadraticPolygon pol12; - pol11.pushBack(e1); pol12.pushBack(e2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol11.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol12.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol11.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol12.getArea(),1e-6); - CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol9,pol10)); - CPPUNIT_ASSERT_EQUAL(3,pol9.size()); - CPPUNIT_ASSERT_EQUAL(3,pol10.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol9.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol10.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol9.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol10.getArea(),1e-6); - // - center2[0]=0.; center2[1]=0.; radius2=radius1; - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,M_PI/3.,2*M_PI/3.); - commonNode.clear(); - QuadraticPolygon pol13; QuadraticPolygon pol14; - QuadraticPolygon pol15; QuadraticPolygon pol16; - pol15.pushBack(e1); pol16.pushBack(e2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol15.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol16.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol15.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.6095032974147,pol16.getArea(),1e-6); - CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol13,pol14)); - CPPUNIT_ASSERT_EQUAL(3,pol13.size()); - CPPUNIT_ASSERT_EQUAL(1,pol14.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol13.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol13.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol14.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.6095032974147,pol14.getArea(),1e-6); - // - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,2*M_PI/3.,M_PI/3.); - commonNode.clear(); - QuadraticPolygon pol17; QuadraticPolygon pol18; - QuadraticPolygon pol19; QuadraticPolygon pol20; - pol19.pushBack(e1); pol20.pushBack(e2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol19.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol20.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol19.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.6095032974147,pol20.getArea(),1e-6); - CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol17,pol18)); - CPPUNIT_ASSERT_EQUAL(3,pol17.size()); - CPPUNIT_ASSERT_EQUAL(1,pol18.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol17.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol17.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol18.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.6095032974147,pol18.getArea(),1e-6); - //no intersection #1 - center2[0]=4.277; center2[1]=-4.277; - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,M_PI/4.,5*M_PI/4.); - QuadraticPolygon polTemp1; QuadraticPolygon polTemp2; - CPPUNIT_ASSERT(!e1->intersectWith(e2,commonNode,polTemp1,polTemp2)); - e1->decrRef(); e2->decrRef(); - //no intersection #2 - center2[0]=1.; center2[1]=-1.; radius2=0.2; - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,M_PI/4.,5*M_PI/4.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,commonNode,polTemp1,polTemp2)); - e1->decrRef(); e2->decrRef(); -} - -void QuadraticPlanarInterpTest::IntersectArcCircleSegumentBase() -{ - double center[2]={2.,2.}; - EdgeArcCircle *e1=buildArcOfCircle(center,2.3,M_PI/4.,5.*M_PI/4.); - EdgeLin *e2=new EdgeLin(-1.3,1.,3.,5.3); - EdgeIntersector *intersector=new ArcCSegIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - vector v4; - MergePoints v3; - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[0])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.3,(*v4[0])[1],1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.3,(*v4[1])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[1])[1],1e-10); - v4[0]->decrRef(); v4[1]->decrRef(); e2->decrRef(); v3.clear(); v4.clear(); delete intersector; - // - e2=new EdgeLin(3.,5.3,-1.3,1.); - intersector=new ArcCSegIntersector(*e1,*e2); - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[0])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.3,(*v4[0])[1],1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.3,(*v4[1])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[1])[1],1e-10); - v4[0]->decrRef(); v4[1]->decrRef(); e2->decrRef(); v3.clear(); v4.clear(); delete intersector; - // tangent intersection - e2=new EdgeLin(-1.,4.3,3.,4.3); - intersector=new ArcCSegIntersector(*e1,*e2); - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[0])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.3,(*v4[0])[1],1e-10); - v4[0]->decrRef(); e2->decrRef(); v3.clear(); delete intersector; - // no intersection - e2=new EdgeLin(-2.,-2.,-1.,-3.); - intersector=new ArcCSegIntersector(*e1,*e2); - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); CPPUNIT_ASSERT(obvious && !areOverlapped); - e2->decrRef(); v3.clear(); delete intersector; - // - e1->decrRef(); -} - -QuadraticPolygon *QuadraticPlanarInterpTest::buildQuadraticPolygonCoarseInfo(const double *coords, const int *conn, int lgth) -{ - vector nodes; - for(int i=0;i -#include -#include - -using namespace std; -using namespace INTERP_KERNEL; - - -void QuadraticPlanarInterpTest::checkInOutDetection() -{ - Node *n1=new Node(0.,0.); - Node *n2=new Node(1.,0.); - Node *n3=new Node(0.5,1.); - EdgeLin *e1=new EdgeLin(n1,n2); - EdgeLin *e2=new EdgeLin(n2,n3); - EdgeLin *e3=new EdgeLin(n3,n1); - ComposedEdge *tri=new ComposedEdge; - tri->pushBack(e1); tri->pushBack(e2); tri->pushBack(e3); - // - Node *where=new Node(0.4,0.1); - CPPUNIT_ASSERT(tri->isInOrOut(where)); where->decrRef(); - where=new Node(-0.1,1.); - CPPUNIT_ASSERT(!tri->isInOrOut(where)); where->decrRef(); - where=new Node(0.6,-0.1); - CPPUNIT_ASSERT(!tri->isInOrOut(where)); where->decrRef(); - //Clean-up - n1->decrRef(); n2->decrRef(); n3->decrRef(); - ComposedEdge::Delete(tri); -} - -/*! - * Check Iterators mechanism. - */ -void QuadraticPlanarInterpTest::checkAssemblingBases1() -{ - Node *n1=new Node(0.,0.); - Node *n2=new Node(0.1,0.); EdgeLin *e1_2=new EdgeLin(n1,n2); - Node *n3=new Node(0.2,0.); EdgeLin *e2_3=new EdgeLin(n2,n3); - Node *n4=new Node(0.3,0.); EdgeLin *e3_4=new EdgeLin(n3,n4); - Node *n5=new Node(0.4,0.); EdgeLin *e4_5=new EdgeLin(n4,n5); - Node *n6=new Node(0.5,0.); EdgeLin *e5_6=new EdgeLin(n5,n6); - Node *n7=new Node(0.6,0.); EdgeLin *e6_7=new EdgeLin(n6,n7); - Node *n8=new Node(0.7,0.); EdgeLin *e7_8=new EdgeLin(n7,n8); - Node *n9=new Node(0.8,0.); EdgeLin *e8_9=new EdgeLin(n8,n9); - Node *n10=new Node(0.9,0.); EdgeLin *e9_10=new EdgeLin(n9,n10); - Node *n11=new Node(1.,0.); EdgeLin *e10_11=new EdgeLin(n10,n11); - Node *n12=new Node(0.5,1.); EdgeLin *e11_12=new EdgeLin(n11,n12); - EdgeLin *e12_1=new EdgeLin(n12,n1); - //Only one level - e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef(); - e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef(); - ComposedEdge *c=new ComposedEdge; - c->pushBack(e1_2); c->pushBack(e2_3); c->pushBack(e3_4); c->pushBack(e4_5); c->pushBack(e5_6); c->pushBack(e6_7); - c->pushBack(e7_8); c->pushBack(e8_9); c->pushBack(e9_10); c->pushBack(e10_11); c->pushBack(e11_12); c->pushBack(e12_1); - CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize()); - IteratorOnComposedEdge it(c); - CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); - it.next(); CPPUNIT_ASSERT(it.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it.finished()); - it.next(); it.next(); CPPUNIT_ASSERT(it.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it.finished()); - it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it.finished()); - it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it.finished()); - it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); - it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished()); - it.next(); CPPUNIT_ASSERT(it.finished()); - it.first(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); - it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished()); - it.nextLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); - it.last(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished()); - //Multi-Level - ComposedEdge::Delete(c); - //(e1_2, (e2_3,(e3_4, e4_5, e5_6, e6_7, (e7_8, e8_9 ), ( e9_10 , e10_11 ), e11_12 ),e12_1 ) ) - e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef(); - e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef(); - ComposedEdge *c2_2_4=new ComposedEdge; c2_2_4->pushBack(e7_8); c2_2_4->pushBack(e8_9); - ComposedEdge *c2_2_5=new ComposedEdge; c2_2_5->pushBack(e9_10); c2_2_5->pushBack(e10_11); - ComposedEdge *c2_2=new ComposedEdge; c2_2->pushBack(e3_4); c2_2->pushBack(e4_5); c2_2->pushBack(e5_6); c2_2->pushBack(e6_7); c2_2->pushBack(c2_2_4); c2_2->pushBack(c2_2_5); c2_2->pushBack(e11_12); - ComposedEdge *c2=new ComposedEdge; c2->pushBack(e2_3); c2->pushBack(c2_2); c2->pushBack(e12_1); - c=new ComposedEdge; c->pushBack(e1_2); c->pushBack(c2); CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize()); - IteratorOnComposedEdge it2(c); - CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); - it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); - it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - it2.next(); CPPUNIT_ASSERT(it2.finished()); - it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - it2.last(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); - // substitutions. - /*it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - ElementaryEdge *&tmp=it2.current(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - ComposedEdge *c1=new ComposedEdge; Node *n1_bis=new Node(0.,0.05); EdgeLin *e1_1bis=new EdgeLin(n1,n1_bis); EdgeLin *e1bis_2=new EdgeLin(n1_bis,n2); e1_1bis->incrRef(); e1bis_2->incrRef(); - c1->pushBack(e1_1bis); c1->pushBack(e1bis_2); delete tmp; tmp=(ElementaryEdge *)c1; CPPUNIT_ASSERT_EQUAL(13,c->recursiveSize()); - CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());// here testing capability of Iterator.'current' method to deal with change of hierarchy. - it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); - it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e11_12); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e10_11); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e9_10); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e8_9); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e7_8); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e6_7); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e5_6); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - //go forward - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e5_6); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e6_7); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e7_8); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e8_9); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e9_10); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e10_11); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e11_12); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());*/ - ComposedEdge::SoftDelete(c2_2_4); - ComposedEdge::SoftDelete(c2_2_5); - ComposedEdge::SoftDelete(c2_2); - ComposedEdge::SoftDelete(c2); - ComposedEdge::Delete(c); - //clean-up - //e1_1bis->decrRef(); e1bis_2->decrRef(); - e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_7->decrRef(); - e7_8->decrRef(); e8_9->decrRef(); e9_10->decrRef(); e10_11->decrRef(); e11_12->decrRef(); e12_1->decrRef(); - //n1_bis->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - n7->decrRef(); n8->decrRef(); n9->decrRef(); n10->decrRef(); n11->decrRef(); n12->decrRef(); -} - -/*! - * Check splitting of 2 polygons. After this operation, all ElementaryEdge are either in/out/on. - */ -void QuadraticPlanarInterpTest::checkAssemblingBases2() -{ - //The "most" basic test1 - Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-0.3); - Node *n2=new Node(1.,0.); Node *n5=new Node(1.,-0.3); - Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.7); - EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); - EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); - EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); - // - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); - QuadraticPolygon cpyPol1(pol1); int nbOfSplits=0; - cpyPol1.splitPolygonsEachOther(pol1,pol2,nbOfSplits); - CPPUNIT_ASSERT_EQUAL(5,pol1.recursiveSize()); - CPPUNIT_ASSERT_EQUAL(5,pol2.recursiveSize());CPPUNIT_ASSERT_EQUAL(15,nbOfSplits); - checkBasicsOfPolygons(pol1,pol2,true); - CPPUNIT_ASSERT(pol2[1]->getEndNode()==pol1[1]->getEndNode()); - CPPUNIT_ASSERT(pol2[1]->getEndNode()->getLoc()==ON_1); - CPPUNIT_ASSERT(pol2[3]->getEndNode()==pol1[0]->getEndNode()); - CPPUNIT_ASSERT(pol2[3]->getEndNode()->getLoc()==ON_1); - cpyPol1.performLocatingOperation(pol2); - ElementaryEdge *tmp=dynamic_cast(pol2[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol2[1]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol2[2]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1); - tmp=dynamic_cast(pol2[3]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1); - tmp=dynamic_cast(pol2[4]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - //clean-up for test1 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Deeper test some extremities of pol2 are on edges of pol1. - - n1=new Node(0.,0.); n4=new Node(1.5,-0.5); - n2=new Node(1.,0.); n5=new Node(0.5,0.); - n3=new Node(0.5,1.); n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - EdgeLin *e5_4=new EdgeLin(n5,n4); EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_6=new EdgeLin(n7,n6); EdgeLin *e6_5=new EdgeLin(n6,n5); - // - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef(); - QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); - QuadraticPolygon pol4; pol4.pushBack(e5_4); pol4.pushBack(e4_7); pol4.pushBack(e7_6); pol4.pushBack(e6_5); - QuadraticPolygon cpyPol3(pol3); nbOfSplits=0; - cpyPol3.splitPolygonsEachOther(pol3,pol4,nbOfSplits); - CPPUNIT_ASSERT_EQUAL(5,pol3.recursiveSize()); - CPPUNIT_ASSERT_EQUAL(4,pol4.recursiveSize());CPPUNIT_ASSERT_EQUAL(16,nbOfSplits); - checkBasicsOfPolygons(pol3,pol4,true); - CPPUNIT_ASSERT(pol4[0]->getStartNode()==pol3[0]->getEndNode()); CPPUNIT_ASSERT(pol4[0]->getStartNode()==n5); - CPPUNIT_ASSERT(n5->getLoc()==ON_LIM_1); - CPPUNIT_ASSERT(pol4[2]->getEndNode()==pol3[2]->getEndNode()); CPPUNIT_ASSERT(pol4[2]->getEndNode()==n6); - CPPUNIT_ASSERT(n6->getLoc()==ON_LIM_1); - cpyPol3.performLocatingOperation(pol4); - tmp=dynamic_cast(pol4[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_7); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol4[3]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e6_5); - tmp=dynamic_cast(pol4[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e5_4); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol4[2]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e7_6); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol4[3]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e6_5); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1); - //clean-up for test2 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e5_4->decrRef(); e4_7->decrRef(); e7_6->decrRef(); e6_5->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); - - //Test with one edge of pol2 is included in pol1. - - n1=new Node(0.,0.); n4=new Node(-0.5,0.); - n2=new Node(1.,0.); n5=new Node(0.,-1.); - n3=new Node(0.5,1.); n6=new Node(0.5,0.); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1); - QuadraticPolygon pol6; pol6.pushBack(e4_5); pol6.pushBack(e5_6); pol6.pushBack(e6_4); - QuadraticPolygon cpyPol5(pol5); nbOfSplits=0; - cpyPol5.splitPolygonsEachOther(pol5,pol6,nbOfSplits); - CPPUNIT_ASSERT_EQUAL(4,pol5.recursiveSize()); - CPPUNIT_ASSERT_EQUAL(4,pol6.recursiveSize()); CPPUNIT_ASSERT_EQUAL(13,nbOfSplits); - checkBasicsOfPolygons(pol5,pol6,false); - CPPUNIT_ASSERT(pol6[2]->getStartNode()==pol5[0]->getEndNode()); CPPUNIT_ASSERT(pol6[2]->getStartNode()==n6); - CPPUNIT_ASSERT(n6->getLoc()==ON_LIM_1); - CPPUNIT_ASSERT(pol6[2]->getEndNode()==pol5[0]->getStartNode()); CPPUNIT_ASSERT(pol5[0]->getStartNode()==n1); - CPPUNIT_ASSERT(n1->getLoc()==ON_LIM_1); - cpyPol5.performLocatingOperation(pol6); - tmp=dynamic_cast(pol6[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol6[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e5_6); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol6[2]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); - tmp=dynamic_cast(pol6[3]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - //clean-up test3 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Test of full overlapped polygons. - - n1=new Node(0.,0.); n4=new Node(0.,0.); - n2=new Node(1.,0.); n5=new Node(1.,0.); - n3=new Node(0.5,1.); n6=new Node(0.5,1.); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1); - QuadraticPolygon pol8; pol8.pushBack(e4_5); pol8.pushBack(e5_6); pol8.pushBack(e6_4); - QuadraticPolygon cpyPol7(pol7); nbOfSplits=0; - cpyPol7.splitPolygonsEachOther(pol7,pol8,nbOfSplits); - tmp=dynamic_cast(pol8[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e1_2); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); - tmp=dynamic_cast(pol8[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e2_3); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); - tmp=dynamic_cast(pol8[2]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e3_1); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); - //clean-up test4 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); -} - -void QuadraticPlanarInterpTest::checkBasicsOfPolygons(QuadraticPolygon& pol1, QuadraticPolygon& pol2, bool checkDirection) -{ - IteratorOnComposedEdge it1(&pol1),it2(&pol2); it1.previousLoop(); it2.previousLoop(); - Node *nIter1=it1.current()->getEndNode(); Node *nIter2=it2.current()->getEndNode(); - for(it2.first();!it2.finished();it2.next()) - { - CPPUNIT_ASSERT(nIter2==it2.current()->getStartNode()); - if(checkDirection) - CPPUNIT_ASSERT(it2.current()->getDirection()); - nIter2=it2.current()->getEndNode(); - } - for(it1.first();!it1.finished();it1.next()) - { - CPPUNIT_ASSERT(nIter1==it1.current()->getStartNode()); - if(checkDirection) - CPPUNIT_ASSERT(it1.current()->getDirection()); - nIter1=it1.current()->getEndNode(); - } -} diff --git a/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest4.cxx b/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest4.cxx deleted file mode 100644 index cffd067b6..000000000 --- a/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest4.cxx +++ /dev/null @@ -1,1659 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "QuadraticPlanarInterpTest.hxx" -#include "QuadraticPolygon.hxx" -#include "ElementaryEdge.hxx" -#include "EdgeArcCircle.hxx" -#include "EdgeLin.hxx" - -#include -#include -#include -#include - -using namespace std; -using namespace INTERP_KERNEL; - -void QuadraticPlanarInterpTest::checkPolygonsIntersection1() -{ - //The "most" basic test1 - Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-0.3); - Node *n2=new Node(1.,0.); Node *n5=new Node(1.,-0.3); - Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.7); - EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); - EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); - EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); - // - vector result; - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<1;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol1; pol1.circularPermute(); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - for(int i1=0;i1recursiveSize()); - double tmp1=0.,tmp2=0.,tmp3=0.; - pol1.intersectForPerimeter(pol2,tmp1,tmp2,tmp3); - vector v1,v2; - vector v3; - pol1.intersectForPerimeterAdvanced(pol2,v1,v2);//no common edge - pol1.intersectForPoint(pol2,v3); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v3.size()); - if(k==0) - { - CPPUNIT_ASSERT_EQUAL(2,v3[(3-i)%3]); - CPPUNIT_ASSERT_EQUAL(0,v3[(4-i)%3]); - CPPUNIT_ASSERT_EQUAL(0,v3[(5-i)%3]); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,v1[(3-i)%3],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(4-i)%3],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(5-i)%3],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v2[0],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[1],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[2],1.e-14); - } - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,tmp1,1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5652475842498528,tmp2,1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp3,1.e-14);//no common edge - delete result[0]; - } - } - //clean-up for test1 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Deeper test some extremities of pol2 are on edges of pol1. - - n1=new Node(0.,0.); n4=new Node(1.5,-0.5); - n2=new Node(1.,0.); n5=new Node(0.5,0.); - n3=new Node(0.5,1.); n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - EdgeLin *e5_4=new EdgeLin(n5,n4); EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_6=new EdgeLin(n7,n6); EdgeLin *e6_5=new EdgeLin(n6,n5); - // - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<4;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef(); - QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); - for(int i1=0;i1recursiveSize()); - delete result[0]; - } - } - //clean-up for test2 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e5_4->decrRef(); e4_7->decrRef(); e7_6->decrRef(); e6_5->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); - - //Test with one edge of pol2 is included in pol1. - - n1=new Node(0.,0.); n4=new Node(-0.5,0.); - n2=new Node(1.,0.); n5=new Node(0.,-1.); - n3=new Node(0.5,1.); n6=new Node(0.5,0.); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1); - for(int i1=0;i1decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Test of full overlapped polygons. - - n1=new Node(0.,0.); n4=new Node(0.,0.); - n2=new Node(1.,0.); n5=new Node(1.,0.); - n3=new Node(0.5,1.); n6=new Node(0.5,1.); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1); - for(int i1=0;i1recursiveSize()); - delete result[0]; - double tmp1=0.,tmp2=0.,tmp3=0.; - pol7.intersectForPerimeter(pol8,tmp1,tmp2,tmp3); - vector v1,v2; - pol7.intersectForPerimeterAdvanced(pol8,v1,v2);//only common edges. - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v1[0]+v1[1]+v1[2],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v2[0]+v2[1]+v2[2],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp1,1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp2,1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,tmp3,1.e-14); - } - } - //clean-up test4 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Test of closing process - - n1=new Node(0.,0.); n4=new Node(0.539,-0.266); - n2=new Node(1.,0.); n5=new Node(1.039,0.6); - n3=new Node(0.5,1.); n6=new Node(-0.077,0.667); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol9; pol9.pushBack(e1_2); pol9.pushBack(e2_3); pol9.pushBack(e3_1); - for(int i1=0;i1recursiveSize()); - delete result[0]; - } - } - //clean-up test5 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - // Full in case - - n1=new Node(0.,0.); n4=new Node(0.3,0.1); - n2=new Node(1.,0.); n5=new Node(0.7,0.1); - n3=new Node(0.5,1.); n6=new Node(0.5,0.7); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol11; pol11.pushBack(e1_2); pol11.pushBack(e2_3); pol11.pushBack(e3_1); - for(int i1=0;i1recursiveSize()); - delete result[0]; - } - } - //clean-up test6 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - // Full out case - - n1=new Node(0.,0.); n4=new Node(-2,0.); - n2=new Node(1.,0.); n5=new Node(-1.,0.); - n3=new Node(0.5,1.); n6=new Node(-1.5,1.); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol13; pol13.pushBack(e1_2); pol13.pushBack(e2_3); pol13.pushBack(e3_1); - for(int i1=0;i1decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Multi polygons - - n1=new Node(0.,0.); - n2=new Node(1.,0.); - n3=new Node(1.,1.); - n4=new Node(0.,1.); - // - n5=new Node(0.2,0.7); - n6=new Node(0.4,0.7); - n7=new Node(0.4,1.3); - Node *n8=new Node(0.6,1.3); - Node *n9=new Node(0.6,0.7); - Node *n10=new Node(0.9,0.7); - Node *n11=new Node(0.9,2.); - Node *n12=new Node(0.2,2.); - // - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); Edge *e3_4=new EdgeLin(n3,n4); Edge *e4_1=new EdgeLin(n4,n1); - e5_6=new EdgeLin(n5,n6); Edge *e6_7=new EdgeLin(n6,n7); Edge *e7_8=new EdgeLin(n7,n8); Edge *e8_9=new EdgeLin(n8,n9); Edge *e9_10=new EdgeLin(n9,n10); Edge *e10_11=new EdgeLin(n10,n11); - Edge *e11_12=new EdgeLin(n11,n12); Edge *e12_1=new EdgeLin(n12,n5); - // - for(int k=0;k<2;k++) - for(int i=0;i<4;i++) - { - for(int j=0;j<8;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef(); e5_6->incrRef(); e6_7->incrRef(); e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef(); - QuadraticPolygon pol15; pol15.pushBack(e1_2); pol15.pushBack(e2_3); pol15.pushBack(e3_4); pol15.pushBack(e4_1); - for(int i1=0;i1recursiveSize()); CPPUNIT_ASSERT_EQUAL(4,result[1]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,result[0]->getArea()+result[1]->getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.03,fabs(result[0]->getArea()-result[1]->getArea()),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,pol15.intersectWith(pol16),1e-10); - delete result[0]; delete result[1]; - } - } - //clean-up test8 - e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); e5_6->decrRef(); e6_7->decrRef(); e7_8->decrRef(); e8_9->decrRef(); e9_10->decrRef(); e10_11->decrRef(); e11_12->decrRef(); e12_1->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); n8->decrRef(); n9->decrRef(); n10->decrRef(); n11->decrRef(); n12->decrRef(); -} - -/*! - * Testing case where a polygon pol1 is included in an onother polygon pol2. - */ -void QuadraticPlanarInterpTest::checkPolygonsIntersection2() -{ - Node *n1=new Node(0.,0.); Node *n4=new Node(0.2,0.2); - Node *n2=new Node(1.,0.); Node *n5=new Node(0.8,0.2); - Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.8); - Edge *e1_2=new EdgeLin(n1,n2); Edge *e4_5=new EdgeLin(n4,n5); - Edge *e2_3=new EdgeLin(n2,n3); Edge *e5_6=new EdgeLin(n5,n6); - Edge *e3_1=new EdgeLin(n3,n1); Edge *e6_4=new EdgeLin(n6,n4); - // - QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); - vector result=pol1.intersectMySelfWith(pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); - CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10); - delete result[0]; - result.clear(); - pol1.initLocations(); - pol2.initLocations(); - result=pol2.intersectMySelfWith(pol1); - CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); - CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10); - delete result[0]; - //clean-up - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); -} - -void QuadraticPlanarInterpTest::checkAreasCalculations() -{ - Node *n1=new Node(0.,0.); - Node *n2=new Node(1.,0.); - Node *n3=new Node(0.5,1.); - Edge *e1_2=new EdgeLin(n1,n2); - Edge *e2_3=new EdgeLin(n2,n3); - Edge *e3_1=new EdgeLin(n3,n1); - // - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); - QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,pol1.getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,pol1.getPerimeter(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.61803398874989479,pol1.getHydraulicDiameter(),1e-10); - pol1.reverse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.5,pol1.getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,pol1.getPerimeter(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.61803398874989479,pol1.getHydraulicDiameter(),1e-10); - //clean-up - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); - - //case 2 - - n1=new Node(0.,0.); - n2=new Node(1.,0.); - Node *n3m=new Node(1.5,0.5); - n3=new Node(1.,1.); - Node *n4=new Node(0.,1.); - e1_2=new EdgeLin(n1,n2); - e2_3=new EdgeArcCircle(n2,n3m,n3); - Edge *e3_4=new EdgeLin(n3,n4); - Edge *e4_1=new EdgeLin(n4,n1); - // - for(int k=0;k<8;k++) - { - n2->setNewCoords(cos(k*M_PI/4),sin(k*M_PI/4)); - n3->setNewCoords(sqrt(2.)*cos((k+1)*M_PI/4),sqrt(2.)*sin((k+1)*M_PI/4)); - n3m->setNewCoords(1.5811388300841898*cos(0.3217505543966423+k*M_PI/4),1.5811388300841898*sin(0.3217505543966423+k*M_PI/4)); - n4->setNewCoords(cos(k*M_PI/4+M_PI/2),sin(k*M_PI/4+M_PI/2)); - e1_2->update(n3m); e2_3->update(n3m); e3_4->update(n3m); e4_1->update(n3m); - e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef(); - QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_3); pol2.pushBack(e3_4); pol2.pushBack(e4_1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.3926990816987241,pol2.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6); - pol2.reverse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.3926990816987241,pol2.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6); - } - //clean-up case2 - e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef(); - - //case 3 - - const double radius1=0.7; - const double radius2=0.9; - n1=new Node(1.+radius1*cos(-2.*M_PI/3.),1.+radius1*sin(-2.*M_PI/3.)); - n2=new Node(1.+radius1*cos(-M_PI/3.),1.+radius1*sin(-M_PI/3.)); - Node *n2m=new Node(1.+radius1*cos(M_PI/2.),1.+radius1*sin(M_PI/2.)); - n3=new Node(1.+radius2*cos(-M_PI/3.),1.+radius2*sin(-M_PI/3.)); - n3m=new Node(1.+radius2*cos(M_PI/2.),1.+radius2*sin(M_PI/2.)); - n4=new Node(1.+radius2*cos(-2.*M_PI/3.),1.+radius2*sin(-2.*M_PI/3.)); - e1_2=new EdgeArcCircle(n1,n2m,n2); - e2_3=new EdgeLin(n2,n3); - e3_4=new EdgeArcCircle(n3,n3m,n4); - e4_1=new EdgeLin(n4,n1); - // - e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef(); - QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_4); pol3.pushBack(e4_1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.83775804095727857,pol3.getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10); - pol3.reverse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.83775804095727857,pol3.getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10); - //clean-up case3 - e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); - n1->decrRef(); n2->decrRef(); n2m->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef(); -} - -void QuadraticPlanarInterpTest::checkBarycenterCalculations() -{ - Node *n1=new Node(3.,7.); - Node *n2=new Node(5.,7.); - Node *n3=new Node(4.,8.); - Edge *e1_2=new EdgeLin(n1,n2); - Edge *e2_3=new EdgeLin(n2,n3); - Edge *e3_1=new EdgeLin(n3,n1); - // - double bary[2]; - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); - QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - bary[0]=0.; bary[1]=0.; - e1_2->getBarycenterOfZone(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-56.,bary[0],1.e-10); - bary[0]=0.; bary[1]=0.; - e2_3->getBarycenterOfZone(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(33.66666666666667,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(28.16666666666667,bary[1],1.e-10); - bary[0]=0.; bary[1]=0.; - e3_1->getBarycenterOfZone(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(26.333333333333336,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(28.1666666666667,bary[1],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,pol1.getArea(),1e-10); - pol1.getBarycenter(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10); - // - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); - QuadraticPolygon pol4; pol4.pushBack(e3_1,false); pol4.pushBack(e2_3,false); pol4.pushBack(e1_2,false); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol4.getArea(),1e-10); - pol4.getBarycenter(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10); - //clean-up - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); - //Inverting polygon - n1=new Node(3.,7.); - n2=new Node(5.,7.); - n3=new Node(4.,8.); - e1_2=new EdgeLin(n1,n3); - e2_3=new EdgeLin(n3,n2); - e3_1=new EdgeLin(n2,n1); - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); - QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); - bary[0]=0.; bary[1]=0.; - pol3.getBarycenter(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol3.getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10); - //clean-up - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); - // - double center[2]={3.,7.}; - e1_2=buildArcOfCircle(center,4.,M_PI/3.,4.*M_PI/3.); - bary[0]=0.; bary[1]=0.; - e1_2->getBarycenterOfZone(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(131.685410765053,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(303.262521934362,bary[1],1.e-10); - n1=new Node(0.99999999999999822,3.5358983848622465); - n2=new Node(5.,10.4641016151377544); - Edge *e2_1=new EdgeLin(n1,n2); - // - e1_2->incrRef(); e2_1->incrRef(); - QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_1); - pol2.getBarycenter(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(25.132741228718345,pol2.getArea(),1e-10); - //4*radius/(3.*pi) - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5297896122085546,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.8488263631567756,bary[1],1.e-10); - //clean-up - e1_2->decrRef(); e2_1->decrRef(); - n1->decrRef(); n2->decrRef(); -} - -/*! - * Testing user interface high level function. - */ -void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1() -{ - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); - double coords[]={ - 8.8334591186000004, 5.0999999999999996, - 7.1014083111000001, 6.0999999999999996, - 7.8334591186000004, 6.8320508074999999, - 7.9674337149000003, 5.5999999999999996, - 7.4192455562999999, 6.5142135623000001, - 8.3334591186000004, 5.9660254036999998 - }; - vector nodes; - nodes.push_back(new Node(coords)); - nodes.push_back(new Node(coords+2)); - nodes.push_back(new Node(coords+4)); - nodes.push_back(new Node(coords+6)); - nodes.push_back(new Node(coords+8)); - nodes.push_back(new Node(coords+10)); - QuadraticPolygon *pol=QuadraticPolygon::buildArcCirclePolygon(nodes); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.04719755,pol->getArea(),1e-5); - CPPUNIT_ASSERT_EQUAL(3,pol->size()); - ElementaryEdge *e0=dynamic_cast((*pol)[0]); - ElementaryEdge *e1=dynamic_cast((*pol)[1]); - ElementaryEdge *e2=dynamic_cast((*pol)[0]); - CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2); - CPPUNIT_ASSERT(dynamic_cast(e0->getPtr()));//<- testing detection of colinearity - CPPUNIT_ASSERT(dynamic_cast(e1->getPtr())); - CPPUNIT_ASSERT(dynamic_cast(e2->getPtr()));//<- testing detection of colinearity - nodes.clear(); - delete pol; - nodes.push_back(new Node(coords)); - nodes.push_back(new Node(coords+4)); - nodes.push_back(new Node(coords+2)); - nodes.push_back(new Node(coords+10)); - nodes.push_back(new Node(coords+8)); - nodes.push_back(new Node(coords+6)); - pol=QuadraticPolygon::buildArcCirclePolygon(nodes); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.04719755,pol->getArea(),1e-5); - CPPUNIT_ASSERT_EQUAL(3,pol->size()); - e0=dynamic_cast((*pol)[0]); - e1=dynamic_cast((*pol)[1]); - e2=dynamic_cast((*pol)[0]); - CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2); - CPPUNIT_ASSERT(dynamic_cast(e0->getPtr()));//<- testing detection of colinearity - CPPUNIT_ASSERT(dynamic_cast(e1->getPtr())); - CPPUNIT_ASSERT(dynamic_cast(e2->getPtr()));//<- testing detection of colinearity - delete pol; - const double coords2[]={ - 0.,0., - 1.5,0., - 1.5,1., - 0.,1. - }; - nodes.clear(); - nodes.push_back(new Node(coords2)); - nodes.push_back(new Node(coords2+2)); - nodes.push_back(new Node(coords2+4)); - nodes.push_back(new Node(coords2+6)); - pol=QuadraticPolygon::buildLinearPolygon(nodes); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,pol->getArea(),1e-12); - double tmp[2],tmp2; - pol->getBarycenter(tmp,tmp2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,tmp[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,tmp[1],1e-12); - delete pol; - const double coords3[]={ - 1.0999999999000001, -1.9052558882999999, - 1.9052558881999999, -1.0999999999000001, - 1.7320508075000001, -0.99999999989999999, - 0.99999999989999999, -1.7320508075000001, - 1.5556349186, -1.5556349185, - 1.8186533478, -1.0499999999, - 1.4142135623000001, -1.4142135623000001, - 1.0499999999, -1.8186533479 - }; - nodes.clear(); - nodes.push_back(new Node(coords3)); - nodes.push_back(new Node(coords3+2)); - nodes.push_back(new Node(coords3+4)); - nodes.push_back(new Node(coords3+6)); - nodes.push_back(new Node(coords3+8)); - nodes.push_back(new Node(coords3+10)); - nodes.push_back(new Node(coords3+12)); - nodes.push_back(new Node(coords3+14)); - pol=QuadraticPolygon::buildArcCirclePolygon(nodes); - pol->getBarycenter(tmp,tmp2); - delete pol; - QUADRATIC_PLANAR::setPrecision(1e-14); -} - -void QuadraticPlanarInterpTest::check1DInterpLin() -{ - QUADRATIC_PLANAR::setPrecision(1e-7); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); - const int NB_OF_CELL_AXIAL_1=30; - static const double Z_VALS_1[NB_OF_CELL_AXIAL_1+1]= - { -0.1550 , -0.1356, -0.1162, -0.0969, -0.0775 ,-0.0581, -0.0387, -0.0194, 0.0000 , 0.0500, - 0.1000 , 0.1500 , 0.2000 , 0.2500, 0.3000, 0.3500, 0.4000, 0.4500, 0.5000, 0.5500, - 0.6000, 0.6500, 0.7000, 0.7194, 0.7388, 0.7581, 0.7775, 0.7969, 0.8163, 0.8356, - 0.8550}; - vector zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1); - - const int NB_OF_CELL_AXIAL_2=46; - static const double Z_VALS_2[NB_OF_CELL_AXIAL_2+1]= - { -0.3050 ,-0.2863,-0.2675,-0.2488,-0.2300,-0.2113,-0.1925,-0.1738,-0.1550,-0.1356 - , -0.1162,-0.0969,-0.0775,-0.0581,-0.0387,-0.0194,0.0000, 0.0500, 0.1 ,0.15 - , 0.20, 0.25, 0.30, 0.350 ,0.40 ,0.450 ,0.500 , 0.550, 0.600 ,0.650 ,0.700 - , 0.7194 ,0.7388 ,0.7581 ,0.7775 ,0.7969 ,0.8163 ,0.8356, 0.8550 - , 0.8738 ,0.8925 ,0.9113 ,0.9300 ,0.9488 ,0.9675 ,0.9863, 1.0050}; - vector zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1); - map > m; - Edge::interpolate1DLin(zLev1,zLev2,m); - CPPUNIT_ASSERT_EQUAL(30,(int)m.size()); - double ret=0; - for(int i=0;i<30;i++) - { - CPPUNIT_ASSERT_EQUAL(1,(int)m[i].size()); - CPPUNIT_ASSERT(m[i][8+i] > 0.15); - ret+=m[i][8+i]; - } - CPPUNIT_ASSERT_DOUBLES_EQUAL(ret,30.,1e-12); - // - m.clear(); - const int NB_OF_CELL_AXIAL_3=13; - static const double Z_VALS_3[NB_OF_CELL_AXIAL_3+1]={ - 0.,0.01,0.05,0.10,0.15,0.20,0.25,0.30, - 0.35,0.40,0.45,0.50,0.55,0.60 }; - vector zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1); - Edge::interpolate1DLin(zLev3,zLev1,m); - CPPUNIT_ASSERT_EQUAL(13,(int)m.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[1][8],1e-12); - for(int i=0;i<11;i++) - { - CPPUNIT_ASSERT_EQUAL(1,(int)m[i+2].size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[i+2][i+9],1e-12); - } - QUADRATIC_PLANAR::setPrecision(1e-14); -} - -/*! - * This test looks if intersectors are in coherency. - */ -void QuadraticPlanarInterpTest::checkEpsilonCoherency1() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); - - const double pol1[]={ - -2.1083388455000001, 1.2172499999999999, - -1.7320508075000001, 1, - -1.9201948265, 1.108625 - }; - - const double pol2[]={ - -2.2379999998, 0, - -1.9381648534, 1.1189999998, - -2.1617419990000002, 0.57923702298000002, - -1.9381648534, 1.1189999998, - -1.9909924031999999, 1.1494999999, - -1.9645786283, 1.1342499998 - }; - // - Node *n1=new Node(pol1[0],pol1[1]); - Node *n2=new Node(pol1[2],pol1[3]); - Node *n3; - // - Edge *e1=new EdgeLin(n1,n2); n1->decrRef(); n2->decrRef(); - n1=new Node(pol2[0],pol2[1]); - n2=new Node(pol2[4],pol2[5]); - n3=new Node(pol2[2],pol2[3]); - Edge *e2=new EdgeArcCircle(n1,n2,n3); n1->decrRef(); n2->decrRef(); n3->decrRef(); - e2->decrRef(); - e1->decrRef(); -} - -/*! - * Tests to avoid regressions : Basic one. - */ -void QuadraticPlanarInterpTest::checkNonRegression1() -{ - const double coords1[]= - { - 16.1732057215, -25.110999999800001, - 16.02555485246479, -25.340997988918762 - }; - Node *nS1=new Node(coords1); - Node *nE1=new Node(coords1+2); - const double radius1=2.902; - const double angleS1=-0.49999999950907054; const double angleL1=-0.0942156629996692; - const double center1[2]={13.66, -23.66}; - EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1); - // - const double coords2[]= - { - 16.041579804000001, -25.350249998999999, - 16.367740958999999, -24.132999999999999 - }; - Node *nS2=new Node(coords2); - Node *nE2=new Node(coords2+2); - const double radius2=2.4345; - const double angleS2=-0.523598776190207; const double angleL2=0.5235987755846041; - const double center2[]={ 13.933240960547204, -24.132999998525658 }; - EdgeArcCircle *e2=new EdgeArcCircle(nS2,nE2,center2,radius2,angleS2,angleL2); - MergePoints merge; - QuadraticPolygon c1,c2; - e1->intersectWith(e2,merge,c1,c2); - CPPUNIT_ASSERT_EQUAL(2,c1.size()); CPPUNIT_ASSERT_EQUAL(2,c2.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCurveLength(),c1.getPerimeter(),1e-5); - //clean-up - nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef(); -} - -void QuadraticPlanarInterpTest::checkNonRegression2() -{ - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); - double coords1[]= - { - 15.141499999899999, -26.226033271399999, - 16.226033271199999, -25.141499999800001, - 16.1732057215, -25.110999999800001, - 15.110999999899999, -26.1732057217, - 15.755157392699999, -25.755157392499999, - 16.199619496299999, -25.126249999799999, - 15.7120238788, -25.712023879099998, - 15.126249999899999, -26.199619496499999 - }; - double coords2[]= - { - 15.933240959000001, -24.132999999999999, - 15.665291765999999, -25.132999998999999, - 16.041579804000001, -25.350249998999999, - 16.367740958999999, -24.132999999999999, - 15.865092611, -24.650638091000001, - 15.853435785, -25.241624998999999, - 16.284787383000001, -24.763094964, - 16.150490958999999, -24.132999999999999 - }; - vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,v[0]->getArea(),1e-7); - delete v[0]; - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,pol1->intersectWith(*pol2),1e-7); - delete pol1; - delete pol2; -} - -/*! - * Tests to avoid regressions : Basic one. - */ -void QuadraticPlanarInterpTest::checkNonRegression3() -{ - const double coords1[]= - { - 10.962340811000001, -22.417749999000002, - 12.217990959, -21.162099852000001 - }; - Node *nS1=new Node(coords1); - Node *nE1=new Node(coords1+2); - const double radius1=3.4304999897666599; - const double angleS1=2.6179938783536514; const double angleL1=-0.52359877711901204; - const double center1[2]={13.933240950441375, -24.132999992807399}; - EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1); - // - const double coords2[]= - { - 11.1467942784, -22.2090000002, - 11.0939667286, -22.178500000099998 - }; - Node *nS2=new Node(coords2); - Node *nE2=new Node(coords2+2); - EdgeLin *e2=new EdgeLin(nS2,nE2); - MergePoints merge; - QuadraticPolygon c1,c2; - CPPUNIT_ASSERT(e1->intersectWith(e2,merge,c1,c2)); - CPPUNIT_ASSERT_EQUAL(2,c1.size()); - CPPUNIT_ASSERT_EQUAL(2,c2.size()); - ElementaryEdge *tmp1=dynamic_cast(c1.front()); CPPUNIT_ASSERT(tmp1); - EdgeArcCircle *tmp2=dynamic_cast(tmp1->getPtr()); CPPUNIT_ASSERT(tmp2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.6179938783536514,tmp2->getAngle0(),1e-14); - //clean-up - nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef(); -} - -void QuadraticPlanarInterpTest::checkNonRegression4() -{ - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); - double coords1[]= - { - 10.962340811000001, -22.417749999000002, - 12.217990959, -21.162099852000001, - 12.051990958999999, -20.874579418, - 10.674820377, -22.251749999000001, - 11.507511146000001, -21.707270185999999, - 12.134990959, -21.018339635, - 11.272751694, -21.472510735, - 10.818580594, -22.334749999 - }; - - double coords2[]= - { - 10.758000000199999, -23.66, - 11.1467942784, -22.2090000002, - 11.0939667286, -22.178500000099998, - 10.696999999999999, -23.66, - 10.856883252299999, -22.908907131159999, - 11.1203805035, -22.1937500001, - 10.797961776699999, -22.893119169449999, - 10.727500000099999, -23.66 - }; - vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7); - delete v[0]; - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression5() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); - double coords1[]= - { - -1.7320508075000001, 1, - -1, 1.7320508075000001 , - -1.2172499999999999, 2.1083388455000001, - -2.1083388455000001, 1.2172499999999999, - -1.4142135623000001, 1.4142135623000001, - -1.108625, 1.9201948265, - -1.7214514588000001, 1.7214514588000001, - -1.9201948265, 1.108625}; - - double coords2[]= - { - -2.2379999998, 0, - -1.9381648534, 1.1189999998, - -1.9909924031999999, 1.1494999999, - -2.2989999998999999, 0, - -2.1617419990000002, 0.57923702298000002, - -1.9645786283, 1.1342499998, - -2.2206634745999998, 0.59502498461999997, - -2.2684999997999999, 0}; - //Edge1_of_pol2 inter Edge4_of_pol1 = {-1.9381648533711939, 1.1189999998498941} - //Edge4_of_pol1 _angle = -0.523598775922546, _angle0 = -3.1415926535897931, _radius = 2.2379999983074721, _center = {-1.4925279436059493e-09, 1.3300635705141101e-10}} - vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(0,(int)v.size()); - //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7); - //delete v[0]; - //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression6() -{ - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); - double coords1[]= - { - 10.962340811000001, -22.417749999000002, - 12.217990959, -21.162099852000001, - 12.051990958999999, -20.874579418, - 10.674820377, -22.251749999000001, - 11.507511146000001, -21.707270185999999, - 12.134990959, -21.018339635, - 11.272751694, -21.472510735, - 10.818580594, -22.334749999 - }; - double coords2[]= - { 10.426, -23.66, - 10.859273844199999, -22.043000000100001, - 10.806446294799999, -22.012500000199999, - 10.3650000002, -23.66, - 10.536195877799999, -22.822979208099998, - 10.832860069499999, -22.027750000200001, - 10.477274402499999, -22.80719124657, - 10.3955000001, -23.66}; - vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0]->getArea(),0.0150659,1e-7); - delete v[0]; - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression7() -{ - QUADRATIC_PLANAR::setPrecision(1e-5); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); - double coords1[]= - { - -2., 0, - -1.7320508075000001, 1, - -2.1083388455000001, 1.2172499999999999, - -2.4344999999999999, 0, - -1.9318516525603098, 0.51763809027157182, - -1.9201948265, 1.108625, - -2.3515464241024469, 0.63009496529570408, - -2.2172499999999999, 0 - }; - double coords2[]= - { -2.3369999999000002, 0, - -2.0239013684999998, 1.1684999999000001, - -2.1927763221999998, 1.2659999998, - -2.5319999998, 0, - -2.2573686559260442, 0.60486010843437632, - -2.1083388453499996, 1.2172499998499999, - -2.445724191994314, 0.65532982205982326, - -2.4344999998499999, 0 }; - vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.121795,v[0]->getArea(),1.e-6); - delete v[0]; - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression8() -{ - QUADRATIC_PLANAR::setPrecision(1e-3); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); - double coords1[]= - { - -13.933240959000001, -28.559499999, - -16.146490959000001, -27.966461449000001, - -16.383240958999998, -28.376524478, - -13.933240959000001, -29.032999999000001, - -15.078903461873765, -28.408670669106311, - -16.264865958999998, -28.1714929635, - -15.201454280317435, -28.866036547696734, - -13.933240959000001, -28.796249999 }; - double coords2[]= - { -16.382999999950002, -28.376524478457149, - -13.933000000014729, -29.03299999982551, - -13.93300000006697, -28.793999999915993, - -16.263500000000001, -28.169544407039268, - -15.201213320921273, -28.866036548734634, - -13.933000000040851, -28.913499999870751, - -15.139355569325469, -28.635180276305853, - -16.323249999975001, -28.273034442748209 }; - vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.598232,v[0]->getArea(),1.e-6); - delete v[0]; - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression9() -{ - QUADRATIC_PLANAR::setPrecision(1e-7); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-8); - double coords1[]= - { - -0.04476229252902969, -0.085118027765365603, - -0.046952683430894329, -0.085704941238358354, - -0.046952683430894329, -0.088063823748058725, - -0.043582851274179504, -0.087160879944491371, - -0.045818853668170414, -0.085555669718918592, - -0.046952683430894329, -0.086884382493208526, - -0.045208329947517549, -0.087834175256748526, - -0.044172571901604597, -0.086139453854928494 }; - - double coords2[]= - { -0.05065868681155701, -0.087744551996665671, - -0.046951871439587615, -0.088737790182236015, - -0.046951871439683469, -0.088063823751059062, - -0.050321703596054014, -0.087160879946116557, - -0.0488706602695924, -0.08848517684025306, - -0.046951871439635542, -0.088400806966647538, - -0.048696224921445964, -0.087834175258503858, - -0.050490195203805516, -0.087452715971391121}; - - vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(0,(int)v.size()); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression10() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords1[]= - { -0.002269581957210453, -0.09851030343724453, - -0.004268022334182935, -0.1059685844580936, - -0.002777851483521377, -0.1023709937816271}; - double coords2[]= - { -0.004114727297178323, -0.1049870239624718, - -0.003544545103522544, -0.1053162188055505}; - Node *n1_1=new Node(coords1); - Node *n2_1=new Node(coords1+2); - Node *n3_1=new Node(coords1+4); - Node *n1_2=new Node(coords2); - Node *n2_2=new Node(coords2+2); - EdgeArcCircle *e1=new EdgeArcCircle(n1_1,n3_1,n2_1); - EdgeLin *e2=new EdgeLin(n1_2,n2_2); - MergePoints merge; - ComposedEdge *c1=new ComposedEdge; - ComposedEdge *c2=new ComposedEdge; - CPPUNIT_ASSERT(e1->intersectWith(e2,merge,*c1,*c2)); - CPPUNIT_ASSERT_EQUAL(2,c1->size()); - CPPUNIT_ASSERT_EQUAL(2,c2->size()); - ComposedEdge::Delete(c1); ComposedEdge::Delete(c2); - n1_1->decrRef(); n2_1->decrRef(); n3_1->decrRef(); - n1_2->decrRef(); n2_2->decrRef(); - e1->decrRef(); e2->decrRef(); -} - -void QuadraticPlanarInterpTest::checkNonRegression11() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords1[]= - { -0.002269581957210453, -0.09851030343724453, - -0.004268022334182935, -0.1059685844580936, - -0.002886178753789801, -0.1067663922211958, - -0.0006739664310059821, -0.09851030343724453, - -0.002777851483521377, -0.1023709937816271, - -0.003577100543986368, -0.1063674883396447, - -0.001236605237717319, -0.1027839694676665, - -0.001471774194108217, -0.09851030343724453}; - double coords2[]= - { -0.003544545103522544, -0.1053162188055505, - -0.001941023322604723, -0.09851030343724451, - -0.002598140593501099, -0.09851030343724451, - -0.004114727297178323, -0.1049870239624718, - -0.002347317802266182, -0.1020064358043286, - -0.002269581958052911, -0.09851030343724451, - -0.002982346712452072, -0.1018362598405457, - -0.003829636200350435, -0.1051516213840111}; - - vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.28973e-06,v[0]->getArea(),1.e-11); - delete v[0]; - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression12() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-6); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords1[]= - { -0.5032251558760915, -0.8716087994449138, - -0.4695268343089433, -0.8806382374805872, - -0.4695268343089433, -0.8570494123835835, - -0.4914307433275896, -0.8511802776536561, - -0.4869703691141082, -0.8783417525751493, - -0.4695268343089433, -0.8688438249320853, - -0.480865131947653, -0.8555566971861125, - -0.4973279496018406, -0.8613945385492849}; - - double coords2[]= - { -0.5065868681155701, -0.8774455199666568, - -0.4695187143958762, -0.8873779018223601, - -0.4695187143968347, -0.8806382375105907, - -0.5032170359605401, -0.8716087994611657, - -0.488706602695924, -0.8848517684025307, - -0.4695187143963554, -0.8840080696664754, - -0.4869622492144596, -0.8783417525850385, - -0.5049019520380551, -0.8745271597139112}; - - vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v[0]->getArea(),1.e-6); - delete v[0]; - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression13() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); - - double coords_1[194]={ - 0, 0, 0.304375, -7.454791178893722e-17, 0.2152256265236553, -0.2152256265236555, -5.591093384170291e-17, -0.304375, - -0.2152256265236555, -0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375, - 0.2152256265236554, 0.2152256265236554, 0.60875, -1.490958235778744e-16, 0.5624116654162459, -0.2329585394522483, 0.4304512530473107, -0.4304512530473109, - 0.2329585394522485, -0.5624116654162458, -1.118218676834058e-16, -0.60875, -0.2329585394522482, -0.5624116654162459, -0.4304512530473109, -0.4304512530473108, - -0.5624116654162459, -0.2329585394522483, -0.60875, 7.454791178893722e-17, -0.5624116654162458, 0.2329585394522485, -0.4304512530473108, 0.4304512530473109, - -0.2329585394522484, 0.5624116654162458, 3.727395589446861e-17, 0.60875, 0.2329585394522485, 0.5624116654162458, 0.4304512530473109, 0.4304512530473108, - 0.5624116654162458, 0.2329585394522484, 0.913125, -2.236437353668116e-16, 0.645676879570966, -0.6456768795709663, -1.677328015251087e-16, -0.913125, - -0.6456768795709663, -0.6456768795709661, -0.913125, 1.118218676834058e-16, -0.6456768795709661, 0.6456768795709662, 5.591093384170291e-17, 0.913125, - 0.6456768795709662, 0.6456768795709661, 1.2175, -2.981916471557489e-16, 1.124823330832492, -0.4659170789044966, 0.8609025060946214, -0.8609025060946218, - 0.4659170789044971, -1.124823330832492, -2.236437353668116e-16, -1.2175, -0.4659170789044965, -1.124823330832492, -0.8609025060946218, -0.8609025060946216, - -1.124823330832492, -0.4659170789044967, -1.2175, 1.490958235778744e-16, -1.124823330832492, 0.465917078904497, -0.8609025060946216, 0.8609025060946217, - -0.4659170789044967, 1.124823330832492, 7.454791178893722e-17, 1.2175, 0.4659170789044969, 1.124823330832492, 0.8609025060946217, 0.8609025060946216, - 1.124823330832492, 0.4659170789044968, 1.521875, -3.727395589446861e-16, 1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875, - -1.076128132618277, -1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875, - 1.076128132618277, 1.076128132618277, 1.82625, -4.472874707336233e-16, 1.687234996248738, -0.6988756183567448, 1.291353759141932, -1.291353759141933, - 0.6988756183567456, -1.687234996248737, -3.354656030502175e-16, -1.82625, -0.6988756183567447, -1.687234996248738, -1.291353759141933, -1.291353759141932, - -1.687234996248738, -0.6988756183567449, -1.82625, 2.236437353668116e-16, -1.687234996248737, 0.6988756183567454, -1.291353759141932, 1.291353759141932, - -0.6988756183567451, 1.687234996248737, 1.118218676834058e-16, 1.82625, 0.6988756183567453, 1.687234996248737, 1.291353759141932, 1.291353759141932, - 1.687234996248737, 0.6988756183567452, 2.130625, -5.218353825225606e-16, 1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625, - -1.506579385665588, -1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625, - 1.506579385665588, 1.506579385665588, 2.435, -5.963832943114977e-16, 2.249646661664984, -0.9318341578089931, 1.721805012189243, -1.721805012189244, - 0.9318341578089941, -2.249646661664983, -4.472874707336233e-16, -2.435, -0.9318341578089929, -2.249646661664984, -1.721805012189244, -1.721805012189243, - -2.249646661664984, -0.9318341578089934, -2.435, 2.981916471557489e-16, -2.249646661664983, 0.9318341578089939, -1.721805012189243, 1.721805012189243, - -0.9318341578089935, 2.249646661664983, 1.490958235778744e-16, 2.435, 0.9318341578089938, 2.249646661664983, 1.721805012189243, 1.721805012189243, - 2.249646661664983, 0.9318341578089936 }; - - int tab6_1[48]={ - 0, 9, 11, 1, 10, 2, 0, 11, 13, 2, 12, 3, 0, 13, 15, 3, 14, 4, 0, 15, - 17, 4, 16, 5, 0, 17, 19, 5, 18, 6, 0, 19, 21, 6, 20, 7, 0, 21, 23, 7, - 22, 8, 0, 23, 9, 8, 24, 1 }; - - int tab8_1[192]={ - 9, 33, 35, 11, 25, 34, 26, 10, 11, 35, 37, 13, 26, 36, 27, 12, 13, 37, 39, 15, - 27, 38, 28, 14, 15, 39, 41, 17, 28, 40, 29, 16, 17, 41, 43, 19, 29, 42, 30, 18, - 19, 43, 45, 21, 30, 44, 31, 20, 21, 45, 47, 23, 31, 46, 32, 22, 23, 47, 33, 9, - 32, 48, 25, 24, 33, 57, 59, 35, 49, 58, 50, 34, 35, 59, 61, 37, 50, 60, 51, 36, - 37, 61, 63, 39, 51, 62, 52, 38, 39, 63, 65, 41, 52, 64, 53, 40, 41, 65, 67, 43, - 53, 66, 54, 42, 43, 67, 69, 45, 54, 68, 55, 44, 45, 69, 71, 47, 55, 70, 56, 46, - 47, 71, 57, 33, 56, 72, 49, 48, 57, 81, 83, 59, 73, 82, 74, 58, 59, 83, 85, 61, - 74, 84, 75, 60, 61, 85, 87, 63, 75, 86, 76, 62, 63, 87, 89, 65, 76, 88, 77, 64, - 65, 89, 91, 67, 77, 90, 78, 66, 67, 91, 93, 69, 78, 92, 79, 68, 69, 93, 95, 71, - 79, 94, 80, 70, 71, 95, 81, 57, 80, 96, 73, 72 }; - - double coords_2[20]={ - 0.5159941860137611, 0, 0, -0.5159941860137611, -0.5159941860137611, 0, 0, 0.5159941860137611, - 0.6684941860137611, 0, 0, -0.6684941860137611, -0.6684941860137611, 0, 0, 0.6684941860137611, - 0.5922441860137611, 0, -0.5922441860137611, 0 }; - - int tab8_2[16]={ - 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 }; - - double perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2; - - const int *work1=tab6_1; - for(int i=0;i<8;i++,work1+=6) - { - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,6); - const int *work2=tab8_2; - for(int j=0;j<2;j++,work2+=8) - { - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8); - //vector tmp; - //pol1->intersectForPoint(*pol2,tmp); - pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2); - //pol1->intersectMySelfWith(*pol2); - delete pol2; - } - delete pol1; - } - work1=tab8_1; - for(int i=0;i<24;i++,work1+=8) - { - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,8); - const int *work2=tab8_2; - for(int j=0;j<2;j++,work2+=8) - { - - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8); - //vector tmp; - //pol1->intersectForPoint(*pol2,tmp); - pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2); - delete pol2; - } - delete pol1; - } -} - -/*! - Some overlapping cases for intersectForPoint. -*/ -void QuadraticPlanarInterpTest::checkNonRegression14() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); - - double coords[72]={ - 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1., - -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0., - -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658, - 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5, - -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65, - -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877, - -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565, - -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169, - 0.,-1.3,0.,-1.5 - }; - int tab[48]={ - 0,1,2,3,4,5,6,7, - 8,9,10,11,2,14,12,13, - 9,15,16,10,5,17,18,14, - 9,15,16,10,34,17,35,14, - 19,20,21,22,23,24,25,26, - 27,28,29,30,31,32,2,33 - }; - QuadraticPolygon *pol1,*pol2; - vector goalOfTest; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8); - // Level 1 - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8); - pol1->intersectForPoint(*pol2,goalOfTest); - const int res1[4]={0,1,0,0}; - CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); - CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res1)); - delete pol2; - // Level 2 - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8); - pol1->intersectForPoint(*pol2,goalOfTest); - const int res2[4]={0,2,0,0}; - CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); - CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2)); - delete pol2; - //Level 2 bis - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+24,8); - pol1->intersectForPoint(*pol2,goalOfTest); - const int res2Bis[4]={0,2,0,0}; - CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); - CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2Bis)); - delete pol2; - // Level 3 - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+40,8); - pol1->intersectForPoint(*pol2,goalOfTest); - const int res3[4]={0,3,0,0}; - CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); - CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res3)); - delete pol2; - // Level 4 - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+32,8); - pol1->intersectForPoint(*pol2,goalOfTest); - const int res4[4]={0,4,0,0}; - CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); - CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res4)); - delete pol2; - // - delete pol1; -} - -/*! - * This test is one of the most complicated intersection configuration. - */ -void QuadraticPlanarInterpTest::checkNonRegression15() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); - - double coords[72]={ - 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1., - -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0., - -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658, - 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5, - -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65, - -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877, - -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565, - -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169, - 0.,-1.3,0.,-1.5 - }; - - int tab[24]={ - 0,1,2,3,4,5,6,7, - 9,15,16,10,7,17,5,14, - 9,10,16,15,14,5,17,7 - }; - - const double RefLgth=3.88995883524451; - const double RefArea=0.383185168001075; - // - QuadraticPolygon *pol1,*pol2; - //pol1 and pol2 in same orientation - pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8); - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8); - vector res=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12); - delete res[0]; - //pol1 and pol2 in same orientation but inversing intersection call pol1<->pol2 - res=pol2->intersectMySelfWith(*pol1); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12); - delete res[0]; - delete pol2; - //pol1 and pol2 in opposite orientation - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8); - res=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-RefArea,res[0]->getArea(),1e-12); - delete res[0]; - //pol1 and pol2 in opposite orientation but inversing intersection call pol1<->pol2 - res=pol2->intersectMySelfWith(*pol1); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12); - delete res[0]; - delete pol2; - // - delete pol1; -} - -class DoubleEqual -{ -public: - DoubleEqual(double eps):_eps(eps) { } - bool operator()(double x, double y) { return fabs(x-y)<_eps; } -private: - double _eps; -}; - -/*! - * This test is to see the reuse of a polygon in intersect* methods. initLocation needed ... - */ -void QuadraticPlanarInterpTest::checkNonRegression16() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords1[194]={ - 0, 0, 0.304375, 0, 0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375, - -0.2152256265236554, 0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236555, -0.2152256265236554, -5.591093384170291e-17, -0.304375, - 0.2152256265236553, -0.2152256265236555, 0.60875, 0, 0.5624116654162458, 0.2329585394522484, 0.4304512530473109, 0.4304512530473108, - 0.2329585394522485, 0.5624116654162458, 3.727395589446861e-17, 0.60875, -0.2329585394522484, 0.5624116654162458, -0.4304512530473108, 0.4304512530473109, - -0.5624116654162458, 0.2329585394522485, -0.60875, 7.454791178893722e-17, -0.5624116654162459, -0.2329585394522483, -0.4304512530473109, -0.4304512530473108, - -0.2329585394522482, -0.5624116654162459, -1.118218676834058e-16, -0.60875, 0.2329585394522485, -0.5624116654162458, 0.4304512530473107, -0.4304512530473109, - 0.5624116654162459, -0.2329585394522483, 0.913125, 0, 0.6456768795709662, 0.6456768795709661, 5.591093384170291e-17, 0.913125, - -0.6456768795709661, 0.6456768795709662, -0.913125, 1.118218676834058e-16, -0.6456768795709663, -0.6456768795709661, -1.677328015251087e-16, -0.913125, - 0.645676879570966, -0.6456768795709663, 1.2175, 0, 1.124823330832492, 0.4659170789044968, 0.8609025060946217, 0.8609025060946216, - 0.4659170789044969, 1.124823330832492, 7.454791178893722e-17, 1.2175, -0.4659170789044967, 1.124823330832492, -0.8609025060946216, 0.8609025060946217, - -1.124823330832492, 0.465917078904497, -1.2175, 1.490958235778744e-16, -1.124823330832492, -0.4659170789044967, -0.8609025060946218, -0.8609025060946216, - -0.4659170789044965, -1.124823330832492, -2.236437353668116e-16, -1.2175, 0.4659170789044971, -1.124823330832492, 0.8609025060946214, -0.8609025060946218, - 1.124823330832492, -0.4659170789044966, 1.521875, 0, 1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875, - -1.076128132618277, 1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875, - 1.076128132618277, -1.076128132618277, 1.82625, 0, 1.687234996248737, 0.6988756183567452, 1.291353759141932, 1.291353759141932, - 0.6988756183567453, 1.687234996248737, 1.118218676834058e-16, 1.82625, -0.6988756183567451, 1.687234996248737, -1.291353759141932, 1.291353759141932, - -1.687234996248737, 0.6988756183567454, -1.82625, 2.236437353668116e-16, -1.687234996248738, -0.6988756183567449, -1.291353759141933, -1.291353759141932, - -0.6988756183567447, -1.687234996248738, -3.354656030502175e-16, -1.82625, 0.6988756183567456, -1.687234996248737, 1.291353759141932, -1.291353759141933, - 1.687234996248738, -0.6988756183567448, 2.130625, 0, 1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625, - -1.506579385665588, 1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625, - 1.506579385665588, -1.506579385665588, 2.435, 0, 2.249646661664983, 0.9318341578089936, 1.721805012189243, 1.721805012189243, - 0.9318341578089938, 2.249646661664983, 1.490958235778744e-16, 2.435, -0.9318341578089935, 2.249646661664983, -1.721805012189243, 1.721805012189243, - -2.249646661664983, 0.9318341578089939, -2.435, 2.981916471557489e-16, -2.249646661664984, -0.9318341578089934, -1.721805012189244, -1.721805012189243, - -0.9318341578089929, -2.249646661664984, -4.472874707336233e-16, -2.435, 0.9318341578089941, -2.249646661664983, 1.721805012189243, -1.721805012189244, - 2.249646661664984, -0.9318341578089931, }; - - int tab1_8[192]={ - 11, 35, 33, 9, 26, 34, 25, 10, 13, 37, 35, 11, 27, 36, 26, 12, 15, 39, 37, 13, - 28, 38, 27, 14, 17, 41, 39, 15, 29, 40, 28, 16, 19, 43, 41, 17, 30, 42, 29, 18, - 21, 45, 43, 19, 31, 44, 30, 20, 23, 47, 45, 21, 32, 46, 31, 22, 9, 33, 47, 23, - 25, 48, 32, 24, 35, 59, 57, 33, 50, 58, 49, 34, 37, 61, 59, 35, 51, 60, 50, 36, - 39, 63, 61, 37, 52, 62, 51, 38, 41, 65, 63, 39, 53, 64, 52, 40, 43, 67, 65, 41, - 54, 66, 53, 42, 45, 69, 67, 43, 55, 68, 54, 44, 47, 71, 69, 45, 56, 70, 55, 46, - 33, 57, 71, 47, 49, 72, 56, 48, 59, 83, 81, 57, 74, 82, 73, 58, 61, 85, 83, 59, - 75, 84, 74, 60, 63, 87, 85, 61, 76, 86, 75, 62, 65, 89, 87, 63, 77, 88, 76, 64, - 67, 91, 89, 65, 78, 90, 77, 66, 69, 93, 91, 67, 79, 92, 78, 68, 71, 95, 93, 69, - 80, 94, 79, 70, 57, 81, 95, 71, 73, 96, 80, 72, }; - - double coords2[20]={ - 2.435, 0, 0, -2.435, -2.435, 0, 0, 2.435, - 2.6925, 0, 0, -2.6925, -2.6925, 0, 0, 2.6925, - 2.56375, 0, -2.56375, 0, }; - - int tab2_8[16]={ 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 }; - - QuadraticPolygon *pol1,*pol2; - //pol1 and pol2 in same orientation - vector test1,test2; - for(int ii=0;ii<24;ii++) - { - pol1=buildQuadraticPolygonCoarseInfo(coords1,tab1_8+8*ii,8); - for(int jj=0;jj<2;jj++) - { - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab2_8+jj*8,8); - // - vector v1,v2; - pol1->initLocations(); - pol1->intersectForPerimeterAdvanced(*pol2,v1,v2); - if(ii==16 && jj==1) - test1=v1; - if(ii==20 && jj==1) - test2=v1; - delete pol2; - } - delete pol1; - } - const double test1_res[4]={0.,1.9124445278727873,0.,0.}; - CPPUNIT_ASSERT(std::equal(test1.begin(),test1.end(),test1_res,DoubleEqual(1e-10))); - const double test2_res[4]={0.,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(test2.begin(),test2.end(),test2_res,DoubleEqual(1e-10))); -} - -/*! - * This test checks overlapped intersections END-INSIDE and INSIDE-START with same and opposite orientation. - */ -void QuadraticPlanarInterpTest::checkNonRegression17() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1., 0., 1., 0. , 1.5, 0., -1.5, 0., - 0. , 1., 1.25, 0., 0., 1.5, -1.25, 0.}; - - double coords2[16]={ - 0.70710678118654757, 0.70710678118654757, -1., 0., -1.25, 0., 0.88388347648318444, 0.88388347648318444, - 0., -1., -1.125, 0., 0., -1.25, 0.79549512883486606, 0.79549512883486606 }; - - double coords3[16]={ - 0.70710678118654757, 0.70710678118654757, 0.88388347648318444, 0.88388347648318444, -1.25, 0., -1., 0., - 0.79549512883486606, 0.79549512883486606, 0., -1.25, -1.125, 0., 0., -1. }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNormalize() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-14); - Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-3.); - Node *n2=new Node(10.,0.); Node *n5=new Node(10.,-3.); - Node *n3=new Node(5.,10.); Node *n6=new Node(5.,7.); - EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); - EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); - EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); - // - QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - double area1Start=pol1.getArea(); - double fact=pol1.normalize(&pol2); - double area1End=pol1.getArea(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(area1Start,area1End*fact*fact,1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13.,fact,1.e-14); - double area=pol1.intersectWith(pol2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,area*fact*fact,1e-14); - // - n1=new Node(0.,0.); n4=new Node(0.,-3.); - n2=new Node(10.,0.); n5=new Node(10.,-3.); - n3=new Node(5.,10.); n6=new Node(5.,7.); - e1_2=new EdgeLin(n1,n2); e4_5=new EdgeLin(n4,n5); - e2_3=new EdgeLin(n2,n3); e5_6=new EdgeLin(n5,n6); - e3_1=new EdgeLin(n3,n1); e6_4=new EdgeLin(n6,n4); - QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); - QuadraticPolygon pol4; pol4.pushBack(e4_5); pol4.pushBack(e5_6); pol4.pushBack(e6_4); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,pol3.intersectWithAbs(pol4),1.e-14); - // Ok testing EdgeArcCircle update. - double center[2]={5.,5.}; - double radius=300.; - EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.); - const Bounds& b=e1->getBounds(); - double x,y,fact2; - fact2=b.getCaracteristicDim(); - b.getBarycenter(x,y); - CPPUNIT_ASSERT_DOUBLES_EQUAL(78.539816339744817,e1->getCurveLength(),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15106.061037591669,e1->getAreaOfZone(),1e-10); - e1->getStartNode()->applySimilarity(x,y,fact2); - e1->getEndNode()->applySimilarity(x,y,fact2); - e1->applySimilarity(x,y,fact2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(62.132034355964237,fact2,1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.2640792652913602,e1->getCurveLength(),1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.034741420428165526,e1->getAreaOfZone(),1e-13); - e1->decrRef(); -} diff --git a/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest5.cxx b/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest5.cxx deleted file mode 100644 index 88b70d2e0..000000000 --- a/src/INTERP_KERNEL/Test/QuadraticPlanarInterpTest5.cxx +++ /dev/null @@ -1,1168 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "QuadraticPlanarInterpTest.hxx" -#include "QuadraticPolygon.hxx" -#include "ElementaryEdge.hxx" -#include "EdgeArcCircle.hxx" -#include "EdgeLin.hxx" - -#include -#include -#include -#include - -using namespace std; -using namespace INTERP_KERNEL; - -class DoubleEqual -{ -public: - DoubleEqual(double eps):_eps(eps) { } - bool operator()(double x, double y) { return fabs(x-y)<_eps; } -private: - double _eps; -}; - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0000() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, - -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.383022221559489, -0.1786061951567303, -0.5745333323392334, -0.01790929273509539, 0.5745333323392335, -0.01790929273509556, 0.383022221559489, -0.1786061951567304, - -0.4787777769493612, -0.0982577439459128, 4.592273826833915e-17, 0.25, 0.4787777769493612, -0.09825774394591297, 3.061515884555943e-17, 0 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0001() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, - -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, - -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.272708,pol1->intersectWith(*pol2),1.e-6); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.272708,pol2->intersectWith(*pol1),1.e-6); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0002() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, - -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.4979288880273356, 0.4178119462962507, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.4979288880273357, 0.4178119462962505, - -0.555382221261259, 0.4660210170227412, 4.898425415289509e-17, 0.8, 0.5553822212612591, 0.466021017022741, 3.979970649922726e-17, 0.65 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.122173,pol1->intersectWith(*pol2),1.e-6); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.122173,pol2->intersectWith(*pol1),1.e-6); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0003() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.3535533905932737, 0.3535533905932738, -0.5303300858899106, 0.5303300858899107, 0.5303300858899107, 0.5303300858899106, 0.3535533905932738, 0.3535533905932737, - -0.4419417382415922, 0.4419417382415922, 4.592273826833915e-17, 0.75, 0.4419417382415922, 0.4419417382415922, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.4979288880273356, 0.4178119462962507, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.4979288880273357, 0.4178119462962505, - -0.555382221261259, 0.4660210170227412, 4.898425415289509e-17, 0.8, 0.5553822212612591, 0.466021017022741, 3.979970649922726e-17, 0.65 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol1->intersectWith(*pol2),1.e-6); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol2->intersectWith(*pol1),1.e-6); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0004() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4596194077712559, 0.4596194077712559, -0.5303300858899106, 0.5303300858899107, 0.5303300858899107, 0.5303300858899106, 0.4596194077712559, 0.4596194077712559, - -0.4949747468305832, 0.4949747468305833, 4.592273826833915e-17, 0.75, 0.4949747468305833, 0.4949747468305832, 3.979970649922726e-17, 0.65 }; - - double coords2[16]={ - -0.383022221559489, 0.3213938048432697, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.383022221559489, 0.3213938048432696, - -0.4979288880273356, 0.4178119462962507, 4.898425415289509e-17, 0.8, 0.4979288880273357, 0.4178119462962505, 3.061515884555943e-17, 0.5 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol1->intersectWith(*pol2),1.e-6); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol2->intersectWith(*pol1),1.e-6); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0005() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.383022221559489, 0.3213938048432696, - -0.4979288880273356, 0.4178119462962507, 4.898425415289509e-17, 0.8, 0.4979288880273357, 0.4178119462962505, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.4596194077712559, 0.4596194077712559, -0.5303300858899106, 0.5303300858899107, 0.5303300858899107, 0.5303300858899106, 0.4596194077712559, 0.4596194077712559, - -0.4949747468305832, 0.4949747468305833, 4.592273826833915e-17, 0.75, 0.4949747468305833, 0.4949747468305832, 3.979970649922726e-17, 0.65 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol1->intersectWith(*pol2),1.e-6); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol2->intersectWith(*pol1),1.e-6); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0006() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5362311101832845, 0.4499513267805776, 0.5362311101832846, 0.4499513267805774, 0.383022221559489, 0.3213938048432696, - -0.4596266658713867, 0.3856725658119237, 4.28612223837832e-17, 0.7, 0.4596266658713868, 0.3856725658119236, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.1811733315717646, 0.6761480784023478, -0.2070552360820167, 0.7727406610312547, 0.2070552360820166, 0.7727406610312547, 0.1811733315717645, 0.6761480784023478, - -0.1941142838268906, 0.7244443697168013, 4.898425415289509e-17, 0.8, 0.1941142838268906, 0.7244443697168013, 4.28612223837832e-17, 0.7 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.366519,0.,0.}; - double test2_res[4]={0.,0.,0.,0.366519}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0007() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5362311101832845, 0.4499513267805776, 0.5362311101832846, 0.4499513267805774, 0.383022221559489, 0.3213938048432696, - -0.4596266658713867, 0.3856725658119237, 4.28612223837832e-17, 0.7, 0.4596266658713868, 0.3856725658119236, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.4499513267805775, 0.5362311101832846, -0.5142300877492315, 0.6128355544951825, -0.1389185421335442, 0.7878462024097664, -0.1215537243668512, 0.6893654271085455, - -0.4820907072649045, 0.5745333323392335, -0.3380946093925595, 0.7250462296293201, -0.1302361332501977, 0.738605814759156, -0.2958327832184895, 0.634415450925655 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.366519,0.,0.}; - double test2_res[4]={0.,0.,0.,0.366519}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0008() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5362311101832845, 0.4499513267805776, 0.5362311101832846, 0.4499513267805774, 0.383022221559489, 0.3213938048432696, - -0.4596266658713867, 0.3856725658119237, 4.28612223837832e-17, 0.7, 0.4596266658713868, 0.3856725658119236, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.6344154509256549, 0.2958327832184896, -0.72504622962932, 0.3380946093925596, -0.4588611490808367, 0.6553216354311937, -0.401503505445732, 0.5734064310022944, - -0.6797308402774874, 0.3169636963055246, -0.6128355544951823, 0.5142300877492316, -0.4301823272632844, 0.614364033216744, -0.5362311101832845, 0.4499513267805776 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.18326,0.,0.}; - double test2_res[4]={0.,0.,0.,0.18326}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-5))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-5))); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0009() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, - -0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4 }; - double coords2[16]={ - 0.5, -1.224606353822377e-16, 0.6, -1.469527624586853e-16, -0.6, 7.347638122934263e-17, -0.5, 6.123031769111886e-17, - 0.55, -1.347066989204615e-16, -1.102145718440139e-16, -0.6, -0.55, 6.735334946023075e-17, -9.184547653667829e-17, -0.5 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0010() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, --0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4 }; - double coords2[16]={ - 0.4346666218300808, -0.1164685702961343, 0.579555495773441, -0.1552914270615124, -0.579555495773441, -0.1552914270615122, -0.4346666218300808, -0.1164685702961342, -0.5071110588017609, -0.1358799986788234, -1.102145718440139e-16, -0.6, -0.507111058801761, -0.1358799986788232, -8.266092888301047e-17, -0.45 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0011() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, --0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4 }; - double coords2[16]={ - 0.4829629131445342, -0.1294095225512603, 0.579555495773441, -0.1552914270615124, -0.579555495773441, -0.1552914270615122, -0.4829629131445342, -0.1294095225512602, -0.5312592044589877, -0.1423504748063864, -1.102145718440139e-16, -0.6, -0.5312592044589877, -0.1423504748063862, -9.184547653667829e-17, -0.5 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - double val1,val2,val3; - pol1->intersectForPerimeter(*pol2,val1,val2,val3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); - vector val4,val5; - pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); - double test1_res[4]={0.,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - pol1->intersectForPerimeter(*pol2,val1,val2,val3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); - val4.clear(); val5.clear(); - pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); - CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar2511() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, - -0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4, }; - - double coords2[16]={ - 0.579555495773441, -0.1552914270615124, -0.579555495773441, -0.1552914270615122, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512603, - -1.102145718440139e-16, -0.6, -0.5312592044589877, -0.1423504748063862, -9.184547653667829e-17, -0.5, 0.5312592044589877, -0.1423504748063864, }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - double val1,val2,val3; - pol1->intersectForPerimeter(*pol2,val1,val2,val3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); - vector val4,val5; - pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); - double test1_res[4]={0.,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - pol1->intersectForPerimeter(*pol2,val1,val2,val3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); - val4.clear(); val5.clear(); - pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); - CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0012() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, - -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - - double coords2[16]={ - 6.123031769111886e-18, 1.85, 1.224606353822377e-17, 1.95, 1.224606353822377e-17, 1.55, 6.123031769111886e-18, 1.65, - 9.18454765366783e-18, 1.9, 0.2, 1.75, 9.18454765366783e-18, 1.6, 0.1, 1.75 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.05,0.}; - double test2_res[4]={0.,0.,0.05,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,1,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0013() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, - -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - - double coords2[16]={ - 6.123031769111886e-18, 1.7, 1.224606353822377e-17, 1.8, 1.224606353822377e-17, 1.4, 6.123031769111886e-18, 1.5, - 9.18454765366783e-18, 1.75, 0.2, 1.6, 9.18454765366783e-18, 1.45, 0.1, 1.6 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.1,0.}; - double test2_res[4]={0.,0.,0.1,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,2,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0014() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, --1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - double coords2[16]={ - 6.123031769111886e-18, 1.55, 1.224606353822377e-17, 1.65, 1.224606353822377e-17, 1.25, 6.123031769111886e-18, 1.35, -9.18454765366783e-18, 1.6, 0.2, 1.45, 9.18454765366783e-18, 1.3, 0.1, 1.45 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.15,0.}; - double test2_res[4]={0.05,0.,0.1,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,3,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0015() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, --1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - double coords2[16]={ - 6.123031769111886e-18, 1.4, 1.224606353822377e-17, 1.5, 1.224606353822377e-17, 1.1, 6.123031769111886e-18, 1.2, -9.18454765366783e-18, 1.45, 0.2, 1.3, 9.18454765366783e-18, 1.15, 0.1, 1.3 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.2,0.}; - double test2_res[4]={0.1,0.,0.1,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,4,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0016() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, --1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - double coords2[16]={ - 6.123031769111886e-18, 1.25, 1.224606353822377e-17, 1.35, 1.224606353822377e-17, 0.95, 6.123031769111886e-18, 1.05, -9.18454765366783e-18, 1.3, 0.2, 1.15, 9.18454765366783e-18, 0.9999999999999999, 0.1, 1.15 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.15,0.}; - double test2_res[4]={0.1,0.,0.05,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,3,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0017() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, - -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - - double coords2[16]={ - 6.123031769111886e-18, 1.1, 1.224606353822377e-17, 1.2, 1.224606353822377e-17, 0.8, 6.123031769111886e-18, 0.9, - 9.18454765366783e-18, 1.15, 0.2, 1, 9.18454765366783e-18, 0.85, 0.1, 1 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.1,0.}; - double test2_res[4]={0.1,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,2,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0018() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, - -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - - double coords2[16]={ - 6.123031769111886e-18, 0.95, 1.224606353822377e-17, 1.05, 1.224606353822377e-17, 0.6499999999999999, 6.123031769111886e-18, 0.75, - 9.18454765366783e-18, 1, 0.2, 0.85, 9.18454765366783e-18, 0.7, 0.1, 0.85 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.05,0.}; - double test2_res[4]={0.05,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,1,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0019() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - 0.9500000000000001, 1.836909530733566e-17, 0.8, 3.673819061467131e-17, 1.4, 0, 1.25, 0, - 0.8750000000000001, 2.755364296100349e-17, 1.1, 0.3, 1.325, 0, 1.1, 0.15 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0020() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - 0.05000000000000002, 1.836909530733566e-17, -0.09999999999999998, 3.673819061467131e-17, 0.5, 0, 0.35, 0, - -0.02499999999999997, 2.755364296100349e-17, 0.2, 0.3, 0.425, 0, 0.2, 0.15 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.,0.}; - double test2_res[4]={0.,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0021() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -1, -0.07999999999999999, -1.15, -0.07999999999999996, -0.55, -0.08, -0.7, -0.08, - -1.075, -0.07999999999999997, -0.85, 0.22, -0.625, -0.08, -0.85, 0.06999999999999999 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0311485,pol1->intersectWith(*pol2),1.e-7); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0311485,pol2->intersectWith(*pol1),1.e-7); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.162251,0.151523,0.,0.}; - double test2_res[4]={0.,0.311383,0.,0.0978193}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={2,2,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} -void QuadraticPlanarInterpTest::checkNonRegressionOmar0022() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - 0.15, -0.07999999999999999, 0, -0.07999999999999996, 0.6, -0.08, 0.45, -0.08, - 0.07500000000000001, -0.07999999999999997, 0.3, 0.22, 0.5249999999999999, -0.08, 0.3, 0.06999999999999999 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00902229,pol1->intersectWith(*pol2),1.e-8); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00902229,pol2->intersectWith(*pol1),1.e-8); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0023() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5, }; - - double coords2[16]={ - 0.4156854249492381, 0.5656854249492381, 0.2656854249492381, 0.5656854249492381, 0.8656854249492381, 0.5656854249492381, 0.7156854249492381, 0.5656854249492381, - 0.3406854249492381, 0.5656854249492381, 0.5656854249492381, 0.8656854249492381, 0.7906854249492381, 0.5656854249492381, 0.5656854249492381, 0.7156854249492381 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0215659,pol1->intersectWith(*pol2),1.e-7); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0215659,pol2->intersectWith(*pol1),1.e-7); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0024() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, --0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - double coords2[16]={ - 0.5656854249492381, 0.5656854249492381, 0.4156854249492382, 0.5656854249492381, 1.015685424949238, 0.5656854249492381, 0.8656854249492382, 0.5656854249492381, -0.4906854249492382, 0.5656854249492381, 0.7156854249492381, 0.8656854249492381, 0.9406854249492381, 0.5656854249492381, 0.7156854249492381, 0.7156854249492381 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol1->intersectWith(*pol2),1.e-8); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol2->intersectWith(*pol1),1.e-8); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar2524() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, --0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - double coords2[16]={ - 0.4156854249492382, 0.5656854249492381, 1.015685424949238, 0.5656854249492381, 0.8656854249492382, 0.5656854249492381, 0.5656854249492381, 0.5656854249492381, -0.7156854249492381, 0.8656854249492381, 0.9406854249492381, 0.5656854249492381, 0.7156854249492381, 0.7156854249492381, 0.4906854249492382, 0.5656854249492381 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol1->intersectWith(*pol2),1.e-8); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol2->intersectWith(*pol1),1.e-8); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0025() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - 0.715685424949238, 0.5656854249492381, 0.565685424949238, 0.5656854249492381, 1.165685424949238, 0.5656854249492381, 1.015685424949238, 0.5656854249492381, - 0.6406854249492381, 0.5656854249492381, 0.8656854249492381, 0.8656854249492381, 1.090685424949238, 0.5656854249492381, 0.8656854249492381, 0.7156854249492381 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,1,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0026() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, - -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; - - double coords2[16]={ - 0.1, 0.95, 0.2, 0.95, -0.2, 0.95, -0.1, 0.95, - 0.15, 0.95, 1.224606353822377e-17, 0.75, -0.15, 0.95, 6.123031769111886e-18, 0.85 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,1,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0027() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, - -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; - - double coords2[16]={ - -0.1, 0.7, -0.2, 0.7, 0.2, 0.7, 0.1, 0.7, - -0.15, 0.7, 1.224606353822377e-17, 0.8999999999999999, 0.15, 0.7, 6.123031769111886e-18, 0.7999999999999999 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00712309,pol1->intersectWith(*pol2),1.e-8); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00712309,pol2->intersectWith(*pol1),1.e-8); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.222704,0.,0.}; - double test2_res[4]={0.1,0.0465335,0.1,0.092554}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,4,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0028() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, - -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; - - double coords2[16]={ - -0.07071067811865477, 0.4792893218813453, -0.1414213562373095, 0.4085786437626905, 0.1414213562373095, 0.6914213562373095, 0.07071067811865477, 0.6207106781186548, - -0.1060660171779822, 0.4439339828220179, -0.1414213562373095, 0.6914213562373096, 0.1060660171779822, 0.6560660171779822, -0.07071067811865475, 0.6207106781186548 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol1->intersectWith(*pol2),1.e-7); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol2->intersectWith(*pol1),1.e-7); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.,0.}; - double test2_res[4]={0.1,0.628319,0.1,0.314159}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,1,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0029() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, - -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; - - double coords2[16]={ - -0.07071067811865477, 0.1292893218813453, -0.1414213562373095, 0.05857864376269051, 0.1414213562373095, 0.3414213562373095, 0.07071067811865477, 0.2707106781186548, - -0.1060660171779822, 0.09393398282201787, -0.1414213562373095, 0.3414213562373095, 0.1060660171779822, 0.3060660171779822, -0.07071067811865475, 0.2707106781186548 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.,0.}; - double test2_res[4]={0.,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,0,1}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0030() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, - -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; - - double coords2[16]={ - -0.4889087296526012, 0.3889087296526012, -0.5889087296526012, 0.3889087296526012, -0.1889087296526012, 0.3889087296526012, -0.2889087296526012, 0.3889087296526012, - -0.5389087296526012, 0.3889087296526012, -0.3889087296526012, 0.5889087296526012, -0.2389087296526012, 0.3889087296526012, -0.3889087296526012, 0.4889087296526012 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol1->intersectWith(*pol2),1.e-7); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol2->intersectWith(*pol1),1.e-7); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.,0.}; - double test2_res[4]={0.1,0.628319,0.1,0.314159}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; - vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,1,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} diff --git a/src/INTERP_KERNEL/Test/RemapperTest.cxx b/src/INTERP_KERNEL/Test/RemapperTest.cxx deleted file mode 100644 index 2e361c12f..000000000 --- a/src/INTERP_KERNEL/Test/RemapperTest.cxx +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "RemapperTest.hxx" -#include "Remapper.hxx" - -#include -#include - -namespace INTERP_TEST -{ - - - void RemapperTest::setUp() - { - } - - - void RemapperTest::tearDown() - { - } - - /** - * Test that creates a tree in 2D and check that - * the results are correct in three - * cases : - * a non matching search - * a standard case - * a bbox overlapping the bboxes of the tree - */ - void RemapperTest::test_Remapper() { - string sourcename=getenv("MED_ROOT_DIR"); - sourcename +="/share/salome/resources/med/square1.med"; - MEDMEM::MESH source_mesh (MED_DRIVER,sourcename,"Mesh_2"); - - string targetname=getenv("MED_ROOT_DIR"); - targetname +="/share/salome/resources/med/square2.med"; - MEDMEM::MESH target_mesh (MED_DRIVER,targetname,"Mesh_3"); - - MEDMEM::SUPPORT source_support(&source_mesh,"on All support"); - MEDMEM::FIELD source_field(&source_support,1); - double* value=const_cast(source_field.getValue()); - for (int i=0; i target_field(&target_support,1); - double* targetvalue=const_cast(target_field.getValue()); - for (int i=0; i *source_areas=source_mesh.getArea(&source_support); - MEDMEM::FIELD *target_areas=target_mesh.getArea(&target_support); - absField(*source_areas); //absolute value - absField(*target_areas); //absolute value - - //target square is in reverse order as compared to initial square - double source_integral=source_field.normL2(1,source_areas); - double target_integral=target_field.normL2(1,target_areas); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(source_integral,target_integral,1e-10); - delete source_areas; - delete target_areas; - - } - - void RemapperTest::absField(MEDMEM::FIELD& field) - { - double* areas=const_cast(field.getValue()); - for (int i=0; i< field.getNumberOfValues();i++) - { - areas[i]=fabs(areas[i]); - } - } - -} diff --git a/src/INTERP_KERNEL/Test/RemapperTest.hxx b/src/INTERP_KERNEL/Test/RemapperTest.hxx deleted file mode 100644 index bd58b533b..000000000 --- a/src/INTERP_KERNEL/Test/RemapperTest.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __TU_REMAPPER_HXX__ -#define __TU_REMAPPER_HXX__ - -#include -#include "Remapper.hxx" -#include "MEDMEM_Field.hxx" - -namespace INTERP_TEST -{ - - /** - * \brief Test suite testing some of the low level methods of TransformedTriangle. - * - */ - class RemapperTest : public CppUnit::TestFixture - { - - CPPUNIT_TEST_SUITE( RemapperTest ); - CPPUNIT_TEST( test_Remapper ); - CPPUNIT_TEST_SUITE_END(); - - - public: - void setUp(); - - void tearDown(); - - // tests - void test_Remapper(); - - private: - void absField(MEDMEM::FIELD&); - }; - - - - -} - - - -#endif diff --git a/src/INTERP_KERNEL/Test/SingleElementPlanarTests.cxx b/src/INTERP_KERNEL/Test/SingleElementPlanarTests.cxx deleted file mode 100755 index 89f2b5689..000000000 --- a/src/INTERP_KERNEL/Test/SingleElementPlanarTests.cxx +++ /dev/null @@ -1,1045 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "SingleElementPlanarTests.hxx" -#include "InterpolationUtils.hxx" -#include "PolygonAlgorithms.hxx" -#include "PolygonAlgorithms.txx" -#include "InterpolationPlanarTestSuite.hxx" -#include - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - const double _Epsilon = 1.e-12; - const double _Precision = 1.e-12; - const double _losange1[8] = { 1,0, 0,1, -1,0, 0,-1 }; - const double _losange2[8] = { 2,0, 1,1, 0,0, 1,-1 }; - const double _losange3[8] = {2.5,0.5,1.5,1.5,0.5,0.5,1.5,-0.5 }; - const double _square1[8] = { -1,-1, -1,1, 1,1, 1,-1}; - const double _square2[8] = {1,-0.25,0,-0.25,0,0.25,1,0.25 }; - const double _losange4[8] = { 3,0, 2,1, 1,0, 2,-1 }; - const double _losange5[8] = { 1.5,0, 0,1.5,-1.5,0, 0,-1.5 }; - const double _losange6[12]= { 2,0, 1,1, 0.5,0.5,0,0, 0.5,-0.5, 1,-1 }; - const double _losange7[10]= { 1,0, 0,1, -1,0, 0,-1, 0.5,-0.5 }; - const double _square3[10] = { -1,-1, -1,1, 0.5,1, 1,1, 1,-1, }; - const double _square4[8] = {-0.5,-1,-0.5,1,1.5,1,1.5,-1 }; - const double _square5[10] = { -1,-1, -1,1, 0,1, 1,1, 1,-1 }; - const double _losange8[8] = { 0,1, 1,-1, 0,-1.5,-0.5,-1 }; - const double _losange9[8] = {0.5,0, 0,1, -1.5,0, 0,-1 }; - const double _hexagon1[12]= { -2,0, -1,-1, 1,-1, 2,0, 1,1, -1,1 }; - const double _hexagon2[12]= {-1.5,0.5,-1,-1, 1,-1, 2,1, 1,1, -1,1 }; - const double _hexagon3[12]= { -2,2, -1,1, 1,1, 2,2, 1,3, -1,3 }; - const double _square6[8] = { -1,1, -1,3, 0.5,3,0.5,1 }; - const double _losange10[8]= { 0,-1, 1,-2, 0,-3, -1,-2 }; - const double _triangle1[6]= {0.5,0, 1,1, 0,1 }; - const double _triangle2[6]= { 0,0.5, 0,-0.5,1.5,0 }; - const double _triangle3[9]= {-1,2,0, 1,2,0, 0,2,1 }; - const double _triangle4[9]= {1./2,2,0, 1, 2, 1, 1, 2, 0.5 }; - const double _parallel1[8] = {-1,0, -0.5,1, 0.5,1, 0,0}; - const double _parallel2[8]= {-0.5,1, 0,0, 1.,0, 0.5,1 }; - const double _parallel3[8]= {-0.5,-1, 0,0, 1,0, 0.5,-1}; - const double _triangle5[6]= { 0,0, 0,0.5, 0.5,0.5 }; - const double _triangle6[6]= { 1./3,1./3, 1./3,2./3, 2./3,2./3 }; - const double _triangle7[6]= {0.5,2, 1,1, 0,1 }; - const double _triangle8[6]= {22.4601,35.2129, 13.9921,34.693, 18.2853,26.2812 }; - const double _triangle9[6]= {13.9921,34.693, 22.4601,35.2129, 18.2785,42.3869 }; - const double _triangle10[6]= {84.8575,98.2042, 80,100, 82.2601,95.7202}; - const double _triangle11[6]= {80,100, 76.6659,91.9804, 85.3912,92.5061 }; - - // Two diamonds intersecting without degeneracy (two distinct crossing points) - // /\ /\ - // / \/ \ - // / /\ \ - // / / \ \ - // \ \ / / - // \ \/ / - // \ /\ / - // \/ \/ - - - // \brief Status : pass - void SingleElementPlanarTests::diamondsBasic() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange2,4,4); - deque< double > expected_result; - - expected_result.push_back(0.5);expected_result.push_back(-0.5); - expected_result.push_back(0);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(1);expected_result.push_back(0); - - CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - void SingleElementPlanarTests::diamondsBasic_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange2,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - expected_result.push_back(1);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(0);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(-0.5); - - CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - - // Two diamonds with overlapping edges in an exclusion configuration - // /\ - // / \ - // /\ / \ - // / \/ \ - // / \ / - // / \ / - // \ /\ / - // \ / \/ - // \ / - // \/ - // \brief Status : pass - void SingleElementPlanarTests::tangentDiamonds() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange3,4,4); - deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Diamond exclusion tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::tangentDiamonds_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange3,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(1);expected_result.push_back(0); - - CPPUNIT_ASSERT_MESSAGE("Diamond exclusion tangency test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two tangent squares with overlapping edges, in an inclusion configuration - // _____________ - // | | - // | _______| - // | | | - // | |_______| - // | | - // |_____________| - - // \brief Status : pass - void SingleElementPlanarTests::tangentSquares() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_square2,4,4); - deque< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(0.25); - expected_result.push_back(0.);expected_result.push_back(-0.25); - expected_result.push_back(1.);expected_result.push_back(-0.25); - expected_result.push_back(1.);expected_result.push_back(0.25); - - CPPUNIT_ASSERT_MESSAGE("Squares inclusion tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::tangentSquares_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_square2,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(0.25); - expected_result.push_back(0.25);expected_result.push_back(0.25); - expected_result.push_back(1./6);expected_result.push_back(1./6); - expected_result.push_back(0.);expected_result.push_back(0.25); - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(-0.25); - expected_result.push_back(1.);expected_result.push_back(-0.25); - - CPPUNIT_ASSERT_MESSAGE("Squares inclusion tangency test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two diamonds sharing a vertex in an exclusion configuration - // /\ /\ - // / \ / \ - // / \ / \ - // / \/ \ - // \ /\ / - // \ / \ / - // \ / \ / - // \/ \/ - - - // \brief Status : pass - void SingleElementPlanarTests::diamondsSharingVertex1() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange4,4,4); - deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Diamond sharing (1) vertex test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::diamondsSharingVertex1_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange4,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - expected_result.push_back(1.);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Diamonds sharing (1) vertex test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two identical squares - // _____________ - // | | - // | | - // | | - // | | - // | | - // |_____________| - - // \brief Status : pass - void SingleElementPlanarTests::identicalSquares() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_square1,4,4); - deque< double > expected_result; - - expected_result.push_back(-1.);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::identicalSquares_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_square1,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - // Square and diamond intersecting with no degeneracy - // /\ - // / \ - // / \ - // __/______\__ - // | / \ | - // |/ \| - // / \ - // /| |\ - // \| |/ - // \ / - // |\ /| - // |_\________/_| - // \ / - // \ / - // \ / - // \/ - // \brief Status : pass - void SingleElementPlanarTests::squareAndDiamondBasic() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_losange5,4,4); - deque< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(0.5); - expected_result.push_back(0.5);expected_result.push_back(1.); - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(0.5); - expected_result.push_back(-1.);expected_result.push_back(-0.5); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - expected_result.push_back(0.5);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-0.5); - - CPPUNIT_ASSERT_MESSAGE("Square and diamond basic test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::squareAndDiamondBasic_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_losange5,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(0.); - expected_result.push_back(1.);expected_result.push_back(0.5); - expected_result.push_back(0.75);expected_result.push_back(0.75); - expected_result.push_back(0.5);expected_result.push_back(1.); - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(0.5); - expected_result.push_back(-1.);expected_result.push_back(0.); - expected_result.push_back(-1.);expected_result.push_back(-0.5); - expected_result.push_back(-0.75);expected_result.push_back(-0.75); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - expected_result.push_back(0.5);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-0.5); - - - CPPUNIT_ASSERT_MESSAGE("Square and diamond basic test failed (TRIANGULATION), maybe not significant (0,0) should be removed", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - // square and diamond intersecting at four degenerated pointss - // ______ - // | /\ | - // | / \ | - // |/ \| - // |\ /| - // | \ / | - // |__\/__| - // \brief Status : pass - - void SingleElementPlanarTests::squareAndDiamondCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_losange1,4,4); - deque< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(-1.); - expected_result.push_back(-1.);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(1.);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Square and diamond critical tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::squareAndDiamondCritical_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_losange1,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(0);expected_result.push_back(0); - expected_result.push_back(-1.);expected_result.push_back(0.); - expected_result.push_back(-0.5);expected_result.push_back(-0.5); - expected_result.push_back(0.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Square and diamond basic test failed (TRIANGULATION) maybe not significant (0,0) should be removed", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - // Two diamonds intersecting at one vertex on edge and one double vertex - // /\ /\ - // / \ / \ - // / ¤ \ - // / / \ \ - // \ \ / / - // \ * / - // \ / \ / - // \/ \/ - - - // \brief Status : pass - void SingleElementPlanarTests::diamondsCritical() - { - - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_losange6,_losange7,6,5); - deque< double > expected_result; - - expected_result.push_back(0.5);expected_result.push_back(-0.5); - expected_result.push_back(0.5);expected_result.push_back(-0.5); - expected_result.push_back(0);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(1);expected_result.push_back(0); - - CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::diamondsCritical_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange6,_losange7,6,5,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(1);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(0);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(-0.5); - - CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two tangent squares with starting and ending vertices on edges - // _____ ___.___ ______ - // | | | | - // | | | | - // | | | | - // | | | | - // | | | | - // |_____|_______|______| - - // \brief Status : pass - void SingleElementPlanarTests::quadranglesCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_square4,_square3,4,5); - deque< double > expected_result; - - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Critical quadrangles with tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::quadranglesCritical_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square4,_square3,4,5,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(0.5); - expected_result.push_back(1.);expected_result.push_back(1.); - expected_result.push_back(0.5);expected_result.push_back(1.); - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(-0.5);expected_result.push_back(-1./3); - expected_result.push_back(-0.5);expected_result.push_back(-0.5); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - - CPPUNIT_ASSERT_MESSAGE("Critical quadrangles with tangency test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - - // square and diamond crossing and tangency at double vertices, starting vertex on edge - // _____.____ - // | / \ | - // | / \ | - // | / \ | - // |_/_______\| - // \ / - // \ / - // \ / - // \ / - // \brief Status : pass - void SingleElementPlanarTests::quadrangleAndDiamondCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_square5,_losange8,5,4); - deque< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - - CPPUNIT_ASSERT_MESSAGE("Square and diamond critical tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::quadrangleAndDiamondCritical_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square5,_losange8,5,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1./3);expected_result.push_back(1./3); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(-1./3);expected_result.push_back(-1./3); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - expected_result.push_back(0.);expected_result.push_back(-1.); - - CPPUNIT_ASSERT_MESSAGE("Square and diamond critical tangency test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } // square and diamond intersecting at four degenerated pointss - // - // ²/²\ - // ² / ² \ - // ² / ² \ - // ² \ ² / - // ² \ ² / - // ²\²/ - // \brief Status : pass - - void SingleElementPlanarTests::diamondsCritical2() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange9,4,4); - deque< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(-1.); - expected_result.push_back(0.);expected_result.push_back(-1.); - expected_result.push_back(-1.);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(0.5);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Diamonds with crossing at double vertex test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::diamondsCritical2_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange9,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(-1.); - expected_result.push_back(0.5);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Diamonds with crossing at double vertex test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two tangent hexagons with double vertices and a critical starting vertex on edge - // _________ - // / \²²² - // ² \² - // / \ - // / ² ² \ - // \ / - // \ ² ² / - // \ / - // \²_______²/ - - - // \brief Status : pass - void SingleElementPlanarTests::hexagonsCritical1() - { - - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_hexagon1,_hexagon2,6,6); - deque< double > expected_result; - - expected_result.push_back(5./3);expected_result.push_back(1./3); - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(-1.);expected_result.push_back(-1.); - expected_result.push_back(-1.5);expected_result.push_back(0.5); - expected_result.push_back(-1.);expected_result.push_back(1.); - expected_result.push_back(1.);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("First hexagon critical crossing test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::hexagonsCritical1_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_hexagon1,_hexagon2,6,6,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(-1.);expected_result.push_back(1.); - expected_result.push_back(-1.5);expected_result.push_back(0.5); - expected_result.push_back(-8./7);expected_result.push_back(2./7); - expected_result.push_back(-1.4);expected_result.push_back(0.2); - expected_result.push_back(-4./3);expected_result.push_back(0.); - expected_result.push_back(-2./3);expected_result.push_back(0.); - expected_result.push_back(-1.25);expected_result.push_back(-0.25); - expected_result.push_back(-1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1.5);expected_result.push_back(0.); - expected_result.push_back(5./3);expected_result.push_back(1./3); - expected_result.push_back(1.125);expected_result.push_back(0.875); - expected_result.push_back(1.);expected_result.push_back(1.); - expected_result.push_back(0.25);expected_result.push_back(0.75); - - CPPUNIT_ASSERT_MESSAGE("First hexagon critical crossing test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two tangent hexagons with double vertices and a critical starting vertex on edge - // _______ - // / \ - // / \ - // \ / - // \_______/ - // / \ - // / \ - // \ / - // \_______/ - - - // \brief Status : pass - void SingleElementPlanarTests::hexagonsCritical2() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_hexagon1,_hexagon3,6,6); - deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Second hexagon critical crossing test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::hexagonsCritical2_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_hexagon1,_hexagon3,6,6,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - expected_result.push_back(1.);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Second hexagon critical crossing test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Square and quadrilateron with outer tangency - // ________ - // | | - // | | - // | | - // |________|___ - // | | - // | | - // | | - // | | - // | | - // |____________| - - // \brief Status : pass - void SingleElementPlanarTests::squareAndQuadrangleCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_square6,4,4); - deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (CONVEX)", (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::squareAndQuadrangleCritical_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_square6,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - expected_result.push_back(-1.);expected_result.push_back(1.); - expected_result.push_back(0.5);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - // Two diamonds sharing a vertex in an exclusion configuration - // /\ - // / \ - // / \ - // / \ - // \ / - // \ / - // \ / - // \/ - // /\ - // / \ - // / \ - // / \ - // \ / - // \ / - // \ / - // \/ - - - // \brief Status : pass - void SingleElementPlanarTests:: diamondsSharingVertex2() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange10,4,4); - deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Diamond sharing vertex (2) test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests:: diamondsSharingVertex2_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange10,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - expected_result.push_back(0.);expected_result.push_back(-1.); - - CPPUNIT_ASSERT_MESSAGE("Diamond sharing vertex (2) test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Triangle and diamond with a critical crossing at double starting vertex - // ____ - // /|\ / - // / | \/ - // / | /\ - // / |/ \ - // \ / - // \ / - // \ / - // \ / - - // \brief Status : pass - void SingleElementPlanarTests:: triangleAndDiamondCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_triangle1,4,3); - deque< double > expected_result; - - expected_result.push_back(2./3);expected_result.push_back(1./3); - expected_result.push_back(0.5);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Triangle and diamonds critical test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests:: triangleAndDiamondCritical_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_triangle1,4,3,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(2./3);expected_result.push_back(1./3); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(0.5);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Triangle and diamonds critical test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Basic triangle and square intersection (two distinct points) - // __________ - // | | - // | |\ | - // | | \| - // | | \ - // | | |\ - // | | |/ - // | | / - // | | /| - // | |/ | - // |__________| - - // \brief Status : pass - void SingleElementPlanarTests::triangleAndSquareBasic() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_triangle2,4,3); - deque< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(1./6); - expected_result.push_back(1.);expected_result.push_back(-1./6); - expected_result.push_back(0.);expected_result.push_back(-0.5); - expected_result.push_back(0.);expected_result.push_back(0.5); - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - void SingleElementPlanarTests::triangleAndSquareBasic_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_triangle2,4,3,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(1./6); - expected_result.push_back(0.375);expected_result.push_back(0.375); - expected_result.push_back(0.);expected_result.push_back(0.5); - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(-0.5); - expected_result.push_back(1.);expected_result.push_back(-1./6); - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - // Two triangles with a starting vertex on edge - - // /\ ²²²² - // / ² ² - // / ² ² - // /__²___\ - - // \brief Status : pass - void SingleElementPlanarTests::trianglesCritical() - { - INTERP_KERNEL::PolygonAlgorithms<3> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_triangle3,_triangle4,3,3); - deque< double > expected_result; - - expected_result.push_back(2./3);expected_result.push_back(2.);expected_result.push_back(1./3); - expected_result.push_back(0.5);expected_result.push_back(2.);expected_result.push_back(0.); - expected_result.push_back(0.75);expected_result.push_back(2.);expected_result.push_back(0.25); - - CPPUNIT_ASSERT_MESSAGE("Triangles critical test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,3>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesCritical_Triangulation() - { - vector< double > actual_result; - double _triangle3rotated[6],_triangle4rotated[6]; - for (int i=0; i<3; i++)_triangle3rotated[2*i] = _triangle3[3*i]; - for (int i=0; i<3; i++)_triangle3rotated[2*i+1] = _triangle3[3*i+2]; - for (int i=0; i<3; i++)_triangle4rotated[2*i] = _triangle4[3*i]; - for (int i=0; i<3; i++)_triangle4rotated[2*i+1] = _triangle4[3*i+2]; - - INTERP_KERNEL::intersec_de_polygone<2>(_triangle3rotated,_triangle4rotated,3,3,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(0.5);expected_result.push_back(0.); - expected_result.push_back(2./3);expected_result.push_back(1./3); - expected_result.push_back(0.75);expected_result.push_back(0.25); - - CPPUNIT_ASSERT_MESSAGE("Triangles critical test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two tangent paralellograms intersecting at 3 double vertices (one being a starting vertex) - // _______ - // /\ /\ - // / \ / \ - // / \ / \ - // /______\/______\ - - - // \brief Status : pass - void SingleElementPlanarTests::paralellogramsCritical1() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_parallel1,_parallel2,4,4); - deque< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(0.5);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test (1) failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::paralellogramsCritical1_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_parallel1,_parallel2,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(0.25);expected_result.push_back(0.5); - expected_result.push_back(0.5);expected_result.push_back(1.); - expected_result.push_back(0.);expected_result.push_back(2./3); - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(-0.25);expected_result.push_back(0.5); - expected_result.push_back(0.);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test (1) failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two paralellograms sharing a vertex in an exclusion configuration - // ________ - // / / - // / / - // / / - // /_______/_______ - // / / - // / / - // / / - // /_______/ - - - // \brief Status : pass - void SingleElementPlanarTests::paralellogramsCritical2() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_parallel1,_parallel3,4,4); - deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::paralellogramsCritical2_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_parallel1,_parallel3,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two triangles in a tangency configuration with a starting vertex on edge - - // _____ - // | / - // __|___/ - // | | / - // | | / - // | |/ - // | / - // | / - // |/ - - // \brief Status : pass - void SingleElementPlanarTests::trianglesTangencyCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_triangle5,_triangle6,3,3); - deque< double > expected_result; - - expected_result.push_back(1./3);expected_result.push_back(1./2); - expected_result.push_back(1./3);expected_result.push_back(1./3); - expected_result.push_back(1./2);expected_result.push_back(1./2); - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesTangencyCritical_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_triangle5,_triangle6,3,3,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - - expected_result.push_back(1./3);expected_result.push_back(1./2); - expected_result.push_back(1./2);expected_result.push_back(1./2); - expected_result.push_back(1./3);expected_result.push_back(1./3); - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two triangles with double starting point in an outer tangency configuration - // /\ - // / \ - // / \ - // /______\ - // \ / - // \ / - // \ / - // \/ - - - // \brief Status : pass - void SingleElementPlanarTests::trianglesTangencyCritical2() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_triangle1,_triangle7,3,3); - deque< double > expected_result; - - // if(!checkDequesEqual(actual_result,expected_result, _Epsilon)) - // { - // cerr<< "CPP_UNIT expected result= " << endl; - // dequePrintOut(expected_result); - // cerr<< "CPP_UNIT actual result= " << endl; - // dequePrintOut(actual_result); - // } - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (2) test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesTangencyCritical2_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_triangle1,_triangle7,3,3,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - expected_result.push_back(1.);expected_result.push_back(1.); - expected_result.push_back(0.);expected_result.push_back(1.); - - // if(!checkVectorsEqual(actual_result,expected_result, _Epsilon)) - // { - // cerr<< "CPP_UNIT expected result= " << endl; - // vectPrintOut(expected_result); - // cerr<< "CPP_UNIT actual result= " << endl; - // vectPrintOut(actual_result); - // } - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (2) test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - // \brief Status : pass - void SingleElementPlanarTests::trianglesTangencyCritical3() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_triangle8,_triangle9,3,3); - deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (3) test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesTangencyCritical3_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_triangle8,_triangle9,3,3,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - expected_result.push_back(22.4601);expected_result.push_back(35.2129); - expected_result.push_back(13.9921);expected_result.push_back(34.693); - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (3) test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesTangencyCritical4() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - deque< double > actual_result = intersector.intersectConvexPolygons(_triangle10,_triangle11,3,3); - - deque< double > expected_result; - expected_result.push_back(82.745193090443536);expected_result.push_back(96.184114390029166); - expected_result.push_back(82.260099999999994);expected_result.push_back(95.720200000000006); - expected_result.push_back(80);expected_result.push_back(100.); - - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (4) test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesTangencyCritical4_Triangulation() - { - vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_triangle10,_triangle11,3,3,actual_result,_Epsilon/_Precision, _Precision ); - - vector< double > expected_result; - expected_result.push_back(80);expected_result.push_back(100.); - expected_result.push_back(82.745193090443536);expected_result.push_back(96.184114390029166); - expected_result.push_back(82.260099999999994);expected_result.push_back(95.720200000000006); - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (4) test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - -} diff --git a/src/INTERP_KERNEL/Test/SingleElementPlanarTests.hxx b/src/INTERP_KERNEL/Test/SingleElementPlanarTests.hxx deleted file mode 100755 index ad0a420cd..000000000 --- a/src/INTERP_KERNEL/Test/SingleElementPlanarTests.hxx +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __SINGLE_ELEMENT_PLANAR_TESTS_HXX_ -#define __SINGLE_ELEMENT_PLANAR_TESTS_HXX_ - -#include "InterpolationPlanarTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class testing algorithm by intersecting simple meshes having only one planar element each. - * This serves mainly to verify that the volume calculations between elements is correct. - * - */ - class SingleElementPlanarTests : public InterpolationPlanarTestSuite - { - CPPUNIT_TEST_SUITE( SingleElementPlanarTests ); - - CPPUNIT_TEST( diamondsBasic ); - CPPUNIT_TEST( tangentDiamonds ); - CPPUNIT_TEST( tangentSquares ); - CPPUNIT_TEST( diamondsSharingVertex1 ); - CPPUNIT_TEST( identicalSquares ); - CPPUNIT_TEST( squareAndDiamondBasic ); - CPPUNIT_TEST( squareAndDiamondCritical ); - CPPUNIT_TEST( diamondsCritical ); - CPPUNIT_TEST( quadranglesCritical ); - CPPUNIT_TEST( quadrangleAndDiamondCritical ); - CPPUNIT_TEST( diamondsCritical2 ); - CPPUNIT_TEST( hexagonsCritical1 ); - CPPUNIT_TEST( hexagonsCritical2 ); - CPPUNIT_TEST( squareAndQuadrangleCritical ); - CPPUNIT_TEST( diamondsSharingVertex2 ); - CPPUNIT_TEST( triangleAndDiamondCritical ); - CPPUNIT_TEST( triangleAndSquareBasic ); - CPPUNIT_TEST( trianglesCritical ); - CPPUNIT_TEST( paralellogramsCritical1 ); - CPPUNIT_TEST( paralellogramsCritical2 ); - CPPUNIT_TEST( trianglesTangencyCritical ); - CPPUNIT_TEST( trianglesTangencyCritical2 ); - CPPUNIT_TEST( trianglesTangencyCritical3 ); - CPPUNIT_TEST( trianglesTangencyCritical4 ); - CPPUNIT_TEST( diamondsBasic_Triangulation ); - CPPUNIT_TEST( tangentDiamonds_Triangulation ); - CPPUNIT_TEST( tangentSquares_Triangulation ); - CPPUNIT_TEST( diamondsSharingVertex1_Triangulation ); - CPPUNIT_TEST( identicalSquares_Triangulation ); - CPPUNIT_TEST( squareAndDiamondBasic_Triangulation ); - CPPUNIT_TEST( squareAndDiamondCritical_Triangulation ); - CPPUNIT_TEST( diamondsCritical_Triangulation ); - CPPUNIT_TEST( quadranglesCritical_Triangulation ); - CPPUNIT_TEST( quadrangleAndDiamondCritical_Triangulation ); - CPPUNIT_TEST( diamondsCritical2_Triangulation ); - CPPUNIT_TEST( hexagonsCritical1_Triangulation ); - CPPUNIT_TEST( hexagonsCritical2_Triangulation ); - CPPUNIT_TEST( squareAndQuadrangleCritical_Triangulation ); - CPPUNIT_TEST( diamondsSharingVertex2_Triangulation ); - CPPUNIT_TEST( triangleAndDiamondCritical_Triangulation ); - CPPUNIT_TEST( triangleAndSquareBasic_Triangulation ); - CPPUNIT_TEST( trianglesCritical_Triangulation ); - CPPUNIT_TEST( paralellogramsCritical1_Triangulation ); - CPPUNIT_TEST( paralellogramsCritical2_Triangulation ); - CPPUNIT_TEST( trianglesTangencyCritical_Triangulation ); - CPPUNIT_TEST( trianglesTangencyCritical2_Triangulation ); - CPPUNIT_TEST( trianglesTangencyCritical3_Triangulation ); - CPPUNIT_TEST( trianglesTangencyCritical4_Triangulation ); - - CPPUNIT_TEST_SUITE_END(); - - public: - - void diamondsBasic(); - void tangentDiamonds(); - void tangentSquares(); - void diamondsSharingVertex1(); - void identicalSquares(); - void squareAndDiamondBasic(); - void squareAndDiamondCritical(); - void diamondsCritical(); - void quadranglesCritical(); - void quadrangleAndDiamondCritical(); - void diamondsCritical2(); - void hexagonsCritical1(); - void hexagonsCritical2(); - void squareAndQuadrangleCritical(); - void diamondsSharingVertex2(); - void triangleAndDiamondCritical(); - void triangleAndSquareBasic(); - void trianglesCritical(); - void paralellogramsCritical1(); - void paralellogramsCritical2(); - void trianglesTangencyCritical(); - void trianglesTangencyCritical2(); - void trianglesTangencyCritical3(); - void trianglesTangencyCritical4(); - void diamondsBasic_Triangulation(); - void tangentDiamonds_Triangulation(); - void tangentSquares_Triangulation(); - void diamondsSharingVertex1_Triangulation(); - void identicalSquares_Triangulation(); - void squareAndDiamondBasic_Triangulation(); - void squareAndDiamondCritical_Triangulation(); - void diamondsCritical_Triangulation(); - void quadranglesCritical_Triangulation(); - void quadrangleAndDiamondCritical_Triangulation(); - void diamondsCritical2_Triangulation(); - void hexagonsCritical1_Triangulation(); - void hexagonsCritical2_Triangulation(); - void squareAndQuadrangleCritical_Triangulation(); - void diamondsSharingVertex2_Triangulation(); - void triangleAndDiamondCritical_Triangulation(); - void triangleAndSquareBasic_Triangulation(); - void trianglesCritical_Triangulation(); - void paralellogramsCritical1_Triangulation(); - void paralellogramsCritical2_Triangulation(); - void trianglesTangencyCritical_Triangulation(); - void trianglesTangencyCritical2_Triangulation(); - void trianglesTangencyCritical3_Triangulation(); - void trianglesTangencyCritical4_Triangulation(); - }; -} -#endif diff --git a/src/INTERP_KERNEL/Test/SingleElementTetraTests.hxx b/src/INTERP_KERNEL/Test/SingleElementTetraTests.hxx deleted file mode 100644 index f5e22b464..000000000 --- a/src/INTERP_KERNEL/Test/SingleElementTetraTests.hxx +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __SINGLE_ELEMENT_TETRA_TESTS_HXX_ -#define __SINGLE_ELEMENT_TETRA_TESTS_HXX_ - -#include "InterpolationTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class testing algorithm by intersecting simple meshes having only one element each. This serves mainly to verify that - * the volume calculations between elements is correct. - * - */ - class SingleElementTetraTests : public InterpolationTestSuite<3,3> - { - CPPUNIT_TEST_SUITE( SingleElementTetraTests ); - - 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 ); - - CPPUNIT_TEST_SUITE_END(); - - public: - - /// Unit tetrahedron mesh intersecting itself - /// \brief Status : pass - void tetraReflexiveUnit() - { - _testTools->intersectMeshes("UnitTetra", "UnitTetra", 1.0/6.0); - } - - /// Tetrahedron mesh with itself - /// \brief Status : pass - void tetraReflexiveGeneral() - { - _testTools->intersectMeshes("GeneralTetra", "GeneralTetra", 0.428559); - } - - /// Unit tetrahedron mesh intersecting slightly displaced copy of itself - /// \brief Status : pass - void tetraNudged() - { - _testTools->intersectMeshes("UnitTetra", "NudgedTetra", 0.142896); - } - - /// Single-element unit tetrahedron mesh intersecting even slightly displaced (along one axis only) copy of itself - /// \brief Status : pass - void tetraNudgedSimpler() - { - _testTools->intersectMeshes("UnitTetra", "NudgedSimpler", 0.152112); - } - - /// Tetrahedron intersecting unit tetrahedron with in non-degenerate way around corner O - /// \brief Status : pass - void tetraCorner() - { - _testTools->intersectMeshes("UnitTetra", "CornerTetra", 0.0135435); - } - - /// Tetrahedron situated totally inside another - /// \brief Status : pass - void tetraSimpleIncluded() - { - _testTools->intersectMeshes("SimpleIncludedTetra", "SimpleIncludingTetra", 17.0156); - } - - /// Displaced unit tetrahedron intersecting another unit tetrahedron with which it shares an edge - /// \brief Status : pass - void tetraDegenEdge() - { - _testTools->intersectMeshes("UnitTetraDegenT", "DegenEdgeXY", 0.0); - } - - /// Displaced unit tetrahedron intersecting another unit tetrahedron with which it shares a face - /// \brief Status : pass - void tetraDegenFace() - { - _testTools->intersectMeshes("UnitTetraDegenT", "DegenFaceXYZ", 0.0); - } - - /// Displaced unit tetrahedron intersecting another unit tetrahedron with which it shares a part of the face XYZ - /// \brief Status : pass - void tetraDegenTranslatedInPlane() - { - _testTools->intersectMeshes("UnitTetraDegenT", "DegenTranslatedInPlane", 0.0571667); - } - - /// Tetrahedron having only half-strip intersections with the unit tetrahedron - /// \brief Status : pass, but does not really test what it should - does not check that the intersections are detected. No longer needed. - 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 - _testTools->intersectMeshes("HalfstripOnly", "UnitTetra", 0.0); - } - - /// Tetrahedron having only half-strip intersections with the unit tetrahedron - /// \brief Status : pass, but does not really test what it should - does not check that the intersections are detected. No longer needed. - 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 - _testTools->intersectMeshes("HalfstripOnly2", "UnitTetra", 0.0); - } - - /// Tetrahedron having only half-strip intersections with the unit tetrahedron - /// \brief Status : pass, but does not really test what it should - does not check that the intersections are detected. No longer needed. - 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 - _testTools->intersectMeshes("SimpleHalfstripOnly", "UnitTetra", 0.0); - } - - /// Two intersecting tetrahedra situated in a general position in space - /// \brief Status : pass - void generalTetra() - { - _testTools->intersectMeshes("GenTetra1", "GenTetra2", 4.91393); - } - - /// Tetrahedron which is in a tricky position relative to unit tetrahedron. - /// \brief Status : pass - void trickyTetra1() - { - _testTools->intersectMeshes("UnitTetra", "TrickyTetra1", 0.0); - } - - /// Two large tetrahedra which nearly share part of an edge and intersect at the origin. Created with goal of getting the as-of-yet uncovered "consistency" test - /// part of the correction of double products covered. However, it does not succeed with this. - /// \brief Status : fails, but is quite far-fetched as far as typical use cases are concerned - void inconsistentTetra() - { - _testTools->intersectMeshes("LargeUnitTetra.med", "LargeUnitTetra", "LargeInconsistentTetra.med", "LargeInconsistent", 7.86231e7); - } - - }; -} -#endif diff --git a/src/INTERP_KERNEL/Test/TestInterpKernel.cxx b/src/INTERP_KERNEL/Test/TestInterpKernel.cxx deleted file mode 100644 index 41501ea7e..000000000 --- a/src/INTERP_KERNEL/Test/TestInterpKernel.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "CppUnitTest.hxx" -#include "TransformedTriangleTest.hxx" -#include "UnitTetraIntersectionBaryTest.hxx" -#include "TransformedTriangleIntersectTest.hxx" -#include "MultiElementTetraTests.hxx" -#include "SingleElementTetraTests.hxx" -#include "HexaTests.hxx" -#include "BBTreeTest.hxx" -#include "PointLocatorTest.hxx" -#include "RemapperTest.hxx" -#include "MultiElement2DTests.hxx" -#include "SingleElementPlanarTests.hxx" -#include "QuadraticPlanarInterpTest.hxx" -#include "InterpolationOptionsTest.hxx" -using namespace INTERP_TEST; - -//--- Registers the fixture into the 'registry' - -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( UnitTetraIntersectionBaryTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( BBTreeTest); -CPPUNIT_TEST_SUITE_REGISTRATION( RemapperTest); -CPPUNIT_TEST_SUITE_REGISTRATION( PointLocatorTest); -CPPUNIT_TEST_SUITE_REGISTRATION( MultiElement2DTests ); -CPPUNIT_TEST_SUITE_REGISTRATION( SingleElementPlanarTests ); -CPPUNIT_TEST_SUITE_REGISTRATION( QuadraticPlanarInterpTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( InterpolationOptionsTest ); - -// --- generic Main program from KERNEL_SRC/src/Basics/Test - -#include "BasicMainTest.hxx" diff --git a/src/INTERP_KERNEL/Test/TestingUtils.hxx b/src/INTERP_KERNEL/Test/TestingUtils.hxx deleted file mode 100644 index 1057f58c2..000000000 --- a/src/INTERP_KERNEL/Test/TestingUtils.hxx +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _TESTING_UTILS_HXX_ -#define _TESTING_UTILS_HXX_ - -#include "Interpolation3D.hxx" -#include "MEDMEM_Mesh.hxx" - -#include -#include -#include -#include -#include - -#include "VectorUtils.hxx" - -// levels : -// 1 - titles and volume results -// 2 - symmetry / diagonal results and intersection matrix output -// 3 - empty -// 4 - empty -// 5 - misc -#include "Log.hxx" - -using namespace MEDMEM; -using namespace std; -using namespace INTERP_KERNEL; -using namespace MED_EN; - - -double sumVolume(const IntersectionMatrix& m) -{ - - vector volumes; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - volumes.push_back(iter2->second); - // vol += std::fabs(iter2->second); - } - } - - // sum in ascending order to avoid rounding errors - - sort(volumes.begin(), volumes.end()); - const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); - - return vol; -} - -#if 0 - -bool areCompatitable(const IntersectionMatrix& m1, const IntersectionMatrix& m2) -{ - bool compatitable = true; - int i = 0; - 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; - if(m2.at(j-1).count(i+1) == 0) - { - if(!epsilonEqual(iter2->second, 0.0, VOL_PREC)) - { - LOG(2, "V1( " << i << ", " << j << ") exists, but V2( " << j - 1 << ", " << i + 1 << ") " << " does not " ); - LOG(2, "(" << i << ", " << j << ") fails"); - compatitable = false; - } - } - } - ++i; - } - if(!compatitable) - { - LOG(1, "*** matrices are not compatitable"); - } - return compatitable; -} - -bool testSymmetric(const IntersectionMatrix& m1, const IntersectionMatrix& m2) -{ - - int i = 0; - bool isSymmetric = true; - - LOG(1, "Checking symmetry src - target" ); - isSymmetric = isSymmetric & areCompatitable(m1, m2) ; - LOG(1, "Checking symmetry target - src" ); - isSymmetric = isSymmetric & areCompatitable(m2, m1); - - 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) - // { - map theMap = m2.at(j-1); - const double v2 = theMap[i + 1]; - if(v1 != v2) - { - LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 ); - if(!epsilonEqualRelative(v1, v2, VOL_PREC)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isSymmetric = false; - } - } - } - ++i; - } - if(!isSymmetric) - { - LOG(1, "*** matrices are not symmetric"); - } - return isSymmetric; -} - -bool testDiagonal(const IntersectionMatrix& m) -{ - LOG(1, "Checking if matrix is diagonal" ); - int i = 1; - bool isDiagonal = true; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - const double vol = iter2->second; - if(vol != 0.0 && (i != j)) - { - LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" ); - if(!epsilonEqual(vol, 0.0, VOL_PREC)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isDiagonal = false; - } - } - } - ++i; - } - if(!isDiagonal) - { - LOG(1, "*** matrix is not diagonal"); - } - return isDiagonal; -} - -#endif - -void dumpIntersectionMatrix(const IntersectionMatrix& m) -{ - int i = 0; - std::cout << "Intersection matrix is " << endl; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - - std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << endl; - - } - ++i; - } - std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; -} - -std::pair countNumberOfMatrixEntries(const IntersectionMatrix& m) -{ - - int numElems = 0; - int numNonZero = 0; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - numElems += iter->size(); - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - if(!epsilonEqual(iter2->second, 0.0, VOL_PREC)) - { - ++numNonZero; - } - } - } - return std::make_pair(numElems, numNonZero); -} - - -void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) -{ - const string dataBaseDir = getenv("MED_ROOT_DIR"); - const string dataDir = dataBaseDir + "/share/salome/resources/med/"; - - 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"); - - Interpolation3D* interpolator = new Interpolation3D(); - - m = interpolator->interpolateMeshes(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)); - - delete interpolator; - - LOG(1, "Intersection calculation done. " << std::endl ); - -} - - - - - - - - -#if 0 -void intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec, bool doubleTest) -{ - LOG(1, std::endl << std::endl << "=============================" ); - - using std::string; - const string path1 = string(mesh1path) + string(mesh1); - const string path2 = string(mesh2path) + string(mesh2); - - const bool isTestReflexive = (path1.compare(path2) == 0); - - IntersectionMatrix matrix1; - calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix1); -#endif - - std::cout.precision(16); - - const double vol1 = sumVolume(matrix1); - - if(!doubleTest) - { - LOG(1, "vol = " << vol1 <<" correctVol = " << correctVol ); - // CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(correctVol, vol1)); - - if(isTestReflexive) - { - // CPPUNIT_ASSERT_EQUAL_MESSAGE("Reflexive test failed", true, testDiagonal(matrix1)); - } - } - else - { - - IntersectionMatrix matrix2; - calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix2); -#endif - - const double vol2 = sumVolume(matrix2); - - LOG(1, "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol ); - - // CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(vol1, correctVol)); - // CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec * std::max(vol2, correctVol)); - // CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, prec * std::max(vol1, vol2)); - // CPPUNIT_ASSERT_EQUAL_MESSAGE("Symmetry test failed", true, testSymmetric(matrix1, matrix2)); - } - -} - - - -#endif - - -#endif diff --git a/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx b/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx deleted file mode 100644 index 500af44c0..000000000 --- a/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.cxx +++ /dev/null @@ -1,2283 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "TransformedTriangleIntersectTest.hxx" -#include - -#include "Log.hxx" - -/// macro to test for zero double products outside the segment-edge intersection test method -/// as is done in TransformedTriangle when OPTIMIZE is defined -#define TEST_ZERO_DP_EDGE(seg, edge) isZero[TT::NO_DP*int(seg) + int(DoubleProduct(edge))] - -/// macro to test for zero double products outside the segment-corner intersection test method -/// as is done in TransformedTriangle when OPTIMIZE is defined -#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] )] - -/// macro to test for zero double products outside the segment-ray intersection test method -/// as is done in TransformedTriangle when OPTIMIZE is defined -#define TEST_ZERO_DP_RAY(seg, corner) isZero[TT::NO_DP*int(seg) + TT::DP_SEGMENT_RAY_INTERSECTION[7*(corner-1)]] - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - - //////////////////////////////////////////////////////////////////////////////////////////////////////// - /// \class TransformedTriangleIntersectTest - /// \brief Class testing the intersection detection methods of TransformedTriangle. - /// - /// This class contains unit tests for the intersection methods of the TransformedTriangle class. - //////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Each method in the class 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
-  /// -----------------------------------------------------------------------------------------------------
-  /// 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 - //////////////////////////////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////////////////////////////// - /// 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     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle1() - { - LOG(1, "+++++++ Testing triangle 1" ); - - 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 - }; - - 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 - - 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); - } - } - - // 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, 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, 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, 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)); - 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, 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, 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(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(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     - 
-  /// 
- /// \brief Status: pass - void TransformedTriangleIntersectTest::testTriangle2() - { - LOG(1, "+++++++ Testing triangle 2" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - -0.5, 0.5, 0.25, // P - 1.5, 0.5,-0.25, // Q - -0.5,-1.5, 0.75 // 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 - - 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); - } - } - - // 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(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, 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, 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, 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)); - 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, 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, 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)); - 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; - } - - /// 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     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle3() - { - LOG(1, "+++++++ Testing triangle 3" ); - 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 - - 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); - } - } - - // 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(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, 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(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, 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, 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, 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)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::PQ, 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, 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, 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, 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(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     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle4() - { - LOG(1, "+++++++ Testing triangle 4" ); - 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 - }; - - 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 - - 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); - } - } - - // 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(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)); - - 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, 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, 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, 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)); - 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, 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, 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)); - 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
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle5() - { - LOG(1, "+++++++ Testing triangle 5" ); - - 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 - - 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); - } - } - - // 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, 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, 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, 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)); - 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, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(true , 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, 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(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(true , tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - /// Triangle 6 has the following intersections - ///
-  /// CI     -
-  /// COH    -
-  /// CAH    -
-  /// SF     -
-  /// SE     -
-  /// SC     -
-  /// SHS    -
-  /// SR     (PQ, X), (QR, Z) 
-  /// TE     -
-  /// TR     Y 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle6() - { - LOG(1, "+++++++ Testing triangle 6" ); - - 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 - - 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); - } - } - - // 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, 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, 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, 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)); - 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(true , 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, 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(true , 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(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 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle7() - { - - LOG(1, "+++++++ Testing triangle 7" ); - 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]); - - // 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 - - 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); - } - } - - // 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(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, 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, 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, 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)); - 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, 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, 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)); - 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     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle8() - { - LOG(1, "+++++++ Testing triangle 8" ); - 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 - - 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); - } - } - - // 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, 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, 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, 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(true , 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)); - 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, 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, 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(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     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle9() - { - LOG(1, "+++++++ Testing triangle 9" ); - 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 - - 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); - } - } - - // 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, 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(true , 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, 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, 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)); - 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, 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, 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(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     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle10() - { - LOG(1, "+++++++ Testing triangle 10" ); - 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 - - 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); - } - } - - // 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, 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(true , 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, 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, 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)); - 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, 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, 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(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, OZ]
-  /// TR     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle11() - { - LOG(1, "+++++++ Testing triangle 11" ); - 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 - - 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); - } - } - - // 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 , 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, 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, 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(true , 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)); - 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, 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, 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(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 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     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle12() - { - LOG(1, "+++++++ Testing triangle 12" ); - 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 - - 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); - } - } - - // 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, 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(true , 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, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(true , 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, 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)); - 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, 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, 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(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     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle13() - { - LOG(1, "+++++++ Testing triangle 13" ); - 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 - - 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); - } - } - - // 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, 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, 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, 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(true , 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(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, 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, 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(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; - } - - -} // NAMESPACE - - - - - - - -///// TEMPLATE /////////////////////////////// - - - -#if 0 -// Triangle x has the following intersections -// CI - -// COH - -// CAH - -// SF - -// SE - -// SC - -// SHS - -// SR - -// TE - -// TR - - -void TransformedTriangleIntersectTest::testTriangleX() -{ - LOG(1, "+++++++ Testing triangle X" ); - 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 deleted file mode 100644 index 752c0508c..000000000 --- a/src/INTERP_KERNEL/Test/TransformedTriangleIntersectTest.hxx +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __TU_TRANSFORMED_TRIANGLE_INTERSECT_HXX__ -#define __TU_TRANSFORMED_TRIANGLE_INTERSECT_HXX__ - -#include -#include "../TransformedTriangle.hxx" - -namespace INTERP_TEST -{ - - 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_KERNEL::TransformedTriangle::TriSegment TriSegment; - typedef INTERP_KERNEL::TransformedTriangle::DoubleProduct DoubleProduct; - - public: - - void testTriangle1(); - - void testTriangle2(); - - void testTriangle3(); - - void testTriangle4(); - - void testTriangle5(); - - void testTriangle6(); - - void testTriangle7(); - - void testTriangle8(); - - void testTriangle9(); - - void testTriangle10(); - - void testTriangle11(); - - void testTriangle12(); - - void testTriangle13(); - - private: - - }; - -} - - - - - - -#endif diff --git a/src/INTERP_KERNEL/Test/TransformedTriangleTest.cxx b/src/INTERP_KERNEL/Test/TransformedTriangleTest.cxx deleted file mode 100644 index e668dbc03..000000000 --- a/src/INTERP_KERNEL/Test/TransformedTriangleTest.cxx +++ /dev/null @@ -1,354 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "TransformedTriangleTest.hxx" - -#include - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - - /** - * Creates the TransformedTriangle objects used by the tests. - * - */ - void TransformedTriangleTest::setUp() - { - // tri1 -> no unstable double products - no changes brought about by preCalculateDoubleProducts - // this allows the testing of calcUnstableT - // tri2 -> unstable double products - for testing calcStableC / preCalculateDoubleProducts - - // triangle to test unstable C and T calculations - p1[0] = -1.5 ; p1[1] = 0.5; p1[2] = 0.5; - q1[0] = 2.0 ; q1[1] = 0.4; q1[2] = 0.6; - r1[0] = 1.0 ; r1[1] = 2.4; r1[2] = 1.2; - hp1 = 1 - p1[0] - p1[1] - p1[2]; - hq1 = 1 - q1[0] - q1[1] - q1[2]; - hr1 = 1 - r1[0] - r1[1] - r1[2]; - Hp1 = 1 - p1[0] - p1[1]; - Hq1 = 1 - q1[0] - q1[1]; - Hr1 = 1 - r1[0] - r1[1]; - - // std::cout <_coords[i], ERR_TOL); - CPPUNIT_ASSERT_DOUBLES_EQUAL(good_values2[i], tri2->_coords[i], ERR_TOL); - } - - CPPUNIT_ASSERT_EQUAL(true, tri1->_is_double_products_calculated); - CPPUNIT_ASSERT_EQUAL(true, tri2->_is_double_products_calculated); - } - - /// Tests the calculation of double products (without the corrections) - /// \brief Status : pass - void TransformedTriangleTest::test_calcUnstableC() { - typedef TransformedTriangle::TriSegment TriSegment; - - // test that the correct c-values are calculated - - double correct_c_vals[24] = - { - p1[0] * q1[1] - p1[1] * q1[0], - p1[1] * q1[2] - p1[2] * q1[1], - p1[2] * q1[0] - p1[0] * q1[2], - p1[0] * hq1 - hp1 * q1[0], - p1[1] * hq1 - hp1 * q1[1], - p1[2] * hq1 - hp1 * q1[2], - Hp1 * q1[0] - p1[0] * Hq1, - p1[1] * Hq1 - Hp1 * q1[1], - q1[0] * r1[1] - q1[1] * r1[0], - q1[1] * r1[2] - q1[2] * r1[1], - q1[2] * r1[0] - q1[0] * r1[2], - q1[0] * hr1 - hq1 * r1[0], - q1[1] * hr1 - hq1 * r1[1], - q1[2] * hr1 - hq1 * r1[2], - Hq1 * r1[0] - q1[0] * Hr1, - q1[1] * Hr1 - Hq1 * r1[1], - r1[0]*p1[1]-r1[1]*p1[0], - r1[1]*p1[2]-r1[2]*p1[1], - r1[2]*p1[0]-r1[0]*p1[2], - r1[0] * hp1 - hr1 * p1[0], - r1[1] * hp1 - hr1 * p1[1], - r1[2] * hp1 - hr1 * p1[2], - Hr1 * p1[0] - r1[0] * Hp1, - r1[1] * Hp1 - Hr1 * p1[1] - }; - - double c_vals[3 * 8]; - for(TriSegment seg = TransformedTriangle::PQ ; seg <= TransformedTriangle::RP ; seg = TriSegment(seg + 1)) { - - c_vals[seg*8 + 0] = tri1->calcUnstableC(seg, TransformedTriangle::C_XY); - c_vals[seg*8 + 1] = tri1->calcUnstableC(seg, TransformedTriangle::C_YZ); - c_vals[seg*8 + 2] = tri1->calcUnstableC(seg, TransformedTriangle::C_ZX); - c_vals[seg*8 + 3] = tri1->calcUnstableC(seg, TransformedTriangle::C_XH); - c_vals[seg*8 + 4] = tri1->calcUnstableC(seg, TransformedTriangle::C_YH); - c_vals[seg*8 + 5] = tri1->calcUnstableC(seg, TransformedTriangle::C_ZH); - c_vals[seg*8 + 6] = tri1->calcUnstableC(seg, TransformedTriangle::C_01); - c_vals[seg*8 + 7] = tri1->calcUnstableC(seg, TransformedTriangle::C_10); - - } - - for(int i = 0 ; i < 3*8 ; ++i) { - CPPUNIT_ASSERT_DOUBLES_EQUAL( correct_c_vals[i], c_vals[i], ERR_TOL ); - } - - - } - - /// Tests the calculation of triple products (without corrections) - /// \brief Status : pass - void TransformedTriangleTest::test_calcUnstableT() - { - typedef TransformedTriangle::TetraCorner TetraCorner; - - // correct values calculated by determinants (Grandy, [15]) - const double correct_t_vals[4] = - { - p1[0]*(q1[1]*r1[2] - q1[2]*r1[1]) - - q1[0]*(p1[1]*r1[2] - p1[2]*r1[1]) + - r1[0]*(p1[1]*q1[2] - p1[2]*q1[1]), - - -(hp1*(q1[1]*r1[2] - q1[2]*r1[1]) - - hq1*(p1[1]*r1[2] - p1[2]*r1[1]) + - hr1*(p1[1]*q1[2] - p1[2]*q1[1])), - - -(p1[0]*(hq1*r1[2] - q1[2]*hr1) - - q1[0]*(hp1*r1[2] - p1[2]*hr1) + - r1[0]*(hp1*q1[2] - p1[2]*hq1)), - - -(p1[0]*(q1[1]*hr1 - r1[1]*hq1) - - q1[0]*(p1[1]*hr1 - r1[1]*hp1) + - r1[0]*(p1[1]*hq1 - q1[1]*hp1)) - }; - - - // test that triple products are correctly calculated - for(TetraCorner corner = TransformedTriangle::O ; corner <= TransformedTriangle::Z ; corner = TetraCorner(corner + 1)) - { - - for(int row = 1 ; row < 4 ; ++row) - { - const double t = tri1->calcTByDevelopingRow(corner, row, false); - // std::cout << std::endl << " Corner = " << corner << " Row = " << row << " got: " << t << - // " expected: " << correct_t_vals[corner]<< std::endl; - CPPUNIT_ASSERT_DOUBLES_EQUAL(correct_t_vals[corner], t, ERR_TOL); - } - } - } - - /// Tests the consistency correction - /// \brief Status : fails because it is not significant - the consistency correction is not brought into play - void TransformedTriangleTest::test_calcStableC_Consistency() - { - - typedef TransformedTriangle::TriSegment TriSegment; - typedef TransformedTriangle::TetraCorner TetraCorner; - - // grandy, eq 14 - double correct_c_vals[24] = - { - p2[0] * q2[1] - p2[1] * q2[0], - p2[1] * q2[2] - p2[2] * q2[1], - p2[2] * q2[0] - p2[0] * q2[2], - p2[0] * hq2 - hp2 * q2[0], - p2[1] * hq2 - hp2 * q2[1], - p2[2] * hq2 - hp2 * q2[2], - Hp2 * q2[0] - p2[0] * Hq2, - p2[1] * Hq2 - Hp2 * q2[1], - q2[0] * r2[1] - q2[1] * r2[0], - q2[1] * r2[2] - q2[2] * r2[1], - q2[2] * r2[0] - q2[0] * r2[2], - q2[0] * hr2 - hq2 * r2[0], - q2[1] * hr2 - hq2 * r2[1], - q2[2] * hr2 - hq2 * r2[2], - Hq2 * r2[0] - q2[0] * Hr2, - q2[1] * Hr2 - Hq2 * r2[1], - r2[0]*p2[1]-r2[1]*p2[0], - r2[1]*p2[2]-r2[2]*p2[1], - r2[2]*p2[0]-r2[0]*p2[2], - r2[0] * hp2 - hr2 * p2[0], - r2[1] * hp2 - hr2 * p2[1], - r2[2] * hp2 - hr2 * p2[2], - Hr2 * p2[0] - r2[0] * Hp2, - r2[1] * Hp2 - Hr2 * p2[1] - }; - - - // number of inconsistent cases found : - // should be (at least) 1 for the test to be meaningful - int num_cases = 0; - - // find unstable products to check for consistency (Grandy [46]) - for(TriSegment seg = TransformedTriangle::PQ ; seg <= TransformedTriangle::RP ; seg = TriSegment(seg + 1)) - { - const double c_xy = tri2->calcUnstableC(seg, TransformedTriangle::C_XY); - const double c_yz = tri2->calcUnstableC(seg, TransformedTriangle::C_YZ); - const double c_zx = tri2->calcUnstableC(seg, TransformedTriangle::C_ZX); - const double c_xh = tri2->calcUnstableC(seg, TransformedTriangle::C_XH); - const double c_yh = tri2->calcUnstableC(seg, TransformedTriangle::C_YH); - const double c_zh = tri2->calcUnstableC(seg, TransformedTriangle::C_ZH); - - const int num_zero = (c_yz*c_xh == 0.0 ? 1 : 0) + (c_zx*c_yh == 0.0 ? 1 : 0) + (c_xy*c_zh == 0.0 ? 1 : 0); - const int num_neg = (c_yz*c_xh < 0.0 ? 1 : 0) + (c_zx*c_yh < 0.0 ? 1 : 0) + (c_xy*c_zh < 0.0 ? 1 : 0); - - if((num_zero == 1 && num_neg != 1) || num_zero == 2 || num_neg == 0 && num_zero !=3 || num_neg == 3 ) - { - ++num_cases; - - double min_dist = -1.0; // initialised first time through loop - TetraCorner min_corner = TransformedTriangle::O; - - for(TetraCorner corner = TransformedTriangle::O ; corner <= TransformedTriangle::Z ; corner = TetraCorner(corner + 1)) - { - // calculate distance from each corner of tetraeder to the segment - // 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 ptCorner[3] = { - corner == TransformedTriangle::X ? 1.0 : 0.0, - corner == TransformedTriangle::Y ? 1.0 : 0.0, - corner == TransformedTriangle::Z ? 1.0 : 0.0, - }; - - const double diff_21[3] = { ptQ[0] - ptP[0], ptQ[1] - ptP[1], ptQ[2] - ptP[2] }; - const double diff_1_corner[3] = { ptP[0] - ptCorner[0], ptP[1] - ptCorner[1], ptP[2] - ptCorner[2] }; - - const double cross[3] = { - diff_21[1]*diff_1_corner[2] - diff_21[2]*diff_1_corner[1], - diff_21[2]*diff_1_corner[0] - diff_21[0]*diff_1_corner[2], - diff_21[0]*diff_1_corner[1] - diff_21[1]*diff_1_corner[0] - }; - - const double cross_sq = cross[0]*cross[0] + cross[1]*cross[1] + cross[2]*cross[2]; - - const double norm_pq = diff_21[0]*diff_21[0] + diff_21[1]*diff_21[1] + diff_21[2]*diff_21[2]; - - if(corner == TransformedTriangle::O || (cross_sq / norm_pq) < min_dist) - { - min_dist = cross_sq / norm_pq; - min_corner = corner; - } - } - - // now check if the corresponding double products are zero - static const DoubleProduct DOUBLE_PRODUCTS[12] = - { - TransformedTriangle::C_YZ, TransformedTriangle::C_XY, TransformedTriangle::C_ZX, // O - TransformedTriangle::C_ZH, TransformedTriangle::C_YZ, TransformedTriangle::C_YH, // X - TransformedTriangle::C_ZH, TransformedTriangle::C_ZX, TransformedTriangle::C_XH, // Y - TransformedTriangle::C_XY, TransformedTriangle::C_YH, TransformedTriangle::C_XH // Z - }; - - 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; - CPPUNIT_ASSERT_EQUAL(0.0, tri2->calcStableC(seg, dp)); - correct_c_vals[8*seg + dp] = 0.0; - } - } - - } - - if(num_cases < 1) - { - CPPUNIT_FAIL("Consistency test not pertinent"); - } - - // std::cout << std::endl << "Number of geometric inconsistencies : " << num_cases << std::endl; - - // check that all other double products have right value too - double c_vals[8*3]; - - for(TriSegment seg = TransformedTriangle::PQ ; seg <= TransformedTriangle::RP ; seg = TriSegment(seg + 1)) { - - c_vals[seg*8 + 0] = tri2->calcStableC(seg, TransformedTriangle::C_XY); - c_vals[seg*8 + 1] = tri2->calcStableC(seg, TransformedTriangle::C_YZ); - c_vals[seg*8 + 2] = tri2->calcStableC(seg, TransformedTriangle::C_ZX); - c_vals[seg*8 + 3] = tri2->calcStableC(seg, TransformedTriangle::C_XH); - c_vals[seg*8 + 4] = tri2->calcStableC(seg, TransformedTriangle::C_YH); - c_vals[seg*8 + 5] = tri2->calcStableC(seg, TransformedTriangle::C_ZH); - c_vals[seg*8 + 6] = tri2->calcStableC(seg, TransformedTriangle::C_01); - c_vals[seg*8 + 7] = tri2->calcStableC(seg, TransformedTriangle::C_10); - - } - - for(int i = 0 ; i < 24 ; ++i) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(correct_c_vals[i], c_vals[i], ERR_TOL); - } - } - -} diff --git a/src/INTERP_KERNEL/Test/TransformedTriangleTest.hxx b/src/INTERP_KERNEL/Test/TransformedTriangleTest.hxx deleted file mode 100644 index c3ff65de7..000000000 --- a/src/INTERP_KERNEL/Test/TransformedTriangleTest.hxx +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __TU_TRANSFORMED_TRIANGLE_HXX__ -#define __TU_TRANSFORMED_TRIANGLE_HXX__ - -#include -#include "../TransformedTriangle.hxx" - -#define ERR_TOL 1.0e-8 - -using INTERP_KERNEL::TransformedTriangle; - -namespace INTERP_TEST -{ - - /** - * \brief Test suite testing some of the low level methods of TransformedTriangle. - * - */ - class TransformedTriangleTest : public CppUnit::TestFixture - { - - CPPUNIT_TEST_SUITE( TransformedTriangleTest ); - CPPUNIT_TEST( test_constructor ); - CPPUNIT_TEST( test_calcUnstableC ); - CPPUNIT_TEST( test_calcUnstableT ); - //removed because the test fails to enter the desired code branch - // CPPUNIT_TEST( test_calcStableC_Consistency ); - CPPUNIT_TEST_SUITE_END(); - - typedef INTERP_KERNEL::TransformedTriangle::TriSegment TriSegment; - typedef INTERP_KERNEL::TransformedTriangle::DoubleProduct DoubleProduct; - - public: - void setUp(); - - void tearDown(); - - // tests - void test_constructor(); - - void test_calcUnstableC(); - - void test_calcUnstableT(); - - void test_calcStableC_Consistency(); - - double p1[3], q1[3], r1[3]; - double hp1, hq1, hr1; - double Hp1, Hq1, Hr1; - - double p2[3], q2[3], r2[3]; - double hp2, hq2, hr2; - double Hp2, Hq2, Hr2; - - double stable_c2[24]; - - private: - TransformedTriangle* tri1; - TransformedTriangle* tri2; - - }; - - - - -} - - - -#endif diff --git a/src/INTERP_KERNEL/Test/UnitTetraIntersectionBaryTest.cxx b/src/INTERP_KERNEL/Test/UnitTetraIntersectionBaryTest.cxx deleted file mode 100644 index c92b25e5e..000000000 --- a/src/INTERP_KERNEL/Test/UnitTetraIntersectionBaryTest.cxx +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : UnitTetraIntersectionBaryTest.cxx -// Created : Thu Dec 11 15:54:41 2008 -// Author : Edward AGAPOV (eap) -#include "UnitTetraIntersectionBaryTest.hxx" - -#include "UnitTetraIntersectionBary.hxx" -#include "TetraAffineTransform.hxx" -#include "InterpolationUtils.hxx" - -#include - -using namespace INTERP_KERNEL; -using namespace std; - -namespace INTERP_TEST -{ - void fill_UnitTetraIntersectionBary(UnitTetraIntersectionBary& bary, double nodes[][3]) - { - int faceConn[4][3] = { { 0, 2, 1 }, - { 0, 1, 3 }, - { 1, 2, 3 }, - { 3, 2, 0 } }; - bary.init(); - for ( int i = 0; i < 4; ++i ) { - int* faceNodes = faceConn[ i ]; - TransformedTriangle tri(nodes[faceNodes[0]], nodes[faceNodes[1]], nodes[faceNodes[2]]); - tri.calculateIntersectionVolume(); - bary.addSide( tri ); - } - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_1() - { - // cutting tetra coincides with the unit one - double nodes[4][3] = { { 0.0, 0.0, 0.0 }, - { 1.0, 0.0, 0.0 }, - { 0.0, 1.0, 0.0 }, - { 0.0, 0.0, 1.0 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_2() - { - // cutting tetra fully include the unit one - double nodes[4][3] = { {-0.1,-0.1,-0.1 }, - { 1.5,-0.1,-0.1 }, - {-0.1, 1.5,-0.1 }, - {-0.1,-0.1, 1.5 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_3() - { - // cutting tetra is same as the unit one but moved up by 0.5 - double nodes[4][3] = { { 0.0, 0.0, 0.5 }, - { 1.0, 0.0, 0.5 }, - { 0.0, 1.0, 0.5 }, - { 0.0, 0.0, 1.5 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.020833333333333332, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.625, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_4() - { - // same as previous but no cutting sides lay on the sides of unit tetra - double nodes[4][3] = { {-0.2,-0.2, 0.5 }, - { 1.0, 0.0, 0.5 }, - { 0.0, 1.0, 0.5 }, - { 0.0, 0.0, 2.0 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.020833333333333332, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.625, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_5() - { - // cutting tetra is similar and parallel to the UT but moved (-0.1,-0.1,-0.1) - double nodes[4][3] = { {-0.1,-0.1,-0.1 }, - { 1.1,-0.1,-0.1 }, - {-0.1, 1.1,-0.1 }, - {-0.1,-0.1, 1.1 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1215, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.225, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.225, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.225, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_6() - { - // cutting tetra is deeped into the UT with one corner - double nodes[4][3] = { { 0.2, 0.2, 0.2 }, - { 1.0, 0.2, 0.2 }, - { 0.9, 1.0, 0.2 }, - { 0.9, 9.0, 1.0 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.000441855, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.353463 , baryCenter[0], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.33877 , baryCenter[1], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.207767 , baryCenter[2], 1e-5 ); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_7() - { - // cutting tetra passes through the UT with one corner - double nodes[4][3] = { {-0.2, 0.2, 0.2 }, - { 1.0, 0.2, 0.2 }, - { 0.9, 1.0, 0.2 }, - { 0.9, 0.9, 1.0 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0103501, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.215578 , baryCenter[0], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.341363 , baryCenter[1], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.263903 , baryCenter[2], 1e-5 ); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_8() - { - // cutting tetra passes through the UT with one edge - double nodes[4][3] = { { 0.5, 0.2, -0.2 }, // O - {-0.5,-0.2, -0.2 }, // OX - { 1.0,-0.5, -0.2 }, // OY - { 0.5, 0.2, 1.5 } };//OZ - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0349217, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.332275 , baryCenter[0], 1e-2 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0565892 , baryCenter[1], 1e-3 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.308713 , baryCenter[2], 1e-2 ); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_9() - { - // cutting tetra touches the UT at an edge, intersection volume == 0 - double nodes[4][3] = { { 1.0, 0.0, 0.0 }, // 0 - {-1.0, 2.0, 2.0 }, // OX - {-1.0,-2.0, 2.0 }, // OY - { 1.0, 0.0, 2.0 } };//OZ - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( !ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, vol, 1e-15); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -1. , baryCenter[0], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -1. , baryCenter[1], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -1. , baryCenter[2], 1e-5 ); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_10() - { - // cutting tetra fully includes theUT and touches it at an edge - double nodes[4][3] = { { 1.0, 0.0, 0.0 }, // 0 - {-1.0,-4.0, 2.0 }, // OX - {-1.0, 4.0, 2.0 }, // OY - { 1.0, 0.0,-2.0 } };//OZ - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_11() - { - // cutting tetra intersects the UT and touches it at an edge - double nodes[4][3] = { { 1.0, 0.0, 0.0 }, // 0 - {-1.0,-4.0, 2.0 }, // OX - {-1.0, 4.0, 2.0 }, // OY - {-1.0, 0.0,-1.0 } };//OZ - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.15873 , vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.250000, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.230952, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.260714, baryCenter[2], 1e-5); - } - - void UnitTetraIntersectionBaryTest::test_TetraAffineTransform_reverseApply() - { - double nodes[4][3] = { {-4.0, 9.0, 3.0 }, - {11.0, 0.0, 2.0 }, - { 0.0, 0.0, 0.0 }, - { 2.0, 1.0,10.0 }}; - // double pSrc[3] = { -4.0, 9.0, 3.0 }; - double pSrc[3] = { 40., -20., 100. }; - double pDest[] = {1,1,1}; - const double* n[4] = { &nodes[0][0], &nodes[1][0], &nodes[2][0], &nodes[3][0] }; - TetraAffineTransform a(&n[0]); - a.apply( pDest, pSrc ); - a.reverseApply( pDest, pDest ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( pSrc[0], pDest[0], 1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL( pSrc[1], pDest[1], 1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL( pSrc[2], pDest[2], 1e-12); - } - - void UnitTetraIntersectionBaryTest::test_barycentric_coords() - { - // compute barycentric coordinates - double nodes[4][3] = { {11.0, 0.0, 2.0 }, - {-4.0, 9.0, 3.0 }, - { 0.0, 0.0, 0.0 }, - { 6.0, 1.0,10.0 }}; - vector n (4); - n[0] = &nodes[0][0]; - n[1] = &nodes[1][0]; - n[2] = &nodes[2][0]; - n[3] = &nodes[3][0]; - double p [3] = { 2, 2, 5 }, bc[4]; - barycentric_coords(n, p, bc); - double bcSum = 0; - double p2 [3] = { 0,0,0 }; - for ( int i = 0; i < 4; ++i ) { - bcSum += bc[i]; - p2[0] += bc[i]*n[i][0]; - p2[1] += bc[i]*n[i][1]; - p2[2] += bc[i]*n[i][2]; - } - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., bcSum, 1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL( p[0], p2[0], 1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL( p[1], p2[1], 1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL( p[2], p2[2], 1e-12); - } -} diff --git a/src/INTERP_KERNEL/Test/UnitTetraIntersectionBaryTest.hxx b/src/INTERP_KERNEL/Test/UnitTetraIntersectionBaryTest.hxx deleted file mode 100644 index 26c1be3fd..000000000 --- a/src/INTERP_KERNEL/Test/UnitTetraIntersectionBaryTest.hxx +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : UnitTetraIntersectionBaryTests.hxx -// Created : Thu Nov 6 17:11:27 2008 -// Author : Edward AGAPOV (eap) -#ifndef __UNITTETRAINTERSECTIONBARYTEST_HXX__ -#define __UNITTETRAINTERSECTIONBARYTEST_HXX__ - -#include - -namespace INTERP_TEST -{ - /** - * \brief Test suite testing UnitTetraIntersectionBary class. - * - */ - class UnitTetraIntersectionBaryTest : public CppUnit::TestFixture - { - CPPUNIT_TEST_SUITE( UnitTetraIntersectionBaryTest ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_1 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_2 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_3 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_4 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_5 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_6 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_7 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_8 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_9 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_10 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_11 ); - CPPUNIT_TEST( test_TetraAffineTransform_reverseApply ); - CPPUNIT_TEST( test_barycentric_coords ); - CPPUNIT_TEST_SUITE_END(); - public: - void test_UnitTetraIntersectionBary_1(); - void test_UnitTetraIntersectionBary_2(); - void test_UnitTetraIntersectionBary_3(); - void test_UnitTetraIntersectionBary_4(); - void test_UnitTetraIntersectionBary_5(); - void test_UnitTetraIntersectionBary_6(); - void test_UnitTetraIntersectionBary_7(); - void test_UnitTetraIntersectionBary_8(); - void test_UnitTetraIntersectionBary_9(); - void test_UnitTetraIntersectionBary_10(); - void test_UnitTetraIntersectionBary_11(); - void test_TetraAffineTransform_reverseApply(); - void test_barycentric_coords(); - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Test/perf_test.sh b/src/INTERP_KERNEL/Test/perf_test.sh deleted file mode 100755 index 1a087b4a6..000000000 --- a/src/INTERP_KERNEL/Test/perf_test.sh +++ /dev/null @@ -1,165 +0,0 @@ -#!/bin/bash -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# should be run from the build directory, so that ./PerfTest is available -# output file -# -RES_FILE=perf_OPTIMIZE - -#outputs lines of form : -#"no. source elems no. target elems user time" -function test_pair { - echo -n $1 | sed 's/\(PerfCyl\)\([0-9]*\)/\2/' | sed 's/\(PerfBoxT\)\([0-9]*\)/\2/' | sed 's/\(PerfBox\)\([0-9]*\)/\2/' >> $RES_FILE - echo -n " " >> $RES_FILE - echo -n $2 | sed 's/\(PerfCyl\)\([0-9]*\)/\2/' | sed 's/\(PerfBoxT\)\([0-9]*\)/\2/' | sed 's/\(PerfBox\)\([0-9]*\)/\2/' >> $RES_FILE - echo -n " " >> $RES_FILE - time -o $RES_FILE --append -f"%U" ./PerfTest $1 $2 - echo -} - -function test_box_box { -echo PerfBox PerfBox >> $RES_FILE - -test_pair PerfBox1495 PerfBox1495 -test_pair PerfBox2506 PerfBox2506 -test_pair PerfBox5708 PerfBox5708 -test_pair PerfBox13461 PerfBox13461 -test_pair PerfBox30808 PerfBox30808 -test_pair PerfBox47176 PerfBox47176 - -test_pair PerfBox1495 PerfBox2506 -test_pair PerfBox1495 PerfBox5708 -test_pair PerfBox1495 PerfBox13461 -test_pair PerfBox1495 PerfBox30808 -test_pair PerfBox1495 PerfBox47176 - -test_pair PerfBox2506 PerfBox5708 -test_pair PerfBox2506 PerfBox13461 -test_pair PerfBox2506 PerfBox30808 -test_pair PerfBox2506 PerfBox47176 - -test_pair PerfBox5708 PerfBox13461 -test_pair PerfBox5708 PerfBox30808 -test_pair PerfBox5708 PerfBox47176 - -test_pair PerfBox13461 PerfBox30808 -test_pair PerfBox13461 PerfBox47176 - -test_pair PerfBox30808 PerfBox47176 - -} - -function test_cyl_cyl { -echo PerfCyl PerfCyl >> $RES_FILE - -test_pair PerfCyl1047 PerfCyl1047 -test_pair PerfCyl3020 PerfCyl3020 -test_pair PerfCyl6556 PerfCyl6556 -test_pair PerfCyl9766 PerfCyl9766 -test_pair PerfCyl25745 PerfCyl25745 -test_pair PerfCyl47601 PerfCyl47601 - -test_pair PerfCyl1047 PerfCyl3020 -test_pair PerfCyl1047 PerfCyl6556 -test_pair PerfCyl1047 PerfCyl9766 -test_pair PerfCyl1047 PerfCyl25745 -test_pair PerfCyl1047 PerfCyl47601 - -test_pair PerfCyl3020 PerfCyl6556 -test_pair PerfCyl3020 PerfCyl9766 -test_pair PerfCyl3020 PerfCyl25745 -test_pair PerfCyl3020 PerfCyl47601 - -test_pair PerfCyl6556 PerfCyl9766 -test_pair PerfCyl6556 PerfCyl25745 -test_pair PerfCyl6556 PerfCyl47601 - -test_pair PerfCyl9766 PerfCyl25745 -test_pair PerfCyl9766 PerfCyl47601 - -test_pair PerfCyl25745 PerfCyl47601 - -} - -function test_box_cyl { - echo PerfBox PerfCyl >> $RES_FILE - test_pair PerfBox1495 PerfCyl1047 - test_pair PerfBox1495 PerfCyl3020 - test_pair PerfBox1495 PerfCyl6556 - test_pair PerfBox1495 PerfCyl9766 - test_pair PerfBox1495 PerfCyl25745 - test_pair PerfBox1495 PerfCyl47601 - - test_pair PerfBox2506 PerfCyl1047 - test_pair PerfBox2506 PerfCyl3020 - test_pair PerfBox2506 PerfCyl6556 - test_pair PerfBox2506 PerfCyl9766 - test_pair PerfBox2506 PerfCyl25745 - test_pair PerfBox2506 PerfCyl47601 - - test_pair PerfBox5708 PerfCyl1047 - test_pair PerfBox5708 PerfCyl3020 - test_pair PerfBox5708 PerfCyl6556 - test_pair PerfBox5708 PerfCyl9766 - test_pair PerfBox5708 PerfCyl25745 - test_pair PerfBox5708 PerfCyl47601 - - test_pair PerfBox13461 PerfCyl1047 - test_pair PerfBox13461 PerfCyl3020 - test_pair PerfBox13461 PerfCyl6556 - test_pair PerfBox13461 PerfCyl9766 - test_pair PerfBox13461 PerfCyl25745 - test_pair PerfBox13461 PerfCyl47601 - - test_pair PerfBox30808 PerfCyl1047 - test_pair PerfBox30808 PerfCyl3020 - test_pair PerfBox30808 PerfCyl6556 - test_pair PerfBox30808 PerfCyl9766 - test_pair PerfBox30808 PerfCyl25745 - test_pair PerfBox30808 PerfCyl47601 - - test_pair PerfBox47176 PerfCyl1047 - test_pair PerfBox47176 PerfCyl3020 - test_pair PerfBox47176 PerfCyl6556 - test_pair PerfBox47176 PerfCyl9766 - test_pair PerfBox47176 PerfCyl25745 - test_pair PerfBox47176 PerfCyl47601 -} - -function test_box_transbox { - echo PerfBox PerfBoxT >> $RES_FILE - test_pair PerfBox1495 PerfBoxT1493 - test_pair PerfBox2506 PerfBoxT2676 - test_pair PerfBox5708 PerfBoxT5717 - test_pair PerfBox13461 PerfBoxT12469 - test_pair PerfBox30808 PerfBoxT29019 - test_pair PerfBox47176 PerfBoxT47278 -} - - - -#functions to execute : - -echo PerfTest execution on `date` > $RES_FILE -test_box_cyl -test_box_box -test_cyl_cyl -test_box_transbox - -cat $RES_FILE \ No newline at end of file diff --git a/src/INTERP_KERNELTest/BBTreeTest.cxx b/src/INTERP_KERNELTest/BBTreeTest.cxx new file mode 100644 index 000000000..85661913f --- /dev/null +++ b/src/INTERP_KERNELTest/BBTreeTest.cxx @@ -0,0 +1,84 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "BBTreeTest.hxx" +#include +#include +namespace INTERP_TEST +{ + + + void BBTreeTest::setUp() + { + } + + + void BBTreeTest::tearDown() + { + } + + /** + * Test that creates a tree in 2D and check that + * the results are correct in three + * cases : + * a non matching search + * a standard case + * a bbox overlapping the bboxes of the tree + */ + void BBTreeTest::test_BBTree() { + //bbox tree creation + const int N=10; + double* bbox=new double[4*N*N]; + for (int i=0; i tree(bbox,0,0,N*N); + std::vector elems; + + //box outside the tree + double bbox1[4]={-2.0, -1.0, 0.0, 1.0}; + tree.getIntersectingElems(bbox1,elems); + CPPUNIT_ASSERT_EQUAL(0,(int)elems.size()); + elems.clear(); + + //box intersecting 4 tree elems + double bbox2[4]={2.5, 3.5, 0.5, 1.5}; + tree.getIntersectingElems(bbox2,elems); + CPPUNIT_ASSERT_EQUAL(4,(int)elems.size()); + elems.clear(); + + //box exactly superimposed to two tree elems + double bbox3[4]={5.0,6.0,7.0,9.0}; + tree.getIntersectingElems(bbox3,elems); + CPPUNIT_ASSERT_EQUAL(2,(int)elems.size()); + elems.clear(); + + double xx[2]={1.0,1.0}; + tree.getElementsAroundPoint(xx,elems); + CPPUNIT_ASSERT_EQUAL(4,(int)elems.size()); + + delete[] bbox; + } + + +} diff --git a/src/INTERP_KERNELTest/BBTreeTest.hxx b/src/INTERP_KERNELTest/BBTreeTest.hxx new file mode 100644 index 000000000..8007e0ba8 --- /dev/null +++ b/src/INTERP_KERNELTest/BBTreeTest.hxx @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __TU_BB_TREE_HXX__ +#define __TU_BB_TREE_HXX__ + +#include +#include "../BBTree.txx" + +namespace INTERP_TEST +{ + + /** + * \brief Test suite testing some of the low level methods of TransformedTriangle. + * + */ + class BBTreeTest : public CppUnit::TestFixture + { + + CPPUNIT_TEST_SUITE( BBTreeTest ); + CPPUNIT_TEST( test_BBTree ); + CPPUNIT_TEST_SUITE_END(); + + + public: + void setUp(); + + void tearDown(); + + // tests + void test_BBTree(); + + }; + + + + +} + + + +#endif diff --git a/src/INTERP_KERNELTest/BasicMainTest.hxx b/src/INTERP_KERNELTest/BasicMainTest.hxx new file mode 100644 index 000000000..8220e33a0 --- /dev/null +++ b/src/INTERP_KERNELTest/BasicMainTest.hxx @@ -0,0 +1,87 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef _BASICMAINTEST_HXX_ +#define _BASICMAINTEST_HXX_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +// ============================================================================ +/*! + * Main program source for Unit Tests with cppunit package does not depend + * on actual tests, so we use the same for all partial unit tests. + */ +// ============================================================================ + +int main(int argc, char* argv[]) +{ + // --- Create the event manager and test controller + CPPUNIT_NS::TestResult controller; + + // --- Add a listener that colllects test result + CPPUNIT_NS::TestResultCollector result; + controller.addListener( &result ); + + // --- Add a listener that print dots as test run. +#ifdef WIN32 + CPPUNIT_NS::TextTestProgressListener progress; +#else + CPPUNIT_NS::BriefTestProgressListener progress; +#endif + controller.addListener( &progress ); + + // --- Get the top level suite from the registry + + CPPUNIT_NS::Test *suite = + CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); + + // --- Adds the test to the list of test to run + + CPPUNIT_NS::TestRunner runner; + runner.addTest( suite ); + runner.run( controller); + + // --- Print test in a compiler compatible format. + + std::ofstream testFile; + testFile.open("UnitTestsResult", std::ios::out | std::ios::trunc); + //CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr ); + CPPUNIT_NS::CompilerOutputter outputter( &result, testFile ); + outputter.write(); + + // --- Run the tests. + + bool wasSucessful = result.wasSuccessful(); + testFile.close(); + + // --- Return error code 1 if the one of test failed. + + return wasSucessful ? 0 : 1; +} + +#endif diff --git a/src/INTERP_KERNELTest/CppUnitTest.cxx b/src/INTERP_KERNELTest/CppUnitTest.cxx new file mode 100644 index 000000000..cb37e28cf --- /dev/null +++ b/src/INTERP_KERNELTest/CppUnitTest.cxx @@ -0,0 +1,19 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "CppUnitTest.hxx" diff --git a/src/INTERP_KERNELTest/CppUnitTest.hxx b/src/INTERP_KERNELTest/CppUnitTest.hxx new file mode 100644 index 000000000..6ebb88e5b --- /dev/null +++ b/src/INTERP_KERNELTest/CppUnitTest.hxx @@ -0,0 +1,84 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __TU_TEST_CPPUNIT_HXX__ +#define __TU_TEST_CPPUNIT_HXX__ + +#include + +/** + * \brief Class tested by TestBogusClass : not very useful + */ +class BogusClass { + friend class TestBogusClass; + +public: + BogusClass(double _x) : x(_x) {;} + + double getX() { return x; } + +private: + double x; +}; + +/** + * \brief Class used to figure out CppUnit : not very useful + * + */ +class TestBogusClass : public CppUnit::TestFixture +{ + + CPPUNIT_TEST_SUITE( TestBogusClass ); + CPPUNIT_TEST( test1 ); + CPPUNIT_TEST( test2 ); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() { + obj = new BogusClass(3.14); + } + + void tearDown() { + delete obj; + } + + void test1() { + // test something + CPPUNIT_ASSERT(obj->x == 3.14); + CPPUNIT_ASSERT(obj->getX() == obj->x); + } + + void test2() { + // test something else + obj->x += 2.6; + CPPUNIT_ASSERT(obj->getX() > 3.14); + } + +private: + BogusClass* obj; + +}; + + + + + + + + +#endif diff --git a/src/INTERP_KERNELTest/HexaTests.hxx b/src/INTERP_KERNELTest/HexaTests.hxx new file mode 100644 index 000000000..a7f0adf1e --- /dev/null +++ b/src/INTERP_KERNELTest/HexaTests.hxx @@ -0,0 +1,75 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __HEXA_TESTS_HXX_ +#define __HEXA_TESTS_HXX_ + +#include "InterpolationTestSuite.hxx" + +namespace INTERP_TEST +{ + /** + * \brief Class performing intersection tests on meshes with hexahedral elements. + * + */ + class HexaTests : public InterpolationTestSuite<3,3> + { + CPPUNIT_TEST_SUITE( HexaTests ); + + CPPUNIT_TEST( simpleHexaBox ); + //VB : slightly inaccurate so that it triggers a failure of the test + // should be investigated in the future + // CPPUNIT_TEST( reflexiveHexaBox ); + CPPUNIT_TEST( hexaBoxes ); + CPPUNIT_TEST( hexaBoxesMoved ); + + CPPUNIT_TEST_SUITE_END(); + + public: + + /// Intersection between two boxes, aligned with the axes.One has 60 hexahedral elements and the other has 39 tetrahedral elements + /// \brief Status : pass + void simpleHexaBox() + { + _testTools->intersectMeshes("BoxHexa1", "BoxTetra2", 65250, 1.0e-5); + } + + /// Intersection of a box with 60 hexahedral elements with itself + /// \brief Status : pass + void reflexiveHexaBox() + { + _testTools->intersectMeshes("BoxHexa1", "BoxHexa1", 204000); + } + + /// Intersection between two boxes, aligned with the axes.Both have hexahedral elements : one 36, the other 60 + /// \brief Status : pass + void hexaBoxes() + { + _testTools->intersectMeshes("BoxHexa1", "BoxHexa2", 65250); + } + + /// Intersection between two boxes in general position with hexahedral elements. One has 200 elements and the other 420. + /// \brief Status : fails - reason unknown. The matrix does not fulfil the transpose requirement : that W_AB = W_BA^T + void hexaBoxesMoved() + { + _testTools->intersectMeshes("MovedHexaBox1", "MovedHexaBox2", 65250); + } + + }; +} +#endif diff --git a/src/INTERP_KERNELTest/Interpolation3DTest.cxx b/src/INTERP_KERNELTest/Interpolation3DTest.cxx new file mode 100644 index 000000000..a538c6fdb --- /dev/null +++ b/src/INTERP_KERNELTest/Interpolation3DTest.cxx @@ -0,0 +1,348 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "Interpolation3DTest.hxx" +#include "MEDMEM_Mesh.hxx" + +#include +#include +#include +#include +#include + +#include "VectorUtils.hxx" + +#include "MEDMEM_Field.hxx" +#include "MEDMEM_Support.hxx" + +// levels : +// 1 - titles and volume results +// 2 - symmetry / diagonal results and intersection matrix output +// 3 - empty +// 4 - empty +// 5 - misc +#include "Log.hxx" + + +//#define VOL_PREC 1.0e-6 + +using namespace MEDMEM; +using namespace std; +using namespace INTERP_KERNEL; +using namespace MED_EN; + +double Interpolation3DTest::sumRow(const IntersectionMatrix& m, int i) const +{ + double vol = 0.0; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + if(iter->count(i) != 0.0) + { + map::const_iterator iter2 = iter->find(i); + vol += iter2->second; + } + } + return vol; +} + +double Interpolation3DTest::sumCol(const IntersectionMatrix& m, int i) const +{ + double vol = 0.0; + const std::map& col = m[i]; + for(map::const_iterator iter = col.begin() ; iter != col.end() ; ++iter) + { + vol += std::fabs(iter->second); + } + return vol; +} + + +void Interpolation3DTest::getVolumes(MESH& mesh, double* tab) const +{ + SUPPORT *sup=new SUPPORT(&mesh,"dummy",MED_CELL); + FIELD* f=mesh.getVolume(sup); + const double *tabS=f->getValue(); + std::copy(tabS,tabS+mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS),tab) + delete sup; +} + +double Interpolation3DTest::sumVolume(const IntersectionMatrix& m) const +{ + + vector volumes; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + volumes.push_back(iter2->second); + // vol += std::abs(iter2->second); + } + } + + // sum in ascending order to avoid rounding errors + + sort(volumes.begin(), volumes.end()); + const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); + + return vol; +} + +bool Interpolation3DTest::testVolumes(const IntersectionMatrix& m, MESH& sMesh, MESH& tMesh) const +{ + bool ok = true; + + // source elements + double* sVol = new double[sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)]; + getVolumes(sMesh, sVol); + + for(int i = 0; i < sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); ++i) + { + const double sum_row = sumRow(m, i+1); + if(!epsilonEqualRelative(sum_row, sVol[i], VOL_PREC)) + { + LOG(1, "Source volume inconsistent : vol of cell " << i << " = " << sVol[i] << " but the row sum is " << sum_row ); + ok = false; + } + LOG(1, "diff = " <::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) + // { + map theMap = m2.at(j-1); + const double v2 = theMap[i + 1]; + if(v1 != v2) + { + LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 ); + if(!epsilonEqualRelative(v1, v2, VOL_PREC)) + { + LOG(2, "(" << i << ", " << j << ") fails"); + isSymmetric = false; + } + } + } + ++i; + } + if(!isSymmetric) + { + LOG(1, "*** matrices are not symmetric"); + } + return isSymmetric; +} + +bool Interpolation3DTest::testDiagonal(const IntersectionMatrix& m) const +{ + LOG(1, "Checking if matrix is diagonal" ); + int i = 1; + bool isDiagonal = true; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + int j = iter2->first; + const double vol = iter2->second; + if(vol != 0.0 && (i != j)) + { + LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" ); + if(!epsilonEqual(vol, 0.0, VOL_PREC)) + { + LOG(2, "(" << i << ", " << j << ") fails"); + isDiagonal = false; + } + } + } + ++i; + } + if(!isDiagonal) + { + LOG(1, "*** matrix is not diagonal"); + } + return isDiagonal; +} + +void Interpolation3DTest::dumpIntersectionMatrix(const IntersectionMatrix& m) const +{ + int i = 0; + std::cout << "Intersection matrix is " << endl; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + + std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << endl; + + } + ++i; + } + std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; +} + +void Interpolation3DTest::setUp() +{ + interpolator = new Interpolation3D(); +} + +void Interpolation3DTest::tearDown() +{ + delete interpolator; +} + +void Interpolation3DTest::calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const +{ + const string dataBaseDir = getenv("MED_ROOT_DIR"); + const string dataDir = dataBaseDir + "/share/salome/resources/med/"; + + LOG(1, std::endl << "=== -> intersecting src = " << mesh1 << ", target = " << mesh2 ); + + LOG(5, "Loading " << mesh1 << " from " << mesh1path); + MESH sMesh(MED_DRIVER, dataDir+mesh1path, mesh1); + + LOG(5, "Loading " << mesh2 << " from " << mesh2path); + MESH tMesh(MED_DRIVER, dataDir+mesh2path, mesh2); + + m = interpolator->interpolateMeshes(sMesh, tMesh); + + // if reflexive, check volumes + if(strcmp(mesh1path,mesh2path) == 0) + { + const bool row_and_col_sums_ok = testVolumes(m, sMesh, tMesh); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Row or column sums incorrect", true, row_and_col_sums_ok); + } + + LOG(1, "Intersection calculation done. " << std::endl ); + +} + +void Interpolation3DTest::intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const +{ + LOG(1, std::endl << std::endl << "=============================" ); + + using std::string; + const string path1 = string(mesh1path) + string(mesh1); + const string path2 = string(mesh2path) + string(mesh2); + + const bool isTestReflexive = (path1.compare(path2) == 0); + + IntersectionMatrix matrix1; + calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1); + +#if LOG_LEVEL >= 2 + dumpIntersectionMatrix(matrix1); +#endif + + std::cout.precision(16); + + const double vol1 = sumVolume(matrix1); + + if(!doubleTest) + { + LOG(1, "vol = " << vol1 <<" correctVol = " << correctVol ); + CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(correctVol, vol1)); + + if(isTestReflexive) + { + CPPUNIT_ASSERT_EQUAL_MESSAGE("Reflexive test failed", true, testDiagonal(matrix1)); + } + } + else + { + + IntersectionMatrix matrix2; + calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2); + +#if LOG_LEVEL >= 2 + dumpIntersectionMatrix(matrix2); +#endif + + const double vol2 = sumVolume(matrix2); + + LOG(1, "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol ); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(vol1, correctVol)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec * std::max(vol2, correctVol)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, prec * std::max(vol1, vol2)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Symmetry test failed", true, testSymmetric(matrix1, matrix2)); + } + +} + + + diff --git a/src/INTERP_KERNELTest/Interpolation3DTest.hxx b/src/INTERP_KERNELTest/Interpolation3DTest.hxx new file mode 100644 index 000000000..77984859e --- /dev/null +++ b/src/INTERP_KERNELTest/Interpolation3DTest.hxx @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __TU_INTERPOLATION_3D_TEST_HXX__ +#define __TU_INTERPOLATION_3D_TEST_HXX__ + +#include +#include "../Interpolation3D.hxx" + +#define ERR_TOL 1.0e-8 + +using MEDMEM::Interpolation3D; +class MEDMEM::MESH; + +/// \brief OBSOLETE - renamed Interpolation3DTestSuite +class Interpolation3DTest : public CppUnit::TestFixture +{ + +public: + void setUp() + { + _testTools = new MeshTestToolkit(); + } + + void tearDown() + { + delete _testTools; + } + +protected: + + MeshToolkit* _testTools; + +}; + +#endif diff --git a/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx b/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx new file mode 100644 index 000000000..6bafcb137 --- /dev/null +++ b/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx @@ -0,0 +1,79 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "InterpolationOptionsTest.hxx" +#include "MEDNormalizedUnstructuredMesh.hxx" +#include "Interpolation2D.hxx" +#include +#include + +namespace INTERP_TEST +{ + + + void InterpolationOptionsTest::setUp() + { + } + + + void InterpolationOptionsTest::tearDown() + { + } + + /** + * Test that creates a tree in 2D and check that + * the results are correct in three + * cases : + * a non matching search + * a standard case + * a bbox overlapping the bboxes of the tree + */ + void InterpolationOptionsTest::test_InterpolationOptions() { + string sourcename=getenv("MED_ROOT_DIR"); + sourcename +="/share/salome/resources/med/square1.med"; + MEDMEM::MESH source_mesh (MED_DRIVER,sourcename,"Mesh_2"); + + string targetname=getenv("MED_ROOT_DIR"); + targetname +="/share/salome/resources/med/square2.med"; + MEDMEM::MESH target_mesh (MED_DRIVER,targetname,"Mesh_3"); + + MEDMEM::SUPPORT source_support(&source_mesh,"on All support"); + MEDMEM::FIELD source_field(&source_support,1); + double* value=const_cast(source_field.getValue()); + for (int i=0; i target_field(&target_support,1); + double* targetvalue=const_cast(target_field.getValue()); + for (int i=0; i wrap_source_mesh(&source_mesh); + MEDNormalizedUnstructuredMesh<2,2> wrap_target_mesh(&target_mesh); + // Go for interpolation... + INTERP_KERNEL::Interpolation2D myInterpolator; + //optionnal call to parametrize your interpolation. First precision, tracelevel, intersector wanted. + myInterpolator.setPrecision(1e-7); + myInterpolator.setPrintLevel(1); + } + + +} diff --git a/src/INTERP_KERNELTest/InterpolationOptionsTest.hxx b/src/INTERP_KERNELTest/InterpolationOptionsTest.hxx new file mode 100644 index 000000000..1507f81e1 --- /dev/null +++ b/src/INTERP_KERNELTest/InterpolationOptionsTest.hxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __TU_INTERPOLATIONOPTIONS_HXX__ +#define __TU_INTERPOLATIONOPTIONS_HXX__ + +#include +#include "../InterpolationOptions.hxx" +#include "MEDMEM_Field.hxx" + +namespace INTERP_TEST +{ + + /** + * \brief Test suite testing some of the low level methods of TransformedTriangle. + * + */ + class InterpolationOptionsTest : public CppUnit::TestFixture + { + + CPPUNIT_TEST_SUITE( InterpolationOptionsTest ); + CPPUNIT_TEST( test_InterpolationOptions ); + CPPUNIT_TEST_SUITE_END(); + + + public: + void setUp(); + + void tearDown(); + + // tests + void test_InterpolationOptions(); + + private: + + }; + + + + +} + + + +#endif diff --git a/src/INTERP_KERNELTest/InterpolationPlanarTestSuite.hxx b/src/INTERP_KERNELTest/InterpolationPlanarTestSuite.hxx new file mode 100644 index 000000000..729061e46 --- /dev/null +++ b/src/INTERP_KERNELTest/InterpolationPlanarTestSuite.hxx @@ -0,0 +1,128 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __TU_INTERPOLATION_PLANAR_TEST_SUITE_HXX__ +#define __TU_INTERPOLATION_PLANAR_TEST_SUITE_HXX__ + +#include +#include +#include +#include + +using namespace std; + +namespace INTERP_TEST +{ + + /** + * \brief Base class for planar mesh intersection test suites. + * + */ + class InterpolationPlanarTestSuite : public CppUnit::TestFixture + { + + public: + double _Epsilon; + double _Precision; + + /** + * Sets up the test suite. + * + */ + void setUp() + { + _Epsilon = 1.e-6; + _Precision = 1.e-6; + } + void tearDown() {} + + // bool checkDequesEqual(std::deque< double > deque1, std::deque< double > deque2, double epsilon); + // bool checkVectorsEqual(std::vector< double > Vect1, std::vector< double > Vect2, double epsilon); + // void dequePrintOut(std::deque< double > deque1); + // void vectPrintOut(std::vector< double > vect); + // void tabPrintOut( const double * tab, int size); + + bool checkDequesEqual(std::deque< double > deque1, + std::deque< double > deque2, double epsilon) + { + int size1 = deque1.size(); + int size2 = deque2.size(); + bool are_equal = size1 == size2; + + if(are_equal) + for(int i = 0; i < size1 && are_equal; i++) + are_equal = fabs(deque1[i] - deque2[i]) < epsilon; + + return are_equal; + } + bool checkVectorsEqual(std::vector< double > vect1, + std::vector< double > vect2, double epsilon) + { + int size1 = vect1.size(); + int size2 = vect2.size(); + bool are_equal = size1 == size2; + + if(are_equal) + for(int i = 0; i < size1 && are_equal; i++) + are_equal = fabs(vect1[i] - vect2[i]) < epsilon; + + return are_equal; + } + void dequePrintOut(std::deque< double > deque1) + { + for(int i = 0; i< (int)deque1.size(); i++) + { + std::cerr << deque1[i] << " "; + } + std::cerr<< endl; + } + void vectPrintOut(std::vector< double > vect) + { + for(int i = 0; i< (int)vect.size(); i++) + { + std::cerr << vect[i] << " "; + } + std::cerr<< endl; + } + void tabPrintOut( const double * tab,int size) + { + for(int i = 0; i< size; i++) + { + std::cerr << tab[i] << " "; + } + std::cerr<< endl; + } + + /** + * Cleans up after the test suite. + * Liberates the MeshTestToolkit object used by the tests. + */ + // void tearDown() + // { + // delete _testTools; + // } + + + + // protected: + // /// MeshTestToolkit object to which the tests are delegated + // MeshTestToolkit* _testTools; + + }; +} +#endif diff --git a/src/INTERP_KERNELTest/InterpolationTestSuite.hxx b/src/INTERP_KERNELTest/InterpolationTestSuite.hxx new file mode 100644 index 000000000..a1151c754 --- /dev/null +++ b/src/INTERP_KERNELTest/InterpolationTestSuite.hxx @@ -0,0 +1,65 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __TU_INTERPOLATION_TEST_SUITE_HXX__ +#define __TU_INTERPOLATION_TEST_SUITE_HXX__ + +#include "MeshTestToolkit.txx" + +#include + +namespace INTERP_TEST +{ + + /** + * \brief Base class for mesh intersection test suites. + * + */ + template + class InterpolationTestSuite : public CppUnit::TestFixture + { + + public: + /** + * Sets up the test suite. + * Creates the MeshTestToolkit object used by the tests. + * + */ + void setUp() + { + _testTools = new MeshTestToolkit(); + } + + /** + * Cleans up after the test suite. + * Liberates the MeshTestToolkit object used by the tests. + */ + void tearDown() + { + delete _testTools; + } + + + + protected: + /// MeshTestToolkit object to which the tests are delegated + MeshTestToolkit* _testTools; + + }; +} +#endif diff --git a/src/INTERP_KERNELTest/MEDMeshMaker.cxx b/src/INTERP_KERNELTest/MEDMeshMaker.cxx new file mode 100644 index 000000000..18fd7e873 --- /dev/null +++ b/src/INTERP_KERNELTest/MEDMeshMaker.cxx @@ -0,0 +1,100 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_Meshing.hxx" + +MEDMEM::MESH* MEDMeshMaker(int dim, int nbedge, MED_EN::medGeometryElement type) +{ + MEDMEM::MESHING* mesh=new MEDMEM::MESHING(); + mesh->setSpaceDimension(dim); + int nbnodes; + int nbelems; + switch (dim) + { + case 2: + nbnodes=(nbedge+1)*(nbedge+1); + if(type==MED_EN::MED_QUAD4) + nbelems=(nbedge*nbedge); + else + throw MEDMEM::MEDEXCEPTION("MEDMeshMaker: type not impletmented"); + break; + case 3: + nbnodes=(nbedge+1)*(nbedge+1)*(nbedge+1); + if (type==MED_EN::MED_HEXA8) + nbelems= nbedge*nbedge*nbedge; + else + throw MEDMEM::MEDEXCEPTION("MEDMeshMaker: type not impletmented"); + break; + } + double* coords = new double[dim*nbnodes]; + int nz; + if (dim==2) nz =1; else nz=nbedge+1; + { + for (int ix=0; ix < nbedge+1; ix++) + for (int iy=0; iysetCoordinates(dim, nbnodes,coords,"CARTESIAN",MED_EN::MED_FULL_INTERLACE); + delete [] coords; + mesh->setNumberOfTypes(1,MED_EN::MED_CELL); + mesh->setTypes(&type,MED_EN::MED_CELL); + mesh->setNumberOfElements(&nbelems,MED_EN::MED_CELL); + + int* conn = new int [nbelems*(type%100)]; + if (dim==2) + { + for (int ix=0; ixsetConnectivity(conn, MED_EN::MED_CELL,type); + delete [] conn; + mesh->setMeshDimension(dim); + return mesh; +} diff --git a/src/INTERP_KERNELTest/MEDMeshMaker.hxx b/src/INTERP_KERNELTest/MEDMeshMaker.hxx new file mode 100644 index 000000000..d06aefd10 --- /dev/null +++ b/src/INTERP_KERNELTest/MEDMeshMaker.hxx @@ -0,0 +1,25 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "MEDMEM_define.hxx" +namespace MEDMEM +{ + class MESH; +} + +MEDMEM::MESH* MEDMeshMaker(int dim, int nbedge, MED_EN::medGeometryElement type); diff --git a/src/INTERP_KERNELTest/Makefile.am b/src/INTERP_KERNELTest/Makefile.am new file mode 100644 index 000000000..2d4c50b33 --- /dev/null +++ b/src/INTERP_KERNELTest/Makefile.am @@ -0,0 +1,102 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +lib_LTLIBRARIES = libInterpKernelTest.la + +salomeinclude_HEADERS = CppUnitTest.hxx \ + TransformedTriangleTest.hxx \ + TransformedTriangleIntersectTest.hxx \ + InterpolationTestSuite.hxx \ + SingleElementTetraTests.hxx \ + MultiElementTetraTests.hxx \ + HexaTests.hxx \ + MeshTestToolkit.hxx \ + MeshTestToolkit.txx \ + BBTreeTest.hxx \ + RemapperTest.hxx \ + SingleElementPlanarTests.hxx \ + MultiElement2DTests.hxx \ + InterpolationPlanarTestSuite.hxx \ + UnitTetraIntersectionBaryTest.hxx \ + PointLocatorTest.hxx \ + MEDMeshMaker.hxx \ + QuadraticPlanarInterpTest.hxx + +EXTRA_DIST += \ + BasicMainTest.hxx \ + Interpolation3DTest.cxx \ + Interpolation3DTest.hxx \ + MultiElement3DSurfTests.hxx \ + TestingUtils.hxx \ + perf_test.sh + +CLEANFILES = \ + UnitTestsResult + +dist_libInterpKernelTest_la_SOURCES= \ + CppUnitTest.cxx \ + TransformedTriangleTest.cxx \ + UnitTetraIntersectionBaryTest.cxx \ + TransformedTriangleIntersectTest.cxx \ + BBTreeTest.cxx \ + RemapperTest.cxx \ + SingleElementPlanarTests.cxx \ + PointLocatorTest.cxx \ + MEDMeshMaker.cxx \ + InterpolationOptionsTest.hxx \ + InterpolationOptionsTest.cxx \ + QuadraticPlanarInterpTest.cxx \ + QuadraticPlanarInterpTest2.cxx \ + QuadraticPlanarInterpTest3.cxx \ + QuadraticPlanarInterpTest4.cxx \ + QuadraticPlanarInterpTest5.cxx + +libInterpKernelTest_la_CPPFLAGS = @CPPUNIT_INCLUDES@ $(MED2_INCLUDES) $(HDF5_INCLUDES) \ + -I$(srcdir)/.. -I$(srcdir)/../MEDWrapper/V2_1/Core -I$(srcdir)/../MEDMEM \ + -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Geometric2D \ + -I$(srcdir)/../INTERP_KERNEL/Bases -DOPTIMIZE -DLOG_LEVEL=0 + +libInterpKernelTest_la_LDFLAGS = @CPPUNIT_LIBS@ ../MEDWrapper/V2_1/Core/libmed_V2_1.la \ + ../INTERP_KERNEL/libinterpkernel.la ../INTERP_KERNEL/Geometric2D/libInterpGeometric2DAlg.la \ + ../MEDMEM/libmedmem.la -lm + +if MED_ENABLE_KERNEL + libInterpKernelTest_la_CPPFLAGS += ${KERNEL_CXXFLAGS} + libInterpKernelTest_la_LDFLAGS += ${KERNEL_LDFLAGS} -lSALOMELocalTrace +endif + +# Executables targets +bin_PROGRAMS = TestINTERP_KERNEL \ + PerfTest + +dist_TestINTERP_KERNEL_SOURCES = TestInterpKernel.cxx +dist_PerfTest_SOURCES = PerfTest.cxx + +LDADD = $(MED2_LIBS) $(libInterpKernelTest_la_LDFLAGS) \ + libInterpKernelTest.la +if MED_ENABLE_KERNEL + LDADD += -lSALOMEBasics +endif +AM_CPPFLAGS = $(libInterpKernelTest_la_CPPFLAGS) + +UNIT_TEST_PROG = TestInterpKernel + +check : tests \ No newline at end of file diff --git a/src/INTERP_KERNELTest/MeshTestToolkit.hxx b/src/INTERP_KERNELTest/MeshTestToolkit.hxx new file mode 100644 index 000000000..5f6b54a4d --- /dev/null +++ b/src/INTERP_KERNELTest/MeshTestToolkit.hxx @@ -0,0 +1,88 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __TU_MESH_TEST_TOOLKIT_HXX__ +#define __TU_MESH_TEST_TOOLKIT_HXX__ + +#include "../Interpolation3D.hxx" +#include "../Interpolation3D.txx" +#include "../InterpolationPlanar.hxx" + +#include +#include + +#define ERR_TOL 1.0e-8 + +typedef std::vector > IntersectionMatrix; + +namespace INTERP_KERNEL +{ + class Interpolation3D; +} + + +namespace MEDMEM { + class MESH; +}; + +namespace INTERP_TEST +{ + /** + * \brief Class providing services for mesh intersection tests. + * + */ + template + class MeshTestToolkit + { + + public: + double _precision; + INTERP_KERNEL::IntersectionType _intersectionType;//Used only in the case MESHDIM==2 (planar intersections) + + MeshTestToolkit():_precision(1.e-6),_intersectionType(INTERP_KERNEL::Triangulation) {} + + ~MeshTestToolkit() {} + + void intersectMeshes(const char* mesh1, const char* mesh2, const double correctVol, const double prec = 1.0e-5, bool doubleTest = true) 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 dumpIntersectionMatrix(const IntersectionMatrix& m) const; + + double sumRow(const IntersectionMatrix& m, int i) const; + + double sumCol(const IntersectionMatrix& m, int i) const; + + void getVolumes( MEDMEM::MESH& mesh, 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 testTranspose(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const; + + bool testDiagonal(const IntersectionMatrix& m) const; + + void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const; + + }; +} +#endif diff --git a/src/INTERP_KERNELTest/MeshTestToolkit.txx b/src/INTERP_KERNELTest/MeshTestToolkit.txx new file mode 100644 index 000000000..84bb2df8e --- /dev/null +++ b/src/INTERP_KERNELTest/MeshTestToolkit.txx @@ -0,0 +1,509 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "MEDNormalizedUnstructuredMesh.hxx" +#include "MEDNormalizedUnstructuredMesh.txx" + +#include "MeshTestToolkit.hxx" +#include "MEDMEM_Mesh.hxx" + +#include "Interpolation3DSurf.txx" +#include "Interpolation2D.txx" +#include "Interpolation3D.txx" + +#include +#include +#include +#include +#include + +//#include "VectorUtils.hxx" + +#include "MEDMEM_Field.hxx" +#include "MEDMEM_Support.hxx" + +// levels : +// 1 - titles and volume results +// 2 - symmetry / diagonal results and intersection matrix output +// 3 - empty +// 4 - empty +// 5 - misc +#include "Log.hxx" + +#include + +//#define VOL_PREC 1.0e-6 + +using namespace MEDMEM; +using namespace std; +using namespace MED_EN; +using namespace INTERP_KERNEL; + +namespace INTERP_TEST +{ + + /** + * Calculates the sum of a row of an intersection matrix + * + * @param m an intersection matrix + * @param i the index of the row (1 <= i <= no. rows) + * @return the sum of the values of row i + * + */ + template + double MeshTestToolkit::sumRow(const IntersectionMatrix& m, int i) const + { + double vol = 0.0; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + if(iter->count(i) != 0.0) + { + map::const_iterator iter2 = iter->find(i); + vol += fabs(iter2->second); + } + } + return vol; + } + + /** + * Calculates the sum of a column of an intersection matrix + * + * @param m an intersection matrix + * @param i the index of the column (0 <= i <= no. rows - 1) + * @return the sum of the values of column i + * + */ + template + double MeshTestToolkit::sumCol(const IntersectionMatrix& m, int i) const + { + double vol = 0.0; + const std::map& col = m[i]; + for(map::const_iterator iter = col.begin() ; iter != col.end() ; ++iter) + { + vol += fabs(iter->second); + } + return vol; + } + + /** + * Gets the volumes of the elements in a mesh. + * + * @param mesh the mesh + * @param tab pointer to double[no. elements of mesh] array in which to store the volumes + */ + template + void MeshTestToolkit::getVolumes(MEDMEM::MESH& mesh, double* tab) const + { + SUPPORT *sup=new SUPPORT(&mesh,"dummy",MED_CELL); + FIELD* f; + switch (MESHDIM) + { + case 2: + f=mesh.getArea(sup); + break; + case 3: + f=mesh.getVolume(sup); + break; + } + const double *tabS = f->getValue(); + std::copy(tabS,tabS+mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS),tab); + delete sup; + delete f; + } + + /** + * Sums all the elements (volumes) of an intersection matrix + * + * @param m the intersection matrix + * @return the sum of the elements of m + */ + + template + double MeshTestToolkit::sumVolume(const IntersectionMatrix& m) const + { + + vector volumes; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + volumes.push_back(fabs(iter2->second)); + } + } + + // sum in ascending order to avoid rounding errors + + sort(volumes.begin(), volumes.end()); + const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); + + return vol; + } + + /** + * Verifies if for a given intersection matrix the sum of each row is equal to the volumes + * of the corresponding source elements and the sum of each column is equal to the volumes + * of the corresponding target elements. This will be true as long as the meshes correspond + * to the same geometry. The equalities are in the "epsilon-sense", making sure the relative + * error is small enough. + * + * @param m the intersection matrix + * @param sMesh the source mesh + * @param tMesh the target mesh + * @return true if the condition is verified, false if not. + */ + template + bool MeshTestToolkit::testVolumes(const IntersectionMatrix& m, MEDMEM::MESH& sMesh, MEDMEM::MESH& tMesh) const + { + bool ok = true; + + // source elements + double* sVol = new double[sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)]; + getVolumes(sMesh, sVol); + + for(int i = 0; i < sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); ++i) + { + const double sum_row = sumRow(m, i+1); + if(!epsilonEqualRelative(sum_row, fabs(sVol[i]), _precision)) + { + LOG(1, "Source volume inconsistent : vol of cell " << i << " = " << sVol[i] << " but the row sum is " << sum_row ); + ok = false; + } + LOG(1, "diff = " < + bool MeshTestToolkit::testTranspose(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const + { + + int i = 0; + bool isSymmetric = true; + + LOG(1, "Checking symmetry src - target" ); + isSymmetric = isSymmetric & areCompatitable(m1, m2) ; + LOG(1, "Checking symmetry target - src" ); + isSymmetric = isSymmetric & areCompatitable(m2, m1); + + 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 = fabs(iter2->second); + //if(m2[j - 1].count(i+1) > 0) + // { + map theMap = m2.at(j-1); + const double v2 = fabs(theMap[i + 1]); + if(v1 != v2) + { + LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 ); + if(!epsilonEqualRelative(v1, v2, _precision)) + { + LOG(2, "(" << i << ", " << j << ") fails"); + isSymmetric = false; + } + } + } + ++i; + } + if(!isSymmetric) + { + LOG(1, "*** matrices are not symmetric"); + } + return isSymmetric; + } + + /** + * Tests if an intersection matrix is diagonal. + * + * @param m the intersection matrix + * @return true if m is diagonal; false if not + * + */ + template + bool MeshTestToolkit::testDiagonal(const IntersectionMatrix& m) const + { + LOG(1, "Checking if matrix is diagonal" ); + int i = 1; + bool isDiagonal = true; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + int j = iter2->first; + const double vol = iter2->second; + if(vol != 0.0 && (i != j)) + { + LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" ); + if(!epsilonEqual(vol, 0.0, _precision)) + { + LOG(2, "(" << i << ", " << j << ") fails"); + isDiagonal = false; + } + } + } + ++i; + } + if(!isDiagonal) + { + LOG(1, "*** matrix is not diagonal"); + } + return isDiagonal; + } + + /** + * Outputs the intersection matrix as a list of all its elements to std::cout. + * + * @param m the intersection matrix to output + */ + template + void MeshTestToolkit::dumpIntersectionMatrix(const IntersectionMatrix& m) const + { + int i = 0; + std::cout << "Intersection matrix is " << endl; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + + std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << endl; + + } + ++i; + } + std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; + } + + /** + * Calculates the intersection matrix for two meshes. + * If the source and target meshes are the same, a CppUnit assertion raised if testVolumes() returns false. + * + * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh1 the name of the source mesh + * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh2 the name of the target mesh + * @param m intersection matrix in which to store the result of the intersection + */ + template + void MeshTestToolkit::calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const + { + const string dataBaseDir = getenv("MED_ROOT_DIR"); + const string dataDir = dataBaseDir + string("/share/salome/resources/med/"); + + LOG(1, std::endl << "=== -> intersecting src = " << mesh1path << ", target = " << mesh2path ); + + LOG(5, "Loading " << mesh1 << " from " << mesh1path); + MESH sMesh(MED_DRIVER, dataDir+mesh1path, mesh1); + + LOG(5, "Loading " << mesh2 << " from " << mesh2path); + MESH tMesh(MED_DRIVER, dataDir+mesh2path, mesh2); + + MEDNormalizedUnstructuredMesh sMesh_wrapper(&sMesh); + MEDNormalizedUnstructuredMesh tMesh_wrapper(&tMesh); + + if (SPACEDIM==2 && MESHDIM==2) + { + Interpolation2D interpolator; + interpolator.setOptions(_precision, LOG_LEVEL, _intersectionType,1); + interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); + } + else if (SPACEDIM==3 && MESHDIM==2) + { + Interpolation3DSurf interpolator; + interpolator.setOptions(_precision,LOG_LEVEL, 0.5,_intersectionType,false,1); + interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); + } + else if (SPACEDIM==3 && MESHDIM==3) + { + Interpolation3D interpolator; + interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); + } + else + { + throw MEDEXCEPTION("Wrong dimensions"); + } + // if reflexive, check volumes + if(strcmp(mesh1path,mesh2path) == 0) + { + const bool row_and_col_sums_ok = testVolumes(m, sMesh, tMesh); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Row or column sums incorrect", true, row_and_col_sums_ok); + const bool is_diagonal =testDiagonal(m); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Self intersection matrix is not diagonal", true, is_diagonal); + } + + LOG(1, "Intersection calculation done. " << std::endl ); + + } + + /** + * Tests the intersection algorithm for two meshes. + * Depending on the nature of the meshes, different tests will be performed. The sum of the elements will + * be compared to the given total volume of the intersection in all cases. If the two meshes are the same, then + * it will be confirmed that the intersection matrix is diagonal, otherwise the intersection matrices will be + * calculated once which each mesh as source mesh, and it will be verified that the they are each others' transpose. + * + * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh1 the name of the source mesh + * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh2 the name of the target mesh + * @param correctVol the total volume of the intersection of the two meshes + * @param prec maximum relative error to be tolerated in volume comparisions + * @param doubleTest if false, only the test with mesh 1 as the source mesh and mesh 2 as the target mesh will be performed + * + */ + template + void MeshTestToolkit::intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const + { + LOG(1, std::endl << std::endl << "=============================" ); + + using std::string; + const string path1 = string(mesh1path) + string(mesh1); + const string path2 = string(mesh2path) + string(mesh2); + + const bool isTestReflexive = (path1.compare(path2) == 0); + + IntersectionMatrix matrix1; + calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1); + +#if LOG_LEVEL >= 2 + dumpIntersectionMatrix(matrix1); +#endif + + std::cout.precision(16); + + const double vol1 = sumVolume(matrix1); + + if(!doubleTest) + { + LOG(1, "vol = " << vol1 <<" correctVol = " << correctVol ); + CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(correctVol, vol1)); + + if(isTestReflexive) + { + CPPUNIT_ASSERT_EQUAL_MESSAGE("Reflexive test failed", true, testDiagonal(matrix1)); + } + } + else + { + + IntersectionMatrix matrix2; + calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2); + +#if LOG_LEVEL >= 2 + dumpIntersectionMatrix(matrix2); +#endif + + const double vol2 = sumVolume(matrix2); + + LOG(1, "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol ); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Symmetry test failed", true, testTranspose(matrix1, matrix2)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(vol1, correctVol)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec * std::max(vol2, correctVol)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, prec * std::max(vol1, vol2)); + } + + } + + /** + * Utility method used to facilitate the call to intersect meshes. + * It calls intersectMeshes, using "mesh1.med" as file name for the mesh with name "mesh1" and + * "mesh2.med" as file name for the mesh with name "mesh2". The rest of the arguments are passed + * along as they are. + * + * @param mesh1 the name of the source mesh + * @param mesh2 the name of the target mesh + * @param correctVol the total volume of the intersection of the two meshes + * @param prec maximum relative error to be tolerated in volume comparisions + * @param doubleTest if false, only the test with mesh 1 as the source mesh and mesh 2 as the target mesh will be performed + * + */ + template + void MeshTestToolkit::intersectMeshes(const char* mesh1, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const + { + const string path1 = string(mesh1) + string(".med"); + std::cout << "here :" << path1 << std::endl; + const string path2 = string(mesh2) + string(".med"); + + intersectMeshes(path1.c_str(), mesh1, path2.c_str(), mesh2, correctVol, prec, doubleTest); + } + + +} diff --git a/src/INTERP_KERNELTest/MultiElement2DTests.hxx b/src/INTERP_KERNELTest/MultiElement2DTests.hxx new file mode 100644 index 000000000..2a9ae1153 --- /dev/null +++ b/src/INTERP_KERNELTest/MultiElement2DTests.hxx @@ -0,0 +1,62 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __MULTI_ELEMENT_2D_TESTS_HXX_ +#define __MULTI_ELEMENT_2D_TESTS_HXX_ + +#include "InterpolationTestSuite.hxx" + +namespace INTERP_TEST +{ + /** + * \brief Class testing algorithm by intersecting meshes of several + * polygonal elements - up to a few thousand. This serves to check the + * filtering methods and the matrix assemblage, as well as verifying + * that computation errors do not become unmanageable. It uses mehes of + * different geometries : triangle, quadrilateral. + * + */ + class MultiElement2DTests : public InterpolationTestSuite<2,2> + { + CPPUNIT_TEST_SUITE( MultiElement2DTests ); + + CPPUNIT_TEST(SymetryTranspose2DTest); + CPPUNIT_TEST(SelfIntersection2DTest); + + CPPUNIT_TEST_SUITE_END(); + + public: + void SymetryTranspose2DTest() + { + _testTools->_intersectionType=INTERP_KERNEL::Triangulation; + _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); + _testTools->_intersectionType=INTERP_KERNEL::Convex; + _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); + } + void SelfIntersection2DTest() + { + IntersectionMatrix m; + _testTools->_intersectionType=INTERP_KERNEL::Triangulation; + _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); + _testTools->_intersectionType=INTERP_KERNEL::Convex; + _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); + } + }; +} + +#endif diff --git a/src/INTERP_KERNELTest/MultiElement3DSurfTests.hxx b/src/INTERP_KERNELTest/MultiElement3DSurfTests.hxx new file mode 100644 index 000000000..0543d73d1 --- /dev/null +++ b/src/INTERP_KERNELTest/MultiElement3DSurfTests.hxx @@ -0,0 +1,62 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __MULTI_ELEMENT_3DSurf_TESTS_HXX_ +#define __MULTI_ELEMENT_3DSurf_TESTS_HXX_ + +#include "InterpolationTestSuite.hxx" + +namespace INTERP_TEST +{ + /** + * \brief Class testing algorithm by intersecting meshes of several + * polygonal elements - up to a few thousand. This serves to check the + * filtering methods and the matrix assemblage, as well as verifying + * that computation errors do not become unmanageable. It uses mehes of + * different geometries : triangle, quadrilateral. + * + */ + class MultiElement2DTests : public InterpolationTestSuite<3,2> + { + CPPUNIT_TEST_SUITE( MultiElement3DSurfTests ); + + CPPUNIT_TEST(SymetryTranspose3DSurfTest); + CPPUNIT_TEST(SelfIntersection3DSurfTest); + + CPPUNIT_TEST_SUITE_END(); + + public: + void SymetryTranspose3DSurfTest() + { + _testTools->_intersectionType=INTERP_KERNEL::Triangulation; + _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); + _testTools->_intersectionType=INTERP_KERNEL::Convex; + _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); + } + void SelfIntersection3DSurfTest() + { + IntersectionMatrix m; + _testTools->_intersectionType=INTERP_KERNEL::Triangulation; + _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); + _testTools->_intersectionType=INTERP_KERNEL::Convex; + _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); + } + }; +} + +#endif diff --git a/src/INTERP_KERNELTest/MultiElementTetraTests.hxx b/src/INTERP_KERNELTest/MultiElementTetraTests.hxx new file mode 100644 index 000000000..d8610688e --- /dev/null +++ b/src/INTERP_KERNELTest/MultiElementTetraTests.hxx @@ -0,0 +1,158 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __MULTI_ELEMENT_TETRA_TESTS_HXX_ +#define __MULTI_ELEMENT_TETRA_TESTS_HXX_ + +#include "InterpolationTestSuite.hxx" + +namespace INTERP_TEST +{ + /** + * \brief Class testing algorithm by intersecting meshes of several + * elements (all tetrahedra) - up to a few thousand. This serves to check the + * filtering methods and the matrix assemblage, as well as verifying + * that computation errors do not become unmanageable. It uses mehes of + * different geometries : tetrahedra, boxes and cylinders. + * + */ + class MultiElementTetraTests : public InterpolationTestSuite<3,3> + { + CPPUNIT_TEST_SUITE( MultiElementTetraTests ); + + CPPUNIT_TEST( tetraComplexIncluded ); + CPPUNIT_TEST( dividedUnitTetraSimplerReflexive ); + CPPUNIT_TEST( dividedUnitTetraReflexive ); + CPPUNIT_TEST( nudgedDividedUnitTetraSimpler ); + CPPUNIT_TEST( nudgedDividedUnitTetra ); + CPPUNIT_TEST( dividedGenTetra ); + CPPUNIT_TEST( tinyBoxReflexive ); + CPPUNIT_TEST( moderateBoxEvenSmallerReflexive ); + CPPUNIT_TEST( moderateBoxSmallReflexive ); + CPPUNIT_TEST( boxReflexive ); + CPPUNIT_TEST( boxReflexiveModerate ); + CPPUNIT_TEST( tetraBoxes ); + CPPUNIT_TEST( moderateBoxesSmaller ); + CPPUNIT_TEST( moderateBoxes ); + + CPPUNIT_TEST_SUITE_END(); + + public: + + /// Tetrahedron situated totally inside another + /// \brief Status : pass + void tetraComplexIncluded() + { + _testTools->intersectMeshes("ComplexIncludedTetra", "ComplexIncludingTetra", 17.0156); + } + + /// Unit tetrahedron divided in 4 elements intersecting itself. + /// \brief Status : pass + void dividedUnitTetraSimplerReflexive() + { + _testTools->intersectMeshes("DividedUnitTetraSimpler", "DividedUnitTetraSimpler", 0.1666667); + } + + /// Unit tetrahedron divided in 14 elements intersecting itself. + /// \brief Status : pass + void dividedUnitTetraReflexive() + { + _testTools->intersectMeshes("DividedUnitTetra", "DividedUnitTetra", 0.1666667); + } + + /// Unit tetrahedron divided in 4 elements intersecting slightly displaced version of itself. + /// \brief Status : pass + void nudgedDividedUnitTetraSimpler() + { + _testTools->intersectMeshes("NudgedDividedUnitTetraSimpler", "DividedUnitTetraSimpler", 0.150191); + } + + /// Unit tetrahedron divided in 14 elements intersecting slightly displaced version of itself. + /// \brief Status : pass + void nudgedDividedUnitTetra() + { + _testTools->intersectMeshes("NudgedDividedUnitTetra", "DividedUnitTetra", 0.150191); + } + + /// Two intersecting tetrahedra in general position, one with 23 elements, the other with 643 elements + /// \brief Status : pass + void dividedGenTetra() + { + _testTools->intersectMeshes("DividedGenTetra1", "DividedGenTetra2", 0.546329); + } + + /// Large box in general position with 12 elements intersecting itself + /// \brief Status : pass + void tinyBoxReflexive() + { + _testTools->intersectMeshes("TinyBox", "TinyBox", 979200); + } + + /// Small box in general position with 33 elements intersecting itself + /// \brief Status : pass + void boxReflexive() + { + _testTools->intersectMeshes("Box3", "Box3", 13.9954); + } + + /// Box in general position with 67 elements intersecting itself + /// \brief Status : pass + void moderateBoxEvenSmallerReflexive() + { + _testTools->intersectMeshes("BoxEvenSmaller1", "BoxEvenSmaller1", 1.44018e6); + } + + /// Box in general position with 544 elements intersecting itself + /// \brief Status : pass + void moderateBoxSmallReflexive() + { + _testTools->intersectMeshes("BoxModSmall1", "BoxModSmall1", 1.44018e6); + } + + /// Large box in general position with 2943 elements intersecting itself + /// \brief Status : pass + void boxReflexiveModerate() + { + _testTools->intersectMeshes("Box1Moderate", "Box1Moderate", 1.0e6); + } + + /// Two intersecting boxes in general position with 12 and 18 elements + /// \brief Status : pass + void tetraBoxes() + { + _testTools->intersectMeshes("Box1", "Box2", 124.197); + } + + /// Two intersecting boxes in general position with 430 and 544 elements + /// \brief Status : pass + void moderateBoxesSmaller() + { + _testTools->intersectMeshes("BoxModSmall1", "BoxModSmall2", 321853); + } + + /// Two intersecting boxes in general position with 2943 and 3068 elements + /// \brief Status : pass + void moderateBoxes() + { + _testTools->intersectMeshes("Box1Moderate", "Box2Moderate", 376856); + } + + }; +} + +#endif diff --git a/src/INTERP_KERNELTest/PerfTest.cxx b/src/INTERP_KERNELTest/PerfTest.cxx new file mode 100644 index 000000000..847aa31b1 --- /dev/null +++ b/src/INTERP_KERNELTest/PerfTest.cxx @@ -0,0 +1,158 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "Interpolation3D.hxx" +#include "Interpolation3D.txx" +#include "MeshTestToolkit.txx" +#include "Log.hxx" +#include "VectorUtils.hxx" + +#include "MEDMEM_Mesh.hxx" +#include "MEDNormalizedUnstructuredMesh.hxx" + +#include +#include + +using namespace MEDMEM; +using namespace MED_EN; + +/** + * \file PerfTest.cxx + * Test program which takes two meshes and calculates their intersection matrix. + * + * USAGE : PerfTest mesh1 mesh2 + * where mesh1 and mesh2 are the names of two meshes located in + * the files mesh1.med, mesh2.med in {$MED_ROOT_DIR}/share/salome/resources/med/ + * + */ + +namespace INTERP_TEST +{ + /** + * \brief Specialization of MeshTestToolkit for the purposes of performance testing. + * + */ + class PerfTestToolkit : public MeshTestToolkit<3,3> + { + + public: + + /** + * Calculates the intersection matrix for two meshes. + * Outputs the names of the meshes intersected, the number of elements in each mesh, + * the number of matrix elements and the number of non-zero matrix elements, etc. + * These values help to determine how well the filtering algorithm is working. + * + * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh1 the name of the source mesh + * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh2 the name of the target mesh + * @param m intersection matrix in which to store the result of the intersection + */ + void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) + { + const string dataBaseDir = getenv("MED_ROOT_DIR"); + const string dataDir = dataBaseDir + "/share/salome/resources/med/"; + + LOG(1, std::endl << "=== -> intersecting src = " << mesh1 << ", target = " << mesh2 ); + + LOG(5, "Loading " << mesh1 << " from " << mesh1path); + const MESH sMesh(MED_DRIVER, dataDir+mesh1path, mesh1); + + + LOG(5, "Loading " << mesh2 << " from " << mesh2path); + const MESH tMesh(MED_DRIVER, dataDir+mesh2path, mesh2); + + MEDNormalizedUnstructuredMesh<3,3> sMesh_wrapper(&sMesh); + MEDNormalizedUnstructuredMesh<3,3> tMesh_wrapper(&tMesh); + + Interpolation3D interpolator; + interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); + + 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 ); + + } + + /** + * Counts the number of elements in an intersection matrix, and the number of these which are non-zero. + * + * @param m the intersection matrix + * @return pair containing as its first element the number of elements in m and as its second element the + * number these which are non-zero + */ + std::pair countNumberOfMatrixEntries(const IntersectionMatrix& m) + { + + int numElems = 0; + int numNonZero = 0; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + numElems += iter->size(); + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + if(!INTERP_KERNEL::epsilonEqual(iter2->second, 0.0, VOL_PREC)) + { + ++numNonZero; + } + } + } + return std::make_pair(numElems, numNonZero); + } + + }; +} + +/** + * Main method of the program. + * Intersects the meshes and outputs some information about the calculation as well as the + * intersection matrix on std::cout. + * + * @param argc number of arguments given to the program (should be 3, the user giving 2 mesh names) + * @param argv vector to the arguments as strings. + */ +int main(int argc, char** argv) +{ + using INTERP_TEST::PerfTestToolkit; + + assert(argc == 3); + + // load meshes + const string mesh1 = argv[1]; + const string mesh2 = argv[2]; + + const string mesh1path = mesh1 + ".med"; + const string mesh2path = mesh2 + ".med"; + + IntersectionMatrix m; + + PerfTestToolkit testTools; + + 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_KERNELTest/PointLocatorTest.cxx b/src/INTERP_KERNELTest/PointLocatorTest.cxx new file mode 100644 index 000000000..02629b4a6 --- /dev/null +++ b/src/INTERP_KERNELTest/PointLocatorTest.cxx @@ -0,0 +1,101 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "PointLocatorTest.hxx" +#include "PointLocator.hxx" +#include "MEDMeshMaker.hxx" + +#include +#include + +namespace INTERP_TEST +{ + + + void PointLocatorTest::setUp() + { + } + + + void PointLocatorTest::tearDown() + { + } + + /** + * Test that creates a tree in 2D and check that + * the results are correct in three + * cases : + * a non matching search + * a standard case + * a bbox overlapping the bboxes of the tree + */ + void PointLocatorTest::test_PointLocator() { + MEDMEM::MESH* mesh2D= MEDMeshMaker(2,2,MED_EN::MED_QUAD4); + INTERP_KERNEL::PointLocator pl(*mesh2D) ; + double x[2]={0.0,0.0}; + std::list elems = pl.locate(x); + CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)(*(elems.begin()))); + elems.clear(); + + double x2[2]={0.25,0.25}; + elems = pl.locate(x2); + CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)(*(elems.begin()))); + elems.clear(); + + double x3[2]={0.5,0.5}; + elems = pl.locate(x3); + CPPUNIT_ASSERT_EQUAL(4,(int)elems.size()); + elems.clear(); + + double x4[2]={-1.0,0.0}; + elems = pl.locate(x4); + CPPUNIT_ASSERT_EQUAL(0,(int)elems.size()); + elems.clear(); + delete mesh2D; + + MEDMEM::MESH* mesh3D= MEDMeshMaker(3,2,MED_EN::MED_HEXA8); + INTERP_KERNEL::PointLocator pl3(*mesh3D); + double xx[3]={0.0,0.0,0.0}; + elems = pl3.locate(xx); + CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)*(elems.begin())); + elems.clear(); + + double xx2[3]={0.25,0.25,0.25}; + elems = pl3.locate(xx2); + CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)*(elems.begin())); + elems.clear(); + + double xx3[3]={0.5,0.5,0.5}; + elems = pl3.locate(xx3); + CPPUNIT_ASSERT_EQUAL(8,(int)elems.size()); + elems.clear(); + + double xx4[3]={-1.0,0.0,0.0}; + elems = pl3.locate(x4); + CPPUNIT_ASSERT_EQUAL(0,(int)elems.size()); + elems.clear(); + delete mesh3D; + + } + + +} diff --git a/src/INTERP_KERNELTest/PointLocatorTest.hxx b/src/INTERP_KERNELTest/PointLocatorTest.hxx new file mode 100644 index 000000000..84c576e47 --- /dev/null +++ b/src/INTERP_KERNELTest/PointLocatorTest.hxx @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __TU_POINTLOCATOR_HXX__ +#define __TU_POINTLOCATOR_HXX__ + +#include +#include "PointLocator.hxx" + +namespace INTERP_TEST +{ + + /** + * \brief Test suite testing some of the low level methods of TransformedTriangle. + * + */ + class PointLocatorTest : public CppUnit::TestFixture + { + + CPPUNIT_TEST_SUITE( PointLocatorTest ); + CPPUNIT_TEST( test_PointLocator ); + CPPUNIT_TEST_SUITE_END(); + + + public: + void setUp(); + + void tearDown(); + + // tests + void test_PointLocator(); + + }; + + + + +} + + + +#endif diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.cxx new file mode 100644 index 000000000..f556f3a4c --- /dev/null +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.cxx @@ -0,0 +1,1023 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "QuadraticPlanarInterpTest.hxx" +#include "QuadraticPolygon.hxx" +#include "EdgeArcCircle.hxx" +#include "ElementaryEdge.hxx" +#include "ComposedEdge.hxx" +#include "EdgeLin.hxx" + +#include +#include + +using namespace std; +using namespace INTERP_KERNEL; + +static const double ADMISSIBLE_ERROR = 1.e-14; + +void QuadraticPlanarInterpTest::setUp() +{ +} + +void QuadraticPlanarInterpTest::tearDown() +{ +} + +void QuadraticPlanarInterpTest::cleanUp() +{ +} + +void QuadraticPlanarInterpTest::ReadWriteInXfigElementary() +{ + //Testing bounds calculation. For Seg2 + istringstream stream("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4700"); + EdgeLin *e1=new EdgeLin(stream); + Bounds bound=e1->getBounds(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.32,bound[0],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.45,bound[1],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.34,bound[2],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.47,bound[3],ADMISSIBLE_ERROR); + e1->decrRef(); + istringstream stream2("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n4500 4700 3200 3400"); + e1=new EdgeLin(stream2); + bound=e1->getBounds(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.32,bound[0],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.45,bound[1],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.34,bound[2],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.47,bound[3],ADMISSIBLE_ERROR); + e1->decrRef(); + //Testing bounds calculation For Arc of circle. + +} + +void QuadraticPlanarInterpTest::ReadWriteInXfigGlobal() +{ + string dataBaseDir(getenv("MED_ROOT_DIR")); + dataBaseDir+="/share/salome/resources/med/"; + string tmp; + tmp=dataBaseDir; tmp+="Pol1.fig"; + QuadraticPolygon pol1(tmp.c_str()); + pol1.dumpInXfigFile("Pol1_gen.fig"); + tmp=dataBaseDir; tmp+="Pol2.fig"; + QuadraticPolygon pol2(tmp.c_str()); + pol2.dumpInXfigFile("Pol2_gen.fig"); + tmp=dataBaseDir; tmp+="Pol3.fig"; + QuadraticPolygon pol3(tmp.c_str()); + pol3.dumpInXfigFile("Pol3_gen.fig"); + tmp=dataBaseDir; tmp+="Pol4.fig"; + QuadraticPolygon pol4(tmp.c_str()); + CPPUNIT_ASSERT_EQUAL(1,pol4.size()); + ElementaryEdge *edge1=dynamic_cast(pol4[0]); + CPPUNIT_ASSERT(edge1); + Edge *edge2=edge1->getPtr(); + EdgeArcCircle *edge=dynamic_cast(edge2); + CPPUNIT_ASSERT(edge); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.24375,edge->getRadius(),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(5.7857653289925404,edge->getAngle(),ADMISSIBLE_ERROR); + double center[2]; + edge->getCenter(center); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48,center[0],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48375,center[1],ADMISSIBLE_ERROR); + const double *start=*edge->getStartNode(); + Node *n1=new Node(start[0]+2*(center[0]-start[0]),start[1]+2*(center[1]-start[1])); + edge->changeMiddle(n1); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.24375,edge->getRadius(),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(5.7857653289925404,edge->getAngle(),ADMISSIBLE_ERROR); + n1->decrRef(); + n1=new Node(center[0],center[1]+0.24375); + edge->changeMiddle(n1); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.24375,edge->getRadius(),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.49741997818704586,edge->getAngle(),ADMISSIBLE_ERROR);//5.7857653289925404 + 2*PI + n1->decrRef(); + //A half circle. + EdgeArcCircle *e=new EdgeArcCircle(0.84,0.54,0.78,0.6,0.84,0.66); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.06,e->getRadius(),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.1415925921507317,e->getAngle(),1e-5); + e->decrRef(); + e=new EdgeArcCircle(0.84,0.54,0.9,0.6,0.84,0.66); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.06,e->getRadius(),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415925921507317,e->getAngle(),1e-5); + e->decrRef(); +} + +void QuadraticPlanarInterpTest::BasicGeometricTools() +{ + Node *n1=new Node(1.,1.); + Node *n2=new Node(4.,2.); + EdgeLin *e1=new EdgeLin(n1,n2); + double tmp[2]; + e1->getNormalVector(tmp); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.94868329805051377,tmp[1],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.31622776601683794,tmp[0],ADMISSIBLE_ERROR); + e1->decrRef(); + n1->decrRef(); n2->decrRef(); + n1=new Node(1.,1.); + n2=new Node(0.,4.); + e1=new EdgeLin(n1,n2); + double tmp2[2]; + e1->getNormalVector(tmp2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,Node::dot(tmp,tmp2),1e-10); + tmp[0]=0.5; tmp[1]=2.5; + CPPUNIT_ASSERT(e1->isNodeLyingOn(tmp)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,e1->getDistanceToPoint(tmp),1e-12); + tmp[1]=2.55; CPPUNIT_ASSERT(!e1->isNodeLyingOn(tmp)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0158113883008418,e1->getDistanceToPoint(tmp),1e-12); + tmp[0]=0.; tmp[1]=5.; + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,e1->getDistanceToPoint(tmp),1e-12); + EdgeArcCircle *e=new EdgeArcCircle(4.,3.,0.,5.,-5.,0.); + tmp[0]=-4.; tmp[1]=3.; + CPPUNIT_ASSERT(e->isNodeLyingOn(tmp)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,e->getDistanceToPoint(tmp),1e-12); + tmp[1]=3.1; CPPUNIT_ASSERT(!e->isNodeLyingOn(tmp)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(6.0632371551998077e-2,e->getDistanceToPoint(tmp),1e-12); + tmp[0]=-4.; tmp[1]=-3.; + CPPUNIT_ASSERT(!e->isNodeLyingOn(tmp)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1622776601683795,e->getDistanceToPoint(tmp),1e-12); + e->decrRef(); + e1->decrRef(); + n1->decrRef(); n2->decrRef(); +} + +void QuadraticPlanarInterpTest::IntersectionBasics() +{ + //Testing intersection of Bounds. + istringstream stream1("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4800"); + EdgeLin *e1=new EdgeLin(stream1); + istringstream stream2("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4800"); + EdgeLin *e2=new EdgeLin(stream2); + Bounds *bound=e1->getBounds().amIIntersectingWith(e2->getBounds()); CPPUNIT_ASSERT(bound); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.32,(*bound)[0],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.45,(*bound)[1],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.34,(*bound)[2],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48,(*bound)[3],ADMISSIBLE_ERROR); + delete bound; + e2->decrRef(); e1->decrRef(); + // + istringstream stream3("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3000 7200 6000 3700"); + EdgeLin *e3=new EdgeLin(stream3); + istringstream stream4("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n4800 6600 7200 4200"); + EdgeLin *e4=new EdgeLin(stream4); + bound=e3->getBounds().amIIntersectingWith(e4->getBounds()); CPPUNIT_ASSERT(bound); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48,(*bound)[0],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.6,(*bound)[1],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.42,(*bound)[2],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.66,(*bound)[3],ADMISSIBLE_ERROR); + delete bound; + e3->decrRef(); e4->decrRef(); +} + +void QuadraticPlanarInterpTest::EdgeLinUnitary() +{ + EdgeLin *e1=new EdgeLin(0.5,0.5,3.7,4.1); + Node *n=new Node(2.1,2.3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),0.5,1e-8); + n->decrRef(); + n=new Node(3.7,4.1); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),1.,1e-8); + n->decrRef(); + n=new Node(0.5,0.5); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),0.,1e-8); + n->decrRef(); + n=new Node(-1.1,-1.3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),-0.5,1e-8); + n->decrRef(); + n=new Node(5.3,5.9); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),1.5,1e-8); + n->decrRef(); e1->decrRef(); +} + +/*! + * Here two things are tested. + * 1 ) One the overlapping calculation capability of edge/edge intersector. + * 2 ) Then the capability to handle the case where 2 segs (whatever their type) are overlapped. + * All the configuration of full or part overlapping have been tested. + */ +void QuadraticPlanarInterpTest::IntersectionEdgeOverlapUnitarySegSeg() +{ + ComposedEdge& v1=*(new ComposedEdge); + ComposedEdge& v2=*(new ComposedEdge); + MergePoints v3; + //Testing merge of geometric equals seg2. + Edge *e1=new EdgeLin(0.5,0.5,1.,1.); Edge *e2=new EdgeLin(0.5,0.5,1.,1.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); + v1.clear(); v2.clear(); v3.clear(); + // - testing by adding some noise + e1->decrRef(); e1=new EdgeLin(0.5+5.e-15,0.5-5.e-15,1.,1.+7.e-15); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Testing merge of geometric equals seg2 but now with opposite direction + e1=new EdgeLin(0.5,0.5,0.7,0.7); e2=new EdgeLin(0.7+6.e-15,0.7-2.e-15,0.5+3.e-15,0.5-4.e-15); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && !v2[0]->getDirection());//compared 8 lines above !v2[0]->getDirection() + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 0 + //Test 1 - OUT_AFTER - OUT_AFTER | same dir. - 0° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.5,0.,2.,0.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 2 - INSIDE - OUT_AFTER | same dir. - 0° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.5,0.,1.5,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresicEqualDirSensitive(v2[0])); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 2 - INSIDE - OUT_AFTER | same dir. - 90° + e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.5,0.,1.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresicEqualDirSensitive(v2[0])); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 2 - INSIDE - OUT_AFTER | same dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.5,0.5,1.5,1.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresicEqualDirSensitive(v2[0])); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 2 - INSIDE - OUT_AFTER | opp. dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.5,1.5,0.5,0.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(!v1[1]->intresicEqualDirSensitive(v2[1]) && v1[1]->intresicEqual(v2[1])); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 3 - INSIDE - INSIDE | same dir. - 0° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.25,0.,0.75,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 3 - INSIDE - INSIDE | same dir. - 90° + e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.25,0.,0.75); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 3 - INSIDE - INSIDE | same dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.25,0.25,0.75,0.75); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 3 - INSIDE - INSIDE | opp dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.75,0.75,0.25,0.25); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && !v1[1]->getDirection()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 3bis - INSIDE - INSIDE - Bis | opp dir. + double center[2]={0.,0.}; + double radius=1.; + e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-2*M_PI/3.+2*M_PI,-M_PI/3.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(v1[0]->getDirection()); CPPUNIT_ASSERT(!v2[0]->getDirection()); + CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(v1[2]->getDirection()); CPPUNIT_ASSERT(!v2[2]->getDirection()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); + CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getStartNode()); + CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 3bis - INSIDE - INSIDE - Bis | same dir. + e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-M_PI/3.,-2*M_PI/3.+2*M_PI); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(v1[0]->getDirection()); CPPUNIT_ASSERT(v2[2]->getDirection()); + CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(v1[2]->getDirection()); CPPUNIT_ASSERT(v2[0]->getDirection()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); + CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getStartNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 3bis - INSIDE - INSIDE - Bis | opp dir. | e1<->e2 to test symetry + e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-2*M_PI/3.+2*M_PI,-M_PI/3.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. + CPPUNIT_ASSERT(e2->intersectWith(e1,v3,v2,v1)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(!v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->getDirection()); + CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(!v1[2]->getDirection()); CPPUNIT_ASSERT(v2[2]->getDirection()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-5); // << not maximal precision because node switching + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); + CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getStartNode()); + CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 3bis - INSIDE - INSIDE - Bis | same dir. | e1<->e2 to test symetry + e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-M_PI/3.,-2*M_PI/3.+2*M_PI); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. + CPPUNIT_ASSERT(e2->intersectWith(e1,v3,v2,v1)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(v1[0]->getDirection()); CPPUNIT_ASSERT(v2[2]->getDirection()); + CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(v1[2]->getDirection()); CPPUNIT_ASSERT(v2[0]->getDirection()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-5); // << not maximal precision because node switching + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); + CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getStartNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 4 - OUT_BEFORE - OUT_BEFORE | same dir. - 0 ° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-1.,0.,-0.5,0.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 5 - OUT_BEFORE - INSIDE | same dir. - 0° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,0.5,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresicEqualDirSensitive(v2[1])); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 5 - OUT_BEFORE - INSIDE | same dir. - 90° + e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0,-0.5,0.,0.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresicEqualDirSensitive(v2[1])); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 5 - OUT_BEFORE - INSIDE | same dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(-0.5,-0.5,0.5,0.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresicEqualDirSensitive(v2[1])); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 5 - OUT_BEFORE - INSIDE | opp dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.5,0.5,-0.5,-0.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(!v1[0]->intresicEqualDirSensitive(v2[0]) && v1[0]->intresicEqual(v2[0]) ); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 6 - OUT_BEFORE - OUT_AFTER | same dir. - 0° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,1.5,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); + CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 6 - OUT_BEFORE - OUT_AFTER | same dir. - 90° + e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,-0.5,0.,1.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); + CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 6 - OUT_BEFORE - OUT_AFTER | same dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(-0.5,-0.5,1.5,1.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); + CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 6 - OUT_BEFORE - OUT_AFTER | opp dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.5,1.5,-0.5,-0.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); + CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && !v2[1]->getDirection()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 7 - END - OUT_AFTER | same dir. - 0° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.,0.,1.5,0.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 7 - END - OUT_AFTER | opp dir. - 0° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.5,0.,1.,0.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); + CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 8 - START - END | same dir. - 0° + e1=new EdgeLin(0.,0.,0.7,0.); e2=new EdgeLin(0.,0.,0.7,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 8 - START - END | same dir. - 90° + e1=new EdgeLin(0.,0.,0.,0.7); e2=new EdgeLin(0.,0.,0.,0.7); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 8 - START - END | same dir. - 45° + e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(0.,0.,0.7,0.7); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 8 - START - END | opp. dir. - 45° + e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(0.7,0.7,0.,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && !v2[0]->getDirection()); + CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 9 - OUT_BEFORE - START | same dir. + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,0.,0.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); + CPPUNIT_ASSERT(e2->getEndNode()==e1->getStartNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 10 - START - OUT_AFTER | same dir. - 0° + e1=new EdgeLin(0.,0.,0.7,0.); e2=new EdgeLin(0.,0.,1.,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 10 - START - OUT_AFTER | same dir. - 90° + e1=new EdgeLin(0.,0.,0.,0.7); e2=new EdgeLin(0.,0.,0.,1.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 10 - START - OUT_AFTER | same dir. - 45° + e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(0.,0.,1.,1.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 10 - START - OUT_AFTER | opp dir. - 45° + e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(1.,1.,0.,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && !v2[1]->getDirection()); + CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 11 - INSIDE - END | same dir. - 0° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.7,0.,1.,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 11 - INSIDE - END | same dir. - 90° + e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.7,0.,1.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 11 - INSIDE - END | same dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.7,0.7,1.,1.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 11 - INSIDE - END | opp dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.,1.,0.7,0.7); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getStartNode()); + CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && !v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 12 - OUT_BEFORE - END | same dir. - 0° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,1.,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); + CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 12 - OUT_BEFORE - END | same dir. - 90° + e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,-0.5,0.,1.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); + CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 12 - OUT_BEFORE - END | same dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(-0.5,-0.5,1.,1.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); + CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 12 - OUT_BEFORE - END | opp dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.,1.,-0.5,-0.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && !v2[0]->getDirection()); + CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 13 - START - INSIDE | same dir. - 0° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.,0.,0.5,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e2->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 13 - START - INSIDE | same dir. - 90° + e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.,0.,0.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e2->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 13 - START - INSIDE | same dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.,0.,0.5,0.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e2->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 13 - START - INSIDE | opp dir. - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.5,0.5,0.,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && !v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); + CPPUNIT_ASSERT(e2->getEndNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 14 - INSIDE - START | same dir. + e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,M_PI/3.,-M_PI); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresicEqual(v2[0])); + CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); + CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2*M_PI/3.,v1[0]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v2[0]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 14 - INSIDE - START | opp dir. + e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,-M_PI,M_PI/3.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(v2[1]->getPtr()) && !v2[1]->getDirection() && v1[1]->getDirection()); + CPPUNIT_ASSERT(v2[0]->getStartNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); + CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==e1->getEndNode()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2*M_PI/3.,v1[0]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v2[1]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[0]->getCurveLength(),1.e-12); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 15 - END - INSIDE | same dir. + e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,0.,-4.*M_PI/3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresicEqual(v2[1])); + CPPUNIT_ASSERT(v2[0]->getEndNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getStartNode()==e1->getEndNode()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[0]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[0]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2.*M_PI/3.,v1[1]->getCurveLength(),1.e-12); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 15 - END - INSIDE | opp dir. + e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,-4.*M_PI/3,0.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[0]->getPtr()) && !v2[0]->getDirection() && v1[0]->getDirection()); + CPPUNIT_ASSERT(v2[0]->getEndNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); + CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); + CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getEndNode()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[0]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2.*M_PI/3.,v1[1]->getCurveLength(),1.e-12); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + // + ComposedEdge::Delete(&v1); + ComposedEdge::Delete(&v2); +} + +/*! + * Here there is test of cases where between 2 edges intersects only in points not on edge. + */ +void QuadraticPlanarInterpTest::IntersectionPointOnlyUnitarySegSeg() +{ + // 0° - classical + EdgeLin *e1=new EdgeLin(0.,0.,1.,0.); + EdgeLin *e2=new EdgeLin(0.3,0.3,0.5,-0.3); + ComposedEdge& v1=*(new ComposedEdge); + ComposedEdge& v2=*(new ComposedEdge); MergePoints v3; + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4,(*v1[0]->getEndNode())[0],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,(*v1[0]->getEndNode())[1],ADMISSIBLE_ERROR); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + // 90° - classical + e1=new EdgeLin(0.,0.,0.,1.); + e2=new EdgeLin(-0.3,0.3,0.3,0.5); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); + CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); + CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,(*v1[0]->getEndNode())[0],ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4,(*v1[0]->getEndNode())[1],ADMISSIBLE_ERROR); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 1 - 0° + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.,0.,0.,1.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 1 - 90° + e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.,1.,0.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 1 - 45° + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.,0.,1.,-1.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 2 + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.,1.,1.,0.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(v3.isEnd1(0)); CPPUNIT_ASSERT(v3.isEnd2(0)); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 3 + e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.,0.,1.,1.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(v3.isEnd1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Test 4 + e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.,-1.,0.,0.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isEnd2(0)); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Intersection extremity of one edge and inside of other edge. 2 End. + e1=new EdgeLin(0.,0.,1.,0.); + e2=new EdgeLin(0.5,1.,0.5,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); + CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode() && v1[0]->getEndNode()==e2->getEndNode() && v1[1]->getStartNode()==e2->getEndNode() && v1[1]->getEndNode()==e1->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getDirection() && v1[1]->getDirection()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Intersection extremity of one edge and inside of other edge. 2 Start. + e1=new EdgeLin(0.,0.,1.,0.); + e2=new EdgeLin(0.5,0.,0.5,1.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); + CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode() && v1[0]->getEndNode()==e2->getStartNode() && v1[1]->getStartNode()==e2->getStartNode() && v1[1]->getEndNode()==e1->getEndNode()); + CPPUNIT_ASSERT(v1[0]->getDirection() && v1[1]->getDirection()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Intersection extremity of one edge and inside of other edge. 1 Start. + e1=new EdgeLin(0.5,0.,0.5,1.); + e2=new EdgeLin(0.,0.,1.,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); + CPPUNIT_ASSERT(v2[0]->getStartNode()==e2->getStartNode() && v2[0]->getEndNode()==e1->getStartNode() && v2[1]->getStartNode()==e1->getStartNode() && v2[1]->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getDirection() && v2[1]->getDirection()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + //Intersection extremity of one edge and inside of other edge. 1 End. + e1=new EdgeLin(0.5,1.,0.5,0.); + e2=new EdgeLin(0.,0.,1.,0.); + CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); + CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); + CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); + CPPUNIT_ASSERT(v2[0]->getStartNode()==e2->getStartNode() && v2[0]->getEndNode()==e1->getEndNode() && v2[1]->getStartNode()==e1->getEndNode() && v2[1]->getEndNode()==e2->getEndNode()); + CPPUNIT_ASSERT(v2[0]->getDirection() && v2[1]->getDirection()); + e2->decrRef(); e1->decrRef(); + v1.clear(); v2.clear(); v3.clear(); + ComposedEdge::Delete(&v2); + ComposedEdge::Delete(&v1); +} diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.hxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.hxx new file mode 100644 index 000000000..da60159a8 --- /dev/null +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.hxx @@ -0,0 +1,201 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef _QUADRATICPLANARINTERPTEST_HXX_ +#define _QUADRATICPLANARINTERPTEST_HXX_ + +#include + +namespace INTERP_KERNEL +{ + class Node; + class EdgeArcCircle; + class QuadraticPolygon; + + class QuadraticPlanarInterpTest : public CppUnit::TestFixture + { + CPPUNIT_TEST_SUITE( QuadraticPlanarInterpTest ); + CPPUNIT_TEST( ReadWriteInXfigElementary ); + CPPUNIT_TEST( ReadWriteInXfigGlobal ); + CPPUNIT_TEST( BasicGeometricTools ); + CPPUNIT_TEST( IntersectionBasics ); + CPPUNIT_TEST( EdgeLinUnitary ); + CPPUNIT_TEST( IntersectionEdgeOverlapUnitarySegSeg ); + CPPUNIT_TEST( IntersectionPointOnlyUnitarySegSeg ); + CPPUNIT_TEST( IntersectArcCircleBase ); + CPPUNIT_TEST( IntersectArcCircleFull ); + CPPUNIT_TEST( IntersectArcCircleSegumentBase ); + CPPUNIT_TEST( checkInOutDetection ); + CPPUNIT_TEST( checkAssemblingBases1 ); + CPPUNIT_TEST( checkAssemblingBases2 ); + CPPUNIT_TEST( checkPolygonsIntersection1 ); + CPPUNIT_TEST( checkPolygonsIntersection2 ); + CPPUNIT_TEST( checkAreasCalculations ); + CPPUNIT_TEST( checkBarycenterCalculations ); + CPPUNIT_TEST( checkHighLevelFunctionTest1 ); + CPPUNIT_TEST( check1DInterpLin ); + CPPUNIT_TEST( checkEpsilonCoherency1 ); + CPPUNIT_TEST( checkNonRegression1 ); + CPPUNIT_TEST( checkNonRegression2 ); + CPPUNIT_TEST( checkNonRegression3 ); + CPPUNIT_TEST( checkNonRegression4 ); + CPPUNIT_TEST( checkNonRegression5 ); + CPPUNIT_TEST( checkNonRegression6 ); + CPPUNIT_TEST( checkNonRegression7 ); + CPPUNIT_TEST( checkNonRegression8 ); + CPPUNIT_TEST( checkNonRegression9 ); + CPPUNIT_TEST( checkNonRegression10 ); + CPPUNIT_TEST( checkNonRegression11 ); + CPPUNIT_TEST( checkNonRegression12 ); + CPPUNIT_TEST ( checkNonRegression13 ); + CPPUNIT_TEST ( checkNonRegression14 ); + CPPUNIT_TEST ( checkNonRegression15 ); + CPPUNIT_TEST ( checkNonRegression16 ); + CPPUNIT_TEST ( checkNonRegression17 ); + // + CPPUNIT_TEST ( checkNonRegressionOmar0000 ); + CPPUNIT_TEST ( checkNonRegressionOmar0001 ); + CPPUNIT_TEST ( checkNonRegressionOmar0002 ); + CPPUNIT_TEST ( checkNonRegressionOmar0003 ); + CPPUNIT_TEST ( checkNonRegressionOmar0004 ); + CPPUNIT_TEST ( checkNonRegressionOmar0005 ); + CPPUNIT_TEST ( checkNonRegressionOmar0006 ); + CPPUNIT_TEST ( checkNonRegressionOmar0007 ); + CPPUNIT_TEST ( checkNonRegressionOmar0008 ); + CPPUNIT_TEST ( checkNonRegressionOmar0009 ); + CPPUNIT_TEST ( checkNonRegressionOmar0010 ); + CPPUNIT_TEST ( checkNonRegressionOmar0011 ); + CPPUNIT_TEST ( checkNonRegressionOmar2511 ); + CPPUNIT_TEST ( checkNonRegressionOmar0012 ); + CPPUNIT_TEST ( checkNonRegressionOmar0013 ); + CPPUNIT_TEST ( checkNonRegressionOmar0014 ); + CPPUNIT_TEST ( checkNonRegressionOmar0015 ); + CPPUNIT_TEST ( checkNonRegressionOmar0016 ); + CPPUNIT_TEST ( checkNonRegressionOmar0017 ); + CPPUNIT_TEST ( checkNonRegressionOmar0018 ); + CPPUNIT_TEST ( checkNonRegressionOmar0019 ); + CPPUNIT_TEST ( checkNonRegressionOmar0020 ); + CPPUNIT_TEST ( checkNonRegressionOmar0021 ); + CPPUNIT_TEST ( checkNonRegressionOmar0022 ); + CPPUNIT_TEST ( checkNonRegressionOmar0023 ); + CPPUNIT_TEST ( checkNonRegressionOmar0024 ); + CPPUNIT_TEST ( checkNonRegressionOmar2524 ); + CPPUNIT_TEST ( checkNonRegressionOmar0025 ); + CPPUNIT_TEST ( checkNonRegressionOmar0026 ); + CPPUNIT_TEST ( checkNonRegressionOmar0027 ); + CPPUNIT_TEST ( checkNonRegressionOmar0028 ); + CPPUNIT_TEST ( checkNonRegressionOmar0029 ); + CPPUNIT_TEST ( checkNonRegressionOmar0030 ); + // + CPPUNIT_TEST( checkNormalize ); + CPPUNIT_TEST_SUITE_END(); + public: + void setUp(); + void tearDown(); + void cleanUp(); + // + void ReadWriteInXfigElementary(); + void ReadWriteInXfigGlobal(); + void BasicGeometricTools(); + void IntersectionBasics(); + void EdgeLinUnitary(); + void IntersectionEdgeOverlapUnitarySegSeg(); + void IntersectionPointOnlyUnitarySegSeg(); + // + void IntersectArcCircleBase(); + void IntersectArcCircleFull(); + void IntersectArcCircleSegumentBase(); + // + void checkInOutDetection(); + // + void checkAssemblingBases1(); + void checkAssemblingBases2(); + // + void checkPolygonsIntersection1(); + void checkPolygonsIntersection2(); + void checkAreasCalculations(); + void checkBarycenterCalculations(); + // + void checkHighLevelFunctionTest1(); + // + void check1DInterpLin(); + // + void checkEpsilonCoherency1(); + // + void checkNonRegression1(); + void checkNonRegression2(); + void checkNonRegression3(); + void checkNonRegression4(); + void checkNonRegression5(); + void checkNonRegression6(); + void checkNonRegression7(); + void checkNonRegression8(); + void checkNonRegression9(); + void checkNonRegression10(); + void checkNonRegression11(); + void checkNonRegression12(); + void checkNonRegression13(); + void checkNonRegression14(); + void checkNonRegression15(); + void checkNonRegression16(); + void checkNonRegression17(); + // + void checkNonRegressionOmar0000(); + void checkNonRegressionOmar0001(); + void checkNonRegressionOmar0002(); + void checkNonRegressionOmar0003(); + void checkNonRegressionOmar0004(); + void checkNonRegressionOmar0005(); + void checkNonRegressionOmar0006(); + void checkNonRegressionOmar0007(); + void checkNonRegressionOmar0008(); + void checkNonRegressionOmar0009(); + void checkNonRegressionOmar0010(); + void checkNonRegressionOmar0011(); + void checkNonRegressionOmar2511(); + void checkNonRegressionOmar0012(); + void checkNonRegressionOmar0013(); + void checkNonRegressionOmar0014(); + void checkNonRegressionOmar0015(); + void checkNonRegressionOmar0016(); + void checkNonRegressionOmar0017(); + void checkNonRegressionOmar0018(); + void checkNonRegressionOmar0019(); + void checkNonRegressionOmar0020(); + void checkNonRegressionOmar0021(); + void checkNonRegressionOmar0022(); + void checkNonRegressionOmar0023(); + void checkNonRegressionOmar0024(); + void checkNonRegressionOmar2524(); + void checkNonRegressionOmar0025(); + void checkNonRegressionOmar0026(); + void checkNonRegressionOmar0027(); + void checkNonRegressionOmar0028(); + void checkNonRegressionOmar0029(); + void checkNonRegressionOmar0030(); + // + void checkNormalize(); + private: + QuadraticPolygon *buildQuadraticPolygonCoarseInfo(const double *coords, const int *conn, int lgth); + EdgeArcCircle *buildArcOfCircle(const double *center, double radius, double alphaStart, double alphaEnd); + double btw2NodesAndACenter(const Node& n1, const Node& n2, const double *center); + void checkBasicsOfPolygons(QuadraticPolygon& pol1, QuadraticPolygon& pol2, bool checkDirection); + }; +} + +#endif diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest2.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest2.cxx new file mode 100644 index 000000000..026ce84ea --- /dev/null +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest2.cxx @@ -0,0 +1,669 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "QuadraticPlanarInterpTest.hxx" +#include "QuadraticPolygon.hxx" +#include "EdgeArcCircle.hxx" +#include "EdgeLin.hxx" + +#include +#include +#include + +using namespace std; +using namespace INTERP_KERNEL; + +static const double ADMISSIBLE_ERROR = 1.e-14; + +void QuadraticPlanarInterpTest::IntersectArcCircleBase() +{ + double center[2]={0.5,0.5}; + double radius=0.3; + EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI/3),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(M_PI/4),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(M_PI/4),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/3),ADMISSIBLE_ERROR); + e1->decrRef(); + // + e1=buildArcOfCircle(center,radius,M_PI/3.,M_PI/2.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI/2),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(M_PI/3),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(M_PI/3),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/2),ADMISSIBLE_ERROR); + e1->decrRef(); + // + e1=buildArcOfCircle(center,radius,M_PI/3.,3.*M_PI/4.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(3*M_PI/4),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(M_PI/3),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(3*M_PI/4),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/2),ADMISSIBLE_ERROR);//<< + e1->decrRef(); + // + e1=buildArcOfCircle(center,radius,3*M_PI/4,7*M_PI/8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(7*M_PI/8),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(3*M_PI/4),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(7*M_PI/8),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(3*M_PI/4),ADMISSIBLE_ERROR); + e1->decrRef(); + // + e1=buildArcOfCircle(center,radius,7.*M_PI/8.,9.*M_PI/8.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI),ADMISSIBLE_ERROR);//<< + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(7*M_PI/8),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(9*M_PI/8),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(7*M_PI/8),ADMISSIBLE_ERROR); + e1->decrRef(); + // + e1=buildArcOfCircle(center,radius,9.*M_PI/8.,11.*M_PI/8.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(9*M_PI/8),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(11*M_PI/8),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(11*M_PI/8),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(9*M_PI/8),ADMISSIBLE_ERROR); + e1->decrRef(); + // + e1=buildArcOfCircle(center,radius,11.*M_PI/8.,7.*M_PI/4.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(11*M_PI/8),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(7*M_PI/4),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(3*M_PI/2),ADMISSIBLE_ERROR);//<< + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(7*M_PI/4),ADMISSIBLE_ERROR); + e1->decrRef(); + // + e1=buildArcOfCircle(center,radius,7.*M_PI/4.,15.*M_PI/8.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(7*M_PI/4),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(15*M_PI/8),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(7*M_PI/4),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(15*M_PI/8),ADMISSIBLE_ERROR); + e1->decrRef(); + // + e1=buildArcOfCircle(center,radius,-M_PI/8.,M_PI/4.); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI/4),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(0.),ADMISSIBLE_ERROR); //<< + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(15*M_PI/8),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/4),ADMISSIBLE_ERROR); + e1->decrRef(); + // + // ArcCArcCIntersector + // + TypeOfLocInEdge where1,where2; + vector v4; + MergePoints v3; + EdgeArcCircle *e2; + ArcCArcCIntersector *intersector=0; + for(unsigned k=0;k<8;k++) + { + e1=buildArcOfCircle(center,radius,M_PI/4.+k*M_PI/4.,M_PI/3.+k*M_PI/4.); + e2=buildArcOfCircle(center,radius,M_PI/4.+k*M_PI/4.,M_PI/3.+k*M_PI/4.); + intersector=new ArcCArcCIntersector(*e1,*e2); + intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); + CPPUNIT_ASSERT(where1==START && where2==END); + delete intersector; v3.clear(); e2->decrRef(); + // + e2=buildArcOfCircle(center,radius,7*M_PI/24.+k*M_PI/4.,M_PI/3.+k*M_PI/4.); + intersector=new ArcCArcCIntersector(*e1,*e2); + intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); + CPPUNIT_ASSERT(where1==INSIDE && where2==END); + delete intersector; v3.clear(); e2->decrRef(); + // + e2=buildArcOfCircle(center,radius,M_PI/4.+k*M_PI/4.,7*M_PI/24.+k*M_PI/4.); + intersector=new ArcCArcCIntersector(*e1,*e2); + intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); + CPPUNIT_ASSERT(where1==START && where2==INSIDE); + delete intersector; v3.clear(); e2->decrRef(); + // + e2=buildArcOfCircle(center,radius,13.*M_PI/48.+k*M_PI/4.,15*M_PI/48.+k*M_PI/4.); + intersector=new ArcCArcCIntersector(*e1,*e2); + intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); + CPPUNIT_ASSERT(where1==INSIDE && where2==INSIDE); + delete intersector; v3.clear(); e2->decrRef(); + // + e2=buildArcOfCircle(center,radius,-M_PI/4.+k*M_PI/4.,M_PI/6.+k*M_PI/4.); + intersector=new ArcCArcCIntersector(*e1,*e2); + intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); + CPPUNIT_ASSERT(where1==OUT_BEFORE && where2==OUT_BEFORE); + delete intersector; v3.clear(); e2->decrRef(); + // + e2=buildArcOfCircle(center,radius,0+k*M_PI/4.,5*M_PI/6.+k*M_PI/4.); + intersector=new ArcCArcCIntersector(*e1,*e2); + intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); + CPPUNIT_ASSERT(where1==OUT_BEFORE && where2==OUT_AFTER); + delete intersector; v3.clear(); e2->decrRef(); + e1->decrRef(); + } + // Ok now let's see intersection only. 2 intersections R1 > R2 ; dist(circle1,circle2)>R1; Opposite order. + for(unsigned k=0;k<8;k++) + { + center[0]=0.; center[1]=0.; + double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); + e1=buildArcOfCircle(center,3.,(k-1)*M_PI/4.,(k+1)*M_PI/4.); + e2=buildArcOfCircle(center2,1.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); + intersector=new ArcCArcCIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); + CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); + CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.35587863972199624,1e-10); + for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) + (*iter)->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + // Ok now let's see intersection only. 2 intersections R1 > R2 ; dist(circle1,circle2)>R1; Same order. + for(unsigned k=0;k<7;k++) + { + center[0]=0.; center[1]=0.; + double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); + e1=buildArcOfCircle(center,3.,(k-1)*M_PI/4.,(k+1)*M_PI/4.); + e2=buildArcOfCircle(center2,1.,M_PI+(k+1)*M_PI/4.,M_PI+(k-1)*M_PI/4.); + intersector=new ArcCArcCIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); + CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); + CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.35587863972199624,1e-10); + for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) + (*iter)->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + // 2 intersections R1>R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); + CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); + CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.6793851523346941,1e-10); + for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) + (*iter)->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + // 2 intersections R1>R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); + CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); + CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.6793851523346941,1e-10); + for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) + (*iter)->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)>R2; Opposite order. + for(unsigned k=0;k<1;k++) + { + double center2[2]; center[0]=0.; center[1]=0.; + center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); + e1=buildArcOfCircle(center,1.,(k-1)*M_PI/4.,(k+1)*M_PI/4.); + e2=buildArcOfCircle(center2,3.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); + intersector=new ArcCArcCIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); + CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.1195732971845034,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); + for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) + (*iter)->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)>R2; same order. + for(unsigned k=0;k<8;k++) + { + double center2[2]; center[0]=0.; center[1]=0.; + center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); + e1=buildArcOfCircle(center,1.,(k+1)*M_PI/4.,(k-1)*M_PI/4.); + e2=buildArcOfCircle(center2,3.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); + intersector=new ArcCArcCIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); + CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.1195732971845034,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); + for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) + (*iter)->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); + CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.0844420190512074,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); + for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) + (*iter)->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); + CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.0844420190512074,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); + for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) + (*iter)->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + // Tangent intersection + QUADRATIC_PLANAR::setPrecision(1e-5); + for(unsigned k=0;k<8;k++) + { + double center2[2]; center[0]=0.; center[1]=0.; + center2[0]=4.*cos(k*M_PI/4.); center2[1]=4.*sin(k*M_PI/4.); + e1=buildArcOfCircle(center,1.,(k+1)*M_PI/4.,(k-1)*M_PI/4.); + e2=buildArcOfCircle(center2,3.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); + intersector=new ArcCArcCIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); // order has no sence here because v4.size() expected to 1 but for valgrind serenity test. + CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); + for(vector::iterator iter=v4.begin();iter!=v4.end();iter++) + (*iter)->decrRef(); + v4.clear(); v4.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + QUADRATIC_PLANAR::setPrecision(1e-14); + // Extremities # 1 + for(unsigned k=0;k<8;k++) + { + center[0]=0.; center[1]=0.; + double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); + e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); + e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.-0.55978664859225125,M_PI+k*M_PI/4.+0.55978664859225125); + intersector=new ArcCArcCIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(!intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT_EQUAL(0,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getStartNode()==e1->getEndNode()); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + for(unsigned k=0;k<8;k++) + { + center[0]=0.; center[1]=0.; + double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); + e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); + e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.55978664859225125,M_PI+k*M_PI/4.-0.55978664859225125); + intersector=new ArcCArcCIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(!intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT_EQUAL(0,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==e1->getEndNode()); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + // Extremities # 2 + for(unsigned k=0;k<8;k++) + { + center[0]=0.; center[1]=0.; + double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); + e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); + e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.55978664859225125,M_PI+k*M_PI/4.-0.7); + intersector=new ArcCArcCIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); + CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v4[0]); + v4[0]->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + // Extremities # 3 + for(unsigned k=0;k<8;k++) + { + center[0]=0.; center[1]=0.; + double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); + e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); + e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.7,M_PI+k*M_PI/4.-0.7); + intersector=new ArcCArcCIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(e1->getStartNode()==v4[0]); CPPUNIT_ASSERT(e1->getEndNode()==v4[1]); + v4[0]->decrRef(); v4[1]->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + // Extremities # 4 + for(unsigned k=0;k<8;k++) + { + center[0]=0.; center[1]=0.; + double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); + Node *nodeS=new Node(center[0]+3.*cos(k*M_PI/4.-0.17793931986099812),center[1]+3.*sin(k*M_PI/4.-0.17793931986099812)); + Node *nodeE=new Node(center[0]+3.*cos(k*M_PI/4.),center[1]+3.*sin(k*M_PI/4.)); + double angle=k*M_PI/4.-0.17793931986099812; + angle=angle>M_PI?angle-2.*M_PI:angle; + e1=new EdgeArcCircle(nodeS,nodeE,//Problem of precision 1e-14 to easily reached. + center,3.,angle,0.17793931986099812); + nodeS->decrRef(); nodeE->decrRef(); + e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.7,M_PI+k*M_PI/4.-0.7); + intersector=new ArcCArcCIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(e1->getStartNode()==v4[0]); + v4[0]->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } + //Extremities # 5 + for(unsigned k=0;k<8;k++) + { + center[0]=0.; center[1]=0.; + double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); + Node *nodeS=new Node(center[0]+3.*cos(k*M_PI/4.-0.17793931986099812),center[1]+3.*sin(k*M_PI/4.-0.17793931986099812)); + Node *nodeE=new Node(center[0]+3.*cos(k*M_PI/4.)+0.5,center[1]+3.*sin(k*M_PI/4.)); + double angle=k*M_PI/4.-0.17793931986099812; + angle=angle>M_PI?angle-2.*M_PI:angle; + e1=new EdgeArcCircle(nodeS,nodeE,//Problem of precision 1e-14 to easily reached. + center,3.,angle,0.67793931986099812); + nodeS->decrRef(); nodeE->decrRef(); + e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.7,M_PI+k*M_PI/4.-0.7); + intersector=new ArcCArcCIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT(e1->getStartNode()==v4[0]); + v4[0]->decrRef(); v4[1]->decrRef(); + v4.clear(); v3.clear(); + delete intersector; e2->decrRef(); e1->decrRef(); + } +} + +void QuadraticPlanarInterpTest::IntersectArcCircleFull() +{ + double center1[2]; center1[0]=0.; center1[1]=0.; double radius1=3.; + double center2[2]; center2[0]=0.75; center2[1]=-2.6; double radius2=1.; + EdgeArcCircle *e1=buildArcOfCircle(center1,radius1,-M_PI/3.,4.*M_PI/3.); + EdgeArcCircle *e2=buildArcOfCircle(center2,radius2,0.,M_PI/2.); + MergePoints commonNode; + QuadraticPolygon pol1; QuadraticPolygon pol2; + QuadraticPolygon pol3; QuadraticPolygon pol4; + pol3.pushBack(e1); pol4.pushBack(e2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol3.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol4.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(19.6648305849,pol3.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol4.getArea(),1e-6); + CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol1,pol2)); + CPPUNIT_ASSERT_EQUAL(2,pol1.size()); + CPPUNIT_ASSERT_EQUAL(2,pol2.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(19.6648305849,pol1.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol2.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol1.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol2.getPerimeter(),1e-6); + // + e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); + e2=buildArcOfCircle(center2,radius2,0.,M_PI/2.); + commonNode.clear(); + QuadraticPolygon pol5; QuadraticPolygon pol6; + QuadraticPolygon pol7; QuadraticPolygon pol8; + pol7.pushBack(e1); pol8.pushBack(e2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol7.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol8.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol7.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol8.getArea(),1e-6); + CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol5,pol6)); + CPPUNIT_ASSERT_EQUAL(2,pol5.size()); + CPPUNIT_ASSERT_EQUAL(2,pol6.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol5.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol6.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol5.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol6.getPerimeter(),1e-6); + // + center2[0]=3.5; center2[1]=0.; + e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); + e2=buildArcOfCircle(center2,radius2,M_PI/2.,3*M_PI/2.); + commonNode.clear(); + QuadraticPolygon pol9; QuadraticPolygon pol10; + QuadraticPolygon pol11; QuadraticPolygon pol12; + pol11.pushBack(e1); pol12.pushBack(e2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol11.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol12.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol11.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol12.getArea(),1e-6); + CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol9,pol10)); + CPPUNIT_ASSERT_EQUAL(3,pol9.size()); + CPPUNIT_ASSERT_EQUAL(3,pol10.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol9.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol10.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol9.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol10.getArea(),1e-6); + // + center2[0]=0.; center2[1]=0.; radius2=radius1; + e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); + e2=buildArcOfCircle(center2,radius2,M_PI/3.,2*M_PI/3.); + commonNode.clear(); + QuadraticPolygon pol13; QuadraticPolygon pol14; + QuadraticPolygon pol15; QuadraticPolygon pol16; + pol15.pushBack(e1); pol16.pushBack(e2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol15.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol16.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol15.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(8.6095032974147,pol16.getArea(),1e-6); + CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol13,pol14)); + CPPUNIT_ASSERT_EQUAL(3,pol13.size()); + CPPUNIT_ASSERT_EQUAL(1,pol14.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol13.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol13.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol14.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(8.6095032974147,pol14.getArea(),1e-6); + // + e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); + e2=buildArcOfCircle(center2,radius2,2*M_PI/3.,M_PI/3.); + commonNode.clear(); + QuadraticPolygon pol17; QuadraticPolygon pol18; + QuadraticPolygon pol19; QuadraticPolygon pol20; + pol19.pushBack(e1); pol20.pushBack(e2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol19.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol20.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol19.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.6095032974147,pol20.getArea(),1e-6); + CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol17,pol18)); + CPPUNIT_ASSERT_EQUAL(3,pol17.size()); + CPPUNIT_ASSERT_EQUAL(1,pol18.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol17.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol17.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol18.getPerimeter(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.6095032974147,pol18.getArea(),1e-6); + //no intersection #1 + center2[0]=4.277; center2[1]=-4.277; + e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); + e2=buildArcOfCircle(center2,radius2,M_PI/4.,5*M_PI/4.); + QuadraticPolygon polTemp1; QuadraticPolygon polTemp2; + CPPUNIT_ASSERT(!e1->intersectWith(e2,commonNode,polTemp1,polTemp2)); + e1->decrRef(); e2->decrRef(); + //no intersection #2 + center2[0]=1.; center2[1]=-1.; radius2=0.2; + e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); + e2=buildArcOfCircle(center2,radius2,M_PI/4.,5*M_PI/4.); + CPPUNIT_ASSERT(!e1->intersectWith(e2,commonNode,polTemp1,polTemp2)); + e1->decrRef(); e2->decrRef(); +} + +void QuadraticPlanarInterpTest::IntersectArcCircleSegumentBase() +{ + double center[2]={2.,2.}; + EdgeArcCircle *e1=buildArcOfCircle(center,2.3,M_PI/4.,5.*M_PI/4.); + EdgeLin *e2=new EdgeLin(-1.3,1.,3.,5.3); + EdgeIntersector *intersector=new ArcCSegIntersector(*e1,*e2); + bool order; + bool obvious,areOverlapped; + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); + CPPUNIT_ASSERT(!obvious && !areOverlapped); + vector v4; + MergePoints v3; + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[0])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.3,(*v4[0])[1],1e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.3,(*v4[1])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[1])[1],1e-10); + v4[0]->decrRef(); v4[1]->decrRef(); e2->decrRef(); v3.clear(); v4.clear(); delete intersector; + // + e2=new EdgeLin(3.,5.3,-1.3,1.); + intersector=new ArcCSegIntersector(*e1,*e2); + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[0])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.3,(*v4[0])[1],1e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.3,(*v4[1])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[1])[1],1e-10); + v4[0]->decrRef(); v4[1]->decrRef(); e2->decrRef(); v3.clear(); v4.clear(); delete intersector; + // tangent intersection + e2=new EdgeLin(-1.,4.3,3.,4.3); + intersector=new ArcCSegIntersector(*e1,*e2); + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); CPPUNIT_ASSERT(!obvious && !areOverlapped); + CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[0])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.3,(*v4[0])[1],1e-10); + v4[0]->decrRef(); e2->decrRef(); v3.clear(); delete intersector; + // no intersection + e2=new EdgeLin(-2.,-2.,-1.,-3.); + intersector=new ArcCSegIntersector(*e1,*e2); + intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); CPPUNIT_ASSERT(obvious && !areOverlapped); + e2->decrRef(); v3.clear(); delete intersector; + // + e1->decrRef(); +} + +QuadraticPolygon *QuadraticPlanarInterpTest::buildQuadraticPolygonCoarseInfo(const double *coords, const int *conn, int lgth) +{ + vector nodes; + for(int i=0;i +#include +#include + +using namespace std; +using namespace INTERP_KERNEL; + + +void QuadraticPlanarInterpTest::checkInOutDetection() +{ + Node *n1=new Node(0.,0.); + Node *n2=new Node(1.,0.); + Node *n3=new Node(0.5,1.); + EdgeLin *e1=new EdgeLin(n1,n2); + EdgeLin *e2=new EdgeLin(n2,n3); + EdgeLin *e3=new EdgeLin(n3,n1); + ComposedEdge *tri=new ComposedEdge; + tri->pushBack(e1); tri->pushBack(e2); tri->pushBack(e3); + // + Node *where=new Node(0.4,0.1); + CPPUNIT_ASSERT(tri->isInOrOut(where)); where->decrRef(); + where=new Node(-0.1,1.); + CPPUNIT_ASSERT(!tri->isInOrOut(where)); where->decrRef(); + where=new Node(0.6,-0.1); + CPPUNIT_ASSERT(!tri->isInOrOut(where)); where->decrRef(); + //Clean-up + n1->decrRef(); n2->decrRef(); n3->decrRef(); + ComposedEdge::Delete(tri); +} + +/*! + * Check Iterators mechanism. + */ +void QuadraticPlanarInterpTest::checkAssemblingBases1() +{ + Node *n1=new Node(0.,0.); + Node *n2=new Node(0.1,0.); EdgeLin *e1_2=new EdgeLin(n1,n2); + Node *n3=new Node(0.2,0.); EdgeLin *e2_3=new EdgeLin(n2,n3); + Node *n4=new Node(0.3,0.); EdgeLin *e3_4=new EdgeLin(n3,n4); + Node *n5=new Node(0.4,0.); EdgeLin *e4_5=new EdgeLin(n4,n5); + Node *n6=new Node(0.5,0.); EdgeLin *e5_6=new EdgeLin(n5,n6); + Node *n7=new Node(0.6,0.); EdgeLin *e6_7=new EdgeLin(n6,n7); + Node *n8=new Node(0.7,0.); EdgeLin *e7_8=new EdgeLin(n7,n8); + Node *n9=new Node(0.8,0.); EdgeLin *e8_9=new EdgeLin(n8,n9); + Node *n10=new Node(0.9,0.); EdgeLin *e9_10=new EdgeLin(n9,n10); + Node *n11=new Node(1.,0.); EdgeLin *e10_11=new EdgeLin(n10,n11); + Node *n12=new Node(0.5,1.); EdgeLin *e11_12=new EdgeLin(n11,n12); + EdgeLin *e12_1=new EdgeLin(n12,n1); + //Only one level + e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef(); + e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef(); + ComposedEdge *c=new ComposedEdge; + c->pushBack(e1_2); c->pushBack(e2_3); c->pushBack(e3_4); c->pushBack(e4_5); c->pushBack(e5_6); c->pushBack(e6_7); + c->pushBack(e7_8); c->pushBack(e8_9); c->pushBack(e9_10); c->pushBack(e10_11); c->pushBack(e11_12); c->pushBack(e12_1); + CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize()); + IteratorOnComposedEdge it(c); + CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); + it.next(); CPPUNIT_ASSERT(it.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it.finished()); + it.next(); it.next(); CPPUNIT_ASSERT(it.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it.finished()); + it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it.finished()); + it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it.finished()); + it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); + it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished()); + it.next(); CPPUNIT_ASSERT(it.finished()); + it.first(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); + it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished()); + it.nextLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); + it.last(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished()); + //Multi-Level + ComposedEdge::Delete(c); + //(e1_2, (e2_3,(e3_4, e4_5, e5_6, e6_7, (e7_8, e8_9 ), ( e9_10 , e10_11 ), e11_12 ),e12_1 ) ) + e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef(); + e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef(); + ComposedEdge *c2_2_4=new ComposedEdge; c2_2_4->pushBack(e7_8); c2_2_4->pushBack(e8_9); + ComposedEdge *c2_2_5=new ComposedEdge; c2_2_5->pushBack(e9_10); c2_2_5->pushBack(e10_11); + ComposedEdge *c2_2=new ComposedEdge; c2_2->pushBack(e3_4); c2_2->pushBack(e4_5); c2_2->pushBack(e5_6); c2_2->pushBack(e6_7); c2_2->pushBack(c2_2_4); c2_2->pushBack(c2_2_5); c2_2->pushBack(e11_12); + ComposedEdge *c2=new ComposedEdge; c2->pushBack(e2_3); c2->pushBack(c2_2); c2->pushBack(e12_1); + c=new ComposedEdge; c->pushBack(e1_2); c->pushBack(c2); CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize()); + IteratorOnComposedEdge it2(c); + CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); + it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); + it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); + it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); + it2.next(); CPPUNIT_ASSERT(it2.finished()); + it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); + it2.last(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); + it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); + // substitutions. + /*it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); + ElementaryEdge *&tmp=it2.current(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); + ComposedEdge *c1=new ComposedEdge; Node *n1_bis=new Node(0.,0.05); EdgeLin *e1_1bis=new EdgeLin(n1,n1_bis); EdgeLin *e1bis_2=new EdgeLin(n1_bis,n2); e1_1bis->incrRef(); e1bis_2->incrRef(); + c1->pushBack(e1_1bis); c1->pushBack(e1bis_2); delete tmp; tmp=(ElementaryEdge *)c1; CPPUNIT_ASSERT_EQUAL(13,c->recursiveSize()); + CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());// here testing capability of Iterator.'current' method to deal with change of hierarchy. + it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); + it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e11_12); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e10_11); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e9_10); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e8_9); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e7_8); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e6_7); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e5_6); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished()); + it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); + //go forward + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e5_6); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e6_7); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e7_8); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e8_9); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e9_10); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e10_11); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e11_12); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); + it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());*/ + ComposedEdge::SoftDelete(c2_2_4); + ComposedEdge::SoftDelete(c2_2_5); + ComposedEdge::SoftDelete(c2_2); + ComposedEdge::SoftDelete(c2); + ComposedEdge::Delete(c); + //clean-up + //e1_1bis->decrRef(); e1bis_2->decrRef(); + e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_7->decrRef(); + e7_8->decrRef(); e8_9->decrRef(); e9_10->decrRef(); e10_11->decrRef(); e11_12->decrRef(); e12_1->decrRef(); + //n1_bis->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + n7->decrRef(); n8->decrRef(); n9->decrRef(); n10->decrRef(); n11->decrRef(); n12->decrRef(); +} + +/*! + * Check splitting of 2 polygons. After this operation, all ElementaryEdge are either in/out/on. + */ +void QuadraticPlanarInterpTest::checkAssemblingBases2() +{ + //The "most" basic test1 + Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-0.3); + Node *n2=new Node(1.,0.); Node *n5=new Node(1.,-0.3); + Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.7); + EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); + EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); + EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); + // + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); + QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); + QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); + QuadraticPolygon cpyPol1(pol1); int nbOfSplits=0; + cpyPol1.splitPolygonsEachOther(pol1,pol2,nbOfSplits); + CPPUNIT_ASSERT_EQUAL(5,pol1.recursiveSize()); + CPPUNIT_ASSERT_EQUAL(5,pol2.recursiveSize());CPPUNIT_ASSERT_EQUAL(15,nbOfSplits); + checkBasicsOfPolygons(pol1,pol2,true); + CPPUNIT_ASSERT(pol2[1]->getEndNode()==pol1[1]->getEndNode()); + CPPUNIT_ASSERT(pol2[1]->getEndNode()->getLoc()==ON_1); + CPPUNIT_ASSERT(pol2[3]->getEndNode()==pol1[0]->getEndNode()); + CPPUNIT_ASSERT(pol2[3]->getEndNode()->getLoc()==ON_1); + cpyPol1.performLocatingOperation(pol2); + ElementaryEdge *tmp=dynamic_cast(pol2[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); + tmp=dynamic_cast(pol2[1]); CPPUNIT_ASSERT(tmp); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); + tmp=dynamic_cast(pol2[2]); CPPUNIT_ASSERT(tmp); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1); + tmp=dynamic_cast(pol2[3]); CPPUNIT_ASSERT(tmp); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1); + tmp=dynamic_cast(pol2[4]); CPPUNIT_ASSERT(tmp); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); + //clean-up for test1 + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + + //Deeper test some extremities of pol2 are on edges of pol1. + + n1=new Node(0.,0.); n4=new Node(1.5,-0.5); + n2=new Node(1.,0.); n5=new Node(0.5,0.); + n3=new Node(0.5,1.); n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5); + e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); + EdgeLin *e5_4=new EdgeLin(n5,n4); EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_6=new EdgeLin(n7,n6); EdgeLin *e6_5=new EdgeLin(n6,n5); + // + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef(); + QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); + QuadraticPolygon pol4; pol4.pushBack(e5_4); pol4.pushBack(e4_7); pol4.pushBack(e7_6); pol4.pushBack(e6_5); + QuadraticPolygon cpyPol3(pol3); nbOfSplits=0; + cpyPol3.splitPolygonsEachOther(pol3,pol4,nbOfSplits); + CPPUNIT_ASSERT_EQUAL(5,pol3.recursiveSize()); + CPPUNIT_ASSERT_EQUAL(4,pol4.recursiveSize());CPPUNIT_ASSERT_EQUAL(16,nbOfSplits); + checkBasicsOfPolygons(pol3,pol4,true); + CPPUNIT_ASSERT(pol4[0]->getStartNode()==pol3[0]->getEndNode()); CPPUNIT_ASSERT(pol4[0]->getStartNode()==n5); + CPPUNIT_ASSERT(n5->getLoc()==ON_LIM_1); + CPPUNIT_ASSERT(pol4[2]->getEndNode()==pol3[2]->getEndNode()); CPPUNIT_ASSERT(pol4[2]->getEndNode()==n6); + CPPUNIT_ASSERT(n6->getLoc()==ON_LIM_1); + cpyPol3.performLocatingOperation(pol4); + tmp=dynamic_cast(pol4[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_7); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); + tmp=dynamic_cast(pol4[3]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e6_5); + tmp=dynamic_cast(pol4[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e5_4); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); + tmp=dynamic_cast(pol4[2]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e7_6); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); + tmp=dynamic_cast(pol4[3]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e6_5); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1); + //clean-up for test2 + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e5_4->decrRef(); e4_7->decrRef(); e7_6->decrRef(); e6_5->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); + + //Test with one edge of pol2 is included in pol1. + + n1=new Node(0.,0.); n4=new Node(-0.5,0.); + n2=new Node(1.,0.); n5=new Node(0.,-1.); + n3=new Node(0.5,1.); n6=new Node(0.5,0.); + e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); + e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); + QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1); + QuadraticPolygon pol6; pol6.pushBack(e4_5); pol6.pushBack(e5_6); pol6.pushBack(e6_4); + QuadraticPolygon cpyPol5(pol5); nbOfSplits=0; + cpyPol5.splitPolygonsEachOther(pol5,pol6,nbOfSplits); + CPPUNIT_ASSERT_EQUAL(4,pol5.recursiveSize()); + CPPUNIT_ASSERT_EQUAL(4,pol6.recursiveSize()); CPPUNIT_ASSERT_EQUAL(13,nbOfSplits); + checkBasicsOfPolygons(pol5,pol6,false); + CPPUNIT_ASSERT(pol6[2]->getStartNode()==pol5[0]->getEndNode()); CPPUNIT_ASSERT(pol6[2]->getStartNode()==n6); + CPPUNIT_ASSERT(n6->getLoc()==ON_LIM_1); + CPPUNIT_ASSERT(pol6[2]->getEndNode()==pol5[0]->getStartNode()); CPPUNIT_ASSERT(pol5[0]->getStartNode()==n1); + CPPUNIT_ASSERT(n1->getLoc()==ON_LIM_1); + cpyPol5.performLocatingOperation(pol6); + tmp=dynamic_cast(pol6[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); + tmp=dynamic_cast(pol6[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e5_6); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); + tmp=dynamic_cast(pol6[2]); CPPUNIT_ASSERT(tmp); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); + tmp=dynamic_cast(pol6[3]); CPPUNIT_ASSERT(tmp); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); + //clean-up test3 + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + + //Test of full overlapped polygons. + + n1=new Node(0.,0.); n4=new Node(0.,0.); + n2=new Node(1.,0.); n5=new Node(1.,0.); + n3=new Node(0.5,1.); n6=new Node(0.5,1.); + e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); + e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); + QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1); + QuadraticPolygon pol8; pol8.pushBack(e4_5); pol8.pushBack(e5_6); pol8.pushBack(e6_4); + QuadraticPolygon cpyPol7(pol7); nbOfSplits=0; + cpyPol7.splitPolygonsEachOther(pol7,pol8,nbOfSplits); + tmp=dynamic_cast(pol8[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e1_2); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); + tmp=dynamic_cast(pol8[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e2_3); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); + tmp=dynamic_cast(pol8[2]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e3_1); + CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); + //clean-up test4 + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); +} + +void QuadraticPlanarInterpTest::checkBasicsOfPolygons(QuadraticPolygon& pol1, QuadraticPolygon& pol2, bool checkDirection) +{ + IteratorOnComposedEdge it1(&pol1),it2(&pol2); it1.previousLoop(); it2.previousLoop(); + Node *nIter1=it1.current()->getEndNode(); Node *nIter2=it2.current()->getEndNode(); + for(it2.first();!it2.finished();it2.next()) + { + CPPUNIT_ASSERT(nIter2==it2.current()->getStartNode()); + if(checkDirection) + CPPUNIT_ASSERT(it2.current()->getDirection()); + nIter2=it2.current()->getEndNode(); + } + for(it1.first();!it1.finished();it1.next()) + { + CPPUNIT_ASSERT(nIter1==it1.current()->getStartNode()); + if(checkDirection) + CPPUNIT_ASSERT(it1.current()->getDirection()); + nIter1=it1.current()->getEndNode(); + } +} diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx new file mode 100644 index 000000000..cffd067b6 --- /dev/null +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx @@ -0,0 +1,1659 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "QuadraticPlanarInterpTest.hxx" +#include "QuadraticPolygon.hxx" +#include "ElementaryEdge.hxx" +#include "EdgeArcCircle.hxx" +#include "EdgeLin.hxx" + +#include +#include +#include +#include + +using namespace std; +using namespace INTERP_KERNEL; + +void QuadraticPlanarInterpTest::checkPolygonsIntersection1() +{ + //The "most" basic test1 + Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-0.3); + Node *n2=new Node(1.,0.); Node *n5=new Node(1.,-0.3); + Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.7); + EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); + EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); + EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); + // + vector result; + for(int k=0;k<2;k++) + for(int i=0;i<3;i++) + { + for(int j=0;j<1;j++) + { + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); + QuadraticPolygon pol1; pol1.circularPermute(); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); + for(int i1=0;i1recursiveSize()); + double tmp1=0.,tmp2=0.,tmp3=0.; + pol1.intersectForPerimeter(pol2,tmp1,tmp2,tmp3); + vector v1,v2; + vector v3; + pol1.intersectForPerimeterAdvanced(pol2,v1,v2);//no common edge + pol1.intersectForPoint(pol2,v3); + CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); + CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); + CPPUNIT_ASSERT_EQUAL(3,(int)v3.size()); + if(k==0) + { + CPPUNIT_ASSERT_EQUAL(2,v3[(3-i)%3]); + CPPUNIT_ASSERT_EQUAL(0,v3[(4-i)%3]); + CPPUNIT_ASSERT_EQUAL(0,v3[(5-i)%3]); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,v1[(3-i)%3],1.e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(4-i)%3],1.e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(5-i)%3],1.e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v2[0],1.e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[1],1.e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[2],1.e-14); + } + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,tmp1,1.e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5652475842498528,tmp2,1.e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp3,1.e-14);//no common edge + delete result[0]; + } + } + //clean-up for test1 + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + + //Deeper test some extremities of pol2 are on edges of pol1. + + n1=new Node(0.,0.); n4=new Node(1.5,-0.5); + n2=new Node(1.,0.); n5=new Node(0.5,0.); + n3=new Node(0.5,1.); n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5); + e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); + EdgeLin *e5_4=new EdgeLin(n5,n4); EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_6=new EdgeLin(n7,n6); EdgeLin *e6_5=new EdgeLin(n6,n5); + // + for(int k=0;k<2;k++) + for(int i=0;i<3;i++) + { + for(int j=0;j<4;j++) + { + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef(); + QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); + for(int i1=0;i1recursiveSize()); + delete result[0]; + } + } + //clean-up for test2 + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e5_4->decrRef(); e4_7->decrRef(); e7_6->decrRef(); e6_5->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); + + //Test with one edge of pol2 is included in pol1. + + n1=new Node(0.,0.); n4=new Node(-0.5,0.); + n2=new Node(1.,0.); n5=new Node(0.,-1.); + n3=new Node(0.5,1.); n6=new Node(0.5,0.); + e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); + e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); + for(int k=0;k<2;k++) + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); + QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1); + for(int i1=0;i1decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + + //Test of full overlapped polygons. + + n1=new Node(0.,0.); n4=new Node(0.,0.); + n2=new Node(1.,0.); n5=new Node(1.,0.); + n3=new Node(0.5,1.); n6=new Node(0.5,1.); + e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); + e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); + for(int k=0;k<2;k++) + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); + QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1); + for(int i1=0;i1recursiveSize()); + delete result[0]; + double tmp1=0.,tmp2=0.,tmp3=0.; + pol7.intersectForPerimeter(pol8,tmp1,tmp2,tmp3); + vector v1,v2; + pol7.intersectForPerimeterAdvanced(pol8,v1,v2);//only common edges. + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v1[0]+v1[1]+v1[2],1.e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v2[0]+v2[1]+v2[2],1.e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp1,1.e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp2,1.e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,tmp3,1.e-14); + } + } + //clean-up test4 + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + + //Test of closing process + + n1=new Node(0.,0.); n4=new Node(0.539,-0.266); + n2=new Node(1.,0.); n5=new Node(1.039,0.6); + n3=new Node(0.5,1.); n6=new Node(-0.077,0.667); + e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); + e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); + for(int k=0;k<2;k++) + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); + QuadraticPolygon pol9; pol9.pushBack(e1_2); pol9.pushBack(e2_3); pol9.pushBack(e3_1); + for(int i1=0;i1recursiveSize()); + delete result[0]; + } + } + //clean-up test5 + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + + // Full in case + + n1=new Node(0.,0.); n4=new Node(0.3,0.1); + n2=new Node(1.,0.); n5=new Node(0.7,0.1); + n3=new Node(0.5,1.); n6=new Node(0.5,0.7); + e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); + e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); + for(int k=0;k<2;k++) + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); + QuadraticPolygon pol11; pol11.pushBack(e1_2); pol11.pushBack(e2_3); pol11.pushBack(e3_1); + for(int i1=0;i1recursiveSize()); + delete result[0]; + } + } + //clean-up test6 + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + + // Full out case + + n1=new Node(0.,0.); n4=new Node(-2,0.); + n2=new Node(1.,0.); n5=new Node(-1.,0.); + n3=new Node(0.5,1.); n6=new Node(-1.5,1.); + e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); + e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); + for(int k=0;k<2;k++) + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); + QuadraticPolygon pol13; pol13.pushBack(e1_2); pol13.pushBack(e2_3); pol13.pushBack(e3_1); + for(int i1=0;i1decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + + //Multi polygons + + n1=new Node(0.,0.); + n2=new Node(1.,0.); + n3=new Node(1.,1.); + n4=new Node(0.,1.); + // + n5=new Node(0.2,0.7); + n6=new Node(0.4,0.7); + n7=new Node(0.4,1.3); + Node *n8=new Node(0.6,1.3); + Node *n9=new Node(0.6,0.7); + Node *n10=new Node(0.9,0.7); + Node *n11=new Node(0.9,2.); + Node *n12=new Node(0.2,2.); + // + e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); Edge *e3_4=new EdgeLin(n3,n4); Edge *e4_1=new EdgeLin(n4,n1); + e5_6=new EdgeLin(n5,n6); Edge *e6_7=new EdgeLin(n6,n7); Edge *e7_8=new EdgeLin(n7,n8); Edge *e8_9=new EdgeLin(n8,n9); Edge *e9_10=new EdgeLin(n9,n10); Edge *e10_11=new EdgeLin(n10,n11); + Edge *e11_12=new EdgeLin(n11,n12); Edge *e12_1=new EdgeLin(n12,n5); + // + for(int k=0;k<2;k++) + for(int i=0;i<4;i++) + { + for(int j=0;j<8;j++) + { + e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef(); e5_6->incrRef(); e6_7->incrRef(); e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef(); + QuadraticPolygon pol15; pol15.pushBack(e1_2); pol15.pushBack(e2_3); pol15.pushBack(e3_4); pol15.pushBack(e4_1); + for(int i1=0;i1recursiveSize()); CPPUNIT_ASSERT_EQUAL(4,result[1]->recursiveSize()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,result[0]->getArea()+result[1]->getArea(),1e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.03,fabs(result[0]->getArea()-result[1]->getArea()),1e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,pol15.intersectWith(pol16),1e-10); + delete result[0]; delete result[1]; + } + } + //clean-up test8 + e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); e5_6->decrRef(); e6_7->decrRef(); e7_8->decrRef(); e8_9->decrRef(); e9_10->decrRef(); e10_11->decrRef(); e11_12->decrRef(); e12_1->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); n8->decrRef(); n9->decrRef(); n10->decrRef(); n11->decrRef(); n12->decrRef(); +} + +/*! + * Testing case where a polygon pol1 is included in an onother polygon pol2. + */ +void QuadraticPlanarInterpTest::checkPolygonsIntersection2() +{ + Node *n1=new Node(0.,0.); Node *n4=new Node(0.2,0.2); + Node *n2=new Node(1.,0.); Node *n5=new Node(0.8,0.2); + Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.8); + Edge *e1_2=new EdgeLin(n1,n2); Edge *e4_5=new EdgeLin(n4,n5); + Edge *e2_3=new EdgeLin(n2,n3); Edge *e5_6=new EdgeLin(n5,n6); + Edge *e3_1=new EdgeLin(n3,n1); Edge *e6_4=new EdgeLin(n6,n4); + // + QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); + QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); + vector result=pol1.intersectMySelfWith(pol2); + CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); + CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10); + delete result[0]; + result.clear(); + pol1.initLocations(); + pol2.initLocations(); + result=pol2.intersectMySelfWith(pol1); + CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); + CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10); + delete result[0]; + //clean-up + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); +} + +void QuadraticPlanarInterpTest::checkAreasCalculations() +{ + Node *n1=new Node(0.,0.); + Node *n2=new Node(1.,0.); + Node *n3=new Node(0.5,1.); + Edge *e1_2=new EdgeLin(n1,n2); + Edge *e2_3=new EdgeLin(n2,n3); + Edge *e3_1=new EdgeLin(n3,n1); + // + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); + QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,pol1.getArea(),1e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,pol1.getPerimeter(),1e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.61803398874989479,pol1.getHydraulicDiameter(),1e-10); + pol1.reverse(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.5,pol1.getArea(),1e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,pol1.getPerimeter(),1e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.61803398874989479,pol1.getHydraulicDiameter(),1e-10); + //clean-up + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); + + //case 2 + + n1=new Node(0.,0.); + n2=new Node(1.,0.); + Node *n3m=new Node(1.5,0.5); + n3=new Node(1.,1.); + Node *n4=new Node(0.,1.); + e1_2=new EdgeLin(n1,n2); + e2_3=new EdgeArcCircle(n2,n3m,n3); + Edge *e3_4=new EdgeLin(n3,n4); + Edge *e4_1=new EdgeLin(n4,n1); + // + for(int k=0;k<8;k++) + { + n2->setNewCoords(cos(k*M_PI/4),sin(k*M_PI/4)); + n3->setNewCoords(sqrt(2.)*cos((k+1)*M_PI/4),sqrt(2.)*sin((k+1)*M_PI/4)); + n3m->setNewCoords(1.5811388300841898*cos(0.3217505543966423+k*M_PI/4),1.5811388300841898*sin(0.3217505543966423+k*M_PI/4)); + n4->setNewCoords(cos(k*M_PI/4+M_PI/2),sin(k*M_PI/4+M_PI/2)); + e1_2->update(n3m); e2_3->update(n3m); e3_4->update(n3m); e4_1->update(n3m); + e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef(); + QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_3); pol2.pushBack(e3_4); pol2.pushBack(e4_1); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.3926990816987241,pol2.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6); + pol2.reverse(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.3926990816987241,pol2.getArea(),1e-6); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6); + } + //clean-up case2 + e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef(); + + //case 3 + + const double radius1=0.7; + const double radius2=0.9; + n1=new Node(1.+radius1*cos(-2.*M_PI/3.),1.+radius1*sin(-2.*M_PI/3.)); + n2=new Node(1.+radius1*cos(-M_PI/3.),1.+radius1*sin(-M_PI/3.)); + Node *n2m=new Node(1.+radius1*cos(M_PI/2.),1.+radius1*sin(M_PI/2.)); + n3=new Node(1.+radius2*cos(-M_PI/3.),1.+radius2*sin(-M_PI/3.)); + n3m=new Node(1.+radius2*cos(M_PI/2.),1.+radius2*sin(M_PI/2.)); + n4=new Node(1.+radius2*cos(-2.*M_PI/3.),1.+radius2*sin(-2.*M_PI/3.)); + e1_2=new EdgeArcCircle(n1,n2m,n2); + e2_3=new EdgeLin(n2,n3); + e3_4=new EdgeArcCircle(n3,n3m,n4); + e4_1=new EdgeLin(n4,n1); + // + e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef(); + QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_4); pol3.pushBack(e4_1); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.83775804095727857,pol3.getArea(),1e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10); + pol3.reverse(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.83775804095727857,pol3.getArea(),1e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10); + //clean-up case3 + e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); + n1->decrRef(); n2->decrRef(); n2m->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef(); +} + +void QuadraticPlanarInterpTest::checkBarycenterCalculations() +{ + Node *n1=new Node(3.,7.); + Node *n2=new Node(5.,7.); + Node *n3=new Node(4.,8.); + Edge *e1_2=new EdgeLin(n1,n2); + Edge *e2_3=new EdgeLin(n2,n3); + Edge *e3_1=new EdgeLin(n3,n1); + // + double bary[2]; + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); + QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); + bary[0]=0.; bary[1]=0.; + e1_2->getBarycenterOfZone(bary); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-56.,bary[0],1.e-10); + bary[0]=0.; bary[1]=0.; + e2_3->getBarycenterOfZone(bary); + CPPUNIT_ASSERT_DOUBLES_EQUAL(33.66666666666667,bary[0],1.e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(28.16666666666667,bary[1],1.e-10); + bary[0]=0.; bary[1]=0.; + e3_1->getBarycenterOfZone(bary); + CPPUNIT_ASSERT_DOUBLES_EQUAL(26.333333333333336,bary[0],1.e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(28.1666666666667,bary[1],1.e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,pol1.getArea(),1e-10); + pol1.getBarycenter(bary); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10); + // + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); + QuadraticPolygon pol4; pol4.pushBack(e3_1,false); pol4.pushBack(e2_3,false); pol4.pushBack(e1_2,false); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol4.getArea(),1e-10); + pol4.getBarycenter(bary); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10); + //clean-up + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); + //Inverting polygon + n1=new Node(3.,7.); + n2=new Node(5.,7.); + n3=new Node(4.,8.); + e1_2=new EdgeLin(n1,n3); + e2_3=new EdgeLin(n3,n2); + e3_1=new EdgeLin(n2,n1); + e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); + QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); + bary[0]=0.; bary[1]=0.; + pol3.getBarycenter(bary); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol3.getArea(),1e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10); + //clean-up + e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); + n1->decrRef(); n2->decrRef(); n3->decrRef(); + // + double center[2]={3.,7.}; + e1_2=buildArcOfCircle(center,4.,M_PI/3.,4.*M_PI/3.); + bary[0]=0.; bary[1]=0.; + e1_2->getBarycenterOfZone(bary); + CPPUNIT_ASSERT_DOUBLES_EQUAL(131.685410765053,bary[0],1.e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(303.262521934362,bary[1],1.e-10); + n1=new Node(0.99999999999999822,3.5358983848622465); + n2=new Node(5.,10.4641016151377544); + Edge *e2_1=new EdgeLin(n1,n2); + // + e1_2->incrRef(); e2_1->incrRef(); + QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_1); + pol2.getBarycenter(bary); + CPPUNIT_ASSERT_DOUBLES_EQUAL(25.132741228718345,pol2.getArea(),1e-10); + //4*radius/(3.*pi) + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5297896122085546,bary[0],1.e-10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(7.8488263631567756,bary[1],1.e-10); + //clean-up + e1_2->decrRef(); e2_1->decrRef(); + n1->decrRef(); n2->decrRef(); +} + +/*! + * Testing user interface high level function. + */ +void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1() +{ + QUADRATIC_PLANAR::setPrecision(1e-12); + QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); + double coords[]={ + 8.8334591186000004, 5.0999999999999996, + 7.1014083111000001, 6.0999999999999996, + 7.8334591186000004, 6.8320508074999999, + 7.9674337149000003, 5.5999999999999996, + 7.4192455562999999, 6.5142135623000001, + 8.3334591186000004, 5.9660254036999998 + }; + vector nodes; + nodes.push_back(new Node(coords)); + nodes.push_back(new Node(coords+2)); + nodes.push_back(new Node(coords+4)); + nodes.push_back(new Node(coords+6)); + nodes.push_back(new Node(coords+8)); + nodes.push_back(new Node(coords+10)); + QuadraticPolygon *pol=QuadraticPolygon::buildArcCirclePolygon(nodes); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.04719755,pol->getArea(),1e-5); + CPPUNIT_ASSERT_EQUAL(3,pol->size()); + ElementaryEdge *e0=dynamic_cast((*pol)[0]); + ElementaryEdge *e1=dynamic_cast((*pol)[1]); + ElementaryEdge *e2=dynamic_cast((*pol)[0]); + CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2); + CPPUNIT_ASSERT(dynamic_cast(e0->getPtr()));//<- testing detection of colinearity + CPPUNIT_ASSERT(dynamic_cast(e1->getPtr())); + CPPUNIT_ASSERT(dynamic_cast(e2->getPtr()));//<- testing detection of colinearity + nodes.clear(); + delete pol; + nodes.push_back(new Node(coords)); + nodes.push_back(new Node(coords+4)); + nodes.push_back(new Node(coords+2)); + nodes.push_back(new Node(coords+10)); + nodes.push_back(new Node(coords+8)); + nodes.push_back(new Node(coords+6)); + pol=QuadraticPolygon::buildArcCirclePolygon(nodes); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.04719755,pol->getArea(),1e-5); + CPPUNIT_ASSERT_EQUAL(3,pol->size()); + e0=dynamic_cast((*pol)[0]); + e1=dynamic_cast((*pol)[1]); + e2=dynamic_cast((*pol)[0]); + CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2); + CPPUNIT_ASSERT(dynamic_cast(e0->getPtr()));//<- testing detection of colinearity + CPPUNIT_ASSERT(dynamic_cast(e1->getPtr())); + CPPUNIT_ASSERT(dynamic_cast(e2->getPtr()));//<- testing detection of colinearity + delete pol; + const double coords2[]={ + 0.,0., + 1.5,0., + 1.5,1., + 0.,1. + }; + nodes.clear(); + nodes.push_back(new Node(coords2)); + nodes.push_back(new Node(coords2+2)); + nodes.push_back(new Node(coords2+4)); + nodes.push_back(new Node(coords2+6)); + pol=QuadraticPolygon::buildLinearPolygon(nodes); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,pol->getArea(),1e-12); + double tmp[2],tmp2; + pol->getBarycenter(tmp,tmp2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,tmp[0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,tmp[1],1e-12); + delete pol; + const double coords3[]={ + 1.0999999999000001, -1.9052558882999999, + 1.9052558881999999, -1.0999999999000001, + 1.7320508075000001, -0.99999999989999999, + 0.99999999989999999, -1.7320508075000001, + 1.5556349186, -1.5556349185, + 1.8186533478, -1.0499999999, + 1.4142135623000001, -1.4142135623000001, + 1.0499999999, -1.8186533479 + }; + nodes.clear(); + nodes.push_back(new Node(coords3)); + nodes.push_back(new Node(coords3+2)); + nodes.push_back(new Node(coords3+4)); + nodes.push_back(new Node(coords3+6)); + nodes.push_back(new Node(coords3+8)); + nodes.push_back(new Node(coords3+10)); + nodes.push_back(new Node(coords3+12)); + nodes.push_back(new Node(coords3+14)); + pol=QuadraticPolygon::buildArcCirclePolygon(nodes); + pol->getBarycenter(tmp,tmp2); + delete pol; + QUADRATIC_PLANAR::setPrecision(1e-14); +} + +void QuadraticPlanarInterpTest::check1DInterpLin() +{ + QUADRATIC_PLANAR::setPrecision(1e-7); + QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); + const int NB_OF_CELL_AXIAL_1=30; + static const double Z_VALS_1[NB_OF_CELL_AXIAL_1+1]= + { -0.1550 , -0.1356, -0.1162, -0.0969, -0.0775 ,-0.0581, -0.0387, -0.0194, 0.0000 , 0.0500, + 0.1000 , 0.1500 , 0.2000 , 0.2500, 0.3000, 0.3500, 0.4000, 0.4500, 0.5000, 0.5500, + 0.6000, 0.6500, 0.7000, 0.7194, 0.7388, 0.7581, 0.7775, 0.7969, 0.8163, 0.8356, + 0.8550}; + vector zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1); + + const int NB_OF_CELL_AXIAL_2=46; + static const double Z_VALS_2[NB_OF_CELL_AXIAL_2+1]= + { -0.3050 ,-0.2863,-0.2675,-0.2488,-0.2300,-0.2113,-0.1925,-0.1738,-0.1550,-0.1356 + , -0.1162,-0.0969,-0.0775,-0.0581,-0.0387,-0.0194,0.0000, 0.0500, 0.1 ,0.15 + , 0.20, 0.25, 0.30, 0.350 ,0.40 ,0.450 ,0.500 , 0.550, 0.600 ,0.650 ,0.700 + , 0.7194 ,0.7388 ,0.7581 ,0.7775 ,0.7969 ,0.8163 ,0.8356, 0.8550 + , 0.8738 ,0.8925 ,0.9113 ,0.9300 ,0.9488 ,0.9675 ,0.9863, 1.0050}; + vector zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1); + map > m; + Edge::interpolate1DLin(zLev1,zLev2,m); + CPPUNIT_ASSERT_EQUAL(30,(int)m.size()); + double ret=0; + for(int i=0;i<30;i++) + { + CPPUNIT_ASSERT_EQUAL(1,(int)m[i].size()); + CPPUNIT_ASSERT(m[i][8+i] > 0.15); + ret+=m[i][8+i]; + } + CPPUNIT_ASSERT_DOUBLES_EQUAL(ret,30.,1e-12); + // + m.clear(); + const int NB_OF_CELL_AXIAL_3=13; + static const double Z_VALS_3[NB_OF_CELL_AXIAL_3+1]={ + 0.,0.01,0.05,0.10,0.15,0.20,0.25,0.30, + 0.35,0.40,0.45,0.50,0.55,0.60 }; + vector zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1); + Edge::interpolate1DLin(zLev3,zLev1,m); + CPPUNIT_ASSERT_EQUAL(13,(int)m.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[0][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[1][8],1e-12); + for(int i=0;i<11;i++) + { + CPPUNIT_ASSERT_EQUAL(1,(int)m[i+2].size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[i+2][i+9],1e-12); + } + QUADRATIC_PLANAR::setPrecision(1e-14); +} + +/*! + * This test looks if intersectors are in coherency. + */ +void QuadraticPlanarInterpTest::checkEpsilonCoherency1() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); + + const double pol1[]={ + -2.1083388455000001, 1.2172499999999999, + -1.7320508075000001, 1, + -1.9201948265, 1.108625 + }; + + const double pol2[]={ + -2.2379999998, 0, + -1.9381648534, 1.1189999998, + -2.1617419990000002, 0.57923702298000002, + -1.9381648534, 1.1189999998, + -1.9909924031999999, 1.1494999999, + -1.9645786283, 1.1342499998 + }; + // + Node *n1=new Node(pol1[0],pol1[1]); + Node *n2=new Node(pol1[2],pol1[3]); + Node *n3; + // + Edge *e1=new EdgeLin(n1,n2); n1->decrRef(); n2->decrRef(); + n1=new Node(pol2[0],pol2[1]); + n2=new Node(pol2[4],pol2[5]); + n3=new Node(pol2[2],pol2[3]); + Edge *e2=new EdgeArcCircle(n1,n2,n3); n1->decrRef(); n2->decrRef(); n3->decrRef(); + e2->decrRef(); + e1->decrRef(); +} + +/*! + * Tests to avoid regressions : Basic one. + */ +void QuadraticPlanarInterpTest::checkNonRegression1() +{ + const double coords1[]= + { + 16.1732057215, -25.110999999800001, + 16.02555485246479, -25.340997988918762 + }; + Node *nS1=new Node(coords1); + Node *nE1=new Node(coords1+2); + const double radius1=2.902; + const double angleS1=-0.49999999950907054; const double angleL1=-0.0942156629996692; + const double center1[2]={13.66, -23.66}; + EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1); + // + const double coords2[]= + { + 16.041579804000001, -25.350249998999999, + 16.367740958999999, -24.132999999999999 + }; + Node *nS2=new Node(coords2); + Node *nE2=new Node(coords2+2); + const double radius2=2.4345; + const double angleS2=-0.523598776190207; const double angleL2=0.5235987755846041; + const double center2[]={ 13.933240960547204, -24.132999998525658 }; + EdgeArcCircle *e2=new EdgeArcCircle(nS2,nE2,center2,radius2,angleS2,angleL2); + MergePoints merge; + QuadraticPolygon c1,c2; + e1->intersectWith(e2,merge,c1,c2); + CPPUNIT_ASSERT_EQUAL(2,c1.size()); CPPUNIT_ASSERT_EQUAL(2,c2.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCurveLength(),c1.getPerimeter(),1e-5); + //clean-up + nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef(); +} + +void QuadraticPlanarInterpTest::checkNonRegression2() +{ + QUADRATIC_PLANAR::setPrecision(1e-12); + QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); + double coords1[]= + { + 15.141499999899999, -26.226033271399999, + 16.226033271199999, -25.141499999800001, + 16.1732057215, -25.110999999800001, + 15.110999999899999, -26.1732057217, + 15.755157392699999, -25.755157392499999, + 16.199619496299999, -25.126249999799999, + 15.7120238788, -25.712023879099998, + 15.126249999899999, -26.199619496499999 + }; + double coords2[]= + { + 15.933240959000001, -24.132999999999999, + 15.665291765999999, -25.132999998999999, + 16.041579804000001, -25.350249998999999, + 16.367740958999999, -24.132999999999999, + 15.865092611, -24.650638091000001, + 15.853435785, -25.241624998999999, + 16.284787383000001, -24.763094964, + 16.150490958999999, -24.132999999999999 + }; + vector nodes1; + nodes1.push_back(new Node(coords1)); + nodes1.push_back(new Node(coords1+2)); + nodes1.push_back(new Node(coords1+4)); + nodes1.push_back(new Node(coords1+6)); + nodes1.push_back(new Node(coords1+8)); + nodes1.push_back(new Node(coords1+10)); + nodes1.push_back(new Node(coords1+12)); + nodes1.push_back(new Node(coords1+14)); + QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); + vector nodes2; + nodes2.push_back(new Node(coords2)); + nodes2.push_back(new Node(coords2+2)); + nodes2.push_back(new Node(coords2+4)); + nodes2.push_back(new Node(coords2+6)); + nodes2.push_back(new Node(coords2+8)); + nodes2.push_back(new Node(coords2+10)); + nodes2.push_back(new Node(coords2+12)); + nodes2.push_back(new Node(coords2+14)); + QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); + vector v=pol1->intersectMySelfWith(*pol2); + CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,v[0]->getArea(),1e-7); + delete v[0]; + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,pol1->intersectWith(*pol2),1e-7); + delete pol1; + delete pol2; +} + +/*! + * Tests to avoid regressions : Basic one. + */ +void QuadraticPlanarInterpTest::checkNonRegression3() +{ + const double coords1[]= + { + 10.962340811000001, -22.417749999000002, + 12.217990959, -21.162099852000001 + }; + Node *nS1=new Node(coords1); + Node *nE1=new Node(coords1+2); + const double radius1=3.4304999897666599; + const double angleS1=2.6179938783536514; const double angleL1=-0.52359877711901204; + const double center1[2]={13.933240950441375, -24.132999992807399}; + EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1); + // + const double coords2[]= + { + 11.1467942784, -22.2090000002, + 11.0939667286, -22.178500000099998 + }; + Node *nS2=new Node(coords2); + Node *nE2=new Node(coords2+2); + EdgeLin *e2=new EdgeLin(nS2,nE2); + MergePoints merge; + QuadraticPolygon c1,c2; + CPPUNIT_ASSERT(e1->intersectWith(e2,merge,c1,c2)); + CPPUNIT_ASSERT_EQUAL(2,c1.size()); + CPPUNIT_ASSERT_EQUAL(2,c2.size()); + ElementaryEdge *tmp1=dynamic_cast(c1.front()); CPPUNIT_ASSERT(tmp1); + EdgeArcCircle *tmp2=dynamic_cast(tmp1->getPtr()); CPPUNIT_ASSERT(tmp2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2.6179938783536514,tmp2->getAngle0(),1e-14); + //clean-up + nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef(); +} + +void QuadraticPlanarInterpTest::checkNonRegression4() +{ + QUADRATIC_PLANAR::setPrecision(1e-12); + QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); + double coords1[]= + { + 10.962340811000001, -22.417749999000002, + 12.217990959, -21.162099852000001, + 12.051990958999999, -20.874579418, + 10.674820377, -22.251749999000001, + 11.507511146000001, -21.707270185999999, + 12.134990959, -21.018339635, + 11.272751694, -21.472510735, + 10.818580594, -22.334749999 + }; + + double coords2[]= + { + 10.758000000199999, -23.66, + 11.1467942784, -22.2090000002, + 11.0939667286, -22.178500000099998, + 10.696999999999999, -23.66, + 10.856883252299999, -22.908907131159999, + 11.1203805035, -22.1937500001, + 10.797961776699999, -22.893119169449999, + 10.727500000099999, -23.66 + }; + vector nodes1; + nodes1.push_back(new Node(coords1)); + nodes1.push_back(new Node(coords1+2)); + nodes1.push_back(new Node(coords1+4)); + nodes1.push_back(new Node(coords1+6)); + nodes1.push_back(new Node(coords1+8)); + nodes1.push_back(new Node(coords1+10)); + nodes1.push_back(new Node(coords1+12)); + nodes1.push_back(new Node(coords1+14)); + QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); + vector nodes2; + nodes2.push_back(new Node(coords2)); + nodes2.push_back(new Node(coords2+2)); + nodes2.push_back(new Node(coords2+4)); + nodes2.push_back(new Node(coords2+6)); + nodes2.push_back(new Node(coords2+8)); + nodes2.push_back(new Node(coords2+10)); + nodes2.push_back(new Node(coords2+12)); + nodes2.push_back(new Node(coords2+14)); + QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); + vector v=pol1->intersectMySelfWith(*pol2); + CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7); + delete v[0]; + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegression5() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); + double coords1[]= + { + -1.7320508075000001, 1, + -1, 1.7320508075000001 , + -1.2172499999999999, 2.1083388455000001, + -2.1083388455000001, 1.2172499999999999, + -1.4142135623000001, 1.4142135623000001, + -1.108625, 1.9201948265, + -1.7214514588000001, 1.7214514588000001, + -1.9201948265, 1.108625}; + + double coords2[]= + { + -2.2379999998, 0, + -1.9381648534, 1.1189999998, + -1.9909924031999999, 1.1494999999, + -2.2989999998999999, 0, + -2.1617419990000002, 0.57923702298000002, + -1.9645786283, 1.1342499998, + -2.2206634745999998, 0.59502498461999997, + -2.2684999997999999, 0}; + //Edge1_of_pol2 inter Edge4_of_pol1 = {-1.9381648533711939, 1.1189999998498941} + //Edge4_of_pol1 _angle = -0.523598775922546, _angle0 = -3.1415926535897931, _radius = 2.2379999983074721, _center = {-1.4925279436059493e-09, 1.3300635705141101e-10}} + vector nodes1; + nodes1.push_back(new Node(coords1)); + nodes1.push_back(new Node(coords1+2)); + nodes1.push_back(new Node(coords1+4)); + nodes1.push_back(new Node(coords1+6)); + nodes1.push_back(new Node(coords1+8)); + nodes1.push_back(new Node(coords1+10)); + nodes1.push_back(new Node(coords1+12)); + nodes1.push_back(new Node(coords1+14)); + QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); + vector nodes2; + nodes2.push_back(new Node(coords2)); + nodes2.push_back(new Node(coords2+2)); + nodes2.push_back(new Node(coords2+4)); + nodes2.push_back(new Node(coords2+6)); + nodes2.push_back(new Node(coords2+8)); + nodes2.push_back(new Node(coords2+10)); + nodes2.push_back(new Node(coords2+12)); + nodes2.push_back(new Node(coords2+14)); + QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); + vector v=pol1->intersectMySelfWith(*pol2); + CPPUNIT_ASSERT_EQUAL(0,(int)v.size()); + //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7); + //delete v[0]; + //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegression6() +{ + QUADRATIC_PLANAR::setPrecision(1e-12); + QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); + double coords1[]= + { + 10.962340811000001, -22.417749999000002, + 12.217990959, -21.162099852000001, + 12.051990958999999, -20.874579418, + 10.674820377, -22.251749999000001, + 11.507511146000001, -21.707270185999999, + 12.134990959, -21.018339635, + 11.272751694, -21.472510735, + 10.818580594, -22.334749999 + }; + double coords2[]= + { 10.426, -23.66, + 10.859273844199999, -22.043000000100001, + 10.806446294799999, -22.012500000199999, + 10.3650000002, -23.66, + 10.536195877799999, -22.822979208099998, + 10.832860069499999, -22.027750000200001, + 10.477274402499999, -22.80719124657, + 10.3955000001, -23.66}; + vector nodes1; + nodes1.push_back(new Node(coords1)); + nodes1.push_back(new Node(coords1+2)); + nodes1.push_back(new Node(coords1+4)); + nodes1.push_back(new Node(coords1+6)); + nodes1.push_back(new Node(coords1+8)); + nodes1.push_back(new Node(coords1+10)); + nodes1.push_back(new Node(coords1+12)); + nodes1.push_back(new Node(coords1+14)); + QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); + vector nodes2; + nodes2.push_back(new Node(coords2)); + nodes2.push_back(new Node(coords2+2)); + nodes2.push_back(new Node(coords2+4)); + nodes2.push_back(new Node(coords2+6)); + nodes2.push_back(new Node(coords2+8)); + nodes2.push_back(new Node(coords2+10)); + nodes2.push_back(new Node(coords2+12)); + nodes2.push_back(new Node(coords2+14)); + QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); + vector v=pol1->intersectMySelfWith(*pol2); + CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0]->getArea(),0.0150659,1e-7); + delete v[0]; + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegression7() +{ + QUADRATIC_PLANAR::setPrecision(1e-5); + QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); + double coords1[]= + { + -2., 0, + -1.7320508075000001, 1, + -2.1083388455000001, 1.2172499999999999, + -2.4344999999999999, 0, + -1.9318516525603098, 0.51763809027157182, + -1.9201948265, 1.108625, + -2.3515464241024469, 0.63009496529570408, + -2.2172499999999999, 0 + }; + double coords2[]= + { -2.3369999999000002, 0, + -2.0239013684999998, 1.1684999999000001, + -2.1927763221999998, 1.2659999998, + -2.5319999998, 0, + -2.2573686559260442, 0.60486010843437632, + -2.1083388453499996, 1.2172499998499999, + -2.445724191994314, 0.65532982205982326, + -2.4344999998499999, 0 }; + vector nodes1; + nodes1.push_back(new Node(coords1)); + nodes1.push_back(new Node(coords1+2)); + nodes1.push_back(new Node(coords1+4)); + nodes1.push_back(new Node(coords1+6)); + nodes1.push_back(new Node(coords1+8)); + nodes1.push_back(new Node(coords1+10)); + nodes1.push_back(new Node(coords1+12)); + nodes1.push_back(new Node(coords1+14)); + QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); + vector nodes2; + nodes2.push_back(new Node(coords2)); + nodes2.push_back(new Node(coords2+2)); + nodes2.push_back(new Node(coords2+4)); + nodes2.push_back(new Node(coords2+6)); + nodes2.push_back(new Node(coords2+8)); + nodes2.push_back(new Node(coords2+10)); + nodes2.push_back(new Node(coords2+12)); + nodes2.push_back(new Node(coords2+14)); + QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); + vector v=pol1->intersectMySelfWith(*pol2); + CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.121795,v[0]->getArea(),1.e-6); + delete v[0]; + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegression8() +{ + QUADRATIC_PLANAR::setPrecision(1e-3); + QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); + double coords1[]= + { + -13.933240959000001, -28.559499999, + -16.146490959000001, -27.966461449000001, + -16.383240958999998, -28.376524478, + -13.933240959000001, -29.032999999000001, + -15.078903461873765, -28.408670669106311, + -16.264865958999998, -28.1714929635, + -15.201454280317435, -28.866036547696734, + -13.933240959000001, -28.796249999 }; + double coords2[]= + { -16.382999999950002, -28.376524478457149, + -13.933000000014729, -29.03299999982551, + -13.93300000006697, -28.793999999915993, + -16.263500000000001, -28.169544407039268, + -15.201213320921273, -28.866036548734634, + -13.933000000040851, -28.913499999870751, + -15.139355569325469, -28.635180276305853, + -16.323249999975001, -28.273034442748209 }; + vector nodes1; + nodes1.push_back(new Node(coords1)); + nodes1.push_back(new Node(coords1+2)); + nodes1.push_back(new Node(coords1+4)); + nodes1.push_back(new Node(coords1+6)); + nodes1.push_back(new Node(coords1+8)); + nodes1.push_back(new Node(coords1+10)); + nodes1.push_back(new Node(coords1+12)); + nodes1.push_back(new Node(coords1+14)); + QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); + vector nodes2; + nodes2.push_back(new Node(coords2)); + nodes2.push_back(new Node(coords2+2)); + nodes2.push_back(new Node(coords2+4)); + nodes2.push_back(new Node(coords2+6)); + nodes2.push_back(new Node(coords2+8)); + nodes2.push_back(new Node(coords2+10)); + nodes2.push_back(new Node(coords2+12)); + nodes2.push_back(new Node(coords2+14)); + QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); + vector v=pol1->intersectMySelfWith(*pol2); + CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.598232,v[0]->getArea(),1.e-6); + delete v[0]; + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegression9() +{ + QUADRATIC_PLANAR::setPrecision(1e-7); + QUADRATIC_PLANAR::setArcDetectionPrecision(1e-8); + double coords1[]= + { + -0.04476229252902969, -0.085118027765365603, + -0.046952683430894329, -0.085704941238358354, + -0.046952683430894329, -0.088063823748058725, + -0.043582851274179504, -0.087160879944491371, + -0.045818853668170414, -0.085555669718918592, + -0.046952683430894329, -0.086884382493208526, + -0.045208329947517549, -0.087834175256748526, + -0.044172571901604597, -0.086139453854928494 }; + + double coords2[]= + { -0.05065868681155701, -0.087744551996665671, + -0.046951871439587615, -0.088737790182236015, + -0.046951871439683469, -0.088063823751059062, + -0.050321703596054014, -0.087160879946116557, + -0.0488706602695924, -0.08848517684025306, + -0.046951871439635542, -0.088400806966647538, + -0.048696224921445964, -0.087834175258503858, + -0.050490195203805516, -0.087452715971391121}; + + vector nodes1; + nodes1.push_back(new Node(coords1)); + nodes1.push_back(new Node(coords1+2)); + nodes1.push_back(new Node(coords1+4)); + nodes1.push_back(new Node(coords1+6)); + nodes1.push_back(new Node(coords1+8)); + nodes1.push_back(new Node(coords1+10)); + nodes1.push_back(new Node(coords1+12)); + nodes1.push_back(new Node(coords1+14)); + QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); + vector nodes2; + nodes2.push_back(new Node(coords2)); + nodes2.push_back(new Node(coords2+2)); + nodes2.push_back(new Node(coords2+4)); + nodes2.push_back(new Node(coords2+6)); + nodes2.push_back(new Node(coords2+8)); + nodes2.push_back(new Node(coords2+10)); + nodes2.push_back(new Node(coords2+12)); + nodes2.push_back(new Node(coords2+14)); + QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); + vector v=pol1->intersectMySelfWith(*pol2); + CPPUNIT_ASSERT_EQUAL(0,(int)v.size()); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegression10() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords1[]= + { -0.002269581957210453, -0.09851030343724453, + -0.004268022334182935, -0.1059685844580936, + -0.002777851483521377, -0.1023709937816271}; + double coords2[]= + { -0.004114727297178323, -0.1049870239624718, + -0.003544545103522544, -0.1053162188055505}; + Node *n1_1=new Node(coords1); + Node *n2_1=new Node(coords1+2); + Node *n3_1=new Node(coords1+4); + Node *n1_2=new Node(coords2); + Node *n2_2=new Node(coords2+2); + EdgeArcCircle *e1=new EdgeArcCircle(n1_1,n3_1,n2_1); + EdgeLin *e2=new EdgeLin(n1_2,n2_2); + MergePoints merge; + ComposedEdge *c1=new ComposedEdge; + ComposedEdge *c2=new ComposedEdge; + CPPUNIT_ASSERT(e1->intersectWith(e2,merge,*c1,*c2)); + CPPUNIT_ASSERT_EQUAL(2,c1->size()); + CPPUNIT_ASSERT_EQUAL(2,c2->size()); + ComposedEdge::Delete(c1); ComposedEdge::Delete(c2); + n1_1->decrRef(); n2_1->decrRef(); n3_1->decrRef(); + n1_2->decrRef(); n2_2->decrRef(); + e1->decrRef(); e2->decrRef(); +} + +void QuadraticPlanarInterpTest::checkNonRegression11() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords1[]= + { -0.002269581957210453, -0.09851030343724453, + -0.004268022334182935, -0.1059685844580936, + -0.002886178753789801, -0.1067663922211958, + -0.0006739664310059821, -0.09851030343724453, + -0.002777851483521377, -0.1023709937816271, + -0.003577100543986368, -0.1063674883396447, + -0.001236605237717319, -0.1027839694676665, + -0.001471774194108217, -0.09851030343724453}; + double coords2[]= + { -0.003544545103522544, -0.1053162188055505, + -0.001941023322604723, -0.09851030343724451, + -0.002598140593501099, -0.09851030343724451, + -0.004114727297178323, -0.1049870239624718, + -0.002347317802266182, -0.1020064358043286, + -0.002269581958052911, -0.09851030343724451, + -0.002982346712452072, -0.1018362598405457, + -0.003829636200350435, -0.1051516213840111}; + + vector nodes1; + nodes1.push_back(new Node(coords1)); + nodes1.push_back(new Node(coords1+2)); + nodes1.push_back(new Node(coords1+4)); + nodes1.push_back(new Node(coords1+6)); + nodes1.push_back(new Node(coords1+8)); + nodes1.push_back(new Node(coords1+10)); + nodes1.push_back(new Node(coords1+12)); + nodes1.push_back(new Node(coords1+14)); + QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); + vector nodes2; + nodes2.push_back(new Node(coords2)); + nodes2.push_back(new Node(coords2+2)); + nodes2.push_back(new Node(coords2+4)); + nodes2.push_back(new Node(coords2+6)); + nodes2.push_back(new Node(coords2+8)); + nodes2.push_back(new Node(coords2+10)); + nodes2.push_back(new Node(coords2+12)); + nodes2.push_back(new Node(coords2+14)); + QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); + vector v=pol1->intersectMySelfWith(*pol2); + CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2.28973e-06,v[0]->getArea(),1.e-11); + delete v[0]; + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegression12() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-6); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords1[]= + { -0.5032251558760915, -0.8716087994449138, + -0.4695268343089433, -0.8806382374805872, + -0.4695268343089433, -0.8570494123835835, + -0.4914307433275896, -0.8511802776536561, + -0.4869703691141082, -0.8783417525751493, + -0.4695268343089433, -0.8688438249320853, + -0.480865131947653, -0.8555566971861125, + -0.4973279496018406, -0.8613945385492849}; + + double coords2[]= + { -0.5065868681155701, -0.8774455199666568, + -0.4695187143958762, -0.8873779018223601, + -0.4695187143968347, -0.8806382375105907, + -0.5032170359605401, -0.8716087994611657, + -0.488706602695924, -0.8848517684025307, + -0.4695187143963554, -0.8840080696664754, + -0.4869622492144596, -0.8783417525850385, + -0.5049019520380551, -0.8745271597139112}; + + vector nodes1; + nodes1.push_back(new Node(coords1)); + nodes1.push_back(new Node(coords1+2)); + nodes1.push_back(new Node(coords1+4)); + nodes1.push_back(new Node(coords1+6)); + nodes1.push_back(new Node(coords1+8)); + nodes1.push_back(new Node(coords1+10)); + nodes1.push_back(new Node(coords1+12)); + nodes1.push_back(new Node(coords1+14)); + QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); + vector nodes2; + nodes2.push_back(new Node(coords2)); + nodes2.push_back(new Node(coords2+2)); + nodes2.push_back(new Node(coords2+4)); + nodes2.push_back(new Node(coords2+6)); + nodes2.push_back(new Node(coords2+8)); + nodes2.push_back(new Node(coords2+10)); + nodes2.push_back(new Node(coords2+12)); + nodes2.push_back(new Node(coords2+14)); + QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); + vector v=pol1->intersectMySelfWith(*pol2); + CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v[0]->getArea(),1.e-6); + delete v[0]; + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegression13() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); + + double coords_1[194]={ + 0, 0, 0.304375, -7.454791178893722e-17, 0.2152256265236553, -0.2152256265236555, -5.591093384170291e-17, -0.304375, + -0.2152256265236555, -0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375, + 0.2152256265236554, 0.2152256265236554, 0.60875, -1.490958235778744e-16, 0.5624116654162459, -0.2329585394522483, 0.4304512530473107, -0.4304512530473109, + 0.2329585394522485, -0.5624116654162458, -1.118218676834058e-16, -0.60875, -0.2329585394522482, -0.5624116654162459, -0.4304512530473109, -0.4304512530473108, + -0.5624116654162459, -0.2329585394522483, -0.60875, 7.454791178893722e-17, -0.5624116654162458, 0.2329585394522485, -0.4304512530473108, 0.4304512530473109, + -0.2329585394522484, 0.5624116654162458, 3.727395589446861e-17, 0.60875, 0.2329585394522485, 0.5624116654162458, 0.4304512530473109, 0.4304512530473108, + 0.5624116654162458, 0.2329585394522484, 0.913125, -2.236437353668116e-16, 0.645676879570966, -0.6456768795709663, -1.677328015251087e-16, -0.913125, + -0.6456768795709663, -0.6456768795709661, -0.913125, 1.118218676834058e-16, -0.6456768795709661, 0.6456768795709662, 5.591093384170291e-17, 0.913125, + 0.6456768795709662, 0.6456768795709661, 1.2175, -2.981916471557489e-16, 1.124823330832492, -0.4659170789044966, 0.8609025060946214, -0.8609025060946218, + 0.4659170789044971, -1.124823330832492, -2.236437353668116e-16, -1.2175, -0.4659170789044965, -1.124823330832492, -0.8609025060946218, -0.8609025060946216, + -1.124823330832492, -0.4659170789044967, -1.2175, 1.490958235778744e-16, -1.124823330832492, 0.465917078904497, -0.8609025060946216, 0.8609025060946217, + -0.4659170789044967, 1.124823330832492, 7.454791178893722e-17, 1.2175, 0.4659170789044969, 1.124823330832492, 0.8609025060946217, 0.8609025060946216, + 1.124823330832492, 0.4659170789044968, 1.521875, -3.727395589446861e-16, 1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875, + -1.076128132618277, -1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875, + 1.076128132618277, 1.076128132618277, 1.82625, -4.472874707336233e-16, 1.687234996248738, -0.6988756183567448, 1.291353759141932, -1.291353759141933, + 0.6988756183567456, -1.687234996248737, -3.354656030502175e-16, -1.82625, -0.6988756183567447, -1.687234996248738, -1.291353759141933, -1.291353759141932, + -1.687234996248738, -0.6988756183567449, -1.82625, 2.236437353668116e-16, -1.687234996248737, 0.6988756183567454, -1.291353759141932, 1.291353759141932, + -0.6988756183567451, 1.687234996248737, 1.118218676834058e-16, 1.82625, 0.6988756183567453, 1.687234996248737, 1.291353759141932, 1.291353759141932, + 1.687234996248737, 0.6988756183567452, 2.130625, -5.218353825225606e-16, 1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625, + -1.506579385665588, -1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625, + 1.506579385665588, 1.506579385665588, 2.435, -5.963832943114977e-16, 2.249646661664984, -0.9318341578089931, 1.721805012189243, -1.721805012189244, + 0.9318341578089941, -2.249646661664983, -4.472874707336233e-16, -2.435, -0.9318341578089929, -2.249646661664984, -1.721805012189244, -1.721805012189243, + -2.249646661664984, -0.9318341578089934, -2.435, 2.981916471557489e-16, -2.249646661664983, 0.9318341578089939, -1.721805012189243, 1.721805012189243, + -0.9318341578089935, 2.249646661664983, 1.490958235778744e-16, 2.435, 0.9318341578089938, 2.249646661664983, 1.721805012189243, 1.721805012189243, + 2.249646661664983, 0.9318341578089936 }; + + int tab6_1[48]={ + 0, 9, 11, 1, 10, 2, 0, 11, 13, 2, 12, 3, 0, 13, 15, 3, 14, 4, 0, 15, + 17, 4, 16, 5, 0, 17, 19, 5, 18, 6, 0, 19, 21, 6, 20, 7, 0, 21, 23, 7, + 22, 8, 0, 23, 9, 8, 24, 1 }; + + int tab8_1[192]={ + 9, 33, 35, 11, 25, 34, 26, 10, 11, 35, 37, 13, 26, 36, 27, 12, 13, 37, 39, 15, + 27, 38, 28, 14, 15, 39, 41, 17, 28, 40, 29, 16, 17, 41, 43, 19, 29, 42, 30, 18, + 19, 43, 45, 21, 30, 44, 31, 20, 21, 45, 47, 23, 31, 46, 32, 22, 23, 47, 33, 9, + 32, 48, 25, 24, 33, 57, 59, 35, 49, 58, 50, 34, 35, 59, 61, 37, 50, 60, 51, 36, + 37, 61, 63, 39, 51, 62, 52, 38, 39, 63, 65, 41, 52, 64, 53, 40, 41, 65, 67, 43, + 53, 66, 54, 42, 43, 67, 69, 45, 54, 68, 55, 44, 45, 69, 71, 47, 55, 70, 56, 46, + 47, 71, 57, 33, 56, 72, 49, 48, 57, 81, 83, 59, 73, 82, 74, 58, 59, 83, 85, 61, + 74, 84, 75, 60, 61, 85, 87, 63, 75, 86, 76, 62, 63, 87, 89, 65, 76, 88, 77, 64, + 65, 89, 91, 67, 77, 90, 78, 66, 67, 91, 93, 69, 78, 92, 79, 68, 69, 93, 95, 71, + 79, 94, 80, 70, 71, 95, 81, 57, 80, 96, 73, 72 }; + + double coords_2[20]={ + 0.5159941860137611, 0, 0, -0.5159941860137611, -0.5159941860137611, 0, 0, 0.5159941860137611, + 0.6684941860137611, 0, 0, -0.6684941860137611, -0.6684941860137611, 0, 0, 0.6684941860137611, + 0.5922441860137611, 0, -0.5922441860137611, 0 }; + + int tab8_2[16]={ + 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 }; + + double perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2; + + const int *work1=tab6_1; + for(int i=0;i<8;i++,work1+=6) + { + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,6); + const int *work2=tab8_2; + for(int j=0;j<2;j++,work2+=8) + { + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8); + //vector tmp; + //pol1->intersectForPoint(*pol2,tmp); + pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2); + //pol1->intersectMySelfWith(*pol2); + delete pol2; + } + delete pol1; + } + work1=tab8_1; + for(int i=0;i<24;i++,work1+=8) + { + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,8); + const int *work2=tab8_2; + for(int j=0;j<2;j++,work2+=8) + { + + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8); + //vector tmp; + //pol1->intersectForPoint(*pol2,tmp); + pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2); + delete pol2; + } + delete pol1; + } +} + +/*! + Some overlapping cases for intersectForPoint. +*/ +void QuadraticPlanarInterpTest::checkNonRegression14() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); + + double coords[72]={ + 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1., + -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0., + -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658, + 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5, + -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65, + -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877, + -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565, + -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169, + 0.,-1.3,0.,-1.5 + }; + int tab[48]={ + 0,1,2,3,4,5,6,7, + 8,9,10,11,2,14,12,13, + 9,15,16,10,5,17,18,14, + 9,15,16,10,34,17,35,14, + 19,20,21,22,23,24,25,26, + 27,28,29,30,31,32,2,33 + }; + QuadraticPolygon *pol1,*pol2; + vector goalOfTest; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8); + // Level 1 + pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8); + pol1->intersectForPoint(*pol2,goalOfTest); + const int res1[4]={0,1,0,0}; + CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); + CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res1)); + delete pol2; + // Level 2 + pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8); + pol1->intersectForPoint(*pol2,goalOfTest); + const int res2[4]={0,2,0,0}; + CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); + CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2)); + delete pol2; + //Level 2 bis + pol2=buildQuadraticPolygonCoarseInfo(coords,tab+24,8); + pol1->intersectForPoint(*pol2,goalOfTest); + const int res2Bis[4]={0,2,0,0}; + CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); + CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2Bis)); + delete pol2; + // Level 3 + pol2=buildQuadraticPolygonCoarseInfo(coords,tab+40,8); + pol1->intersectForPoint(*pol2,goalOfTest); + const int res3[4]={0,3,0,0}; + CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); + CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res3)); + delete pol2; + // Level 4 + pol2=buildQuadraticPolygonCoarseInfo(coords,tab+32,8); + pol1->intersectForPoint(*pol2,goalOfTest); + const int res4[4]={0,4,0,0}; + CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); + CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res4)); + delete pol2; + // + delete pol1; +} + +/*! + * This test is one of the most complicated intersection configuration. + */ +void QuadraticPlanarInterpTest::checkNonRegression15() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); + + double coords[72]={ + 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1., + -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0., + -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658, + 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5, + -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65, + -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877, + -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565, + -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169, + 0.,-1.3,0.,-1.5 + }; + + int tab[24]={ + 0,1,2,3,4,5,6,7, + 9,15,16,10,7,17,5,14, + 9,10,16,15,14,5,17,7 + }; + + const double RefLgth=3.88995883524451; + const double RefArea=0.383185168001075; + // + QuadraticPolygon *pol1,*pol2; + //pol1 and pol2 in same orientation + pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8); + pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8); + vector res=pol1->intersectMySelfWith(*pol2); + CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); + CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12); + delete res[0]; + //pol1 and pol2 in same orientation but inversing intersection call pol1<->pol2 + res=pol2->intersectMySelfWith(*pol1); + CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); + CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12); + delete res[0]; + delete pol2; + //pol1 and pol2 in opposite orientation + pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8); + res=pol1->intersectMySelfWith(*pol2); + CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); + CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-RefArea,res[0]->getArea(),1e-12); + delete res[0]; + //pol1 and pol2 in opposite orientation but inversing intersection call pol1<->pol2 + res=pol2->intersectMySelfWith(*pol1); + CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); + CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12); + delete res[0]; + delete pol2; + // + delete pol1; +} + +class DoubleEqual +{ +public: + DoubleEqual(double eps):_eps(eps) { } + bool operator()(double x, double y) { return fabs(x-y)<_eps; } +private: + double _eps; +}; + +/*! + * This test is to see the reuse of a polygon in intersect* methods. initLocation needed ... + */ +void QuadraticPlanarInterpTest::checkNonRegression16() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords1[194]={ + 0, 0, 0.304375, 0, 0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375, + -0.2152256265236554, 0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236555, -0.2152256265236554, -5.591093384170291e-17, -0.304375, + 0.2152256265236553, -0.2152256265236555, 0.60875, 0, 0.5624116654162458, 0.2329585394522484, 0.4304512530473109, 0.4304512530473108, + 0.2329585394522485, 0.5624116654162458, 3.727395589446861e-17, 0.60875, -0.2329585394522484, 0.5624116654162458, -0.4304512530473108, 0.4304512530473109, + -0.5624116654162458, 0.2329585394522485, -0.60875, 7.454791178893722e-17, -0.5624116654162459, -0.2329585394522483, -0.4304512530473109, -0.4304512530473108, + -0.2329585394522482, -0.5624116654162459, -1.118218676834058e-16, -0.60875, 0.2329585394522485, -0.5624116654162458, 0.4304512530473107, -0.4304512530473109, + 0.5624116654162459, -0.2329585394522483, 0.913125, 0, 0.6456768795709662, 0.6456768795709661, 5.591093384170291e-17, 0.913125, + -0.6456768795709661, 0.6456768795709662, -0.913125, 1.118218676834058e-16, -0.6456768795709663, -0.6456768795709661, -1.677328015251087e-16, -0.913125, + 0.645676879570966, -0.6456768795709663, 1.2175, 0, 1.124823330832492, 0.4659170789044968, 0.8609025060946217, 0.8609025060946216, + 0.4659170789044969, 1.124823330832492, 7.454791178893722e-17, 1.2175, -0.4659170789044967, 1.124823330832492, -0.8609025060946216, 0.8609025060946217, + -1.124823330832492, 0.465917078904497, -1.2175, 1.490958235778744e-16, -1.124823330832492, -0.4659170789044967, -0.8609025060946218, -0.8609025060946216, + -0.4659170789044965, -1.124823330832492, -2.236437353668116e-16, -1.2175, 0.4659170789044971, -1.124823330832492, 0.8609025060946214, -0.8609025060946218, + 1.124823330832492, -0.4659170789044966, 1.521875, 0, 1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875, + -1.076128132618277, 1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875, + 1.076128132618277, -1.076128132618277, 1.82625, 0, 1.687234996248737, 0.6988756183567452, 1.291353759141932, 1.291353759141932, + 0.6988756183567453, 1.687234996248737, 1.118218676834058e-16, 1.82625, -0.6988756183567451, 1.687234996248737, -1.291353759141932, 1.291353759141932, + -1.687234996248737, 0.6988756183567454, -1.82625, 2.236437353668116e-16, -1.687234996248738, -0.6988756183567449, -1.291353759141933, -1.291353759141932, + -0.6988756183567447, -1.687234996248738, -3.354656030502175e-16, -1.82625, 0.6988756183567456, -1.687234996248737, 1.291353759141932, -1.291353759141933, + 1.687234996248738, -0.6988756183567448, 2.130625, 0, 1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625, + -1.506579385665588, 1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625, + 1.506579385665588, -1.506579385665588, 2.435, 0, 2.249646661664983, 0.9318341578089936, 1.721805012189243, 1.721805012189243, + 0.9318341578089938, 2.249646661664983, 1.490958235778744e-16, 2.435, -0.9318341578089935, 2.249646661664983, -1.721805012189243, 1.721805012189243, + -2.249646661664983, 0.9318341578089939, -2.435, 2.981916471557489e-16, -2.249646661664984, -0.9318341578089934, -1.721805012189244, -1.721805012189243, + -0.9318341578089929, -2.249646661664984, -4.472874707336233e-16, -2.435, 0.9318341578089941, -2.249646661664983, 1.721805012189243, -1.721805012189244, + 2.249646661664984, -0.9318341578089931, }; + + int tab1_8[192]={ + 11, 35, 33, 9, 26, 34, 25, 10, 13, 37, 35, 11, 27, 36, 26, 12, 15, 39, 37, 13, + 28, 38, 27, 14, 17, 41, 39, 15, 29, 40, 28, 16, 19, 43, 41, 17, 30, 42, 29, 18, + 21, 45, 43, 19, 31, 44, 30, 20, 23, 47, 45, 21, 32, 46, 31, 22, 9, 33, 47, 23, + 25, 48, 32, 24, 35, 59, 57, 33, 50, 58, 49, 34, 37, 61, 59, 35, 51, 60, 50, 36, + 39, 63, 61, 37, 52, 62, 51, 38, 41, 65, 63, 39, 53, 64, 52, 40, 43, 67, 65, 41, + 54, 66, 53, 42, 45, 69, 67, 43, 55, 68, 54, 44, 47, 71, 69, 45, 56, 70, 55, 46, + 33, 57, 71, 47, 49, 72, 56, 48, 59, 83, 81, 57, 74, 82, 73, 58, 61, 85, 83, 59, + 75, 84, 74, 60, 63, 87, 85, 61, 76, 86, 75, 62, 65, 89, 87, 63, 77, 88, 76, 64, + 67, 91, 89, 65, 78, 90, 77, 66, 69, 93, 91, 67, 79, 92, 78, 68, 71, 95, 93, 69, + 80, 94, 79, 70, 57, 81, 95, 71, 73, 96, 80, 72, }; + + double coords2[20]={ + 2.435, 0, 0, -2.435, -2.435, 0, 0, 2.435, + 2.6925, 0, 0, -2.6925, -2.6925, 0, 0, 2.6925, + 2.56375, 0, -2.56375, 0, }; + + int tab2_8[16]={ 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 }; + + QuadraticPolygon *pol1,*pol2; + //pol1 and pol2 in same orientation + vector test1,test2; + for(int ii=0;ii<24;ii++) + { + pol1=buildQuadraticPolygonCoarseInfo(coords1,tab1_8+8*ii,8); + for(int jj=0;jj<2;jj++) + { + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab2_8+jj*8,8); + // + vector v1,v2; + pol1->initLocations(); + pol1->intersectForPerimeterAdvanced(*pol2,v1,v2); + if(ii==16 && jj==1) + test1=v1; + if(ii==20 && jj==1) + test2=v1; + delete pol2; + } + delete pol1; + } + const double test1_res[4]={0.,1.9124445278727873,0.,0.}; + CPPUNIT_ASSERT(std::equal(test1.begin(),test1.end(),test1_res,DoubleEqual(1e-10))); + const double test2_res[4]={0.,0.,0.,0.}; + CPPUNIT_ASSERT(std::equal(test2.begin(),test2.end(),test2_res,DoubleEqual(1e-10))); +} + +/*! + * This test checks overlapped intersections END-INSIDE and INSIDE-START with same and opposite orientation. + */ +void QuadraticPlanarInterpTest::checkNonRegression17() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -1., 0., 1., 0. , 1.5, 0., -1.5, 0., + 0. , 1., 1.25, 0., 0., 1.5, -1.25, 0.}; + + double coords2[16]={ + 0.70710678118654757, 0.70710678118654757, -1., 0., -1.25, 0., 0.88388347648318444, 0.88388347648318444, + 0., -1., -1.125, 0., 0., -1.25, 0.79549512883486606, 0.79549512883486606 }; + + double coords3[16]={ + 0.70710678118654757, 0.70710678118654757, 0.88388347648318444, 0.88388347648318444, -1.25, 0., -1., 0., + 0.79549512883486606, 0.79549512883486606, 0., -1.25, -1.125, 0., 0., -1. }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNormalize() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-14); + Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-3.); + Node *n2=new Node(10.,0.); Node *n5=new Node(10.,-3.); + Node *n3=new Node(5.,10.); Node *n6=new Node(5.,7.); + EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); + EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); + EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); + // + QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); + QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + double area1Start=pol1.getArea(); + double fact=pol1.normalize(&pol2); + double area1End=pol1.getArea(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(area1Start,area1End*fact*fact,1e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(13.,fact,1.e-14); + double area=pol1.intersectWith(pol2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,area*fact*fact,1e-14); + // + n1=new Node(0.,0.); n4=new Node(0.,-3.); + n2=new Node(10.,0.); n5=new Node(10.,-3.); + n3=new Node(5.,10.); n6=new Node(5.,7.); + e1_2=new EdgeLin(n1,n2); e4_5=new EdgeLin(n4,n5); + e2_3=new EdgeLin(n2,n3); e5_6=new EdgeLin(n5,n6); + e3_1=new EdgeLin(n3,n1); e6_4=new EdgeLin(n6,n4); + QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); + QuadraticPolygon pol4; pol4.pushBack(e4_5); pol4.pushBack(e5_6); pol4.pushBack(e6_4); + n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,pol3.intersectWithAbs(pol4),1.e-14); + // Ok testing EdgeArcCircle update. + double center[2]={5.,5.}; + double radius=300.; + EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.); + const Bounds& b=e1->getBounds(); + double x,y,fact2; + fact2=b.getCaracteristicDim(); + b.getBarycenter(x,y); + CPPUNIT_ASSERT_DOUBLES_EQUAL(78.539816339744817,e1->getCurveLength(),1e-13); + CPPUNIT_ASSERT_DOUBLES_EQUAL(15106.061037591669,e1->getAreaOfZone(),1e-10); + e1->getStartNode()->applySimilarity(x,y,fact2); + e1->getEndNode()->applySimilarity(x,y,fact2); + e1->applySimilarity(x,y,fact2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(62.132034355964237,fact2,1e-13); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.2640792652913602,e1->getCurveLength(),1e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.034741420428165526,e1->getAreaOfZone(),1e-13); + e1->decrRef(); +} diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx new file mode 100644 index 000000000..88b70d2e0 --- /dev/null +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx @@ -0,0 +1,1168 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "QuadraticPlanarInterpTest.hxx" +#include "QuadraticPolygon.hxx" +#include "ElementaryEdge.hxx" +#include "EdgeArcCircle.hxx" +#include "EdgeLin.hxx" + +#include +#include +#include +#include + +using namespace std; +using namespace INTERP_KERNEL; + +class DoubleEqual +{ +public: + DoubleEqual(double eps):_eps(eps) { } + bool operator()(double x, double y) { return fabs(x-y)<_eps; } +private: + double _eps; +}; + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0000() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, + -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + -0.383022221559489, -0.1786061951567303, -0.5745333323392334, -0.01790929273509539, 0.5745333323392335, -0.01790929273509556, 0.383022221559489, -0.1786061951567304, + -0.4787777769493612, -0.0982577439459128, 4.592273826833915e-17, 0.25, 0.4787777769493612, -0.09825774394591297, 3.061515884555943e-17, 0 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0001() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, + -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, + -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.272708,pol1->intersectWith(*pol2),1.e-6); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.272708,pol2->intersectWith(*pol1),1.e-6); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0002() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, + -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + -0.4979288880273356, 0.4178119462962507, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.4979288880273357, 0.4178119462962505, + -0.555382221261259, 0.4660210170227412, 4.898425415289509e-17, 0.8, 0.5553822212612591, 0.466021017022741, 3.979970649922726e-17, 0.65 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.122173,pol1->intersectWith(*pol2),1.e-6); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.122173,pol2->intersectWith(*pol1),1.e-6); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0003() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.3535533905932737, 0.3535533905932738, -0.5303300858899106, 0.5303300858899107, 0.5303300858899107, 0.5303300858899106, 0.3535533905932738, 0.3535533905932737, + -0.4419417382415922, 0.4419417382415922, 4.592273826833915e-17, 0.75, 0.4419417382415922, 0.4419417382415922, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + -0.4979288880273356, 0.4178119462962507, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.4979288880273357, 0.4178119462962505, + -0.555382221261259, 0.4660210170227412, 4.898425415289509e-17, 0.8, 0.5553822212612591, 0.466021017022741, 3.979970649922726e-17, 0.65 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol1->intersectWith(*pol2),1.e-6); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol2->intersectWith(*pol1),1.e-6); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0004() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.4596194077712559, 0.4596194077712559, -0.5303300858899106, 0.5303300858899107, 0.5303300858899107, 0.5303300858899106, 0.4596194077712559, 0.4596194077712559, + -0.4949747468305832, 0.4949747468305833, 4.592273826833915e-17, 0.75, 0.4949747468305833, 0.4949747468305832, 3.979970649922726e-17, 0.65 }; + + double coords2[16]={ + -0.383022221559489, 0.3213938048432697, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.383022221559489, 0.3213938048432696, + -0.4979288880273356, 0.4178119462962507, 4.898425415289509e-17, 0.8, 0.4979288880273357, 0.4178119462962505, 3.061515884555943e-17, 0.5 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol1->intersectWith(*pol2),1.e-6); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol2->intersectWith(*pol1),1.e-6); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0005() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.383022221559489, 0.3213938048432697, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.383022221559489, 0.3213938048432696, + -0.4979288880273356, 0.4178119462962507, 4.898425415289509e-17, 0.8, 0.4979288880273357, 0.4178119462962505, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + -0.4596194077712559, 0.4596194077712559, -0.5303300858899106, 0.5303300858899107, 0.5303300858899107, 0.5303300858899106, 0.4596194077712559, 0.4596194077712559, + -0.4949747468305832, 0.4949747468305833, 4.592273826833915e-17, 0.75, 0.4949747468305833, 0.4949747468305832, 3.979970649922726e-17, 0.65 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol1->intersectWith(*pol2),1.e-6); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol2->intersectWith(*pol1),1.e-6); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0006() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.383022221559489, 0.3213938048432697, -0.5362311101832845, 0.4499513267805776, 0.5362311101832846, 0.4499513267805774, 0.383022221559489, 0.3213938048432696, + -0.4596266658713867, 0.3856725658119237, 4.28612223837832e-17, 0.7, 0.4596266658713868, 0.3856725658119236, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + -0.1811733315717646, 0.6761480784023478, -0.2070552360820167, 0.7727406610312547, 0.2070552360820166, 0.7727406610312547, 0.1811733315717645, 0.6761480784023478, + -0.1941142838268906, 0.7244443697168013, 4.898425415289509e-17, 0.8, 0.1941142838268906, 0.7244443697168013, 4.28612223837832e-17, 0.7 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.366519,0.,0.}; + double test2_res[4]={0.,0.,0.,0.366519}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0007() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.383022221559489, 0.3213938048432697, -0.5362311101832845, 0.4499513267805776, 0.5362311101832846, 0.4499513267805774, 0.383022221559489, 0.3213938048432696, + -0.4596266658713867, 0.3856725658119237, 4.28612223837832e-17, 0.7, 0.4596266658713868, 0.3856725658119236, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + -0.4499513267805775, 0.5362311101832846, -0.5142300877492315, 0.6128355544951825, -0.1389185421335442, 0.7878462024097664, -0.1215537243668512, 0.6893654271085455, + -0.4820907072649045, 0.5745333323392335, -0.3380946093925595, 0.7250462296293201, -0.1302361332501977, 0.738605814759156, -0.2958327832184895, 0.634415450925655 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.366519,0.,0.}; + double test2_res[4]={0.,0.,0.,0.366519}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0008() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.383022221559489, 0.3213938048432697, -0.5362311101832845, 0.4499513267805776, 0.5362311101832846, 0.4499513267805774, 0.383022221559489, 0.3213938048432696, + -0.4596266658713867, 0.3856725658119237, 4.28612223837832e-17, 0.7, 0.4596266658713868, 0.3856725658119236, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + -0.6344154509256549, 0.2958327832184896, -0.72504622962932, 0.3380946093925596, -0.4588611490808367, 0.6553216354311937, -0.401503505445732, 0.5734064310022944, + -0.6797308402774874, 0.3169636963055246, -0.6128355544951823, 0.5142300877492316, -0.4301823272632844, 0.614364033216744, -0.5362311101832845, 0.4499513267805776 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.18326,0.,0.}; + double test2_res[4]={0.,0.,0.,0.18326}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-5))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-5))); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0009() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, + -0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4 }; + double coords2[16]={ + 0.5, -1.224606353822377e-16, 0.6, -1.469527624586853e-16, -0.6, 7.347638122934263e-17, -0.5, 6.123031769111886e-17, + 0.55, -1.347066989204615e-16, -1.102145718440139e-16, -0.6, -0.55, 6.735334946023075e-17, -9.184547653667829e-17, -0.5 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0010() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, +-0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4 }; + double coords2[16]={ + 0.4346666218300808, -0.1164685702961343, 0.579555495773441, -0.1552914270615124, -0.579555495773441, -0.1552914270615122, -0.4346666218300808, -0.1164685702961342, +0.5071110588017609, -0.1358799986788234, -1.102145718440139e-16, -0.6, -0.507111058801761, -0.1358799986788232, -8.266092888301047e-17, -0.45 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0011() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, +-0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4 }; + double coords2[16]={ + 0.4829629131445342, -0.1294095225512603, 0.579555495773441, -0.1552914270615124, -0.579555495773441, -0.1552914270615122, -0.4829629131445342, -0.1294095225512602, +0.5312592044589877, -0.1423504748063864, -1.102145718440139e-16, -0.6, -0.5312592044589877, -0.1423504748063862, -9.184547653667829e-17, -0.5 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + double val1,val2,val3; + pol1->intersectForPerimeter(*pol2,val1,val2,val3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); + vector val4,val5; + pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); + double test1_res[4]={0.,0.,0.,0.}; + CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + pol1->intersectForPerimeter(*pol2,val1,val2,val3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); + val4.clear(); val5.clear(); + pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); + CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar2511() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, + -0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4, }; + + double coords2[16]={ + 0.579555495773441, -0.1552914270615124, -0.579555495773441, -0.1552914270615122, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512603, + -1.102145718440139e-16, -0.6, -0.5312592044589877, -0.1423504748063862, -9.184547653667829e-17, -0.5, 0.5312592044589877, -0.1423504748063864, }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + double val1,val2,val3; + pol1->intersectForPerimeter(*pol2,val1,val2,val3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); + vector val4,val5; + pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); + double test1_res[4]={0.,0.,0.,0.}; + CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + pol1->intersectForPerimeter(*pol2,val1,val2,val3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); + val4.clear(); val5.clear(); + pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); + CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0012() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, + -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; + + double coords2[16]={ + 6.123031769111886e-18, 1.85, 1.224606353822377e-17, 1.95, 1.224606353822377e-17, 1.55, 6.123031769111886e-18, 1.65, + 9.18454765366783e-18, 1.9, 0.2, 1.75, 9.18454765366783e-18, 1.6, 0.1, 1.75 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.,0.05,0.}; + double test2_res[4]={0.,0.,0.05,0.}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,0,1,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0013() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, + -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; + + double coords2[16]={ + 6.123031769111886e-18, 1.7, 1.224606353822377e-17, 1.8, 1.224606353822377e-17, 1.4, 6.123031769111886e-18, 1.5, + 9.18454765366783e-18, 1.75, 0.2, 1.6, 9.18454765366783e-18, 1.45, 0.1, 1.6 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.,0.1,0.}; + double test2_res[4]={0.,0.,0.1,0.}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,0,2,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0014() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, +-1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; + double coords2[16]={ + 6.123031769111886e-18, 1.55, 1.224606353822377e-17, 1.65, 1.224606353822377e-17, 1.25, 6.123031769111886e-18, 1.35, +9.18454765366783e-18, 1.6, 0.2, 1.45, 9.18454765366783e-18, 1.3, 0.1, 1.45 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.,0.15,0.}; + double test2_res[4]={0.05,0.,0.1,0.}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,0,3,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0015() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, +-1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; + double coords2[16]={ + 6.123031769111886e-18, 1.4, 1.224606353822377e-17, 1.5, 1.224606353822377e-17, 1.1, 6.123031769111886e-18, 1.2, +9.18454765366783e-18, 1.45, 0.2, 1.3, 9.18454765366783e-18, 1.15, 0.1, 1.3 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.,0.2,0.}; + double test2_res[4]={0.1,0.,0.1,0.}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,0,4,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0016() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, +-1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; + double coords2[16]={ + 6.123031769111886e-18, 1.25, 1.224606353822377e-17, 1.35, 1.224606353822377e-17, 0.95, 6.123031769111886e-18, 1.05, +9.18454765366783e-18, 1.3, 0.2, 1.15, 9.18454765366783e-18, 0.9999999999999999, 0.1, 1.15 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.,0.15,0.}; + double test2_res[4]={0.1,0.,0.05,0.}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,0,3,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0017() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, + -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; + + double coords2[16]={ + 6.123031769111886e-18, 1.1, 1.224606353822377e-17, 1.2, 1.224606353822377e-17, 0.8, 6.123031769111886e-18, 0.9, + 9.18454765366783e-18, 1.15, 0.2, 1, 9.18454765366783e-18, 0.85, 0.1, 1 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.,0.1,0.}; + double test2_res[4]={0.1,0.,0.,0.}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,0,2,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0018() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, + -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; + + double coords2[16]={ + 6.123031769111886e-18, 0.95, 1.224606353822377e-17, 1.05, 1.224606353822377e-17, 0.6499999999999999, 6.123031769111886e-18, 0.75, + 9.18454765366783e-18, 1, 0.2, 0.85, 9.18454765366783e-18, 0.7, 0.1, 0.85 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.,0.05,0.}; + double test2_res[4]={0.05,0.,0.,0.}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,0,1,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0019() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, + -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + 0.9500000000000001, 1.836909530733566e-17, 0.8, 3.673819061467131e-17, 1.4, 0, 1.25, 0, + 0.8750000000000001, 2.755364296100349e-17, 1.1, 0.3, 1.325, 0, 1.1, 0.15 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0020() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, + -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + 0.05000000000000002, 1.836909530733566e-17, -0.09999999999999998, 3.673819061467131e-17, 0.5, 0, 0.35, 0, + -0.02499999999999997, 2.755364296100349e-17, 0.2, 0.3, 0.425, 0, 0.2, 0.15 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.,0.,0.}; + double test2_res[4]={0.,0.,0.,0.}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,0,0,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0021() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, + -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + -1, -0.07999999999999999, -1.15, -0.07999999999999996, -0.55, -0.08, -0.7, -0.08, + -1.075, -0.07999999999999997, -0.85, 0.22, -0.625, -0.08, -0.85, 0.06999999999999999 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0311485,pol1->intersectWith(*pol2),1.e-7); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0311485,pol2->intersectWith(*pol1),1.e-7); + delete pol1; + delete pol2; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.162251,0.151523,0.,0.}; + double test2_res[4]={0.,0.311383,0.,0.0978193}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={2,2,0,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} +void QuadraticPlanarInterpTest::checkNonRegressionOmar0022() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, + -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + 0.15, -0.07999999999999999, 0, -0.07999999999999996, 0.6, -0.08, 0.45, -0.08, + 0.07500000000000001, -0.07999999999999997, 0.3, 0.22, 0.5249999999999999, -0.08, 0.3, 0.06999999999999999 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00902229,pol1->intersectWith(*pol2),1.e-8); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00902229,pol2->intersectWith(*pol1),1.e-8); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0023() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, + -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5, }; + + double coords2[16]={ + 0.4156854249492381, 0.5656854249492381, 0.2656854249492381, 0.5656854249492381, 0.8656854249492381, 0.5656854249492381, 0.7156854249492381, 0.5656854249492381, + 0.3406854249492381, 0.5656854249492381, 0.5656854249492381, 0.8656854249492381, 0.7906854249492381, 0.5656854249492381, 0.5656854249492381, 0.7156854249492381 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0215659,pol1->intersectWith(*pol2),1.e-7); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0215659,pol2->intersectWith(*pol1),1.e-7); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0024() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, +-0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; + double coords2[16]={ + 0.5656854249492381, 0.5656854249492381, 0.4156854249492382, 0.5656854249492381, 1.015685424949238, 0.5656854249492381, 0.8656854249492382, 0.5656854249492381, +0.4906854249492382, 0.5656854249492381, 0.7156854249492381, 0.8656854249492381, 0.9406854249492381, 0.5656854249492381, 0.7156854249492381, 0.7156854249492381 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol1->intersectWith(*pol2),1.e-8); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol2->intersectWith(*pol1),1.e-8); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar2524() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, +-0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; + double coords2[16]={ + 0.4156854249492382, 0.5656854249492381, 1.015685424949238, 0.5656854249492381, 0.8656854249492382, 0.5656854249492381, 0.5656854249492381, 0.5656854249492381, +0.7156854249492381, 0.8656854249492381, 0.9406854249492381, 0.5656854249492381, 0.7156854249492381, 0.7156854249492381, 0.4906854249492382, 0.5656854249492381 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol1->intersectWith(*pol2),1.e-8); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol2->intersectWith(*pol1),1.e-8); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0025() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, + -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; + + double coords2[16]={ + 0.715685424949238, 0.5656854249492381, 0.565685424949238, 0.5656854249492381, 1.165685424949238, 0.5656854249492381, 1.015685424949238, 0.5656854249492381, + 0.6406854249492381, 0.5656854249492381, 0.8656854249492381, 0.8656854249492381, 1.090685424949238, 0.5656854249492381, 0.8656854249492381, 0.7156854249492381 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; + // + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,1,0,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0026() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, + -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; + + double coords2[16]={ + 0.1, 0.95, 0.2, 0.95, -0.2, 0.95, -0.1, 0.95, + 0.15, 0.95, 1.224606353822377e-17, 0.75, -0.15, 0.95, 6.123031769111886e-18, 0.85 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; + // + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,1,0,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0027() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, + -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; + + double coords2[16]={ + -0.1, 0.7, -0.2, 0.7, 0.2, 0.7, 0.1, 0.7, + -0.15, 0.7, 1.224606353822377e-17, 0.8999999999999999, 0.15, 0.7, 6.123031769111886e-18, 0.7999999999999999 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00712309,pol1->intersectWith(*pol2),1.e-8); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00712309,pol2->intersectWith(*pol1),1.e-8); + delete pol1; + delete pol2; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.222704,0.,0.}; + double test2_res[4]={0.1,0.0465335,0.1,0.092554}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,4,0,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0028() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, + -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; + + double coords2[16]={ + -0.07071067811865477, 0.4792893218813453, -0.1414213562373095, 0.4085786437626905, 0.1414213562373095, 0.6914213562373095, 0.07071067811865477, 0.6207106781186548, + -0.1060660171779822, 0.4439339828220179, -0.1414213562373095, 0.6914213562373096, 0.1060660171779822, 0.6560660171779822, -0.07071067811865475, 0.6207106781186548 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol1->intersectWith(*pol2),1.e-7); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol2->intersectWith(*pol1),1.e-7); + delete pol1; + delete pol2; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.,0.,0.}; + double test2_res[4]={0.1,0.628319,0.1,0.314159}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,1,0,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0029() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, + -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; + + double coords2[16]={ + -0.07071067811865477, 0.1292893218813453, -0.1414213562373095, 0.05857864376269051, 0.1414213562373095, 0.3414213562373095, 0.07071067811865477, 0.2707106781186548, + -0.1060660171779822, 0.09393398282201787, -0.1414213562373095, 0.3414213562373095, 0.1060660171779822, 0.3060660171779822, -0.07071067811865475, 0.2707106781186548 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); + delete pol1; + delete pol2; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.,0.,0.}; + double test2_res[4]={0.,0.,0.,0.}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,0,0,1}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} + +void QuadraticPlanarInterpTest::checkNonRegressionOmar0030() +{ + INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); + INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + double coords[16]={ + -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, + -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; + + double coords2[16]={ + -0.4889087296526012, 0.3889087296526012, -0.5889087296526012, 0.3889087296526012, -0.1889087296526012, 0.3889087296526012, -0.2889087296526012, 0.3889087296526012, + -0.5389087296526012, 0.3889087296526012, -0.3889087296526012, 0.5889087296526012, -0.2389087296526012, 0.3889087296526012, -0.3889087296526012, 0.4889087296526012 }; + + int tab8[8]={ + 0, 1, 2, 3, 4, 5, 6, 7 }; + QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol1->intersectWith(*pol2),1.e-7); + delete pol1; + delete pol2; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol2->intersectWith(*pol1),1.e-7); + delete pol1; + delete pol2; + // + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + vector val1,val2; + pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); + double test1_res[4]={0.,0.,0.,0.}; + double test2_res[4]={0.1,0.628319,0.1,0.314159}; + CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); + CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); + delete pol1; + delete pol2; + vector val3; + pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); + pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); + pol1->intersectForPoint(*pol2,val3); + int test3_res[4]={0,1,0,0}; + CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); + delete pol1; + delete pol2; +} diff --git a/src/INTERP_KERNELTest/RemapperTest.cxx b/src/INTERP_KERNELTest/RemapperTest.cxx new file mode 100644 index 000000000..2e361c12f --- /dev/null +++ b/src/INTERP_KERNELTest/RemapperTest.cxx @@ -0,0 +1,96 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "RemapperTest.hxx" +#include "Remapper.hxx" + +#include +#include + +namespace INTERP_TEST +{ + + + void RemapperTest::setUp() + { + } + + + void RemapperTest::tearDown() + { + } + + /** + * Test that creates a tree in 2D and check that + * the results are correct in three + * cases : + * a non matching search + * a standard case + * a bbox overlapping the bboxes of the tree + */ + void RemapperTest::test_Remapper() { + string sourcename=getenv("MED_ROOT_DIR"); + sourcename +="/share/salome/resources/med/square1.med"; + MEDMEM::MESH source_mesh (MED_DRIVER,sourcename,"Mesh_2"); + + string targetname=getenv("MED_ROOT_DIR"); + targetname +="/share/salome/resources/med/square2.med"; + MEDMEM::MESH target_mesh (MED_DRIVER,targetname,"Mesh_3"); + + MEDMEM::SUPPORT source_support(&source_mesh,"on All support"); + MEDMEM::FIELD source_field(&source_support,1); + double* value=const_cast(source_field.getValue()); + for (int i=0; i target_field(&target_support,1); + double* targetvalue=const_cast(target_field.getValue()); + for (int i=0; i *source_areas=source_mesh.getArea(&source_support); + MEDMEM::FIELD *target_areas=target_mesh.getArea(&target_support); + absField(*source_areas); //absolute value + absField(*target_areas); //absolute value + + //target square is in reverse order as compared to initial square + double source_integral=source_field.normL2(1,source_areas); + double target_integral=target_field.normL2(1,target_areas); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(source_integral,target_integral,1e-10); + delete source_areas; + delete target_areas; + + } + + void RemapperTest::absField(MEDMEM::FIELD& field) + { + double* areas=const_cast(field.getValue()); + for (int i=0; i< field.getNumberOfValues();i++) + { + areas[i]=fabs(areas[i]); + } + } + +} diff --git a/src/INTERP_KERNELTest/RemapperTest.hxx b/src/INTERP_KERNELTest/RemapperTest.hxx new file mode 100644 index 000000000..bd58b533b --- /dev/null +++ b/src/INTERP_KERNELTest/RemapperTest.hxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __TU_REMAPPER_HXX__ +#define __TU_REMAPPER_HXX__ + +#include +#include "Remapper.hxx" +#include "MEDMEM_Field.hxx" + +namespace INTERP_TEST +{ + + /** + * \brief Test suite testing some of the low level methods of TransformedTriangle. + * + */ + class RemapperTest : public CppUnit::TestFixture + { + + CPPUNIT_TEST_SUITE( RemapperTest ); + CPPUNIT_TEST( test_Remapper ); + CPPUNIT_TEST_SUITE_END(); + + + public: + void setUp(); + + void tearDown(); + + // tests + void test_Remapper(); + + private: + void absField(MEDMEM::FIELD&); + }; + + + + +} + + + +#endif diff --git a/src/INTERP_KERNELTest/SingleElementPlanarTests.cxx b/src/INTERP_KERNELTest/SingleElementPlanarTests.cxx new file mode 100644 index 000000000..89f2b5689 --- /dev/null +++ b/src/INTERP_KERNELTest/SingleElementPlanarTests.cxx @@ -0,0 +1,1045 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "SingleElementPlanarTests.hxx" +#include "InterpolationUtils.hxx" +#include "PolygonAlgorithms.hxx" +#include "PolygonAlgorithms.txx" +#include "InterpolationPlanarTestSuite.hxx" +#include + +using namespace INTERP_KERNEL; + +namespace INTERP_TEST +{ + const double _Epsilon = 1.e-12; + const double _Precision = 1.e-12; + const double _losange1[8] = { 1,0, 0,1, -1,0, 0,-1 }; + const double _losange2[8] = { 2,0, 1,1, 0,0, 1,-1 }; + const double _losange3[8] = {2.5,0.5,1.5,1.5,0.5,0.5,1.5,-0.5 }; + const double _square1[8] = { -1,-1, -1,1, 1,1, 1,-1}; + const double _square2[8] = {1,-0.25,0,-0.25,0,0.25,1,0.25 }; + const double _losange4[8] = { 3,0, 2,1, 1,0, 2,-1 }; + const double _losange5[8] = { 1.5,0, 0,1.5,-1.5,0, 0,-1.5 }; + const double _losange6[12]= { 2,0, 1,1, 0.5,0.5,0,0, 0.5,-0.5, 1,-1 }; + const double _losange7[10]= { 1,0, 0,1, -1,0, 0,-1, 0.5,-0.5 }; + const double _square3[10] = { -1,-1, -1,1, 0.5,1, 1,1, 1,-1, }; + const double _square4[8] = {-0.5,-1,-0.5,1,1.5,1,1.5,-1 }; + const double _square5[10] = { -1,-1, -1,1, 0,1, 1,1, 1,-1 }; + const double _losange8[8] = { 0,1, 1,-1, 0,-1.5,-0.5,-1 }; + const double _losange9[8] = {0.5,0, 0,1, -1.5,0, 0,-1 }; + const double _hexagon1[12]= { -2,0, -1,-1, 1,-1, 2,0, 1,1, -1,1 }; + const double _hexagon2[12]= {-1.5,0.5,-1,-1, 1,-1, 2,1, 1,1, -1,1 }; + const double _hexagon3[12]= { -2,2, -1,1, 1,1, 2,2, 1,3, -1,3 }; + const double _square6[8] = { -1,1, -1,3, 0.5,3,0.5,1 }; + const double _losange10[8]= { 0,-1, 1,-2, 0,-3, -1,-2 }; + const double _triangle1[6]= {0.5,0, 1,1, 0,1 }; + const double _triangle2[6]= { 0,0.5, 0,-0.5,1.5,0 }; + const double _triangle3[9]= {-1,2,0, 1,2,0, 0,2,1 }; + const double _triangle4[9]= {1./2,2,0, 1, 2, 1, 1, 2, 0.5 }; + const double _parallel1[8] = {-1,0, -0.5,1, 0.5,1, 0,0}; + const double _parallel2[8]= {-0.5,1, 0,0, 1.,0, 0.5,1 }; + const double _parallel3[8]= {-0.5,-1, 0,0, 1,0, 0.5,-1}; + const double _triangle5[6]= { 0,0, 0,0.5, 0.5,0.5 }; + const double _triangle6[6]= { 1./3,1./3, 1./3,2./3, 2./3,2./3 }; + const double _triangle7[6]= {0.5,2, 1,1, 0,1 }; + const double _triangle8[6]= {22.4601,35.2129, 13.9921,34.693, 18.2853,26.2812 }; + const double _triangle9[6]= {13.9921,34.693, 22.4601,35.2129, 18.2785,42.3869 }; + const double _triangle10[6]= {84.8575,98.2042, 80,100, 82.2601,95.7202}; + const double _triangle11[6]= {80,100, 76.6659,91.9804, 85.3912,92.5061 }; + + // Two diamonds intersecting without degeneracy (two distinct crossing points) + // /\ /\ + // / \/ \ + // / /\ \ + // / / \ \ + // \ \ / / + // \ \/ / + // \ /\ / + // \/ \/ + + + // \brief Status : pass + void SingleElementPlanarTests::diamondsBasic() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange2,4,4); + deque< double > expected_result; + + expected_result.push_back(0.5);expected_result.push_back(-0.5); + expected_result.push_back(0);expected_result.push_back(0); + expected_result.push_back(0.5);expected_result.push_back(0.5); + expected_result.push_back(1);expected_result.push_back(0); + + CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + void SingleElementPlanarTests::diamondsBasic_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange2,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + expected_result.push_back(1);expected_result.push_back(0); + expected_result.push_back(0.5);expected_result.push_back(0.5); + expected_result.push_back(0);expected_result.push_back(0); + expected_result.push_back(0.5);expected_result.push_back(-0.5); + + CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + + // Two diamonds with overlapping edges in an exclusion configuration + // /\ + // / \ + // /\ / \ + // / \/ \ + // / \ / + // / \ / + // \ /\ / + // \ / \/ + // \ / + // \/ + // \brief Status : pass + void SingleElementPlanarTests::tangentDiamonds() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange3,4,4); + deque< double > expected_result; + + CPPUNIT_ASSERT_MESSAGE("Diamond exclusion tangency test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::tangentDiamonds_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange3,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + expected_result.push_back(0.5);expected_result.push_back(0.5); + expected_result.push_back(1);expected_result.push_back(0); + + CPPUNIT_ASSERT_MESSAGE("Diamond exclusion tangency test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Two tangent squares with overlapping edges, in an inclusion configuration + // _____________ + // | | + // | _______| + // | | | + // | |_______| + // | | + // |_____________| + + // \brief Status : pass + void SingleElementPlanarTests::tangentSquares() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_square2,4,4); + deque< double > expected_result; + + expected_result.push_back(0.);expected_result.push_back(0.25); + expected_result.push_back(0.);expected_result.push_back(-0.25); + expected_result.push_back(1.);expected_result.push_back(-0.25); + expected_result.push_back(1.);expected_result.push_back(0.25); + + CPPUNIT_ASSERT_MESSAGE("Squares inclusion tangency test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::tangentSquares_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_square1,_square2,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(1.);expected_result.push_back(0.25); + expected_result.push_back(0.25);expected_result.push_back(0.25); + expected_result.push_back(1./6);expected_result.push_back(1./6); + expected_result.push_back(0.);expected_result.push_back(0.25); + expected_result.push_back(0.);expected_result.push_back(0.); + expected_result.push_back(0.);expected_result.push_back(-0.25); + expected_result.push_back(1.);expected_result.push_back(-0.25); + + CPPUNIT_ASSERT_MESSAGE("Squares inclusion tangency test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Two diamonds sharing a vertex in an exclusion configuration + // /\ /\ + // / \ / \ + // / \ / \ + // / \/ \ + // \ /\ / + // \ / \ / + // \ / \ / + // \/ \/ + + + // \brief Status : pass + void SingleElementPlanarTests::diamondsSharingVertex1() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange4,4,4); + deque< double > expected_result; + + CPPUNIT_ASSERT_MESSAGE("Diamond sharing (1) vertex test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::diamondsSharingVertex1_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange4,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + expected_result.push_back(1.);expected_result.push_back(0.); + + CPPUNIT_ASSERT_MESSAGE("Diamonds sharing (1) vertex test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Two identical squares + // _____________ + // | | + // | | + // | | + // | | + // | | + // |_____________| + + // \brief Status : pass + void SingleElementPlanarTests::identicalSquares() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_square1,4,4); + deque< double > expected_result; + + expected_result.push_back(-1.);expected_result.push_back(1.); + expected_result.push_back(-1.);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(1.); + + CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::identicalSquares_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_square1,_square1,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(1.);expected_result.push_back(1.); + expected_result.push_back(-1.);expected_result.push_back(1.); + expected_result.push_back(-1.);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(-1.); + + CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + // Square and diamond intersecting with no degeneracy + // /\ + // / \ + // / \ + // __/______\__ + // | / \ | + // |/ \| + // / \ + // /| |\ + // \| |/ + // \ / + // |\ /| + // |_\________/_| + // \ / + // \ / + // \ / + // \/ + // \brief Status : pass + void SingleElementPlanarTests::squareAndDiamondBasic() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_losange5,4,4); + deque< double > expected_result; + + expected_result.push_back(1.);expected_result.push_back(0.5); + expected_result.push_back(0.5);expected_result.push_back(1.); + expected_result.push_back(-0.5);expected_result.push_back(1.); + expected_result.push_back(-1.);expected_result.push_back(0.5); + expected_result.push_back(-1.);expected_result.push_back(-0.5); + expected_result.push_back(-0.5);expected_result.push_back(-1.); + expected_result.push_back(0.5);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(-0.5); + + CPPUNIT_ASSERT_MESSAGE("Square and diamond basic test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::squareAndDiamondBasic_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_square1,_losange5,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(1.);expected_result.push_back(0.); + expected_result.push_back(1.);expected_result.push_back(0.5); + expected_result.push_back(0.75);expected_result.push_back(0.75); + expected_result.push_back(0.5);expected_result.push_back(1.); + expected_result.push_back(0.);expected_result.push_back(0.); + expected_result.push_back(-0.5);expected_result.push_back(1.); + expected_result.push_back(-1.);expected_result.push_back(0.5); + expected_result.push_back(-1.);expected_result.push_back(0.); + expected_result.push_back(-1.);expected_result.push_back(-0.5); + expected_result.push_back(-0.75);expected_result.push_back(-0.75); + expected_result.push_back(-0.5);expected_result.push_back(-1.); + expected_result.push_back(0.5);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(-0.5); + + + CPPUNIT_ASSERT_MESSAGE("Square and diamond basic test failed (TRIANGULATION), maybe not significant (0,0) should be removed", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + // square and diamond intersecting at four degenerated pointss + // ______ + // | /\ | + // | / \ | + // |/ \| + // |\ /| + // | \ / | + // |__\/__| + // \brief Status : pass + + void SingleElementPlanarTests::squareAndDiamondCritical() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_losange1,4,4); + deque< double > expected_result; + + expected_result.push_back(0.);expected_result.push_back(-1.); + expected_result.push_back(-1.);expected_result.push_back(0.); + expected_result.push_back(0.);expected_result.push_back(1.); + expected_result.push_back(1.);expected_result.push_back(0.); + + CPPUNIT_ASSERT_MESSAGE("Square and diamond critical tangency test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::squareAndDiamondCritical_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_square1,_losange1,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(0.5);expected_result.push_back(0.5); + expected_result.push_back(0.);expected_result.push_back(1.); + expected_result.push_back(0);expected_result.push_back(0); + expected_result.push_back(-1.);expected_result.push_back(0.); + expected_result.push_back(-0.5);expected_result.push_back(-0.5); + expected_result.push_back(0.);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(0.); + + CPPUNIT_ASSERT_MESSAGE("Square and diamond basic test failed (TRIANGULATION) maybe not significant (0,0) should be removed", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + // Two diamonds intersecting at one vertex on edge and one double vertex + // /\ /\ + // / \ / \ + // / ¤ \ + // / / \ \ + // \ \ / / + // \ * / + // \ / \ / + // \/ \/ + + + // \brief Status : pass + void SingleElementPlanarTests::diamondsCritical() + { + + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_losange6,_losange7,6,5); + deque< double > expected_result; + + expected_result.push_back(0.5);expected_result.push_back(-0.5); + expected_result.push_back(0.5);expected_result.push_back(-0.5); + expected_result.push_back(0);expected_result.push_back(0); + expected_result.push_back(0.5);expected_result.push_back(0.5); + expected_result.push_back(0.5);expected_result.push_back(0.5); + expected_result.push_back(1);expected_result.push_back(0); + + CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::diamondsCritical_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_losange6,_losange7,6,5,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(1);expected_result.push_back(0); + expected_result.push_back(0.5);expected_result.push_back(0.5); + expected_result.push_back(0);expected_result.push_back(0); + expected_result.push_back(0.5);expected_result.push_back(-0.5); + + CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Two tangent squares with starting and ending vertices on edges + // _____ ___.___ ______ + // | | | | + // | | | | + // | | | | + // | | | | + // | | | | + // |_____|_______|______| + + // \brief Status : pass + void SingleElementPlanarTests::quadranglesCritical() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_square4,_square3,4,5); + deque< double > expected_result; + + expected_result.push_back(-0.5);expected_result.push_back(1.); + expected_result.push_back(-0.5);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(1.); + + CPPUNIT_ASSERT_MESSAGE("Critical quadrangles with tangency test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::quadranglesCritical_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_square4,_square3,4,5,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(1.);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(0.5); + expected_result.push_back(1.);expected_result.push_back(1.); + expected_result.push_back(0.5);expected_result.push_back(1.); + expected_result.push_back(-0.5);expected_result.push_back(1.); + expected_result.push_back(-0.5);expected_result.push_back(-1./3); + expected_result.push_back(-0.5);expected_result.push_back(-0.5); + expected_result.push_back(-0.5);expected_result.push_back(-1.); + + CPPUNIT_ASSERT_MESSAGE("Critical quadrangles with tangency test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + + // square and diamond crossing and tangency at double vertices, starting vertex on edge + // _____.____ + // | / \ | + // | / \ | + // | / \ | + // |_/_______\| + // \ / + // \ / + // \ / + // \ / + // \brief Status : pass + void SingleElementPlanarTests::quadrangleAndDiamondCritical() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_square5,_losange8,5,4); + deque< double > expected_result; + + expected_result.push_back(0.);expected_result.push_back(1.); + expected_result.push_back(-0.5);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(-1.); + + CPPUNIT_ASSERT_MESSAGE("Square and diamond critical tangency test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::quadrangleAndDiamondCritical_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_square5,_losange8,5,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(1.);expected_result.push_back(-1.); + expected_result.push_back(1./3);expected_result.push_back(1./3); + expected_result.push_back(0.);expected_result.push_back(1.); + expected_result.push_back(0.);expected_result.push_back(0.); + expected_result.push_back(-1./3);expected_result.push_back(-1./3); + expected_result.push_back(-0.5);expected_result.push_back(-1.); + expected_result.push_back(0.);expected_result.push_back(-1.); + + CPPUNIT_ASSERT_MESSAGE("Square and diamond critical tangency test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } // square and diamond intersecting at four degenerated pointss + // + // ²/²\ + // ² / ² \ + // ² / ² \ + // ² \ ² / + // ² \ ² / + // ²\²/ + // \brief Status : pass + + void SingleElementPlanarTests::diamondsCritical2() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange9,4,4); + deque< double > expected_result; + + expected_result.push_back(0.);expected_result.push_back(-1.); + expected_result.push_back(0.);expected_result.push_back(-1.); + expected_result.push_back(-1.);expected_result.push_back(0.); + expected_result.push_back(0.);expected_result.push_back(1.); + expected_result.push_back(0.);expected_result.push_back(1.); + expected_result.push_back(0.5);expected_result.push_back(0.); + + CPPUNIT_ASSERT_MESSAGE("Diamonds with crossing at double vertex test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::diamondsCritical2_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange9,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(0.);expected_result.push_back(-1.); + expected_result.push_back(0.5);expected_result.push_back(0.); + expected_result.push_back(0.);expected_result.push_back(1.); + expected_result.push_back(-1.);expected_result.push_back(0.); + + CPPUNIT_ASSERT_MESSAGE("Diamonds with crossing at double vertex test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Two tangent hexagons with double vertices and a critical starting vertex on edge + // _________ + // / \²²² + // ² \² + // / \ + // / ² ² \ + // \ / + // \ ² ² / + // \ / + // \²_______²/ + + + // \brief Status : pass + void SingleElementPlanarTests::hexagonsCritical1() + { + + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_hexagon1,_hexagon2,6,6); + deque< double > expected_result; + + expected_result.push_back(5./3);expected_result.push_back(1./3); + expected_result.push_back(1.);expected_result.push_back(-1.); + expected_result.push_back(-1.);expected_result.push_back(-1.); + expected_result.push_back(-1.5);expected_result.push_back(0.5); + expected_result.push_back(-1.);expected_result.push_back(1.); + expected_result.push_back(1.);expected_result.push_back(1.); + + CPPUNIT_ASSERT_MESSAGE("First hexagon critical crossing test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::hexagonsCritical1_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_hexagon1,_hexagon2,6,6,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(-1.);expected_result.push_back(1.); + expected_result.push_back(-1.5);expected_result.push_back(0.5); + expected_result.push_back(-8./7);expected_result.push_back(2./7); + expected_result.push_back(-1.4);expected_result.push_back(0.2); + expected_result.push_back(-4./3);expected_result.push_back(0.); + expected_result.push_back(-2./3);expected_result.push_back(0.); + expected_result.push_back(-1.25);expected_result.push_back(-0.25); + expected_result.push_back(-1.);expected_result.push_back(-1.); + expected_result.push_back(1.);expected_result.push_back(-1.); + expected_result.push_back(1.5);expected_result.push_back(0.); + expected_result.push_back(5./3);expected_result.push_back(1./3); + expected_result.push_back(1.125);expected_result.push_back(0.875); + expected_result.push_back(1.);expected_result.push_back(1.); + expected_result.push_back(0.25);expected_result.push_back(0.75); + + CPPUNIT_ASSERT_MESSAGE("First hexagon critical crossing test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Two tangent hexagons with double vertices and a critical starting vertex on edge + // _______ + // / \ + // / \ + // \ / + // \_______/ + // / \ + // / \ + // \ / + // \_______/ + + + // \brief Status : pass + void SingleElementPlanarTests::hexagonsCritical2() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_hexagon1,_hexagon3,6,6); + deque< double > expected_result; + + CPPUNIT_ASSERT_MESSAGE("Second hexagon critical crossing test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::hexagonsCritical2_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_hexagon1,_hexagon3,6,6,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + expected_result.push_back(1.);expected_result.push_back(1.); + expected_result.push_back(-1.);expected_result.push_back(1.); + + CPPUNIT_ASSERT_MESSAGE("Second hexagon critical crossing test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Square and quadrilateron with outer tangency + // ________ + // | | + // | | + // | | + // |________|___ + // | | + // | | + // | | + // | | + // | | + // |____________| + + // \brief Status : pass + void SingleElementPlanarTests::squareAndQuadrangleCritical() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_square6,4,4); + deque< double > expected_result; + + CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (CONVEX)", (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::squareAndQuadrangleCritical_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_square1,_square6,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + expected_result.push_back(-1.);expected_result.push_back(1.); + expected_result.push_back(0.5);expected_result.push_back(1.); + + CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + // Two diamonds sharing a vertex in an exclusion configuration + // /\ + // / \ + // / \ + // / \ + // \ / + // \ / + // \ / + // \/ + // /\ + // / \ + // / \ + // / \ + // \ / + // \ / + // \ / + // \/ + + + // \brief Status : pass + void SingleElementPlanarTests:: diamondsSharingVertex2() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange10,4,4); + deque< double > expected_result; + + CPPUNIT_ASSERT_MESSAGE("Diamond sharing vertex (2) test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests:: diamondsSharingVertex2_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange10,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + expected_result.push_back(0.);expected_result.push_back(-1.); + + CPPUNIT_ASSERT_MESSAGE("Diamond sharing vertex (2) test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Triangle and diamond with a critical crossing at double starting vertex + // ____ + // /|\ / + // / | \/ + // / | /\ + // / |/ \ + // \ / + // \ / + // \ / + // \ / + + // \brief Status : pass + void SingleElementPlanarTests:: triangleAndDiamondCritical() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_triangle1,4,3); + deque< double > expected_result; + + expected_result.push_back(2./3);expected_result.push_back(1./3); + expected_result.push_back(0.5);expected_result.push_back(0.); + expected_result.push_back(0.);expected_result.push_back(1.); + + CPPUNIT_ASSERT_MESSAGE("Triangle and diamonds critical test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests:: triangleAndDiamondCritical_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_triangle1,4,3,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(2./3);expected_result.push_back(1./3); + expected_result.push_back(0.);expected_result.push_back(1.); + expected_result.push_back(0.5);expected_result.push_back(0.); + + CPPUNIT_ASSERT_MESSAGE("Triangle and diamonds critical test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Basic triangle and square intersection (two distinct points) + // __________ + // | | + // | |\ | + // | | \| + // | | \ + // | | |\ + // | | |/ + // | | / + // | | /| + // | |/ | + // |__________| + + // \brief Status : pass + void SingleElementPlanarTests::triangleAndSquareBasic() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_triangle2,4,3); + deque< double > expected_result; + + expected_result.push_back(1.);expected_result.push_back(1./6); + expected_result.push_back(1.);expected_result.push_back(-1./6); + expected_result.push_back(0.);expected_result.push_back(-0.5); + expected_result.push_back(0.);expected_result.push_back(0.5); + + CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + void SingleElementPlanarTests::triangleAndSquareBasic_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_square1,_triangle2,4,3,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(1.);expected_result.push_back(1./6); + expected_result.push_back(0.375);expected_result.push_back(0.375); + expected_result.push_back(0.);expected_result.push_back(0.5); + expected_result.push_back(0.);expected_result.push_back(0.); + expected_result.push_back(0.);expected_result.push_back(-0.5); + expected_result.push_back(1.);expected_result.push_back(-1./6); + + CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + // Two triangles with a starting vertex on edge + + // /\ ²²²² + // / ² ² + // / ² ² + // /__²___\ + + // \brief Status : pass + void SingleElementPlanarTests::trianglesCritical() + { + INTERP_KERNEL::PolygonAlgorithms<3> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_triangle3,_triangle4,3,3); + deque< double > expected_result; + + expected_result.push_back(2./3);expected_result.push_back(2.);expected_result.push_back(1./3); + expected_result.push_back(0.5);expected_result.push_back(2.);expected_result.push_back(0.); + expected_result.push_back(0.75);expected_result.push_back(2.);expected_result.push_back(0.25); + + CPPUNIT_ASSERT_MESSAGE("Triangles critical test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,3>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::trianglesCritical_Triangulation() + { + vector< double > actual_result; + double _triangle3rotated[6],_triangle4rotated[6]; + for (int i=0; i<3; i++)_triangle3rotated[2*i] = _triangle3[3*i]; + for (int i=0; i<3; i++)_triangle3rotated[2*i+1] = _triangle3[3*i+2]; + for (int i=0; i<3; i++)_triangle4rotated[2*i] = _triangle4[3*i]; + for (int i=0; i<3; i++)_triangle4rotated[2*i+1] = _triangle4[3*i+2]; + + INTERP_KERNEL::intersec_de_polygone<2>(_triangle3rotated,_triangle4rotated,3,3,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(0.5);expected_result.push_back(0.); + expected_result.push_back(2./3);expected_result.push_back(1./3); + expected_result.push_back(0.75);expected_result.push_back(0.25); + + CPPUNIT_ASSERT_MESSAGE("Triangles critical test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Two tangent paralellograms intersecting at 3 double vertices (one being a starting vertex) + // _______ + // /\ /\ + // / \ / \ + // / \ / \ + // /______\/______\ + + + // \brief Status : pass + void SingleElementPlanarTests::paralellogramsCritical1() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_parallel1,_parallel2,4,4); + deque< double > expected_result; + + expected_result.push_back(0.);expected_result.push_back(0.); + expected_result.push_back(0.);expected_result.push_back(0.); + expected_result.push_back(-0.5);expected_result.push_back(1.); + expected_result.push_back(0.5);expected_result.push_back(1.); + + CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test (1) failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::paralellogramsCritical1_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_parallel1,_parallel2,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(0.25);expected_result.push_back(0.5); + expected_result.push_back(0.5);expected_result.push_back(1.); + expected_result.push_back(0.);expected_result.push_back(2./3); + expected_result.push_back(-0.5);expected_result.push_back(1.); + expected_result.push_back(-0.25);expected_result.push_back(0.5); + expected_result.push_back(0.);expected_result.push_back(0.); + + CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test (1) failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Two paralellograms sharing a vertex in an exclusion configuration + // ________ + // / / + // / / + // / / + // /_______/_______ + // / / + // / / + // / / + // /_______/ + + + // \brief Status : pass + void SingleElementPlanarTests::paralellogramsCritical2() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_parallel1,_parallel3,4,4); + deque< double > expected_result; + + CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::paralellogramsCritical2_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_parallel1,_parallel3,4,4,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(0.);expected_result.push_back(0.); + + CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Two triangles in a tangency configuration with a starting vertex on edge + + // _____ + // | / + // __|___/ + // | | / + // | | / + // | |/ + // | / + // | / + // |/ + + // \brief Status : pass + void SingleElementPlanarTests::trianglesTangencyCritical() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_triangle5,_triangle6,3,3); + deque< double > expected_result; + + expected_result.push_back(1./3);expected_result.push_back(1./2); + expected_result.push_back(1./3);expected_result.push_back(1./3); + expected_result.push_back(1./2);expected_result.push_back(1./2); + + CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::trianglesTangencyCritical_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_triangle5,_triangle6,3,3,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + + expected_result.push_back(1./3);expected_result.push_back(1./2); + expected_result.push_back(1./2);expected_result.push_back(1./2); + expected_result.push_back(1./3);expected_result.push_back(1./3); + + CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + + // Two triangles with double starting point in an outer tangency configuration + // /\ + // / \ + // / \ + // /______\ + // \ / + // \ / + // \ / + // \/ + + + // \brief Status : pass + void SingleElementPlanarTests::trianglesTangencyCritical2() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_triangle1,_triangle7,3,3); + deque< double > expected_result; + + // if(!checkDequesEqual(actual_result,expected_result, _Epsilon)) + // { + // cerr<< "CPP_UNIT expected result= " << endl; + // dequePrintOut(expected_result); + // cerr<< "CPP_UNIT actual result= " << endl; + // dequePrintOut(actual_result); + // } + + CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (2) test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::trianglesTangencyCritical2_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_triangle1,_triangle7,3,3,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + expected_result.push_back(1.);expected_result.push_back(1.); + expected_result.push_back(0.);expected_result.push_back(1.); + + // if(!checkVectorsEqual(actual_result,expected_result, _Epsilon)) + // { + // cerr<< "CPP_UNIT expected result= " << endl; + // vectPrintOut(expected_result); + // cerr<< "CPP_UNIT actual result= " << endl; + // vectPrintOut(actual_result); + // } + + CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (2) test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + // \brief Status : pass + void SingleElementPlanarTests::trianglesTangencyCritical3() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_triangle8,_triangle9,3,3); + deque< double > expected_result; + + CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (3) test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::trianglesTangencyCritical3_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_triangle8,_triangle9,3,3,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + expected_result.push_back(22.4601);expected_result.push_back(35.2129); + expected_result.push_back(13.9921);expected_result.push_back(34.693); + + CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (3) test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::trianglesTangencyCritical4() + { + INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + deque< double > actual_result = intersector.intersectConvexPolygons(_triangle10,_triangle11,3,3); + + deque< double > expected_result; + expected_result.push_back(82.745193090443536);expected_result.push_back(96.184114390029166); + expected_result.push_back(82.260099999999994);expected_result.push_back(95.720200000000006); + expected_result.push_back(80);expected_result.push_back(100.); + + + CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (4) test failed (CONVEX)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + void SingleElementPlanarTests::trianglesTangencyCritical4_Triangulation() + { + vector< double > actual_result; + INTERP_KERNEL::intersec_de_polygone<2>(_triangle10,_triangle11,3,3,actual_result,_Epsilon/_Precision, _Precision ); + + vector< double > expected_result; + expected_result.push_back(80);expected_result.push_back(100.); + expected_result.push_back(82.745193090443536);expected_result.push_back(96.184114390029166); + expected_result.push_back(82.260099999999994);expected_result.push_back(95.720200000000006); + + CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (4) test failed (TRIANGULATION)", + (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); + } + +} diff --git a/src/INTERP_KERNELTest/SingleElementPlanarTests.hxx b/src/INTERP_KERNELTest/SingleElementPlanarTests.hxx new file mode 100644 index 000000000..ad0a420cd --- /dev/null +++ b/src/INTERP_KERNELTest/SingleElementPlanarTests.hxx @@ -0,0 +1,138 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __SINGLE_ELEMENT_PLANAR_TESTS_HXX_ +#define __SINGLE_ELEMENT_PLANAR_TESTS_HXX_ + +#include "InterpolationPlanarTestSuite.hxx" + +namespace INTERP_TEST +{ + /** + * \brief Class testing algorithm by intersecting simple meshes having only one planar element each. + * This serves mainly to verify that the volume calculations between elements is correct. + * + */ + class SingleElementPlanarTests : public InterpolationPlanarTestSuite + { + CPPUNIT_TEST_SUITE( SingleElementPlanarTests ); + + CPPUNIT_TEST( diamondsBasic ); + CPPUNIT_TEST( tangentDiamonds ); + CPPUNIT_TEST( tangentSquares ); + CPPUNIT_TEST( diamondsSharingVertex1 ); + CPPUNIT_TEST( identicalSquares ); + CPPUNIT_TEST( squareAndDiamondBasic ); + CPPUNIT_TEST( squareAndDiamondCritical ); + CPPUNIT_TEST( diamondsCritical ); + CPPUNIT_TEST( quadranglesCritical ); + CPPUNIT_TEST( quadrangleAndDiamondCritical ); + CPPUNIT_TEST( diamondsCritical2 ); + CPPUNIT_TEST( hexagonsCritical1 ); + CPPUNIT_TEST( hexagonsCritical2 ); + CPPUNIT_TEST( squareAndQuadrangleCritical ); + CPPUNIT_TEST( diamondsSharingVertex2 ); + CPPUNIT_TEST( triangleAndDiamondCritical ); + CPPUNIT_TEST( triangleAndSquareBasic ); + CPPUNIT_TEST( trianglesCritical ); + CPPUNIT_TEST( paralellogramsCritical1 ); + CPPUNIT_TEST( paralellogramsCritical2 ); + CPPUNIT_TEST( trianglesTangencyCritical ); + CPPUNIT_TEST( trianglesTangencyCritical2 ); + CPPUNIT_TEST( trianglesTangencyCritical3 ); + CPPUNIT_TEST( trianglesTangencyCritical4 ); + CPPUNIT_TEST( diamondsBasic_Triangulation ); + CPPUNIT_TEST( tangentDiamonds_Triangulation ); + CPPUNIT_TEST( tangentSquares_Triangulation ); + CPPUNIT_TEST( diamondsSharingVertex1_Triangulation ); + CPPUNIT_TEST( identicalSquares_Triangulation ); + CPPUNIT_TEST( squareAndDiamondBasic_Triangulation ); + CPPUNIT_TEST( squareAndDiamondCritical_Triangulation ); + CPPUNIT_TEST( diamondsCritical_Triangulation ); + CPPUNIT_TEST( quadranglesCritical_Triangulation ); + CPPUNIT_TEST( quadrangleAndDiamondCritical_Triangulation ); + CPPUNIT_TEST( diamondsCritical2_Triangulation ); + CPPUNIT_TEST( hexagonsCritical1_Triangulation ); + CPPUNIT_TEST( hexagonsCritical2_Triangulation ); + CPPUNIT_TEST( squareAndQuadrangleCritical_Triangulation ); + CPPUNIT_TEST( diamondsSharingVertex2_Triangulation ); + CPPUNIT_TEST( triangleAndDiamondCritical_Triangulation ); + CPPUNIT_TEST( triangleAndSquareBasic_Triangulation ); + CPPUNIT_TEST( trianglesCritical_Triangulation ); + CPPUNIT_TEST( paralellogramsCritical1_Triangulation ); + CPPUNIT_TEST( paralellogramsCritical2_Triangulation ); + CPPUNIT_TEST( trianglesTangencyCritical_Triangulation ); + CPPUNIT_TEST( trianglesTangencyCritical2_Triangulation ); + CPPUNIT_TEST( trianglesTangencyCritical3_Triangulation ); + CPPUNIT_TEST( trianglesTangencyCritical4_Triangulation ); + + CPPUNIT_TEST_SUITE_END(); + + public: + + void diamondsBasic(); + void tangentDiamonds(); + void tangentSquares(); + void diamondsSharingVertex1(); + void identicalSquares(); + void squareAndDiamondBasic(); + void squareAndDiamondCritical(); + void diamondsCritical(); + void quadranglesCritical(); + void quadrangleAndDiamondCritical(); + void diamondsCritical2(); + void hexagonsCritical1(); + void hexagonsCritical2(); + void squareAndQuadrangleCritical(); + void diamondsSharingVertex2(); + void triangleAndDiamondCritical(); + void triangleAndSquareBasic(); + void trianglesCritical(); + void paralellogramsCritical1(); + void paralellogramsCritical2(); + void trianglesTangencyCritical(); + void trianglesTangencyCritical2(); + void trianglesTangencyCritical3(); + void trianglesTangencyCritical4(); + void diamondsBasic_Triangulation(); + void tangentDiamonds_Triangulation(); + void tangentSquares_Triangulation(); + void diamondsSharingVertex1_Triangulation(); + void identicalSquares_Triangulation(); + void squareAndDiamondBasic_Triangulation(); + void squareAndDiamondCritical_Triangulation(); + void diamondsCritical_Triangulation(); + void quadranglesCritical_Triangulation(); + void quadrangleAndDiamondCritical_Triangulation(); + void diamondsCritical2_Triangulation(); + void hexagonsCritical1_Triangulation(); + void hexagonsCritical2_Triangulation(); + void squareAndQuadrangleCritical_Triangulation(); + void diamondsSharingVertex2_Triangulation(); + void triangleAndDiamondCritical_Triangulation(); + void triangleAndSquareBasic_Triangulation(); + void trianglesCritical_Triangulation(); + void paralellogramsCritical1_Triangulation(); + void paralellogramsCritical2_Triangulation(); + void trianglesTangencyCritical_Triangulation(); + void trianglesTangencyCritical2_Triangulation(); + void trianglesTangencyCritical3_Triangulation(); + void trianglesTangencyCritical4_Triangulation(); + }; +} +#endif diff --git a/src/INTERP_KERNELTest/SingleElementTetraTests.hxx b/src/INTERP_KERNELTest/SingleElementTetraTests.hxx new file mode 100644 index 000000000..f5e22b464 --- /dev/null +++ b/src/INTERP_KERNELTest/SingleElementTetraTests.hxx @@ -0,0 +1,169 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __SINGLE_ELEMENT_TETRA_TESTS_HXX_ +#define __SINGLE_ELEMENT_TETRA_TESTS_HXX_ + +#include "InterpolationTestSuite.hxx" + +namespace INTERP_TEST +{ + /** + * \brief Class testing algorithm by intersecting simple meshes having only one element each. This serves mainly to verify that + * the volume calculations between elements is correct. + * + */ + class SingleElementTetraTests : public InterpolationTestSuite<3,3> + { + CPPUNIT_TEST_SUITE( SingleElementTetraTests ); + + 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 ); + + CPPUNIT_TEST_SUITE_END(); + + public: + + /// Unit tetrahedron mesh intersecting itself + /// \brief Status : pass + void tetraReflexiveUnit() + { + _testTools->intersectMeshes("UnitTetra", "UnitTetra", 1.0/6.0); + } + + /// Tetrahedron mesh with itself + /// \brief Status : pass + void tetraReflexiveGeneral() + { + _testTools->intersectMeshes("GeneralTetra", "GeneralTetra", 0.428559); + } + + /// Unit tetrahedron mesh intersecting slightly displaced copy of itself + /// \brief Status : pass + void tetraNudged() + { + _testTools->intersectMeshes("UnitTetra", "NudgedTetra", 0.142896); + } + + /// Single-element unit tetrahedron mesh intersecting even slightly displaced (along one axis only) copy of itself + /// \brief Status : pass + void tetraNudgedSimpler() + { + _testTools->intersectMeshes("UnitTetra", "NudgedSimpler", 0.152112); + } + + /// Tetrahedron intersecting unit tetrahedron with in non-degenerate way around corner O + /// \brief Status : pass + void tetraCorner() + { + _testTools->intersectMeshes("UnitTetra", "CornerTetra", 0.0135435); + } + + /// Tetrahedron situated totally inside another + /// \brief Status : pass + void tetraSimpleIncluded() + { + _testTools->intersectMeshes("SimpleIncludedTetra", "SimpleIncludingTetra", 17.0156); + } + + /// Displaced unit tetrahedron intersecting another unit tetrahedron with which it shares an edge + /// \brief Status : pass + void tetraDegenEdge() + { + _testTools->intersectMeshes("UnitTetraDegenT", "DegenEdgeXY", 0.0); + } + + /// Displaced unit tetrahedron intersecting another unit tetrahedron with which it shares a face + /// \brief Status : pass + void tetraDegenFace() + { + _testTools->intersectMeshes("UnitTetraDegenT", "DegenFaceXYZ", 0.0); + } + + /// Displaced unit tetrahedron intersecting another unit tetrahedron with which it shares a part of the face XYZ + /// \brief Status : pass + void tetraDegenTranslatedInPlane() + { + _testTools->intersectMeshes("UnitTetraDegenT", "DegenTranslatedInPlane", 0.0571667); + } + + /// Tetrahedron having only half-strip intersections with the unit tetrahedron + /// \brief Status : pass, but does not really test what it should - does not check that the intersections are detected. No longer needed. + 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 + _testTools->intersectMeshes("HalfstripOnly", "UnitTetra", 0.0); + } + + /// Tetrahedron having only half-strip intersections with the unit tetrahedron + /// \brief Status : pass, but does not really test what it should - does not check that the intersections are detected. No longer needed. + 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 + _testTools->intersectMeshes("HalfstripOnly2", "UnitTetra", 0.0); + } + + /// Tetrahedron having only half-strip intersections with the unit tetrahedron + /// \brief Status : pass, but does not really test what it should - does not check that the intersections are detected. No longer needed. + 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 + _testTools->intersectMeshes("SimpleHalfstripOnly", "UnitTetra", 0.0); + } + + /// Two intersecting tetrahedra situated in a general position in space + /// \brief Status : pass + void generalTetra() + { + _testTools->intersectMeshes("GenTetra1", "GenTetra2", 4.91393); + } + + /// Tetrahedron which is in a tricky position relative to unit tetrahedron. + /// \brief Status : pass + void trickyTetra1() + { + _testTools->intersectMeshes("UnitTetra", "TrickyTetra1", 0.0); + } + + /// Two large tetrahedra which nearly share part of an edge and intersect at the origin. Created with goal of getting the as-of-yet uncovered "consistency" test + /// part of the correction of double products covered. However, it does not succeed with this. + /// \brief Status : fails, but is quite far-fetched as far as typical use cases are concerned + void inconsistentTetra() + { + _testTools->intersectMeshes("LargeUnitTetra.med", "LargeUnitTetra", "LargeInconsistentTetra.med", "LargeInconsistent", 7.86231e7); + } + + }; +} +#endif diff --git a/src/INTERP_KERNELTest/TestInterpKernel.cxx b/src/INTERP_KERNELTest/TestInterpKernel.cxx new file mode 100644 index 000000000..41501ea7e --- /dev/null +++ b/src/INTERP_KERNELTest/TestInterpKernel.cxx @@ -0,0 +1,53 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "CppUnitTest.hxx" +#include "TransformedTriangleTest.hxx" +#include "UnitTetraIntersectionBaryTest.hxx" +#include "TransformedTriangleIntersectTest.hxx" +#include "MultiElementTetraTests.hxx" +#include "SingleElementTetraTests.hxx" +#include "HexaTests.hxx" +#include "BBTreeTest.hxx" +#include "PointLocatorTest.hxx" +#include "RemapperTest.hxx" +#include "MultiElement2DTests.hxx" +#include "SingleElementPlanarTests.hxx" +#include "QuadraticPlanarInterpTest.hxx" +#include "InterpolationOptionsTest.hxx" +using namespace INTERP_TEST; + +//--- Registers the fixture into the 'registry' + +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( UnitTetraIntersectionBaryTest ); +CPPUNIT_TEST_SUITE_REGISTRATION( BBTreeTest); +CPPUNIT_TEST_SUITE_REGISTRATION( RemapperTest); +CPPUNIT_TEST_SUITE_REGISTRATION( PointLocatorTest); +CPPUNIT_TEST_SUITE_REGISTRATION( MultiElement2DTests ); +CPPUNIT_TEST_SUITE_REGISTRATION( SingleElementPlanarTests ); +CPPUNIT_TEST_SUITE_REGISTRATION( QuadraticPlanarInterpTest ); +CPPUNIT_TEST_SUITE_REGISTRATION( InterpolationOptionsTest ); + +// --- generic Main program from KERNEL_SRC/src/Basics/Test + +#include "BasicMainTest.hxx" diff --git a/src/INTERP_KERNELTest/TestingUtils.hxx b/src/INTERP_KERNELTest/TestingUtils.hxx new file mode 100644 index 000000000..1057f58c2 --- /dev/null +++ b/src/INTERP_KERNELTest/TestingUtils.hxx @@ -0,0 +1,308 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef _TESTING_UTILS_HXX_ +#define _TESTING_UTILS_HXX_ + +#include "Interpolation3D.hxx" +#include "MEDMEM_Mesh.hxx" + +#include +#include +#include +#include +#include + +#include "VectorUtils.hxx" + +// levels : +// 1 - titles and volume results +// 2 - symmetry / diagonal results and intersection matrix output +// 3 - empty +// 4 - empty +// 5 - misc +#include "Log.hxx" + +using namespace MEDMEM; +using namespace std; +using namespace INTERP_KERNEL; +using namespace MED_EN; + + +double sumVolume(const IntersectionMatrix& m) +{ + + vector volumes; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + volumes.push_back(iter2->second); + // vol += std::fabs(iter2->second); + } + } + + // sum in ascending order to avoid rounding errors + + sort(volumes.begin(), volumes.end()); + const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); + + return vol; +} + +#if 0 + +bool areCompatitable(const IntersectionMatrix& m1, const IntersectionMatrix& m2) +{ + bool compatitable = true; + int i = 0; + 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; + if(m2.at(j-1).count(i+1) == 0) + { + if(!epsilonEqual(iter2->second, 0.0, VOL_PREC)) + { + LOG(2, "V1( " << i << ", " << j << ") exists, but V2( " << j - 1 << ", " << i + 1 << ") " << " does not " ); + LOG(2, "(" << i << ", " << j << ") fails"); + compatitable = false; + } + } + } + ++i; + } + if(!compatitable) + { + LOG(1, "*** matrices are not compatitable"); + } + return compatitable; +} + +bool testSymmetric(const IntersectionMatrix& m1, const IntersectionMatrix& m2) +{ + + int i = 0; + bool isSymmetric = true; + + LOG(1, "Checking symmetry src - target" ); + isSymmetric = isSymmetric & areCompatitable(m1, m2) ; + LOG(1, "Checking symmetry target - src" ); + isSymmetric = isSymmetric & areCompatitable(m2, m1); + + 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) + // { + map theMap = m2.at(j-1); + const double v2 = theMap[i + 1]; + if(v1 != v2) + { + LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 ); + if(!epsilonEqualRelative(v1, v2, VOL_PREC)) + { + LOG(2, "(" << i << ", " << j << ") fails"); + isSymmetric = false; + } + } + } + ++i; + } + if(!isSymmetric) + { + LOG(1, "*** matrices are not symmetric"); + } + return isSymmetric; +} + +bool testDiagonal(const IntersectionMatrix& m) +{ + LOG(1, "Checking if matrix is diagonal" ); + int i = 1; + bool isDiagonal = true; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + int j = iter2->first; + const double vol = iter2->second; + if(vol != 0.0 && (i != j)) + { + LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" ); + if(!epsilonEqual(vol, 0.0, VOL_PREC)) + { + LOG(2, "(" << i << ", " << j << ") fails"); + isDiagonal = false; + } + } + } + ++i; + } + if(!isDiagonal) + { + LOG(1, "*** matrix is not diagonal"); + } + return isDiagonal; +} + +#endif + +void dumpIntersectionMatrix(const IntersectionMatrix& m) +{ + int i = 0; + std::cout << "Intersection matrix is " << endl; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + + std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << endl; + + } + ++i; + } + std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; +} + +std::pair countNumberOfMatrixEntries(const IntersectionMatrix& m) +{ + + int numElems = 0; + int numNonZero = 0; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + numElems += iter->size(); + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + if(!epsilonEqual(iter2->second, 0.0, VOL_PREC)) + { + ++numNonZero; + } + } + } + return std::make_pair(numElems, numNonZero); +} + + +void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) +{ + const string dataBaseDir = getenv("MED_ROOT_DIR"); + const string dataDir = dataBaseDir + "/share/salome/resources/med/"; + + 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"); + + Interpolation3D* interpolator = new Interpolation3D(); + + m = interpolator->interpolateMeshes(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)); + + delete interpolator; + + LOG(1, "Intersection calculation done. " << std::endl ); + +} + + + + + + + + +#if 0 +void intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec, bool doubleTest) +{ + LOG(1, std::endl << std::endl << "=============================" ); + + using std::string; + const string path1 = string(mesh1path) + string(mesh1); + const string path2 = string(mesh2path) + string(mesh2); + + const bool isTestReflexive = (path1.compare(path2) == 0); + + IntersectionMatrix matrix1; + calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1); + +#if LOG_LEVEL >= 2 + dumpIntersectionMatrix(matrix1); +#endif + + std::cout.precision(16); + + const double vol1 = sumVolume(matrix1); + + if(!doubleTest) + { + LOG(1, "vol = " << vol1 <<" correctVol = " << correctVol ); + // CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(correctVol, vol1)); + + if(isTestReflexive) + { + // CPPUNIT_ASSERT_EQUAL_MESSAGE("Reflexive test failed", true, testDiagonal(matrix1)); + } + } + else + { + + IntersectionMatrix matrix2; + calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2); + +#if LOG_LEVEL >= 2 + dumpIntersectionMatrix(matrix2); +#endif + + const double vol2 = sumVolume(matrix2); + + LOG(1, "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol ); + + // CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(vol1, correctVol)); + // CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec * std::max(vol2, correctVol)); + // CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, prec * std::max(vol1, vol2)); + // CPPUNIT_ASSERT_EQUAL_MESSAGE("Symmetry test failed", true, testSymmetric(matrix1, matrix2)); + } + +} + + + +#endif + + +#endif diff --git a/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.cxx b/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.cxx new file mode 100644 index 000000000..500af44c0 --- /dev/null +++ b/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.cxx @@ -0,0 +1,2283 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "TransformedTriangleIntersectTest.hxx" +#include + +#include "Log.hxx" + +/// macro to test for zero double products outside the segment-edge intersection test method +/// as is done in TransformedTriangle when OPTIMIZE is defined +#define TEST_ZERO_DP_EDGE(seg, edge) isZero[TT::NO_DP*int(seg) + int(DoubleProduct(edge))] + +/// macro to test for zero double products outside the segment-corner intersection test method +/// as is done in TransformedTriangle when OPTIMIZE is defined +#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] )] + +/// macro to test for zero double products outside the segment-ray intersection test method +/// as is done in TransformedTriangle when OPTIMIZE is defined +#define TEST_ZERO_DP_RAY(seg, corner) isZero[TT::NO_DP*int(seg) + TT::DP_SEGMENT_RAY_INTERSECTION[7*(corner-1)]] + +using namespace INTERP_KERNEL; + +namespace INTERP_TEST +{ + + //////////////////////////////////////////////////////////////////////////////////////////////////////// + /// \class TransformedTriangleIntersectTest + /// \brief Class testing the intersection detection methods of TransformedTriangle. + /// + /// This class contains unit tests for the intersection methods of the TransformedTriangle class. + //////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Each method in the class 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
+  /// -----------------------------------------------------------------------------------------------------
+  /// 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 + //////////////////////////////////////////////////////////////////////////////////////////////////////// + + + //////////////////////////////////////////////////////////////////////////////////////////////////////// + /// 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     - 
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle1() + { + LOG(1, "+++++++ Testing triangle 1" ); + + 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 + }; + + 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 + + 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); + } + } + + // 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, 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, 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, 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)); + 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, 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, 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(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(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     - 
+  /// 
+ /// \brief Status: pass + void TransformedTriangleIntersectTest::testTriangle2() + { + LOG(1, "+++++++ Testing triangle 2" ); + typedef TransformedTriangle TT; + + double coords[9] = + { + -0.5, 0.5, 0.25, // P + 1.5, 0.5,-0.25, // Q + -0.5,-1.5, 0.75 // 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 + + 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); + } + } + + // 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(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, 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, 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, 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)); + 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, 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, 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)); + 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; + } + + /// 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     - 
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle3() + { + LOG(1, "+++++++ Testing triangle 3" ); + 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 + + 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); + } + } + + // 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(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, 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(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, 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, 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, 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)); + CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); + CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::PQ, 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, 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, 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, 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(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     - 
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle4() + { + LOG(1, "+++++++ Testing triangle 4" ); + 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 + }; + + 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 + + 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); + } + } + + // 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(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)); + + 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, 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, 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, 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)); + 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, 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, 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)); + 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
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle5() + { + LOG(1, "+++++++ Testing triangle 5" ); + + 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 + + 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); + } + } + + // 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, 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, 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, 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)); + 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, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); + CPPUNIT_ASSERT_EQUAL(true , 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, 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(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(true , tri->testSurfaceRayIntersection(TT::Z)); + + delete tri; + } + + /// Triangle 6 has the following intersections + ///
+  /// CI     -
+  /// COH    -
+  /// CAH    -
+  /// SF     -
+  /// SE     -
+  /// SC     -
+  /// SHS    -
+  /// SR     (PQ, X), (QR, Z) 
+  /// TE     -
+  /// TR     Y 
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle6() + { + LOG(1, "+++++++ Testing triangle 6" ); + + 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 + + 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); + } + } + + // 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, 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, 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, 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)); + 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(true , 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, 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(true , 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(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 
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle7() + { + + LOG(1, "+++++++ Testing triangle 7" ); + 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]); + + // 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 + + 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); + } + } + + // 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(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, 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, 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, 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)); + 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, 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, 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)); + 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     - 
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle8() + { + LOG(1, "+++++++ Testing triangle 8" ); + 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 + + 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); + } + } + + // 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, 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, 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, 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(true , 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)); + 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, 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, 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(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     - 
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle9() + { + LOG(1, "+++++++ Testing triangle 9" ); + 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 + + 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); + } + } + + // 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, 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(true , 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, 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, 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)); + 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, 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, 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(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     - 
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle10() + { + LOG(1, "+++++++ Testing triangle 10" ); + 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 + + 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); + } + } + + // 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, 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(true , 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, 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, 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)); + 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, 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, 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(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, OZ]
+  /// TR     - 
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle11() + { + LOG(1, "+++++++ Testing triangle 11" ); + 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 + + 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); + } + } + + // 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 , 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, 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, 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(true , 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)); + 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, 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, 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(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 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     - 
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle12() + { + LOG(1, "+++++++ Testing triangle 12" ); + 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 + + 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); + } + } + + // 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, 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(true , 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, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); + CPPUNIT_ASSERT_EQUAL(true , 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, 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)); + 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, 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, 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(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     - 
+  /// 
+ /// \brief Status : pass + void TransformedTriangleIntersectTest::testTriangle13() + { + LOG(1, "+++++++ Testing triangle 13" ); + 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 + + 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); + } + } + + // 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, 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, 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, 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(true , 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(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, 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, 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(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; + } + + +} // NAMESPACE + + + + + + + +///// TEMPLATE /////////////////////////////// + + + +#if 0 +// Triangle x has the following intersections +// CI - +// COH - +// CAH - +// SF - +// SE - +// SC - +// SHS - +// SR - +// TE - +// TR - + +void TransformedTriangleIntersectTest::testTriangleX() +{ + LOG(1, "+++++++ Testing triangle X" ); + 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_KERNELTest/TransformedTriangleIntersectTest.hxx b/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.hxx new file mode 100644 index 000000000..752c0508c --- /dev/null +++ b/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.hxx @@ -0,0 +1,91 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __TU_TRANSFORMED_TRIANGLE_INTERSECT_HXX__ +#define __TU_TRANSFORMED_TRIANGLE_INTERSECT_HXX__ + +#include +#include "../TransformedTriangle.hxx" + +namespace INTERP_TEST +{ + + 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_KERNEL::TransformedTriangle::TriSegment TriSegment; + typedef INTERP_KERNEL::TransformedTriangle::DoubleProduct DoubleProduct; + + public: + + void testTriangle1(); + + void testTriangle2(); + + void testTriangle3(); + + void testTriangle4(); + + void testTriangle5(); + + void testTriangle6(); + + void testTriangle7(); + + void testTriangle8(); + + void testTriangle9(); + + void testTriangle10(); + + void testTriangle11(); + + void testTriangle12(); + + void testTriangle13(); + + private: + + }; + +} + + + + + + +#endif diff --git a/src/INTERP_KERNELTest/TransformedTriangleTest.cxx b/src/INTERP_KERNELTest/TransformedTriangleTest.cxx new file mode 100644 index 000000000..e668dbc03 --- /dev/null +++ b/src/INTERP_KERNELTest/TransformedTriangleTest.cxx @@ -0,0 +1,354 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "TransformedTriangleTest.hxx" + +#include + +using namespace INTERP_KERNEL; + +namespace INTERP_TEST +{ + + /** + * Creates the TransformedTriangle objects used by the tests. + * + */ + void TransformedTriangleTest::setUp() + { + // tri1 -> no unstable double products - no changes brought about by preCalculateDoubleProducts + // this allows the testing of calcUnstableT + // tri2 -> unstable double products - for testing calcStableC / preCalculateDoubleProducts + + // triangle to test unstable C and T calculations + p1[0] = -1.5 ; p1[1] = 0.5; p1[2] = 0.5; + q1[0] = 2.0 ; q1[1] = 0.4; q1[2] = 0.6; + r1[0] = 1.0 ; r1[1] = 2.4; r1[2] = 1.2; + hp1 = 1 - p1[0] - p1[1] - p1[2]; + hq1 = 1 - q1[0] - q1[1] - q1[2]; + hr1 = 1 - r1[0] - r1[1] - r1[2]; + Hp1 = 1 - p1[0] - p1[1]; + Hq1 = 1 - q1[0] - q1[1]; + Hr1 = 1 - r1[0] - r1[1]; + + // std::cout <_coords[i], ERR_TOL); + CPPUNIT_ASSERT_DOUBLES_EQUAL(good_values2[i], tri2->_coords[i], ERR_TOL); + } + + CPPUNIT_ASSERT_EQUAL(true, tri1->_is_double_products_calculated); + CPPUNIT_ASSERT_EQUAL(true, tri2->_is_double_products_calculated); + } + + /// Tests the calculation of double products (without the corrections) + /// \brief Status : pass + void TransformedTriangleTest::test_calcUnstableC() { + typedef TransformedTriangle::TriSegment TriSegment; + + // test that the correct c-values are calculated + + double correct_c_vals[24] = + { + p1[0] * q1[1] - p1[1] * q1[0], + p1[1] * q1[2] - p1[2] * q1[1], + p1[2] * q1[0] - p1[0] * q1[2], + p1[0] * hq1 - hp1 * q1[0], + p1[1] * hq1 - hp1 * q1[1], + p1[2] * hq1 - hp1 * q1[2], + Hp1 * q1[0] - p1[0] * Hq1, + p1[1] * Hq1 - Hp1 * q1[1], + q1[0] * r1[1] - q1[1] * r1[0], + q1[1] * r1[2] - q1[2] * r1[1], + q1[2] * r1[0] - q1[0] * r1[2], + q1[0] * hr1 - hq1 * r1[0], + q1[1] * hr1 - hq1 * r1[1], + q1[2] * hr1 - hq1 * r1[2], + Hq1 * r1[0] - q1[0] * Hr1, + q1[1] * Hr1 - Hq1 * r1[1], + r1[0]*p1[1]-r1[1]*p1[0], + r1[1]*p1[2]-r1[2]*p1[1], + r1[2]*p1[0]-r1[0]*p1[2], + r1[0] * hp1 - hr1 * p1[0], + r1[1] * hp1 - hr1 * p1[1], + r1[2] * hp1 - hr1 * p1[2], + Hr1 * p1[0] - r1[0] * Hp1, + r1[1] * Hp1 - Hr1 * p1[1] + }; + + double c_vals[3 * 8]; + for(TriSegment seg = TransformedTriangle::PQ ; seg <= TransformedTriangle::RP ; seg = TriSegment(seg + 1)) { + + c_vals[seg*8 + 0] = tri1->calcUnstableC(seg, TransformedTriangle::C_XY); + c_vals[seg*8 + 1] = tri1->calcUnstableC(seg, TransformedTriangle::C_YZ); + c_vals[seg*8 + 2] = tri1->calcUnstableC(seg, TransformedTriangle::C_ZX); + c_vals[seg*8 + 3] = tri1->calcUnstableC(seg, TransformedTriangle::C_XH); + c_vals[seg*8 + 4] = tri1->calcUnstableC(seg, TransformedTriangle::C_YH); + c_vals[seg*8 + 5] = tri1->calcUnstableC(seg, TransformedTriangle::C_ZH); + c_vals[seg*8 + 6] = tri1->calcUnstableC(seg, TransformedTriangle::C_01); + c_vals[seg*8 + 7] = tri1->calcUnstableC(seg, TransformedTriangle::C_10); + + } + + for(int i = 0 ; i < 3*8 ; ++i) { + CPPUNIT_ASSERT_DOUBLES_EQUAL( correct_c_vals[i], c_vals[i], ERR_TOL ); + } + + + } + + /// Tests the calculation of triple products (without corrections) + /// \brief Status : pass + void TransformedTriangleTest::test_calcUnstableT() + { + typedef TransformedTriangle::TetraCorner TetraCorner; + + // correct values calculated by determinants (Grandy, [15]) + const double correct_t_vals[4] = + { + p1[0]*(q1[1]*r1[2] - q1[2]*r1[1]) - + q1[0]*(p1[1]*r1[2] - p1[2]*r1[1]) + + r1[0]*(p1[1]*q1[2] - p1[2]*q1[1]), + + -(hp1*(q1[1]*r1[2] - q1[2]*r1[1]) - + hq1*(p1[1]*r1[2] - p1[2]*r1[1]) + + hr1*(p1[1]*q1[2] - p1[2]*q1[1])), + + -(p1[0]*(hq1*r1[2] - q1[2]*hr1) - + q1[0]*(hp1*r1[2] - p1[2]*hr1) + + r1[0]*(hp1*q1[2] - p1[2]*hq1)), + + -(p1[0]*(q1[1]*hr1 - r1[1]*hq1) - + q1[0]*(p1[1]*hr1 - r1[1]*hp1) + + r1[0]*(p1[1]*hq1 - q1[1]*hp1)) + }; + + + // test that triple products are correctly calculated + for(TetraCorner corner = TransformedTriangle::O ; corner <= TransformedTriangle::Z ; corner = TetraCorner(corner + 1)) + { + + for(int row = 1 ; row < 4 ; ++row) + { + const double t = tri1->calcTByDevelopingRow(corner, row, false); + // std::cout << std::endl << " Corner = " << corner << " Row = " << row << " got: " << t << + // " expected: " << correct_t_vals[corner]<< std::endl; + CPPUNIT_ASSERT_DOUBLES_EQUAL(correct_t_vals[corner], t, ERR_TOL); + } + } + } + + /// Tests the consistency correction + /// \brief Status : fails because it is not significant - the consistency correction is not brought into play + void TransformedTriangleTest::test_calcStableC_Consistency() + { + + typedef TransformedTriangle::TriSegment TriSegment; + typedef TransformedTriangle::TetraCorner TetraCorner; + + // grandy, eq 14 + double correct_c_vals[24] = + { + p2[0] * q2[1] - p2[1] * q2[0], + p2[1] * q2[2] - p2[2] * q2[1], + p2[2] * q2[0] - p2[0] * q2[2], + p2[0] * hq2 - hp2 * q2[0], + p2[1] * hq2 - hp2 * q2[1], + p2[2] * hq2 - hp2 * q2[2], + Hp2 * q2[0] - p2[0] * Hq2, + p2[1] * Hq2 - Hp2 * q2[1], + q2[0] * r2[1] - q2[1] * r2[0], + q2[1] * r2[2] - q2[2] * r2[1], + q2[2] * r2[0] - q2[0] * r2[2], + q2[0] * hr2 - hq2 * r2[0], + q2[1] * hr2 - hq2 * r2[1], + q2[2] * hr2 - hq2 * r2[2], + Hq2 * r2[0] - q2[0] * Hr2, + q2[1] * Hr2 - Hq2 * r2[1], + r2[0]*p2[1]-r2[1]*p2[0], + r2[1]*p2[2]-r2[2]*p2[1], + r2[2]*p2[0]-r2[0]*p2[2], + r2[0] * hp2 - hr2 * p2[0], + r2[1] * hp2 - hr2 * p2[1], + r2[2] * hp2 - hr2 * p2[2], + Hr2 * p2[0] - r2[0] * Hp2, + r2[1] * Hp2 - Hr2 * p2[1] + }; + + + // number of inconsistent cases found : + // should be (at least) 1 for the test to be meaningful + int num_cases = 0; + + // find unstable products to check for consistency (Grandy [46]) + for(TriSegment seg = TransformedTriangle::PQ ; seg <= TransformedTriangle::RP ; seg = TriSegment(seg + 1)) + { + const double c_xy = tri2->calcUnstableC(seg, TransformedTriangle::C_XY); + const double c_yz = tri2->calcUnstableC(seg, TransformedTriangle::C_YZ); + const double c_zx = tri2->calcUnstableC(seg, TransformedTriangle::C_ZX); + const double c_xh = tri2->calcUnstableC(seg, TransformedTriangle::C_XH); + const double c_yh = tri2->calcUnstableC(seg, TransformedTriangle::C_YH); + const double c_zh = tri2->calcUnstableC(seg, TransformedTriangle::C_ZH); + + const int num_zero = (c_yz*c_xh == 0.0 ? 1 : 0) + (c_zx*c_yh == 0.0 ? 1 : 0) + (c_xy*c_zh == 0.0 ? 1 : 0); + const int num_neg = (c_yz*c_xh < 0.0 ? 1 : 0) + (c_zx*c_yh < 0.0 ? 1 : 0) + (c_xy*c_zh < 0.0 ? 1 : 0); + + if((num_zero == 1 && num_neg != 1) || num_zero == 2 || num_neg == 0 && num_zero !=3 || num_neg == 3 ) + { + ++num_cases; + + double min_dist = -1.0; // initialised first time through loop + TetraCorner min_corner = TransformedTriangle::O; + + for(TetraCorner corner = TransformedTriangle::O ; corner <= TransformedTriangle::Z ; corner = TetraCorner(corner + 1)) + { + // calculate distance from each corner of tetraeder to the segment + // 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 ptCorner[3] = { + corner == TransformedTriangle::X ? 1.0 : 0.0, + corner == TransformedTriangle::Y ? 1.0 : 0.0, + corner == TransformedTriangle::Z ? 1.0 : 0.0, + }; + + const double diff_21[3] = { ptQ[0] - ptP[0], ptQ[1] - ptP[1], ptQ[2] - ptP[2] }; + const double diff_1_corner[3] = { ptP[0] - ptCorner[0], ptP[1] - ptCorner[1], ptP[2] - ptCorner[2] }; + + const double cross[3] = { + diff_21[1]*diff_1_corner[2] - diff_21[2]*diff_1_corner[1], + diff_21[2]*diff_1_corner[0] - diff_21[0]*diff_1_corner[2], + diff_21[0]*diff_1_corner[1] - diff_21[1]*diff_1_corner[0] + }; + + const double cross_sq = cross[0]*cross[0] + cross[1]*cross[1] + cross[2]*cross[2]; + + const double norm_pq = diff_21[0]*diff_21[0] + diff_21[1]*diff_21[1] + diff_21[2]*diff_21[2]; + + if(corner == TransformedTriangle::O || (cross_sq / norm_pq) < min_dist) + { + min_dist = cross_sq / norm_pq; + min_corner = corner; + } + } + + // now check if the corresponding double products are zero + static const DoubleProduct DOUBLE_PRODUCTS[12] = + { + TransformedTriangle::C_YZ, TransformedTriangle::C_XY, TransformedTriangle::C_ZX, // O + TransformedTriangle::C_ZH, TransformedTriangle::C_YZ, TransformedTriangle::C_YH, // X + TransformedTriangle::C_ZH, TransformedTriangle::C_ZX, TransformedTriangle::C_XH, // Y + TransformedTriangle::C_XY, TransformedTriangle::C_YH, TransformedTriangle::C_XH // Z + }; + + 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; + CPPUNIT_ASSERT_EQUAL(0.0, tri2->calcStableC(seg, dp)); + correct_c_vals[8*seg + dp] = 0.0; + } + } + + } + + if(num_cases < 1) + { + CPPUNIT_FAIL("Consistency test not pertinent"); + } + + // std::cout << std::endl << "Number of geometric inconsistencies : " << num_cases << std::endl; + + // check that all other double products have right value too + double c_vals[8*3]; + + for(TriSegment seg = TransformedTriangle::PQ ; seg <= TransformedTriangle::RP ; seg = TriSegment(seg + 1)) { + + c_vals[seg*8 + 0] = tri2->calcStableC(seg, TransformedTriangle::C_XY); + c_vals[seg*8 + 1] = tri2->calcStableC(seg, TransformedTriangle::C_YZ); + c_vals[seg*8 + 2] = tri2->calcStableC(seg, TransformedTriangle::C_ZX); + c_vals[seg*8 + 3] = tri2->calcStableC(seg, TransformedTriangle::C_XH); + c_vals[seg*8 + 4] = tri2->calcStableC(seg, TransformedTriangle::C_YH); + c_vals[seg*8 + 5] = tri2->calcStableC(seg, TransformedTriangle::C_ZH); + c_vals[seg*8 + 6] = tri2->calcStableC(seg, TransformedTriangle::C_01); + c_vals[seg*8 + 7] = tri2->calcStableC(seg, TransformedTriangle::C_10); + + } + + for(int i = 0 ; i < 24 ; ++i) + { + CPPUNIT_ASSERT_DOUBLES_EQUAL(correct_c_vals[i], c_vals[i], ERR_TOL); + } + } + +} diff --git a/src/INTERP_KERNELTest/TransformedTriangleTest.hxx b/src/INTERP_KERNELTest/TransformedTriangleTest.hxx new file mode 100644 index 000000000..c3ff65de7 --- /dev/null +++ b/src/INTERP_KERNELTest/TransformedTriangleTest.hxx @@ -0,0 +1,87 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __TU_TRANSFORMED_TRIANGLE_HXX__ +#define __TU_TRANSFORMED_TRIANGLE_HXX__ + +#include +#include "../TransformedTriangle.hxx" + +#define ERR_TOL 1.0e-8 + +using INTERP_KERNEL::TransformedTriangle; + +namespace INTERP_TEST +{ + + /** + * \brief Test suite testing some of the low level methods of TransformedTriangle. + * + */ + class TransformedTriangleTest : public CppUnit::TestFixture + { + + CPPUNIT_TEST_SUITE( TransformedTriangleTest ); + CPPUNIT_TEST( test_constructor ); + CPPUNIT_TEST( test_calcUnstableC ); + CPPUNIT_TEST( test_calcUnstableT ); + //removed because the test fails to enter the desired code branch + // CPPUNIT_TEST( test_calcStableC_Consistency ); + CPPUNIT_TEST_SUITE_END(); + + typedef INTERP_KERNEL::TransformedTriangle::TriSegment TriSegment; + typedef INTERP_KERNEL::TransformedTriangle::DoubleProduct DoubleProduct; + + public: + void setUp(); + + void tearDown(); + + // tests + void test_constructor(); + + void test_calcUnstableC(); + + void test_calcUnstableT(); + + void test_calcStableC_Consistency(); + + double p1[3], q1[3], r1[3]; + double hp1, hq1, hr1; + double Hp1, Hq1, Hr1; + + double p2[3], q2[3], r2[3]; + double hp2, hq2, hr2; + double Hp2, Hq2, Hr2; + + double stable_c2[24]; + + private: + TransformedTriangle* tri1; + TransformedTriangle* tri2; + + }; + + + + +} + + + +#endif diff --git a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx new file mode 100644 index 000000000..c92b25e5e --- /dev/null +++ b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx @@ -0,0 +1,293 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : UnitTetraIntersectionBaryTest.cxx +// Created : Thu Dec 11 15:54:41 2008 +// Author : Edward AGAPOV (eap) +#include "UnitTetraIntersectionBaryTest.hxx" + +#include "UnitTetraIntersectionBary.hxx" +#include "TetraAffineTransform.hxx" +#include "InterpolationUtils.hxx" + +#include + +using namespace INTERP_KERNEL; +using namespace std; + +namespace INTERP_TEST +{ + void fill_UnitTetraIntersectionBary(UnitTetraIntersectionBary& bary, double nodes[][3]) + { + int faceConn[4][3] = { { 0, 2, 1 }, + { 0, 1, 3 }, + { 1, 2, 3 }, + { 3, 2, 0 } }; + bary.init(); + for ( int i = 0; i < 4; ++i ) { + int* faceNodes = faceConn[ i ]; + TransformedTriangle tri(nodes[faceNodes[0]], nodes[faceNodes[1]], nodes[faceNodes[2]]); + tri.calculateIntersectionVolume(); + bary.addSide( tri ); + } + } + void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_1() + { + // cutting tetra coincides with the unit one + double nodes[4][3] = { { 0.0, 0.0, 0.0 }, + { 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 } }; + UnitTetraIntersectionBary bary; + fill_UnitTetraIntersectionBary(bary,nodes); + double baryCenter[3]; + bool ok = bary.getBary( baryCenter ); + double vol = bary.getVolume(); + CPPUNIT_ASSERT( ok ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[1], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[2], 1e-5); + } + void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_2() + { + // cutting tetra fully include the unit one + double nodes[4][3] = { {-0.1,-0.1,-0.1 }, + { 1.5,-0.1,-0.1 }, + {-0.1, 1.5,-0.1 }, + {-0.1,-0.1, 1.5 } }; + UnitTetraIntersectionBary bary; + fill_UnitTetraIntersectionBary(bary,nodes); + double baryCenter[3]; + bool ok = bary.getBary( baryCenter ); + double vol = bary.getVolume(); + CPPUNIT_ASSERT( ok ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[1], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[2], 1e-5); + } + void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_3() + { + // cutting tetra is same as the unit one but moved up by 0.5 + double nodes[4][3] = { { 0.0, 0.0, 0.5 }, + { 1.0, 0.0, 0.5 }, + { 0.0, 1.0, 0.5 }, + { 0.0, 0.0, 1.5 } }; + UnitTetraIntersectionBary bary; + fill_UnitTetraIntersectionBary(bary,nodes); + double baryCenter[3]; + bool ok = bary.getBary( baryCenter ); + double vol = bary.getVolume(); + CPPUNIT_ASSERT( ok ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.020833333333333332, vol, 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[0], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[1], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.625, baryCenter[2], 1e-5); + } + void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_4() + { + // same as previous but no cutting sides lay on the sides of unit tetra + double nodes[4][3] = { {-0.2,-0.2, 0.5 }, + { 1.0, 0.0, 0.5 }, + { 0.0, 1.0, 0.5 }, + { 0.0, 0.0, 2.0 } }; + UnitTetraIntersectionBary bary; + fill_UnitTetraIntersectionBary(bary,nodes); + double baryCenter[3]; + bool ok = bary.getBary( baryCenter ); + double vol = bary.getVolume(); + CPPUNIT_ASSERT( ok ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.020833333333333332, vol, 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[0], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[1], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.625, baryCenter[2], 1e-5); + } + void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_5() + { + // cutting tetra is similar and parallel to the UT but moved (-0.1,-0.1,-0.1) + double nodes[4][3] = { {-0.1,-0.1,-0.1 }, + { 1.1,-0.1,-0.1 }, + {-0.1, 1.1,-0.1 }, + {-0.1,-0.1, 1.1 } }; + UnitTetraIntersectionBary bary; + fill_UnitTetraIntersectionBary(bary,nodes); + double baryCenter[3]; + bool ok = bary.getBary( baryCenter ); + double vol = bary.getVolume(); + CPPUNIT_ASSERT( ok ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1215, vol, 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.225, baryCenter[0], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.225, baryCenter[1], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.225, baryCenter[2], 1e-5); + } + void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_6() + { + // cutting tetra is deeped into the UT with one corner + double nodes[4][3] = { { 0.2, 0.2, 0.2 }, + { 1.0, 0.2, 0.2 }, + { 0.9, 1.0, 0.2 }, + { 0.9, 9.0, 1.0 } }; + UnitTetraIntersectionBary bary; + fill_UnitTetraIntersectionBary(bary,nodes); + double baryCenter[3]; + bool ok = bary.getBary( baryCenter ); + double vol = bary.getVolume(); + CPPUNIT_ASSERT( ok ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.000441855, vol, 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.353463 , baryCenter[0], 1e-5 ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.33877 , baryCenter[1], 1e-5 ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.207767 , baryCenter[2], 1e-5 ); + } + void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_7() + { + // cutting tetra passes through the UT with one corner + double nodes[4][3] = { {-0.2, 0.2, 0.2 }, + { 1.0, 0.2, 0.2 }, + { 0.9, 1.0, 0.2 }, + { 0.9, 0.9, 1.0 } }; + UnitTetraIntersectionBary bary; + fill_UnitTetraIntersectionBary(bary,nodes); + double baryCenter[3]; + bool ok = bary.getBary( baryCenter ); + double vol = bary.getVolume(); + CPPUNIT_ASSERT( ok ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0103501, vol, 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.215578 , baryCenter[0], 1e-5 ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.341363 , baryCenter[1], 1e-5 ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.263903 , baryCenter[2], 1e-5 ); + } + void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_8() + { + // cutting tetra passes through the UT with one edge + double nodes[4][3] = { { 0.5, 0.2, -0.2 }, // O + {-0.5,-0.2, -0.2 }, // OX + { 1.0,-0.5, -0.2 }, // OY + { 0.5, 0.2, 1.5 } };//OZ + UnitTetraIntersectionBary bary; + fill_UnitTetraIntersectionBary(bary,nodes); + double baryCenter[3]; + bool ok = bary.getBary( baryCenter ); + double vol = bary.getVolume(); + CPPUNIT_ASSERT( ok ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0349217, vol, 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.332275 , baryCenter[0], 1e-2 ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0565892 , baryCenter[1], 1e-3 ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.308713 , baryCenter[2], 1e-2 ); + } + void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_9() + { + // cutting tetra touches the UT at an edge, intersection volume == 0 + double nodes[4][3] = { { 1.0, 0.0, 0.0 }, // 0 + {-1.0, 2.0, 2.0 }, // OX + {-1.0,-2.0, 2.0 }, // OY + { 1.0, 0.0, 2.0 } };//OZ + UnitTetraIntersectionBary bary; + fill_UnitTetraIntersectionBary(bary,nodes); + double baryCenter[3]; + bool ok = bary.getBary( baryCenter ); + double vol = bary.getVolume(); + CPPUNIT_ASSERT( !ok ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, vol, 1e-15); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -1. , baryCenter[0], 1e-5 ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -1. , baryCenter[1], 1e-5 ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -1. , baryCenter[2], 1e-5 ); + } + void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_10() + { + // cutting tetra fully includes theUT and touches it at an edge + double nodes[4][3] = { { 1.0, 0.0, 0.0 }, // 0 + {-1.0,-4.0, 2.0 }, // OX + {-1.0, 4.0, 2.0 }, // OY + { 1.0, 0.0,-2.0 } };//OZ + UnitTetraIntersectionBary bary; + fill_UnitTetraIntersectionBary(bary,nodes); + double baryCenter[3]; + bool ok = bary.getBary( baryCenter ); + double vol = bary.getVolume(); + CPPUNIT_ASSERT( ok ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[1], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[2], 1e-5); + } + void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_11() + { + // cutting tetra intersects the UT and touches it at an edge + double nodes[4][3] = { { 1.0, 0.0, 0.0 }, // 0 + {-1.0,-4.0, 2.0 }, // OX + {-1.0, 4.0, 2.0 }, // OY + {-1.0, 0.0,-1.0 } };//OZ + UnitTetraIntersectionBary bary; + fill_UnitTetraIntersectionBary(bary,nodes); + double baryCenter[3]; + bool ok = bary.getBary( baryCenter ); + double vol = bary.getVolume(); + CPPUNIT_ASSERT( ok ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.15873 , vol, 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.250000, baryCenter[0], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.230952, baryCenter[1], 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.260714, baryCenter[2], 1e-5); + } + + void UnitTetraIntersectionBaryTest::test_TetraAffineTransform_reverseApply() + { + double nodes[4][3] = { {-4.0, 9.0, 3.0 }, + {11.0, 0.0, 2.0 }, + { 0.0, 0.0, 0.0 }, + { 2.0, 1.0,10.0 }}; + // double pSrc[3] = { -4.0, 9.0, 3.0 }; + double pSrc[3] = { 40., -20., 100. }; + double pDest[] = {1,1,1}; + const double* n[4] = { &nodes[0][0], &nodes[1][0], &nodes[2][0], &nodes[3][0] }; + TetraAffineTransform a(&n[0]); + a.apply( pDest, pSrc ); + a.reverseApply( pDest, pDest ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( pSrc[0], pDest[0], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( pSrc[1], pDest[1], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( pSrc[2], pDest[2], 1e-12); + } + + void UnitTetraIntersectionBaryTest::test_barycentric_coords() + { + // compute barycentric coordinates + double nodes[4][3] = { {11.0, 0.0, 2.0 }, + {-4.0, 9.0, 3.0 }, + { 0.0, 0.0, 0.0 }, + { 6.0, 1.0,10.0 }}; + vector n (4); + n[0] = &nodes[0][0]; + n[1] = &nodes[1][0]; + n[2] = &nodes[2][0]; + n[3] = &nodes[3][0]; + double p [3] = { 2, 2, 5 }, bc[4]; + barycentric_coords(n, p, bc); + double bcSum = 0; + double p2 [3] = { 0,0,0 }; + for ( int i = 0; i < 4; ++i ) { + bcSum += bc[i]; + p2[0] += bc[i]*n[i][0]; + p2[1] += bc[i]*n[i][1]; + p2[2] += bc[i]*n[i][2]; + } + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., bcSum, 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( p[0], p2[0], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( p[1], p2[1], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( p[2], p2[2], 1e-12); + } +} diff --git a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx new file mode 100644 index 000000000..26c1be3fd --- /dev/null +++ b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx @@ -0,0 +1,67 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : UnitTetraIntersectionBaryTests.hxx +// Created : Thu Nov 6 17:11:27 2008 +// Author : Edward AGAPOV (eap) +#ifndef __UNITTETRAINTERSECTIONBARYTEST_HXX__ +#define __UNITTETRAINTERSECTIONBARYTEST_HXX__ + +#include + +namespace INTERP_TEST +{ + /** + * \brief Test suite testing UnitTetraIntersectionBary class. + * + */ + class UnitTetraIntersectionBaryTest : public CppUnit::TestFixture + { + CPPUNIT_TEST_SUITE( UnitTetraIntersectionBaryTest ); + CPPUNIT_TEST( test_UnitTetraIntersectionBary_1 ); + CPPUNIT_TEST( test_UnitTetraIntersectionBary_2 ); + CPPUNIT_TEST( test_UnitTetraIntersectionBary_3 ); + CPPUNIT_TEST( test_UnitTetraIntersectionBary_4 ); + CPPUNIT_TEST( test_UnitTetraIntersectionBary_5 ); + CPPUNIT_TEST( test_UnitTetraIntersectionBary_6 ); + CPPUNIT_TEST( test_UnitTetraIntersectionBary_7 ); + CPPUNIT_TEST( test_UnitTetraIntersectionBary_8 ); + CPPUNIT_TEST( test_UnitTetraIntersectionBary_9 ); + CPPUNIT_TEST( test_UnitTetraIntersectionBary_10 ); + CPPUNIT_TEST( test_UnitTetraIntersectionBary_11 ); + CPPUNIT_TEST( test_TetraAffineTransform_reverseApply ); + CPPUNIT_TEST( test_barycentric_coords ); + CPPUNIT_TEST_SUITE_END(); + public: + void test_UnitTetraIntersectionBary_1(); + void test_UnitTetraIntersectionBary_2(); + void test_UnitTetraIntersectionBary_3(); + void test_UnitTetraIntersectionBary_4(); + void test_UnitTetraIntersectionBary_5(); + void test_UnitTetraIntersectionBary_6(); + void test_UnitTetraIntersectionBary_7(); + void test_UnitTetraIntersectionBary_8(); + void test_UnitTetraIntersectionBary_9(); + void test_UnitTetraIntersectionBary_10(); + void test_UnitTetraIntersectionBary_11(); + void test_TetraAffineTransform_reverseApply(); + void test_barycentric_coords(); + }; +} + +#endif diff --git a/src/INTERP_KERNELTest/perf_test.sh b/src/INTERP_KERNELTest/perf_test.sh new file mode 100755 index 000000000..1a087b4a6 --- /dev/null +++ b/src/INTERP_KERNELTest/perf_test.sh @@ -0,0 +1,165 @@ +#!/bin/bash +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# should be run from the build directory, so that ./PerfTest is available +# output file +# +RES_FILE=perf_OPTIMIZE + +#outputs lines of form : +#"no. source elems no. target elems user time" +function test_pair { + echo -n $1 | sed 's/\(PerfCyl\)\([0-9]*\)/\2/' | sed 's/\(PerfBoxT\)\([0-9]*\)/\2/' | sed 's/\(PerfBox\)\([0-9]*\)/\2/' >> $RES_FILE + echo -n " " >> $RES_FILE + echo -n $2 | sed 's/\(PerfCyl\)\([0-9]*\)/\2/' | sed 's/\(PerfBoxT\)\([0-9]*\)/\2/' | sed 's/\(PerfBox\)\([0-9]*\)/\2/' >> $RES_FILE + echo -n " " >> $RES_FILE + time -o $RES_FILE --append -f"%U" ./PerfTest $1 $2 + echo +} + +function test_box_box { +echo PerfBox PerfBox >> $RES_FILE + +test_pair PerfBox1495 PerfBox1495 +test_pair PerfBox2506 PerfBox2506 +test_pair PerfBox5708 PerfBox5708 +test_pair PerfBox13461 PerfBox13461 +test_pair PerfBox30808 PerfBox30808 +test_pair PerfBox47176 PerfBox47176 + +test_pair PerfBox1495 PerfBox2506 +test_pair PerfBox1495 PerfBox5708 +test_pair PerfBox1495 PerfBox13461 +test_pair PerfBox1495 PerfBox30808 +test_pair PerfBox1495 PerfBox47176 + +test_pair PerfBox2506 PerfBox5708 +test_pair PerfBox2506 PerfBox13461 +test_pair PerfBox2506 PerfBox30808 +test_pair PerfBox2506 PerfBox47176 + +test_pair PerfBox5708 PerfBox13461 +test_pair PerfBox5708 PerfBox30808 +test_pair PerfBox5708 PerfBox47176 + +test_pair PerfBox13461 PerfBox30808 +test_pair PerfBox13461 PerfBox47176 + +test_pair PerfBox30808 PerfBox47176 + +} + +function test_cyl_cyl { +echo PerfCyl PerfCyl >> $RES_FILE + +test_pair PerfCyl1047 PerfCyl1047 +test_pair PerfCyl3020 PerfCyl3020 +test_pair PerfCyl6556 PerfCyl6556 +test_pair PerfCyl9766 PerfCyl9766 +test_pair PerfCyl25745 PerfCyl25745 +test_pair PerfCyl47601 PerfCyl47601 + +test_pair PerfCyl1047 PerfCyl3020 +test_pair PerfCyl1047 PerfCyl6556 +test_pair PerfCyl1047 PerfCyl9766 +test_pair PerfCyl1047 PerfCyl25745 +test_pair PerfCyl1047 PerfCyl47601 + +test_pair PerfCyl3020 PerfCyl6556 +test_pair PerfCyl3020 PerfCyl9766 +test_pair PerfCyl3020 PerfCyl25745 +test_pair PerfCyl3020 PerfCyl47601 + +test_pair PerfCyl6556 PerfCyl9766 +test_pair PerfCyl6556 PerfCyl25745 +test_pair PerfCyl6556 PerfCyl47601 + +test_pair PerfCyl9766 PerfCyl25745 +test_pair PerfCyl9766 PerfCyl47601 + +test_pair PerfCyl25745 PerfCyl47601 + +} + +function test_box_cyl { + echo PerfBox PerfCyl >> $RES_FILE + test_pair PerfBox1495 PerfCyl1047 + test_pair PerfBox1495 PerfCyl3020 + test_pair PerfBox1495 PerfCyl6556 + test_pair PerfBox1495 PerfCyl9766 + test_pair PerfBox1495 PerfCyl25745 + test_pair PerfBox1495 PerfCyl47601 + + test_pair PerfBox2506 PerfCyl1047 + test_pair PerfBox2506 PerfCyl3020 + test_pair PerfBox2506 PerfCyl6556 + test_pair PerfBox2506 PerfCyl9766 + test_pair PerfBox2506 PerfCyl25745 + test_pair PerfBox2506 PerfCyl47601 + + test_pair PerfBox5708 PerfCyl1047 + test_pair PerfBox5708 PerfCyl3020 + test_pair PerfBox5708 PerfCyl6556 + test_pair PerfBox5708 PerfCyl9766 + test_pair PerfBox5708 PerfCyl25745 + test_pair PerfBox5708 PerfCyl47601 + + test_pair PerfBox13461 PerfCyl1047 + test_pair PerfBox13461 PerfCyl3020 + test_pair PerfBox13461 PerfCyl6556 + test_pair PerfBox13461 PerfCyl9766 + test_pair PerfBox13461 PerfCyl25745 + test_pair PerfBox13461 PerfCyl47601 + + test_pair PerfBox30808 PerfCyl1047 + test_pair PerfBox30808 PerfCyl3020 + test_pair PerfBox30808 PerfCyl6556 + test_pair PerfBox30808 PerfCyl9766 + test_pair PerfBox30808 PerfCyl25745 + test_pair PerfBox30808 PerfCyl47601 + + test_pair PerfBox47176 PerfCyl1047 + test_pair PerfBox47176 PerfCyl3020 + test_pair PerfBox47176 PerfCyl6556 + test_pair PerfBox47176 PerfCyl9766 + test_pair PerfBox47176 PerfCyl25745 + test_pair PerfBox47176 PerfCyl47601 +} + +function test_box_transbox { + echo PerfBox PerfBoxT >> $RES_FILE + test_pair PerfBox1495 PerfBoxT1493 + test_pair PerfBox2506 PerfBoxT2676 + test_pair PerfBox5708 PerfBoxT5717 + test_pair PerfBox13461 PerfBoxT12469 + test_pair PerfBox30808 PerfBoxT29019 + test_pair PerfBox47176 PerfBoxT47278 +} + + + +#functions to execute : + +echo PerfTest execution on `date` > $RES_FILE +test_box_cyl +test_box_box +test_cyl_cyl +test_box_transbox + +cat $RES_FILE \ No newline at end of file