From a843e859241baea9b4942877174422d2891206ef Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 18 Sep 2015 15:34:54 +0200 Subject: [PATCH] Correction of bug concerning UNIV info status. --- src/MEDLoader/MEDFileMesh.cxx | 9 ++++++--- src/MEDLoader/Swig/MEDLoaderTest3.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index d94dda94b..5fe829882 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -2574,7 +2574,8 @@ void MEDFileUMesh::writeLL(med_idt fid) const MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo } MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,mdim,MED_UNSTRUCTURED_MESH,desc,"",MED_SORT_DTIT,MED_CARTESIAN,comp,unit)); - MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa)); + if(_univ_wr_status) + MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa)); std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE)); MEDFileUMeshL2::WriteCoords(fid,meshName,_iteration,_order,_time,_coords,_fam_coords,_num_coords,_name_coords); for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_ms.begin();it!=_ms.end();it++) @@ -6093,7 +6094,8 @@ void MEDFileCMesh::writeLL(med_idt fid) const MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo } MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,spaceDim,MED_STRUCTURED_MESH,desc,dtunit,MED_SORT_DTIT,MED_CARTESIAN,comp,unit)); - MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa)); + if(_univ_wr_status) + MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa)); MEDFILESAFECALLERWR0(MEDmeshGridTypeWr,(fid,maa,MED_CARTESIAN_GRID)); for(int i=0;i nodeGridSt=_clmesh->getNodeGridStructure(); MEDFILESAFECALLERWR0(MEDmeshGridStructWr,(fid,maa,_iteration,_order,_time,&nodeGridSt[0])); diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 004c88a5a..f06132a37 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -4595,6 +4595,22 @@ class MEDLoaderTest(unittest.TestCase): # pass + def testUnivStatus1(self): + """ Non regression test to check the effectiveness of univ write status.""" + fname="Pyfile95.med" + arr=DataArrayDouble(10) ; arr.iota() + m=MEDCouplingCMesh() ; m.setCoords(arr,arr) ; m.setName("mesh") + mm=MEDFileCMesh() ; mm.setMesh(m) + mm.setUnivNameWrStatus(False) # test is here + mm.write(fname,2) + mm=MEDFileCMesh(fname) + self.assertEqual(mm.getUnivName(),"") + mm.setUnivNameWrStatus(True) + mm.write(fname,2) + mm=MEDFileCMesh(fname) + self.assertTrue(mm.getUnivName()!="") + pass + pass if __name__ == "__main__": -- 2.39.2