From: ageay Date: Thu, 20 Jun 2013 06:27:50 +0000 (+0000) Subject: Ze test of 1SGTUMesh. X-Git-Tag: B4CMakeModifs~54 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9ea689ca134ff39cd2f1b206c36148ff57e9b650;p=modules%2Fmed.git Ze test of 1SGTUMesh. --- diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index fb67f3a0e..20960db90 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -932,33 +932,25 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords(std::ve std::vector::const_iterator it=a.begin(); if(!(*it)) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords : presence of null instance !"); + std::vector ncs(a.size()); int nbOfCells=(*it)->getNumberOfCells(); const DataArrayDouble *coords=(*it)->getCoords(); const INTERP_KERNEL::CellModel *cm=&((*it)->getCellModel()); int nbNodesPerCell=(*it)->getNumberOfNodesPerCell(); + ncs[0]=(*it)->getNodalConnectivity(); it++; - for(;it!=a.end();it++) + for(int i=1;it!=a.end();i++,it++) { if(cm!=&((*it)->getCellModel())) throw INTERP_KERNEL::Exception("Geometric types mismatches, Merge1SGTUMeshes impossible !"); - nbOfCells+=(*it)->getNumberOfCells(); + (*it)->getNumberOfCells();//to check that all is OK + ncs[i]=(*it)->getNodalConnectivity(); if(coords!=(*it)->getCoords()) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords : not lying on same coords !"); } MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1SGTUMesh("merge",*cm)); ret->setCoords(coords); - MEDCouplingAutoRefCountObjectPtr c=DataArrayInt::New(); - c->alloc(nbOfCells*nbNodesPerCell,1); - int *cPtr=c->getPointer(); - int offset=0; - for(it=a.begin();it!=a.end();it++) - { - int curConnLgth=(*it)->getNodalConnectivityLength(); - const int *curC=(*it)->_conn->begin(); - cPtr=std::copy(curC,curC+curConnLgth,cPtr); - } - // - ret->_conn=c; + ret->_conn=DataArrayInt::Aggregate(ncs); return ret.retn(); } diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index f969265ed..71f26e55c 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -12996,6 +12996,18 @@ class MEDCouplingBasicsTest(unittest.TestCase): mo.setNodalConnectivity(DataArrayInt([1,0,6,7,2,1,7,8,3,2,8,9,4,3,9,10,5,4,10,11])) self.assertTrue(m.isEqual(mo,1e-12)) # + mo2=MEDCoupling1SGTUMesh.Merge1SGTUMeshesOnSameCoords([m[[0,1]],m[[2]],m[[3,4]]]) + mo2.setName(m.getName()) + self.assertTrue(m.isEqual(mo2,1e-12)) + # + mp0=m[[0]] ; mp0.zipCoords() ; mp1=m[2] ; mp1.zipCoords() ; mp2=m[4] ; mp2.zipCoords() + mo3=MEDCoupling1SGTUMesh.Merge1SGTUMeshes([mp0,mp1,mp2]) + self.assertTrue(isinstance(mo3,MEDCoupling1SGTUMesh)) + mo3.setName(m.getName()) + m_ref=m[(0,2,4)] ; m_ref.zipCoords() + m_ref.tryToShareSameCoordsPermute(mo3,1e-12) + self.assertTrue(m_ref.isEqual(mo3,1e-12)) + # m1=um.buildDescendingConnectivity()[0] ids=m1.getCellIdsFullyIncludedInNodeIds(DataArrayInt.Range(0,12,1)) m1=m1[ids] @@ -13073,7 +13085,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): # invalidPfl=DataArrayInt([1,2,3,4,5]) self.assertRaises(InterpKernelException,m.checkTypeConsistencyAndContig,[NORM_QUAD4,5,0],[invalidPfl]) - #self.assertRaises(InterpKernelException,m.buildUnstructured().checkTypeConsistencyAndContig,[NORM_QUAD4,5,0],[invalidPfl])# should throw debug + self.assertRaises(InterpKernelException,m.buildUnstructured().checkTypeConsistencyAndContig,[NORM_QUAD4,5,0],[invalidPfl]) ## self.assertTrue(DataArrayInt([4,4,4,4,4]).isEqual(m.computeNbOfNodesPerCell())) ##