X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FTest%2FMEDCouplingBasicsTest5.cxx;h=d262304631c8da01271fefedfb6f247b35d7a140;hb=6cd41c45013304a8f773a3f3311cc4b7950a5aa5;hp=09854dfc7ef718a5a20dcf26b3e0fb78a88f9a76;hpb=0de3ecddfda5a60cbb17ffa0a5ee53540178e063;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx index 09854dfc7..d26230463 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2014 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. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -84,6 +84,30 @@ void MEDCouplingBasicsTest5::testUMeshTessellate2D1() m1->decrRef(); } +void MEDCouplingBasicsTest5::testUMeshTessellate2DCurve1() +{ + // A quarter of circle: + double mcoords[6] = {0.4,0.0, 0.0,-0.4, 0.283,-0.283}; + int mconnec[3] = {0,1,2}; + + MEDCouplingUMesh *m1 = MEDCouplingUMesh::New(); + m1->setMeshDimension(1); + m1->allocateCells(1); + m1->insertNextCell(INTERP_KERNEL::NORM_SEG3, 3, mconnec); + + DataArrayDouble *myCoords = DataArrayDouble::New(); + myCoords->alloc(3,2); + std::copy(mcoords,mcoords+6,myCoords->getPointer()); + m1->setCoords(myCoords); + myCoords->decrRef(); + + MEDCouplingUMesh *m2 = static_cast(m1->deepCpy()); + m2->tessellate2DCurve(0.1); + CPPUNIT_ASSERT_NO_THROW(m2->checkCoherency1(0.0)); // eps param not used + m1->decrRef(); + m2->decrRef(); +} + /*! * idem MEDCouplingBasicsTest4::testIntersect2DMeshesTmp3 except that m1 and m2 are permuted on call to MEDCouplingUMesh::Intersect2DMeshes */ @@ -1379,7 +1403,7 @@ void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2() // resize with explicit ids list MEDCouplingUMesh *m=build2DTargetMesh_1(); std::set s; s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); const int ids1[3]={0,3,4}; MEDCouplingUMesh *part=static_cast(m->buildPartOfMySelf(ids1,ids1+3,true)); part->simplexize(0)->decrRef(); @@ -1393,7 +1417,7 @@ void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2() CPPUNIT_ASSERT(std::equal(expected2,expected2+6,m->getNodalConnectivityIndex()->getConstPointer())); CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems()); s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); m->decrRef(); part->decrRef(); part2->decrRef(); // no resize with explicit ids list m=build2DTargetMesh_1(); @@ -1407,7 +1431,7 @@ void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2() CPPUNIT_ASSERT(std::equal(expected4,expected4+6,m->getNodalConnectivityIndex()->getConstPointer())); CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems()); s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); s.insert(INTERP_KERNEL::NORM_POLYGON); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); m->decrRef(); part->decrRef(); // resize with range ids m=build2DTargetMesh_1(); @@ -1420,7 +1444,7 @@ void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2() CPPUNIT_ASSERT(std::equal(expected6,expected6+6,m->getNodalConnectivityIndex()->getConstPointer())); CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems()); s.clear(); s.insert(INTERP_KERNEL::NORM_QUAD4); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); m->decrRef(); part->decrRef(); // no resize with range ids m=build2DTargetMesh_1(); @@ -1434,7 +1458,7 @@ void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2() CPPUNIT_ASSERT(std::equal(expected8,expected8+6,m->getNodalConnectivityIndex()->getConstPointer())); CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems()); s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); s.insert(INTERP_KERNEL::NORM_POLYGON); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); m->decrRef(); part->decrRef(); // no resize with range ids negative direction m=build2DTargetMesh_1(); @@ -1448,7 +1472,7 @@ s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD CPPUNIT_ASSERT(std::equal(expected10,expected10+6,m->getNodalConnectivityIndex()->getConstPointer())); CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems()); s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); s.insert(INTERP_KERNEL::NORM_POLYGON); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); part->decrRef(); m->decrRef(); } @@ -1476,7 +1500,7 @@ void MEDCouplingBasicsTest5::testUnPolyze3() m->unPolyze(); CPPUNIT_ASSERT_EQUAL(1,m->getNumberOfCells()); std::set s; s.insert(INTERP_KERNEL::NORM_PENTA6); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); // const int expected1[2]={0,7}; const int expected2[7]={16,0,2,1,3,5,4}; @@ -1774,6 +1798,64 @@ void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp6() d2->decrRef(); } +void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp7() +{ + double eps = 1.0e-8; + // coordinates circle - SEE getCircle() on the Python side + DataArrayDouble *coords1=DataArrayDouble::New(); + const double coordsData1[16]={0.5328427124746189, -0.08284271247461905, -0.03284271247461901, 0.4828427124746191, -0.03284271247461906, -0.082842712474619, 0.5328427124746191, 0.482842712474619}; + coords1->useArray(coordsData1,false,CPP_DEALLOC,8,2); + // connectivity + DataArrayInt *conn1=DataArrayInt::New(); + const int connData1[5]={INTERP_KERNEL::NORM_QPOLYG,0,1,2,3}; + conn1->useArray(connData1,false,CPP_DEALLOC,5,1); + DataArrayInt *connI1=DataArrayInt::New(); + const int connIData1[2]={0,5}; + connI1->useArray(connIData1,false,CPP_DEALLOC,2,1); + MEDCouplingUMesh *m1=MEDCouplingUMesh::New("circle",2); + m1->setCoords(coords1); + m1->setConnectivity(conn1,connI1,true); + coords1->decrRef(); conn1->decrRef(); connI1->decrRef(); + + // square + DataArrayDouble *coords2=DataArrayDouble::New(); + const double coordsData2[8]={-0.5,-0.5, -0.5, 0.5, 0.5, 0.5, 0.5,-0.5}; + coords2->useArray(coordsData2,false,CPP_DEALLOC,4,2); + // connectivity + DataArrayInt *conn2=DataArrayInt::New(); + const int connData2[5]={INTERP_KERNEL::NORM_POLYGON, 0,1,2,3}; + conn2->useArray(connData2,false,CPP_DEALLOC,5,1); + DataArrayInt *connI2=DataArrayInt::New(); + const int connIData2[2]={0,5}; + connI2->useArray(connIData2,false,CPP_DEALLOC,2,1); + MEDCouplingUMesh *m2=MEDCouplingUMesh::New("square",2); + m2->setCoords(coords2); + m2->setConnectivity(conn2,connI2,true); + coords2->decrRef(); conn2->decrRef(); connI2->decrRef(); + + DataArrayInt * resToM1 = 0, * resToM2 = 0; + MEDCouplingUMesh *m_intersec=MEDCouplingUMesh::Intersect2DMeshes(m2, m1, eps, resToM1, resToM2); + m_intersec->zipCoords(); + + const double coo_tgt[34]={-0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.03284271247461901, 0.4828427124746191, \ + -0.014575131106459124, 0.5000000000000001, 0.5, -0.11224989991991996, 0.24271243444677046, 0.5, 0.5, 0.19387505004004, \ + -0.04799910280454185, -0.06682678787499614, -0.023843325638122054, 0.4915644577163915, 0.5, -0.30612494995996, 0.0, -0.5,\ + -0.5, 0.0, -0.25728756555322957, 0.5, -0.023843325638122026, 0.49156445771639157, -0.04799910280454181, -0.06682678787499613}; + const int conn_tgt[22]={32, 5, 2, 6, 4, 7, 8, 9, 10, 32, 6, 3, 0, 1, 5, 4, 11, 12, 13, 14, 15, 16}; + const int connI_tgt[3]={0, 9, 22}; + const int res1_tgt[2] = {0, 0}; + const int res2_tgt[2] = {0, -1}; + + CPPUNIT_ASSERT(std::equal(conn_tgt,conn_tgt+22,m_intersec->getNodalConnectivity()->getConstPointer())); + CPPUNIT_ASSERT(std::equal(connI_tgt,connI_tgt+3,m_intersec->getNodalConnectivityIndex()->getConstPointer())); + CPPUNIT_ASSERT(std::equal(res1_tgt,res1_tgt+2,resToM1->getConstPointer())); + CPPUNIT_ASSERT(std::equal(res2_tgt,res2_tgt+2,resToM2->getConstPointer())); + for(int i=0;i<34;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(coo_tgt[i],m_intersec->getCoords()->getIJ(0,i),1e-12); + m1->decrRef(); m2->decrRef(); m_intersec->decrRef(); + resToM1->decrRef(); resToM2->decrRef(); +} + void MEDCouplingBasicsTest5::testDAIBuildSubstractionOptimized1() { const int tab1[7]={1,3,5,6,7,9,13};