From 99c534b552885cc4ac3c8f516bfb69db955f43f7 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 13 Apr 2015 11:16:40 +0200 Subject: [PATCH] Addition of MEDFileUMesh.__setitem__ in python bindings. --- src/MEDLoader/Swig/MEDLoaderCommon.i | 19 +++++++++++++++++++ src/MEDLoader/Swig/MEDLoaderTest3.py | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) 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() -- 2.39.2