-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2013 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// Author : Anthony Geay (CEA/DEN)
#include "MEDCouplingBasicsTest5.hxx"
#include "MEDCouplingUMesh.hxx"
DataArrayInt *d1=0,*d2=0;
MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m2,m1,1e-10,d1,d2);
m3->unPolyze();
- const int expected1[12]={0,0,1,2,2,3,4,4,5,6,6,7};
- const int expected2[12]={0,1,1,2,3,3,4,5,5,6,7,7};
- CPPUNIT_ASSERT_EQUAL(12,d1->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(12,d2->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(12,m3->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(88,m3->getNumberOfNodes());
+ const int expected1[16]={0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7};
+ const int expected2[16]={0,1,1,-1,2,3,3,-1,4,5,5,-1,6,7,7,-1};
+ CPPUNIT_ASSERT_EQUAL(16,d1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(16,d2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(16,m3->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(104,m3->getNumberOfNodes());
CPPUNIT_ASSERT_EQUAL(2,m3->getSpaceDimension());
- CPPUNIT_ASSERT(std::equal(expected1,expected1+12,d1->getConstPointer()));
- CPPUNIT_ASSERT(std::equal(expected2,expected2+12,d2->getConstPointer()));
- const int expected3[100]={6,16,15,18,44,45,46,8,18,2,1,16,47,48,49,50,8,17,1,2,40,51,52,53,54,6,18,15,20,55,56,57,8,20,7,6,18,58,59,60,61,8,41,6,7,21,62,63,64,65,6,20,15,22,66,67,68,8,22,11,7,20,69,70,71,72,8,21,7,11,42,73,74,75,76,6,22,15,16,77,78,79,8,16,1,13,22,80,81,82,83,8,43,13,1,17,84,85,86,87};
- const int expected4[13]={0,7,16,25,32,41,50,57,66,75,82,91,100};
- const double expected5[176]={0.,0.,1.1,0.,1.1,1.,0.,1.,1.7,0.,1.7,1.,-1.1,1.,-1.1,0.,-1.7,0.,-1.7,1.,-1.7,-1.,-1.1,-1.,0.,-1.,1.1,-1.,1.7,-1.,0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1.,0.,-1.5,0.5,0.,1.25,0.,0.7071067811865476,0.7071067811865476,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.7071067811865476,0.7071067811865476,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.7071067811865476,-0.7071067811865476,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.7071067811865476,-0.7071067811865476,1.0606601717798214,-1.0606601717798214,1.1180339887498951,1.,-1.1180339887498951,1.,-1.1180339887498951,-1.,1.1180339887498951,-1.,0.5,0.,0.,0.5,0.7071067811865477,0.7071067811865476,0.55,1.,1.1,0.5,1.05,0.,0.7071067811865477,0.7071067811865477,1.3,0.,1.1,0.5,1.1090169943749475,1.,1.4012585384440737,0.535233134659635,0.,0.5,-0.5,0.,-0.7071067811865477,0.7071067811865476,-1.05,0.,-1.1,0.5,-0.55,1.,-0.7071067811865477,0.7071067811865477,-1.1090169943749475,1.,-1.1,0.5,-1.3,0.,-1.4012585384440737,0.5352331346596344,-0.5,0.,0.,-0.5,-0.7071067811865475,-0.7071067811865477,-0.55,-1.,-1.1,-0.5,-1.05,0.,-0.7071067811865479,-0.7071067811865476,-1.3,0.,-1.1,-0.5,-1.1090169943749475,-1.,-1.4012585384440734,-0.5352331346596354,0.,-0.5,0.5,0.,0.7071067811865475,-0.7071067811865477,1.05,0.,1.1,-0.5,0.55,-1.,0.7071067811865477,-0.7071067811865476,1.1090169943749475,-1.,1.1,-0.5,1.3,0.,1.4012585384440737,-0.535233134659635};
- CPPUNIT_ASSERT_EQUAL(100,m3->getNodalConnectivity()->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(13,m3->getNodalConnectivityIndex()->getNumberOfTuples());
- CPPUNIT_ASSERT(std::equal(expected3,expected3+100,m3->getNodalConnectivity()->getConstPointer()));
- CPPUNIT_ASSERT(std::equal(expected4,expected4+13,m3->getNodalConnectivityIndex()->getConstPointer()));
- for(int i=0;i<176;i++)
+ CPPUNIT_ASSERT(std::equal(expected1,expected1+16,d1->getConstPointer()));
+ CPPUNIT_ASSERT(std::equal(expected2,expected2+16,d2->getConstPointer()));
+ const int expected3[136]={6,16,15,18,44,45,46,8,18,2,1,16,47,48,49,50,8,17,1,2,40,51,52,53,54,8,40,5,4,17,55,56,57,58,6,18,15,20,59,60,61,8,20,7,6,18,62,63,64,65,8,41,6,7,21,66,67,68,69,8,21,8,9,41,70,71,72,73,6,20,15,22,74,75,76,8,22,11,7,20,77,78,79,80,8,21,7,11,42,81,82,83,84,8,42,10,8,21,85,86,87,88,6,22,15,16,89,90,91,8,16,1,13,22,92,93,94,95,8,43,13,1,17,96,97,98,99,8,17,4,14,43,100,101,102,103};
+ const int expected4[17]={0,7,16,25,34,41,50,59,68,75,84,93,102,109,118,127,136};
+ const double expected5[208]={0.,0.,1.1, 0.,1.1,1.,0.,1.,1.7,0.,1.7,1.,-1.1,1.,-1.1,0.,-1.7,0.,-1.7,1.,-1.7,-1.,-1.1,-1.,0.,-1.,1.1,-1.,1.7,-1.,0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1.,0.,-1.5,0.5,0.,1.25,0.,0.7071067811865476,0.7071067811865476,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.7071067811865476,0.7071067811865476,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.7071067811865476,-0.7071067811865476,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.7071067811865476,-0.7071067811865476,1.0606601717798214,-1.0606601717798214,1.1180339887498951,1.,-1.1180339887498951,1.,-1.1180339887498951,-1.,1.1180339887498951,-1.,0.5,0.,0.,0.5,0.7071067811865477,0.7071067811865476,0.55,1.,1.1,0.5,1.05,0.,0.7071067811865477,0.7071067811865475,1.3,0.,1.1,0.5,1.1090169943749475,1.,1.4012585384440737,0.535233134659635,1.4090169943749475,1.,1.7,0.5,1.6,0.,1.4012585384440737,0.535233134659635,0.,0.5,-0.5,0.,-0.7071067811865477,0.7071067811865476,-1.05,0.,-1.1,0.5,-0.55,1.,-0.7071067811865478,0.7071067811865475,-1.1090169943749475,1.,-1.1,0.5,-1.3,0.,-1.4012585384440737,0.5352331346596344,-1.6,0.,-1.7,0.5,-1.4090169943749475,1.,-1.4012585384440737,0.5352331346596344,-0.5,0.,0.,-0.5,-0.7071067811865475,-0.7071067811865477,-0.55,-1.,-1.1,-0.5,-1.05,0.,-0.7071067811865475,-0.7071067811865477,-1.3,0.,-1.1,-0.5,-1.1090169943749475,-1.,-1.4012585384440734,-0.5352331346596354,-1.4090169943749475,-1.,-1.7,-0.5,-1.6,0.,-1.4012585384440732,-0.5352331346596354,0.,-0.5,0.5,0.,0.7071067811865475,-0.7071067811865477,1.05,0.,1.1,-0.5,0.55,-1.,0.7071067811865475,-0.7071067811865477,1.1090169943749475,-1.,1.1,-0.5,1.3,0.,1.4012585384440737,-0.535233134659635,1.6,0.,1.7,-0.5,1.4090169943749475,-1.,1.4012585384440737,-0.535233134659635};
+ CPPUNIT_ASSERT_EQUAL(136,m3->getNodalConnectivity()->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(17,m3->getNodalConnectivityIndex()->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::equal(expected3,expected3+136,m3->getNodalConnectivity()->getConstPointer()));
+ CPPUNIT_ASSERT(std::equal(expected4,expected4+17,m3->getNodalConnectivityIndex()->getConstPointer()));
+ for(int i=0;i<208;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],m3->getCoords()->getIJ(0,i),1e-12);
d1->decrRef();
d2->decrRef();
//
std::vector<std::pair<int,int> > p(3);
p[0].first=0; p[0].second=3; p[1].first=3; p[1].second=5; p[2].first=5; p[2].second=7;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayDouble *>(da->selectByTupleRanges(p));
CPPUNIT_ASSERT(tmp->isEqual(*da,1e-14));
tmp->decrRef();
p[0].first=0; p[0].second=2; p[1].first=3; p[1].second=4; p[2].first=5; p[2].second=7;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayDouble *>(da->selectByTupleRanges(p));
const double expected1[10]={1.,11.,2.,12.,4.,14.,6.,16.,7.,17.};
CPPUNIT_ASSERT_EQUAL(5,tmp->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(2,tmp->getNumberOfComponents());
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],tmp->getIJ(0,i),1e-14);
tmp->decrRef();
p[0].first=0; p[0].second=2; p[1].first=0; p[1].second=2; p[2].first=5; p[2].second=6;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayDouble *>(da->selectByTupleRanges(p));
const double expected2[10]={1.,11.,2.,12.,1.,11.,2.,12.,6.,16.};
CPPUNIT_ASSERT_EQUAL(5,tmp->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(2,tmp->getNumberOfComponents());
//
std::vector<std::pair<int,int> > p(3);
p[0].first=0; p[0].second=3; p[1].first=3; p[1].second=5; p[2].first=5; p[2].second=7;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayInt *>(da->selectByTupleRanges(p));
CPPUNIT_ASSERT(tmp->isEqual(*da));
tmp->decrRef();
p[0].first=0; p[0].second=2; p[1].first=3; p[1].second=4; p[2].first=5; p[2].second=7;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayInt *>(da->selectByTupleRanges(p));
const int expected1[10]={1,11,2,12,4,14,6,16,7,17};
CPPUNIT_ASSERT_EQUAL(5,tmp->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(2,tmp->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(expected1[i],tmp->getIJ(0,i));
tmp->decrRef();
p[0].first=0; p[0].second=2; p[1].first=0; p[1].second=2; p[2].first=5; p[2].second=6;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayInt *>(da->selectByTupleRanges(p));
const int expected2[10]={1,11,2,12,1,11,2,12,6,16};
CPPUNIT_ASSERT_EQUAL(5,tmp->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(2,tmp->getNumberOfComponents());
mesh2->checkCoherency();
CPPUNIT_ASSERT_EQUAL(2,mesh2->getMeshDimension());
CPPUNIT_ASSERT_EQUAL(30,mesh2->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(31,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(31,revDescIndx->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(13,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(13,descIndx->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(48,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,desc->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(48,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,revDesc->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)31,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(31,revDescIndx->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)13,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(13,descIndx->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)48,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,desc->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)48,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,revDesc->getNumberOfTuples());
const int expected1[48]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,-10,15,-5,-13,16,17,-14,18,-4,19,-2,20,21,22,23,24,25,-11,26,-1,-12,-25,-22,27,28,-7,-20,-24,29,-16,-18,30,-8,-28};
CPPUNIT_ASSERT(std::equal(expected1,expected1+48,desc->getConstPointer()));
const int expected2[13]={0,4,8,12,16,20,24,28,32,36,40,44,48};
CPPUNIT_ASSERT(skin->getCoords()==umesh->getCoords());
const int expected1[19]={0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54};
const int expected2[54]={1,1,0,1,0,5,1,2,1,1,3,2,1,4,3,1,9,4,1,5,10,1,14,9,1,10,15,1,19,14,1,15,20,1,24,19,1,20,25,1,25,26,1,26,27,1,27,28,1,28,29,1,29,24};
- CPPUNIT_ASSERT_EQUAL(19,skin->getNodalConnectivityIndex()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)19,skin->getNodalConnectivityIndex()->getNbOfElems());
CPPUNIT_ASSERT(std::equal(expected1,expected1+19,skin->getNodalConnectivityIndex()->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(54,skin->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)54,skin->getNodalConnectivity()->getNbOfElems());
CPPUNIT_ASSERT(std::equal(expected2,expected2+54,skin->getNodalConnectivity()->getConstPointer()));
DataArrayInt *ids=skin->computeFetchedNodeIds();
const int expected3[18]={0,1,2,3,4,5,9,10,14,15,19,20,24,25,26,27,28,29};
- CPPUNIT_ASSERT_EQUAL(18,ids->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)18,ids->getNbOfElems());
CPPUNIT_ASSERT(std::equal(expected3,expected3+18,ids->getConstPointer()));
MEDCouplingUMesh *part=dynamic_cast<MEDCouplingUMesh *>(umesh->buildFacePartOfMySelfNode(ids->begin(),ids->end(),true));
- part->setName(skin->getName());
+ part->setName(skin->getName().c_str());
CPPUNIT_ASSERT(part->isEqual(skin,1e-12));
MEDCouplingUMesh *part2=dynamic_cast<MEDCouplingUMesh *>(part->buildPartOfMySelf2(1,18,2,true));
DataArrayInt *ids2=DataArrayInt::Range(0,18,2);
CPPUNIT_ASSERT_EQUAL(9,part->getNumberOfCells());
const int expected4[18]={0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8};
CPPUNIT_ASSERT(std::equal(expected4,expected4+18,trad->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(18,trad->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)18,trad->getNbOfElems());
trad->decrRef();
part->decrRef();
part2->decrRef();
m->setPartOfMySelf(ids1,ids1+3,*part2);
const int expected1[20]={3,0,4,1,3,1,4,2,3,4,5,2,3,6,7,4,3,7,5,4};
CPPUNIT_ASSERT(std::equal(expected1,expected1+20,m->getNodalConnectivity()->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(20,m->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)20,m->getNodalConnectivity()->getNbOfElems());
const int expected2[6]={0,4,8,12,16,20};
CPPUNIT_ASSERT(std::equal(expected2,expected2+6,m->getNodalConnectivityIndex()->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(6,m->getNodalConnectivityIndex()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems());
s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3);
CPPUNIT_ASSERT(s==m->getAllTypes());
m->decrRef(); part->decrRef(); part2->decrRef();
m->setPartOfMySelf(ids1+1,ids1+3,*part);
const int expected3[23]={4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3};
CPPUNIT_ASSERT(std::equal(expected3,expected3+23,m->getNodalConnectivity()->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(23,m->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)23,m->getNodalConnectivity()->getNbOfElems());
const int expected4[6]={0,5,9,13,18,23};
CPPUNIT_ASSERT(std::equal(expected4,expected4+6,m->getNodalConnectivityIndex()->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(6,m->getNodalConnectivityIndex()->getNbOfElems());
+ 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());
m->decrRef(); part->decrRef();
m->setPartOfMySelf2(1,3,1,*part);
const int expected5[25]={4,0,3,4,1,4,6,7,4,3,4,7,8,5,4,4,6,7,4,3,4,7,8,5,4};
CPPUNIT_ASSERT(std::equal(expected5,expected5+25,m->getNodalConnectivity()->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(25,m->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)25,m->getNodalConnectivity()->getNbOfElems());
const int expected6[6]={0,5,10,15,20,25};
CPPUNIT_ASSERT(std::equal(expected6,expected6+6,m->getNodalConnectivityIndex()->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(6,m->getNodalConnectivityIndex()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems());
s.clear(); s.insert(INTERP_KERNEL::NORM_QUAD4);
CPPUNIT_ASSERT(s==m->getAllTypes());
m->decrRef(); part->decrRef();
m->setPartOfMySelf2(3,5,1,*part);
const int expected7[23]={4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3};
CPPUNIT_ASSERT(std::equal(expected7,expected7+23,m->getNodalConnectivity()->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(23,m->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)23,m->getNodalConnectivity()->getNbOfElems());
const int expected8[6]={0,5,9,13,18,23};
CPPUNIT_ASSERT(std::equal(expected8,expected8+6,m->getNodalConnectivityIndex()->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(6,m->getNodalConnectivityIndex()->getNbOfElems());
+ 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());
m->decrRef(); part->decrRef();
m->setPartOfMySelf2(4,2,-1,*part);
const int expected9[23]={4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3};
CPPUNIT_ASSERT(std::equal(expected9,expected9+23,m->getNodalConnectivity()->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(23,m->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)23,m->getNodalConnectivity()->getNbOfElems());
const int expected10[6]={0,5,9,13,18,23};
CPPUNIT_ASSERT(std::equal(expected10,expected10+6,m->getNodalConnectivityIndex()->getConstPointer()));
- CPPUNIT_ASSERT_EQUAL(6,m->getNodalConnectivityIndex()->getNbOfElems());
+ 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());
part->decrRef();
d4->decrRef();
d5->decrRef();
}
+
+void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp5()
+{
+ // coordinates
+ DataArrayDouble *coords=DataArrayDouble::New();
+ const double coordsData[376]={41,0,42,0,0,42,0,41,41.5,0,29.698484809834998,29.698484809834994,0,41.5,28.991378028648452,28.991378028648445,-42,0,-41,0,-29.698484809834994,29.698484809834998,-41.5,0,-28.991378028648445,28.991378028648452,0,-42,0,-41,-29.698484809835001,-29.698484809834994,0,-41.5,-28.991378028648455,-28.991378028648445,29.698484809834987,-29.698484809835001,28.991378028648441,-28.991378028648455,43,0,0,43,42.5,0,30.405591591021544,30.40559159102154,0,42.5,-43,0,-30.40559159102154,30.405591591021544,-42.5,0,0,-43,-30.405591591021551,-30.40559159102154,0,-42.5,30.405591591021537,-30.405591591021551,44,0,0,44,43.5,0,31.112698372208094,31.112698372208087,0,43.5,-44,0,-31.112698372208087,31.112698372208094,-43.5,0,0,-44,-31.112698372208097,-31.112698372208087,0,-43.5,31.112698372208083,-31.112698372208097,45,0,0,45,44.5,0,31.81980515339464,31.819805153394636,0,44.5,-45,0,-31.819805153394636,31.81980515339464,-44.5,0,0,-45,-31.819805153394647,-31.819805153394636,0,-44.5,31.819805153394629,-31.819805153394647,47,0,0,47,46,0,33.234018715767739,33.234018715767732,0,46,-47,0,-33.234018715767732,33.234018715767739,-46,0,0,-47,-33.234018715767739,-33.234018715767732,0,-46,33.234018715767725,-33.234018715767739,49,0,0,49,48,0,34.648232278140831,34.648232278140824,0,48,-49,0,-34.648232278140824,34.648232278140831,-48,0,0,-49,-34.648232278140839,-34.648232278140824,0,-48,34.648232278140817,-34.648232278140839,51,0,0,51,50,0,36.062445840513924,36.062445840513924,0,50,-51,0,-36.062445840513924,36.062445840513924,-50,0,0,-51,-36.062445840513931,-36.062445840513924,0,-50,36.062445840513917,-36.062445840513931,53,0,0,53,52,0,37.476659402887023,37.476659402887016,0,52,-53,0,-37.476659402887016,37.476659402887023,-52,0,0,-53,-37.47665940288703,-37.476659402887016,0,-52,37.476659402887009,-37.47665940288703,55,0,0,55,54,0,38.890872965260115,38.890872965260108,0,54,-55,0,-38.890872965260108,38.890872965260115,-54,0,0,-55,-38.890872965260122,-38.890872965260108,0,-54,38.890872965260101,-38.890872965260122,59,0,0,59,57,0,41.719300090006307,41.7193000900063,0,57,-59,0,-41.7193000900063,41.719300090006307,-57,0,0,-59,-41.719300090006314,-41.7193000900063,0,-57,41.719300090006293,-41.719300090006314,63,0,0,63,61,0,44.547727214752499,44.547727214752491,0,61,-63,0,-44.547727214752491,44.547727214752499,-61,0,0,-63,-44.547727214752506,-44.547727214752491,0,-61,44.547727214752484,-44.547727214752506,67,0,0,67,65,0,47.37615433949869,47.376154339498683,0,65,-67,0,-47.376154339498683,47.37615433949869,-65,0,0,-67,-47.376154339498697,-47.376154339498683,0,-65,47.376154339498676,-47.376154339498697,71,0,0,71,69,0,50.204581464244875,50.204581464244868,0,69,-71,0,-50.204581464244868,50.204581464244875,-69,0,0,-71,-50.204581464244889,-50.204581464244868,0,-69,50.20458146424486,-50.204581464244889,75,0,0,75,73,0,53.033008588991066,53.033008588991059,0,73,-75,0,-53.033008588991059,53.033008588991066,-73,0,0,-75,-53.033008588991073,-53.033008588991059,0,-73,53.033008588991052,-53.033008588991073,80,0,0,80,77.5,0,56.568542494923804,56.568542494923797,0,77.5,-80,0,-56.568542494923797,56.568542494923804,-77.5,0,0,-80,-56.568542494923818,-56.568542494923797,0,-77.5,56.56854249492379,-56.568542494923818};
+ coords->useArray(coordsData,false,CPP_DEALLOC,188,2);
+ coords->setName("");
+ DataArrayInt *conn=DataArrayInt::New();
+ const int connData[540]={8,0,1,2,3,4,5,6,7,8,3,2,8,9,6,10,11,12,8,9,8,13,14,11,15,16,17,8,14,13,1,0,16,18,4,19,8,1,20,21,2,22,23,24,5,8,2,21,25,8,24,26,27,10,8,8,25,28,13,27,29,30,15,8,13,28,20,1,30,31,22,18,8,20,32,33,21,34,35,36,23,8,21,33,37,25,36,38,39,26,8,25,37,40,28,39,41,42,29,8,28,40,32,20,42,43,34,31,8,32,44,45,33,46,47,48,35,8,33,45,49,37,48,50,51,38,8,37,49,52,40,51,53,54,41,8,40,52,44,32,54,55,46,43,8,44,56,57,45,58,59,60,47,8,45,57,61,49,60,62,63,50,8,49,61,64,52,63,65,66,53,8,52,64,56,44,66,67,58,55,8,56,68,69,57,70,71,72,59,8,57,69,73,61,72,74,75,62,8,61,73,76,64,75,77,78,65,8,64,76,68,56,78,79,70,67,8,68,80,81,69,82,83,84,71,8,69,81,85,73,84,86,87,74,8,73,85,88,76,87,89,90,77,8,76,88,80,68,90,91,82,79,8,80,92,93,81,94,95,96,83,8,81,93,97,85,96,98,99,86,8,85,97,100,88,99,101,102,89,8,88,100,92,80,102,103,94,91,8,92,104,105,93,106,107,108,95,8,93,105,109,97,108,110,111,98,8,97,109,112,100,111,113,114,101,8,100,112,104,92,114,115,106,103,8,104,116,117,105,118,119,120,107,8,105,117,121,109,120,122,123,110,8,109,121,124,112,123,125,126,113,8,112,124,116,104,126,127,118,115,8,116,128,129,117,130,131,132,119,8,117,129,133,121,132,134,135,122,8,121,133,136,124,135,137,138,125,8,124,136,128,116,138,139,130,127,8,128,140,141,129,142,143,144,131,8,129,141,145,133,144,146,147,134,8,133,145,148,136,147,149,150,137,8,136,148,140,128,150,151,142,139,8,140,152,153,141,154,155,156,143,8,141,153,157,145,156,158,159,146,8,145,157,160,148,159,161,162,149,8,148,160,152,140,162,163,154,151,8,152,164,165,153,166,167,168,155,8,153,165,169,157,168,170,171,158,8,157,169,172,160,171,173,174,161,8,160,172,164,152,174,175,166,163,8,164,176,177,165,178,179,180,167,8,165,177,181,169,180,182,183,170,8,169,181,184,172,183,185,186,173,8,172,184,176,164,186,187,178,175};
+ conn->useArray(connData,false,CPP_DEALLOC,540,1);
+ conn->setName("");
+ DataArrayInt *connI=DataArrayInt::New();
+ const int connIData[61]={0,9,18,27,36,45,54,63,72,81,90,99,108,117,126,135,144,153,162,171,180,189,198,207,216,225,234,243,252,261,270,279,288,297,306,315,324,333,342,351,360,369,378,387,396,405,414,423,432,441,450,459,468,477,486,495,504,513,522,531,540};
+ connI->useArray(connIData,false,CPP_DEALLOC,61,1);
+ connI->setName("");
+ //
+ MEDCouplingUMesh *m1=MEDCouplingUMesh::New("Fix",2);
+ m1->setCoords(coords);
+ m1->setConnectivity(conn,connI,true);
+ coords->decrRef(); conn->decrRef(); connI->decrRef();
+ //
+ coords=DataArrayDouble::New();
+ const double coordsData2[84]={46.5,-2.5,53.5,-2.5,53.5,2.5,46.5,2.5,50,-2.5,53.5,0,50,2.5,46.5,0,60.5,-2.5,60.5,2.5,57,-2.5,60.5,0,57,2.5,53.5,7.5,46.5,7.5,53.5,5,50,7.5,46.5,5,60.5,7.5,60.5,5,57,7.5,-2,47,2,47,2,53,-2,53,0,47,2,50,0,53,-2,50,6,47,6,53,4,47,6,50,4,53,2,59,-2,59,2,56,0,59,-2,56,6,59,6,56,4,59};
+ coords->useArray(coordsData2,false,CPP_DEALLOC,42,2);
+ coords->setName("");
+ // connectivity
+ conn=DataArrayInt::New();
+ const int connData2[72]={8,0,1,2,3,4,5,6,7,8,1,8,9,2,10,11,12,5,8,3,2,13,14,6,15,16,17,8,2,9,18,13,12,19,20,15,8,21,22,23,24,25,26,27,28,8,22,29,30,23,31,32,33,26,8,24,23,34,35,27,36,37,38,8,23,30,39,34,33,40,41,36};
+ conn->useArray(connData2,false,CPP_DEALLOC,72,1);
+ conn->setName("");
+ connI=DataArrayInt::New();
+ const int connIData2[9]={0,9,18,27,36,45,54,63,72};
+ connI->useArray(connIData2,false,CPP_DEALLOC,9,1);
+ connI->setName("");
+ MEDCouplingUMesh *m2=MEDCouplingUMesh::New("Mobile",2);
+ m2->setCoords(coords);
+ m2->setConnectivity(conn,connI,true);
+ coords->decrRef(); conn->decrRef(); connI->decrRef();
+ //
+ DataArrayInt *d1=0,*d2=0;
+ MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1,m2,1e-10,d1,d2);
+ CPPUNIT_ASSERT_EQUAL(105,m3->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(105,d1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(105,d2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(704,m3->getNumberOfNodes());
+ //
+ const double areaExpected[105]={-65.18804756198824,-65.18804756198824,-65.18804756198824,-65.18804756198824,-66.75884388878285,-66.75884388878285,-66.7588438887833,-66.75884388878308,-68.32964021557768,-68.32964021557768,-68.32964021557814,-68.32964021557791,-69.9004365423732,-69.9004365423732,-69.90043654237297,-69.90043654237297,-1.194568659706448,-1.0869994447159463,-142.2316939607081,-144.51326206513068,-144.5132620651309,-1.1945686597064424,-143.3186934054243,-5.002264310862817,-10.0261332846393,-3.9727823117092953,-7.290862524642649,-124.504404940456,-3.9727823117093237,-146.82366506060032,-150.79644737231024,-5.002264310862776,-145.79418306144626,-5.00208651738126,-10.054764051268958,-4.001067863263231,-8.027932154428669,-129.99378209314813,-4.001067863263216,-153.07856481622616,-157.0796326794898,-5.0020865173811915,-152.07754616210832,-5.001928880064381,-10.050590216368969,-4.00098721602491,-8.025810856794209,-136.28350081741684,-4.000987216024939,-159.36183077064402,-163.36281798667005,-5.0019288800643285,-158.36088910660442,-1.2991516319851801,-3.702636830195414,-3.7815130030068254,-6.265364371195623,-0.02516260900254963,-0.6553944641345026,-3.975752765070567,-7.368528340442765,-142.57249927881398,-0.02516260900254963,-3.9757527650706095,-165.64508791977525,-169.64600329384803,-1.299151631985167,-3.7026368301953885,-164.6442148316677,-10.00321285677458,-20.08414323176165,-8.001644468035863,-16.042954878437143,-304.0096070742277,-8.00164446803587,-350.1399180412005,-358.1415625092368,-10.003212856774468,-348.13834965246224,-3.794150313030109,-8.65049239704272,-0.02260276689354157,-0.5885167811200915,-370.2185414798688,-0.022602766893559393,-383.2517009710623,-383.2743037379555,-3.7941503130300576,-379.48015342492505,-408.40704496667513,-408.4070449666742,-408.4070449666742,-408.4070449666742,-433.53978619538975,-433.5397861953902,-433.5397861953911,-433.53978619539066,-458.67252742410983,-458.6725274241094,-458.67252742410983,-458.6725274241089,-608.6835766330232,-608.6835766330232,-608.6835766330232,-608.6835766330241};
+ const int expected1[105]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,16,16,17,18,19,19,20,20,20,20,20,21,21,22,23,23,24,24,24,24,24,25,25,26,27,27,28,28,28,28,28,29,29,30,31,31,32,32,32,32,32,32,32,32,32,33,33,33,34,35,35,35,36,36,36,36,36,37,37,38,39,39,40,40,40,40,40,41,41,42,43,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59};
+ const int expected2[105]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,2,-1,-1,-1,0,-1,0,2,4,5,-1,4,-1,-1,0,-1,0,2,4,5,-1,4,-1,-1,0,-1,0,2,4,5,-1,4,-1,-1,0,-1,0,1,2,3,4,5,6,7,-1,4,6,-1,-1,0,1,-1,1,3,6,7,-1,6,-1,-1,1,-1,1,3,6,7,-1,6,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
+ MEDCouplingFieldDouble *f3f=m3->getMeasureField(ON_CELLS);
+ const double *f3=f3f->getArray()->getConstPointer();
+ for(int i=0;i<105;i++)
+ {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(areaExpected[i],f3[i],1e-10);
+ CPPUNIT_ASSERT_EQUAL(expected1[i],d1->getIJ(i,0));
+ CPPUNIT_ASSERT_EQUAL(expected2[i],d2->getIJ(i,0));
+ }
+ //
+ f3f->decrRef();
+ m3->decrRef();
+ d1->decrRef();
+ d2->decrRef();
+ m2->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest5::testDAIBuildUnique1()
+{
+ DataArrayInt *d=DataArrayInt::New();
+ const int dData[14]={1,2,2,3,3,3,3,4,5,5,7,7,7,19};
+ d->useArray(dData,false,CPP_DEALLOC,14,1);
+ const int expectedData[7]={1,2,3,4,5,7,19};
+ //
+ DataArrayInt *e=d->buildUnique();
+ CPPUNIT_ASSERT_EQUAL(7,e->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,e->getNumberOfComponents());
+ for(int i=0;i<7;i++)
+ CPPUNIT_ASSERT_EQUAL(expectedData[i],e->getIJ(i,0));
+ //
+ e->decrRef();
+ d->decrRef();
+}
+
+void MEDCouplingBasicsTest5::testDAIPartitionByDifferentValues1()
+{
+ const int data[9]={1,0,1,2,0,2,2,-3,2};
+ const int expected1[4]={-3,0,1,2};
+ const int expected2_0[1]={7};
+ const int expected2_1[2]={1,4};
+ const int expected2_2[2]={0,2};
+ const int expected2_3[4]={3,5,6,8};
+ DataArrayInt *d=DataArrayInt::New();
+ d->useArray(data,false,CPP_DEALLOC,9,1);
+ std::vector<int> f;
+ static const int nbOfOutputsExpected=4;
+ std::vector<DataArrayInt *> e=d->partitionByDifferentValues(f);
+ d->decrRef();
+ CPPUNIT_ASSERT_EQUAL(nbOfOutputsExpected,(int)e.size());
+ CPPUNIT_ASSERT_EQUAL(nbOfOutputsExpected,(int)f.size());
+ for(int i=0;i<nbOfOutputsExpected;i++)
+ {
+ CPPUNIT_ASSERT_EQUAL(expected1[i],f[i]);
+ }
+ CPPUNIT_ASSERT_EQUAL((std::size_t)1,e[0]->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)2,e[1]->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)2,e[2]->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)4,e[3]->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(1,e[0]->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(1,e[1]->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(1,e[2]->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(1,e[3]->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::equal(expected2_0,expected2_0+1,e[0]->begin()));
+ CPPUNIT_ASSERT(std::equal(expected2_1,expected2_1+2,e[1]->begin()));
+ CPPUNIT_ASSERT(std::equal(expected2_2,expected2_2+2,e[2]->begin()));
+ CPPUNIT_ASSERT(std::equal(expected2_3,expected2_3+4,e[3]->begin()));
+ e[0]->decrRef(); e[1]->decrRef(); e[2]->decrRef(); e[3]->decrRef();
+}
+
+void MEDCouplingBasicsTest5::testDAICheckMonotonic1()
+{
+ const int data1[6]={-1,0,2,2,4,5};
+ const int data2[6]={6,2,0,-8,-9,-56};
+ const int data3[6]={-1,0,3,2,4,6};
+ const int data4[6]={7,5,2,3,0,-6};
+ DataArrayInt *d=DataArrayInt::New();
+ d->useArray(data1,false,CPP_DEALLOC,6,1);
+ CPPUNIT_ASSERT(d->isMonotonic(true));
+ CPPUNIT_ASSERT(!d->isMonotonic(false));
+ d->checkMonotonic(true);
+ CPPUNIT_ASSERT_THROW(d->checkMonotonic(false),INTERP_KERNEL::Exception);
+ d->useArray(data2,false,CPP_DEALLOC,6,1);
+ CPPUNIT_ASSERT(d->isMonotonic(false));
+ CPPUNIT_ASSERT(!d->isMonotonic(true));
+ d->checkMonotonic(false);
+ CPPUNIT_ASSERT_THROW(d->checkMonotonic(true),INTERP_KERNEL::Exception);
+ d->useArray(data3,false,CPP_DEALLOC,6,1);
+ CPPUNIT_ASSERT(!d->isMonotonic(false));
+ CPPUNIT_ASSERT(!d->isMonotonic(true));
+ CPPUNIT_ASSERT_THROW(d->checkMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT_THROW(d->checkMonotonic(false),INTERP_KERNEL::Exception);
+ d->useArray(data4,false,CPP_DEALLOC,6,1);
+ CPPUNIT_ASSERT(!d->isMonotonic(false));
+ CPPUNIT_ASSERT(!d->isMonotonic(true));
+ CPPUNIT_ASSERT_THROW(d->checkMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT_THROW(d->checkMonotonic(false),INTERP_KERNEL::Exception);
+ d->useArray(data4,false,CPP_DEALLOC,0,1);
+ CPPUNIT_ASSERT(d->isMonotonic(true));
+ CPPUNIT_ASSERT(d->isMonotonic(false));
+ d->checkMonotonic(true);
+ d->checkMonotonic(false);
+ d->useArray(data4,false,CPP_DEALLOC,3,2);//throw because nbComp!=1
+ CPPUNIT_ASSERT_THROW(d->isMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT_THROW(d->isMonotonic(false),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT_THROW(d->checkMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT_THROW(d->checkMonotonic(false),INTERP_KERNEL::Exception);
+ d->decrRef();
+}
+
+void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp6()
+{
+ // coordinates
+ DataArrayDouble *coords=DataArrayDouble::New();
+ const double coordsData[16]={2.7554552980815448e-15,45,-45,5.5109105961630896e-15,-31.819805153394636,31.81980515339464,2.8779199779962799e-15,47,2.8166876380389124e-15,46,-47,5.7558399559925599e-15,-33.234018715767732,33.234018715767739,-46,5.6333752760778247e-15};
+ coords->useArray(coordsData,false,CPP_DEALLOC,8,2);
+ // connectivity
+ DataArrayInt *conn=DataArrayInt::New();
+ const int connData[9]={8,0,3,5,1,4,6,7,2};
+ conn->useArray(connData,false,CPP_DEALLOC,9,1);
+ DataArrayInt *connI=DataArrayInt::New();
+ const int connIData[2]={0,9};
+ connI->useArray(connIData,false,CPP_DEALLOC,2,1);
+ MEDCouplingUMesh *m1=MEDCouplingUMesh::New("Fixe",2);
+ m1->setCoords(coords);
+ m1->setConnectivity(conn,connI,true);
+ coords->decrRef(); conn->decrRef(); connI->decrRef();
+ //
+ coords=DataArrayDouble::New();
+ const double coordsData2[26]={-7.3800475508445391,41.854329503018846,-3.7041190667754655,42.338274668899189,-3.7041190667754655,45.338274668899189,-7.3800475508445382,44.854329503018839,-5.5473631693521845,42.136406608386956,-3.7041190667754655,43.838274668899189,-5.5420833088100014,45.09630208595901,-7.3800475508445382,43.354329503018839,-3.7041190667754651,52.338274668899189,-7.3800475508445382,51.854329503018839,-3.7041190667754655,48.838274668899189,-5.5420833088100014,52.09630208595901,-7.3800475508445382,48.354329503018839};
+ coords->useArray(coordsData2,false,CPP_DEALLOC,13,2);
+ // connectivity
+ conn=DataArrayInt::New();
+ const int connData2[18]={8,0,1,2,3,4,5,6,7,8,3,2,8,9,6,10,11,12};
+ conn->useArray(connData2,false,CPP_DEALLOC,18,1);
+ connI=DataArrayInt::New();
+ const int connIData2[3]={0,9,18};
+ connI->useArray(connIData2,false,CPP_DEALLOC,3,1);
+ //
+ MEDCouplingUMesh *m2=MEDCouplingUMesh::New("Mobile",2);
+ m2->setCoords(coords);
+ m2->setConnectivity(conn,connI,true);
+ coords->decrRef(); conn->decrRef(); connI->decrRef();
+ //
+ DataArrayInt *d1=0,*d2=0;
+ MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1,m2,1e-10,d1,d2);
+ CPPUNIT_ASSERT_EQUAL(4,m3->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(4,d1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(4,d2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(43,m3->getNumberOfNodes());
+ bool areMerged=false;
+ int newNbOfNodes=-1;
+ m3->mergeNodes(1e-12,areMerged,newNbOfNodes)->decrRef();
+ CPPUNIT_ASSERT_EQUAL(35,m3->getNumberOfNodes());
+ m3->zipCoords();
+ CPPUNIT_ASSERT_EQUAL(23,m3->getNumberOfNodes());
+ //
+ MEDCouplingFieldDouble *f=m3->getMeasureField(true);
+ const double *vals=f->getArray()->getConstPointer();
+ const double valuesExpected[4]={1.6603638692585716,5.747555728471923,129.68907101754394,7.4162714498559694};
+ for(int i=0;i<4;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected[i],vals[i],1e-12);
+ f->decrRef();
+ //
+ m1->decrRef();
+ m2->decrRef();
+ m3->decrRef();
+ d1->decrRef();
+ d2->decrRef();
+}
+
+void MEDCouplingBasicsTest5::testDAIBuildSubstractionOptimized1()
+{
+ const int tab1[7]={1,3,5,6,7,9,13};
+ const int tab2[3]={3,5,9};
+ const int tab3[3]={1,3,5};
+ DataArrayInt *da1=DataArrayInt::New(); da1->useArray(tab1,false,CPP_DEALLOC,7,1);
+ DataArrayInt *da2=DataArrayInt::New(); da2->useArray(tab2,false,CPP_DEALLOC,3,1);
+ DataArrayInt *da3=DataArrayInt::New(); da3->useArray(tab3,false,CPP_DEALLOC,3,1);
+ DataArrayInt *da4=DataArrayInt::New(); da4->useArray(tab1,false,CPP_DEALLOC,7,1);
+ //
+ DataArrayInt *a=0;
+ a=da1->buildSubstractionOptimized(da2);
+ CPPUNIT_ASSERT_EQUAL(4,a->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents());
+ const int expected1_0[4]={1,6,7,13};
+ CPPUNIT_ASSERT(std::equal(expected1_0,expected1_0+4,a->begin()));
+ a->decrRef();
+ //
+ a=da1->buildSubstractionOptimized(da3);
+ CPPUNIT_ASSERT_EQUAL(4,a->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents());
+ const int expected2_0[4]={6,7,9,13};
+ CPPUNIT_ASSERT(std::equal(expected2_0,expected2_0+4,a->begin()));
+ a->decrRef();
+ //
+ a=da1->buildSubstractionOptimized(da4);
+ CPPUNIT_ASSERT_EQUAL(0,a->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents());
+ a->decrRef();
+ //
+ da1->decrRef();
+ da2->decrRef();
+ da3->decrRef();
+ da4->decrRef();
+}
+
+void MEDCouplingBasicsTest5::testDAIIsStrictlyMonotonic1()
+{
+ const int tab1[7]={1,3,5,6,7,9,13};
+ DataArrayInt *da1=DataArrayInt::New(); da1->useArray(tab1,false,CPP_DEALLOC,7,1);
+ CPPUNIT_ASSERT(da1->isStrictlyMonotonic(true));
+ da1->checkStrictlyMonotonic(true);
+ CPPUNIT_ASSERT(da1->isMonotonic(true));
+ da1->checkMonotonic(true);
+ CPPUNIT_ASSERT(!da1->isStrictlyMonotonic(false));
+ CPPUNIT_ASSERT_THROW(da1->checkStrictlyMonotonic(false),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!da1->isMonotonic(false));
+ CPPUNIT_ASSERT_THROW(da1->checkMonotonic(false),INTERP_KERNEL::Exception);
+ da1->decrRef();
+ //
+ int tab2[7]={1,3,5,6,6,9,13};
+ da1=DataArrayInt::New(); da1->useArray(tab2,false,CPP_DEALLOC,7,1);
+ CPPUNIT_ASSERT(!da1->isStrictlyMonotonic(true));
+ CPPUNIT_ASSERT_THROW(da1->checkStrictlyMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(da1->isMonotonic(true));
+ da1->checkMonotonic(true);
+ CPPUNIT_ASSERT(!da1->isStrictlyMonotonic(false));
+ CPPUNIT_ASSERT_THROW(da1->checkStrictlyMonotonic(false),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!da1->isMonotonic(false));
+ CPPUNIT_ASSERT_THROW(da1->checkMonotonic(false),INTERP_KERNEL::Exception);
+ da1->decrRef();
+ //
+ const int tab3[7]={1,3,5,6,5,9,13};
+ da1=DataArrayInt::New(); da1->useArray(tab3,false,CPP_DEALLOC,7,1);
+ CPPUNIT_ASSERT(!da1->isStrictlyMonotonic(true));
+ CPPUNIT_ASSERT_THROW(da1->checkStrictlyMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!da1->isMonotonic(true));
+ CPPUNIT_ASSERT_THROW(da1->checkMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!da1->isStrictlyMonotonic(false));
+ CPPUNIT_ASSERT_THROW(da1->checkStrictlyMonotonic(false),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!da1->isMonotonic(false));
+ CPPUNIT_ASSERT_THROW(da1->checkMonotonic(false),INTERP_KERNEL::Exception);
+ da1->decrRef();
+ //
+ const int tab4[7]={13,9,7,6,5,3,1};
+ da1=DataArrayInt::New(); da1->useArray(tab4,false,CPP_DEALLOC,7,1);
+ CPPUNIT_ASSERT(!da1->isStrictlyMonotonic(true));
+ CPPUNIT_ASSERT_THROW(da1->checkStrictlyMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!da1->isMonotonic(true));
+ CPPUNIT_ASSERT_THROW(da1->checkMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(da1->isStrictlyMonotonic(false));
+ da1->checkStrictlyMonotonic(false);
+ CPPUNIT_ASSERT(da1->isMonotonic(false));
+ da1->checkMonotonic(false);
+ da1->decrRef();
+ //
+ const int tab5[7]={13,9,6,6,5,3,1};
+ da1=DataArrayInt::New(); da1->useArray(tab5,false,CPP_DEALLOC,7,1);
+ CPPUNIT_ASSERT(!da1->isStrictlyMonotonic(true));
+ CPPUNIT_ASSERT_THROW(da1->checkStrictlyMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!da1->isMonotonic(true));
+ CPPUNIT_ASSERT_THROW(da1->checkMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!da1->isStrictlyMonotonic(false));
+ CPPUNIT_ASSERT_THROW(da1->checkStrictlyMonotonic(false),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(da1->isMonotonic(false));
+ da1->checkMonotonic(false);
+ da1->decrRef();
+ //
+ const int tab6[7]={13,9,5,6,5,3,1};
+ da1=DataArrayInt::New(); da1->useArray(tab6,false,CPP_DEALLOC,7,1);
+ CPPUNIT_ASSERT(!da1->isStrictlyMonotonic(true));
+ CPPUNIT_ASSERT_THROW(da1->checkStrictlyMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!da1->isMonotonic(true));
+ CPPUNIT_ASSERT_THROW(da1->checkMonotonic(true),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!da1->isStrictlyMonotonic(false));
+ CPPUNIT_ASSERT_THROW(da1->checkStrictlyMonotonic(false),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!da1->isMonotonic(false));
+ CPPUNIT_ASSERT_THROW(da1->checkMonotonic(false),INTERP_KERNEL::Exception);
+ da1->decrRef();
+ //
+ da1=DataArrayInt::New(); da1->useArray(tab1,false,CPP_DEALLOC,0,1);
+ CPPUNIT_ASSERT(da1->isStrictlyMonotonic(true));
+ da1->checkStrictlyMonotonic(true);
+ CPPUNIT_ASSERT(da1->isMonotonic(true));
+ da1->checkMonotonic(true);
+ CPPUNIT_ASSERT(da1->isStrictlyMonotonic(false));
+ da1->checkStrictlyMonotonic(false);
+ CPPUNIT_ASSERT(da1->isMonotonic(false));
+ da1->checkMonotonic(false);
+ da1->decrRef();
+ //
+ da1=DataArrayInt::New(); da1->useArray(tab1,false,CPP_DEALLOC,1,1);
+ CPPUNIT_ASSERT(da1->isStrictlyMonotonic(true));
+ da1->checkStrictlyMonotonic(true);
+ CPPUNIT_ASSERT(da1->isMonotonic(true));
+ da1->checkMonotonic(true);
+ CPPUNIT_ASSERT(da1->isStrictlyMonotonic(false));
+ da1->checkStrictlyMonotonic(false);
+ CPPUNIT_ASSERT(da1->isMonotonic(false));
+ da1->checkMonotonic(false);
+ da1->decrRef();
+}
+
+void MEDCouplingBasicsTest5::testSimplexize3()
+{
+ const int conn[24]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
+ MEDCouplingUMesh *m=MEDCouplingUMesh::New("toto",3);
+ m->allocateCells(0);
+ m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn+0);
+ m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+4);
+ m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+12);
+ m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn+20);
+ const double coords[72]={0.,0.,0.,0.,1.,0.,1.,0.,0.,0.,0.,1.,2.,0.,0.,2.,1.,0.,3.,1.,0.,3.,0.,0.,2.,0.,1.,2.,1.,1.,3.,1.,1.,3.,0.,1.,4.,0.,0.,4.,1.,0.,5.,1.,0.,5.,0.,0.,4.,0.,1.,4.,1.,1.,5.,1.,1.,5.,0.,1.,6.,0.,0.,6.,1.,0.,7.,0.,0.,6.,0.,1.};
+ DataArrayDouble *c=DataArrayDouble::New();
+ c->useArray(coords,false,CPP_DEALLOC,24,3);
+ m->setCoords(c);
+ c->decrRef();
+ m->checkCoherency2();
+ //
+ MEDCouplingUMesh *m1=static_cast<MEDCouplingUMesh *>(m->deepCpy());
+ DataArrayInt *d1=m1->simplexize(INTERP_KERNEL::PLANAR_FACE_5);
+ m1->checkCoherency2();
+ MEDCouplingFieldDouble *f1=m1->getMeasureField(ON_CELLS);
+ const double vol1Expected[12]={1./6, 1./6, 1./6,1./6, 1./6, 1./3,1./6, 1./6, 1./6, 1./6, 1./3, 1./6};
+ CPPUNIT_ASSERT_EQUAL(1,f1->getArray()->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(12,f1->getArray()->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1Expected[i],f1->getIJ(i,0),1e-12);
+ const int connExpected1[60]={14,0,1,2,3,14,4,9,5,6,14,4,8,9,11,14,4,7,11,6,14,9,11,10,6,14,4,9,6,11,14,12,17,13,14,14,12,16,17,19,14,12,15,19,14,14,17,19,18,14,14,12,17,14,19,14,20,21,22,23};
+ const int connIExpected1[13]={0,5,10,15,20,25,30,35,40,45,50,55,60};
+ const int n2o1[12]={0,1,1,1,1,1,2,2,2,2,2,3};
+ CPPUNIT_ASSERT_EQUAL(1,m1->getNodalConnectivity()->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(60,m1->getNodalConnectivity()->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,m1->getNodalConnectivityIndex()->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(13,m1->getNodalConnectivityIndex()->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::equal(connExpected1,connExpected1+60,m1->getNodalConnectivity()->begin()));
+ CPPUNIT_ASSERT(std::equal(connIExpected1,connIExpected1+13,m1->getNodalConnectivityIndex()->begin()));
+ CPPUNIT_ASSERT_EQUAL(1,d1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(12,d1->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::equal(n2o1,n2o1+12,d1->begin()));
+ f1->decrRef();
+ m1->decrRef();
+ d1->decrRef();
+ //
+ MEDCouplingUMesh *m2=static_cast<MEDCouplingUMesh *>(m->deepCpy());
+ DataArrayInt *d2=m2->simplexize(INTERP_KERNEL::PLANAR_FACE_6);
+ m2->checkCoherency2();
+ MEDCouplingFieldDouble *f2=m2->getMeasureField(ON_CELLS);
+ const double vol2Expected[14]={1./6, 1./6, 1./6,1./6, 1./6, 1./6,1./6,1./6, 1./6, 1./6, 1./6, 1./6,1./6,1./6};
+ CPPUNIT_ASSERT_EQUAL(1,f2->getArray()->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(14,f2->getArray()->getNumberOfTuples());
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(vol2Expected[i],f2->getIJ(i,0),1e-12);
+ const int connExpected2[70]={14,0,1,2,3,14,4,9,5,10,14,4,5,6,10,14,4,8,9,10,14,4,11,8,10,14,4,6,7,10,14,4,7,11,10,14,12,17,13,18,14,12,13,14,18,14,12,16,17,18,14,12,19,16,18,14,12,14,15,18,14,12,15,19,18,14,20,21,22,23};
+ const int connIExpected2[15]={0,5,10,15,20,25,30,35,40,45,50,55,60,65,70};
+ const int n2o2[14]={0,1,1,1,1,1,1,2,2,2,2,2,2,3};
+ CPPUNIT_ASSERT_EQUAL(1,m2->getNodalConnectivity()->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(70,m2->getNodalConnectivity()->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,m2->getNodalConnectivityIndex()->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(15,m2->getNodalConnectivityIndex()->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::equal(connExpected2,connExpected2+70,m2->getNodalConnectivity()->begin()));
+ CPPUNIT_ASSERT(std::equal(connIExpected2,connIExpected2+15,m2->getNodalConnectivityIndex()->begin()));
+ CPPUNIT_ASSERT_EQUAL(1,d2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(14,d2->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::equal(n2o2,n2o2+14,d2->begin()));
+ f2->decrRef();
+ m2->decrRef();
+ d2->decrRef();
+ //
+ m->decrRef();
+}