From: Anthony Geay Date: Thu, 20 Apr 2017 06:07:48 +0000 (+0200) Subject: OK. Tested X-Git-Tag: V8_4_0a1~84 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b4997e57498a6d2f4b08109e7de0d844b9fd1ed3;p=tools%2Fmedcoupling.git OK. Tested --- diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 02be59c37..35babc642 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -3370,7 +3370,7 @@ const DataArrayInt *MEDFileUMesh::getRevNumberFieldAtLevel(int meshDimRelToMaxEx { if(meshDimRelToMaxExt==1) { - if(_num_coords.isNotNull()) + if(_num_coords.isNull()) throw INTERP_KERNEL::Exception("MEDFileUMesh::getRevNumberFieldAtLevel : no coordinates renum specified !"); return _rev_num_coords; } @@ -5258,6 +5258,8 @@ void MEDFileUMesh::setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayInt { if(meshDimRelToMaxExt!=1) throw INTERP_KERNEL::Exception("MEDFileUMesh::setGlobalNumFieldAtLevel : Only implemented for meshDimRelToMaxExt==1 for the moment !"); + if(globalNumArr) + globalNumArr->checkNbOfTuplesAndComp(_coords->getNumberOfTuples(),1,"MEDFileUMesh::setGlobalNumFieldAtLevel : Problem in size of node global numbering arr ! "); _global_num_coords.takeRef(globalNumArr); } diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 39cc415f6..3984ba76c 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -99,6 +99,7 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileMesh::getNodeGroupsArr; %newobject MEDCoupling::MEDFileMesh::getNodeFamilyArr; %newobject MEDCoupling::MEDFileMesh::getNodeFamiliesArr; +%newobject MEDCoupling::MEDFileMesh::getGlobalNumFieldAtLevel; %newobject MEDCoupling::MEDFileMesh::getAllFamiliesIdsReferenced; %newobject MEDCoupling::MEDFileMesh::computeAllFamilyIdsInUse; %newobject MEDCoupling::MEDFileMesh::getEquivalences; @@ -1302,6 +1303,12 @@ namespace MEDCoupling if(ret) ret->incrRef(); return ret; } + + virtual DataArrayInt *getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) + { + MCAuto ret(self->getGlobalNumFieldAtLevel(meshDimRelToMaxExt)); + return ret.retn(); + } } }; diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 6738da924..f95495eee 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -5911,6 +5911,32 @@ class MEDLoaderTest3(unittest.TestCase): self.assertTrue(params[i].isEqual(params7[i],1e-12)[0]) pass pass + + def testGlobalNumOnNodes1(self): + fname="Pyfile112.med" + arr=DataArrayDouble(5) ; arr.iota() + m=MEDCouplingUMesh.Build1DMeshFromCoords(arr) + m.setName("mesh") + mm=MEDFileUMesh() + mm[0]=m + self.assertTrue(not mm.getGlobalNumFieldAtLevel(1)) + d=DataArrayInt([7,8,9,2,0]) + dRef=d.deepCopy() + mm.setGlobalNumFieldAtLevel(1,d) + mm.checkConsistency() + self.assertRaises(InterpKernelException,mm.setGlobalNumFieldAtLevel,1,d[::2]) + mm.checkConsistency() + self.assertEqual(d.getHiddenCppPointer(),mm.getGlobalNumFieldAtLevel(1).getHiddenCppPointer()) + self.assertTrue(mm.getGlobalNumFieldAtLevel(1).isEqual(dRef)) + mm.write(fname,2) + mm2=MEDFileMesh.New(fname) + self.assertTrue(mm.isEqual(mm2,1e-12)[0]) + self.assertTrue(mm2.getGlobalNumFieldAtLevel(1).isEqual(dRef)) + mm2.getGlobalNumFieldAtLevel(1).setIJ(0,0,10) + self.assertTrue(not mm.isEqual(mm2,1e-12)[0]) + mm2.getGlobalNumFieldAtLevel(1).setIJ(0,0,7) + self.assertTrue(mm.isEqual(mm2,1e-12)[0]) + pass pass