From: Anthony Geay Date: Fri, 16 Oct 2015 14:18:49 +0000 (+0200) Subject: Correction of bug of double pickelization of MEDFileUMesh instances. X-Git-Tag: V8_0_pre~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aae96be4393361fbf24c6664bb4ae21849168c7f;p=modules%2Fmed.git Correction of bug of double pickelization of MEDFileUMesh instances. --- diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index 639e0f7fa..218f7bb72 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -1348,7 +1348,12 @@ void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const { const MEDCouplingUMesh *m(_m); if(!m) - throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh : null UMesh !"); + { + if(_m_parts.empty()) + throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh : null UMesh !"); + else + return ;// no needs to compte parts they are already here ! + } std::vector ms(m->splitByType()); std::vector< MEDCouplingAutoRefCountObjectPtr > msMSafe(ms.begin(),ms.end()); std::size_t sz(msMSafe.size()); diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index ce979a171..ce9e0e076 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -4627,6 +4627,32 @@ class MEDLoaderTest(unittest.TestCase): lvl = mfu2.getNonEmptyLevels() self.assertEqual((), lvl) + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def testMEDFileUMeshPickeling2(self): + """ Check that pickalization can be performed on a unpickalized instance. Non regression test.""" + name="Mesh_1" + grpName1="HAUT" + grpName2="BASE" + hauteur=1. + nbOfNodesPerAxis=3 + arr=DataArrayDouble(nbOfNodesPerAxis) ; arr.iota() ; arr/=(nbOfNodesPerAxis-1) ; arr*=hauteur + m=MEDCouplingCMesh() ; m.setCoords(arr,arr,arr) ; m=m.buildUnstructured() ; m.setName(name) + mesh=MEDFileUMesh() ; mesh[0]=m + m1=m.computeSkin() ; mesh[-1]=m1 + # + bary1=m1.getBarycenterAndOwner()[:,2] + grp1=bary1.getIdsInRange(hauteur-1e-12,hauteur+1e-12) ; grp1.setName(grpName1) + grp2=bary1.getIdsInRange(0.-1e-12,0.+1e-12) ; grp2.setName(grpName2) + mesh.setGroupsAtLevel(-1,[grp1,grp2]) + + import cPickle + st=cPickle.dumps(mesh,2) + mm=cPickle.loads(st) + st2=cPickle.dumps(mm,2) + mm2=cPickle.loads(st2) + self.assertTrue(mesh.isEqual(mm2,1e-12)[0]) + pass + pass if __name__ == "__main__":