From: abn Date: Wed, 23 Sep 2015 07:43:58 +0000 (+0200) Subject: Mini bug fix: MEDFileUMesh should load correclty a mesh with empty coords. X-Git-Tag: V7_7_0rc1~1^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=76184f4ee8ba59e4f9739ae8e89256106002eb03;p=tools%2Fmedcoupling.git Mini bug fix: MEDFileUMesh should load correclty a mesh with empty coords. --- 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()