From: ageay Date: Fri, 20 Apr 2012 09:59:17 +0000 (+0000) Subject: MEDCouplingUMesh::insertNextCell overloaded in python for simpler use. X-Git-Tag: TRIPOLI_323~45 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bc41093486b0a31c63be60e4ddf922d517904a53;p=tools%2Fmedcoupling.git MEDCouplingUMesh::insertNextCell overloaded in python for simpler use. --- diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 8fd8bbfd9..b1ab06cdd 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -1098,8 +1098,21 @@ namespace ParaMEDMEM { int sz; INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&sz); + if(size>sz) + { + std::ostringstream oss; oss << "Wrap of MEDCouplingUMesh::insertNextCell : request of connectivity with length " << size << " whereas the length of input is " << sz << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } self->insertNextCell(type,size,tmp); } + + void insertNextCell(INTERP_KERNEL::NormalizedCellType type, PyObject *li) throw(INTERP_KERNEL::Exception) + { + int sz; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&sz); + self->insertNextCell(type,sz,tmp); + } + DataArrayInt *getNodalConnectivity() throw(INTERP_KERNEL::Exception) { DataArrayInt *ret=self->getNodalConnectivity(); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 481a14311..4009e8b1c 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -1520,7 +1520,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): targetMesh=MEDCouplingUMesh.New(); targetMesh.setMeshDimension(2); targetMesh.allocateCells(1); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]) + targetMesh.insertNextCell(NORM_QUAD4,targetConn[0:4]) targetMesh.finishInsertingCells(); myCoords=DataArrayDouble.New(); myCoords.setValues(targetCoords,4,3); @@ -2796,7 +2796,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): m2=MEDCouplingUMesh.New(); m2.setMeshDimension(2); m2.allocateCells(1); - m2.insertNextCell(NORM_QUAD4,4,targetConn[0:4]) + m2.insertNextCell(NORM_QUAD4,targetConn[0:4]) m2.finishInsertingCells(); myCoords=DataArrayDouble.New(); myCoords.setValues(targetCoords,4,2); @@ -3813,7 +3813,8 @@ class MEDCouplingBasicsTest(unittest.TestCase): # tmpConn=[0,1,2,3,4,5,6,7] mesh.allocateCells(3); - mesh.insertNextCell(NORM_HEXA8,8,tmpConn[0:8]) + self.assertRaises(InterpKernelException,mesh.insertNextCell,NORM_HEXA8,9,tmpConn[0:8]) + mesh.insertNextCell(NORM_HEXA8,tmpConn[0:8]) mesh.insertNextCell(NORM_PENTA6,6,[i+8 for i in tmpConn]) mesh.insertNextCell(NORM_PYRA5,5,[i+14 for i in tmpConn]) mesh.finishInsertingCells();