std::vector<const MEDCoupling1SGTUMesh *>::const_iterator it=a.begin();
if(!(*it))
throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords : presence of null instance !");
+ std::vector<const DataArrayInt *> 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<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh("merge",*cm));
ret->setCoords(coords);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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();
}
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]
#
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()))
##