From: Anthony Geay Date: Mon, 13 Apr 2015 09:16:40 +0000 (+0200) Subject: Addition of MEDFileUMesh.__setitem__ in python bindings. X-Git-Tag: V7_6_0b1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=99c534b552885cc4ac3c8f516bfb69db955f43f7;p=modules%2Fmed.git Addition of MEDFileUMesh.__setitem__ in python bindings. --- diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index f9143b5a8..bf383c642 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -906,6 +906,25 @@ namespace ParaMEDMEM return self->getMeshAtLevel(meshDimRelToMaxExt,false); } + void __setitem__(int meshDimRelToMax, MEDCouplingPointSet *mesh) throw(INTERP_KERNEL::Exception) + { + if(!mesh) + throw INTERP_KERNEL::Exception("MEDFileUMesh::__setitem__ : Input mesh is NULL !"); + MEDCouplingUMesh *m0(dynamic_cast(mesh)); + if(m0) + { + self->setMeshAtLevel(meshDimRelToMax,m0,false); + return ; + } + MEDCoupling1GTUMesh *m1(dynamic_cast(mesh)); + if(m1) + { + self->setMeshAtLevel(meshDimRelToMax,m1); + return ; + } + throw INTERP_KERNEL::Exception("MEDFileUMesh::__setitem__ : Not recognized input mesh !"); + } + void setMeshes(PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception) { std::vector ms; diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index c4bfe888d..c91562c62 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -3986,10 +3986,10 @@ class MEDLoaderTest(unittest.TestCase): mm.setName("MyFirstMEDCouplingMEDmesh") mm.setDescription("IHopeToConvinceLastMEDMEMUsers") mm.setCoords(c) - mm.setMeshAtLevel(-1,m1); - mm.setMeshAtLevel(0,m); + mm[-1]=m1; + mm[0]=m; mm.setRenumFieldArr(0,DataArrayInt([32,41,50,56,7])) - mm.setMeshAtLevel(-2,m2); + mm[-2]=m2; mm.setRenumFieldArr(-2,DataArrayInt([102,52,45,63])) # playing with groups g1_2=DataArrayInt.New()