From 5c05f1b369200bf31707386a7b3394c117f7f1a5 Mon Sep 17 00:00:00 2001 From: abn Date: Wed, 23 Sep 2015 09:43:58 +0200 Subject: [PATCH] Mini bug fix: MEDFileUMesh should load correclty a mesh with empty coords. --- src/MEDLoader/MEDFileMeshLL.cxx | 3 ++- src/MEDLoader/Swig/MEDLoaderTest4.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index 16fef5d9d..639e0f7fa 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -336,7 +336,8 @@ void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, const std::vectoralloc(nCoords,spaceDim); double *coordsPtr(_coords->getPointer()); - MEDFILESAFECALLERRD0(MEDmeshNodeCoordinateRd,(fid,mName.c_str(),dt,it,MED_FULL_INTERLACE,coordsPtr)); + if (nCoords) + MEDFILESAFECALLERRD0(MEDmeshNodeCoordinateRd,(fid,mName.c_str(),dt,it,MED_FULL_INTERLACE,coordsPtr)); if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0) { _fam_coords=DataArrayInt::New(); diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index 3e2d5f4e6..7fbc0edc0 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -5114,6 +5114,20 @@ class MEDLoaderTest4(unittest.TestCase): pass pass + def testEmptyMesh(self): + fname = "empty_mesh.med" + m = MEDCouplingUMesh('toto', 2) + m.setCoords(DataArrayDouble([], 0, 2)) + m.setConnectivity(DataArrayInt([]), DataArrayInt([0])) + mfu = MEDFileUMesh() + mfu.setMeshAtLevel(0, m) + mfu.write(fname, 2) + mfu2 = MEDFileUMesh(fname) + self.assertEqual('toto', mfu2.getName()) + lvl = mfu2.getNonEmptyLevels() + self.assertEqual((), lvl) + pass -unittest.main() +if __name__ == "__main__": + unittest.main() -- 2.39.2