From 57a667afcc11281db259d777f825f1c0aae0a6b2 Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 1 Jul 2013 09:36:53 +0000 Subject: [PATCH] MED file mesh loading on demand. --- src/MEDLoader/MEDFileMesh.cxx | 36 +++++++++++----------- src/MEDLoader/MEDFileMesh.hxx | 16 +++++----- src/MEDLoader/Swig/MEDLoaderCommon.i | 46 +++++++++++----------------- src/MEDLoader/Swig/MEDLoaderTest3.py | 6 ++-- 4 files changed, 47 insertions(+), 57 deletions(-) diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 50c3f3bf1..7099c550f 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -87,13 +87,13 @@ MEDFileMesh *MEDFileMesh::New(const char *fileName, MEDFileMeshReadSelector *mrs case CARTESIAN: { MEDCouplingAutoRefCountObjectPtr ret=MEDFileCMesh::New(); - ret->loadCMeshFromFile(fid,ms.front().c_str(),dt,it); + ret->loadCMeshFromFile(fid,ms.front().c_str(),dt,it,mrs); return (MEDFileCMesh *)ret.retn(); } case CURVE_LINEAR: { MEDCouplingAutoRefCountObjectPtr ret=MEDFileCurveLinearMesh::New(); - ret->loadCLMeshFromFile(fid,ms.front().c_str(),dt,it); + ret->loadCLMeshFromFile(fid,ms.front().c_str(),dt,it,mrs); return (MEDFileCurveLinearMesh *)ret.retn(); } default: @@ -137,13 +137,13 @@ MEDFileMesh *MEDFileMesh::New(const char *fileName, const char *mName, int dt, i case CARTESIAN: { MEDCouplingAutoRefCountObjectPtr ret=MEDFileCMesh::New(); - ret->loadCMeshFromFile(fid,mName,dt,it); + ret->loadCMeshFromFile(fid,mName,dt,it,mrs); return (MEDFileCMesh *)ret.retn(); } case CURVE_LINEAR: { MEDCouplingAutoRefCountObjectPtr ret=MEDFileCurveLinearMesh::New(); - ret->loadCLMeshFromFile(fid,mName,dt,it); + ret->loadCLMeshFromFile(fid,mName,dt,it,mrs); return (MEDFileCurveLinearMesh *)ret.retn(); } default: @@ -4447,7 +4447,7 @@ MEDFileCMesh *MEDFileCMesh::New() * \throw If there is no meshes in the file. * \throw If the mesh in the file is not a Cartesian one. */ -MEDFileCMesh *MEDFileCMesh::New(const char *fileName) throw(INTERP_KERNEL::Exception) +MEDFileCMesh *MEDFileCMesh::New(const char *fileName, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception) { std::vector ms=MEDLoader::GetMeshNames(fileName); if(ms.empty()) @@ -4461,7 +4461,7 @@ MEDFileCMesh *MEDFileCMesh::New(const char *fileName) throw(INTERP_KERNEL::Excep ParaMEDMEM::MEDCouplingMeshType meshType; std::string dummy2; MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2); - return new MEDFileCMesh(fid,ms.front().c_str(),dt,it); + return new MEDFileCMesh(fid,ms.front().c_str(),dt,it,mrs); } /*! @@ -4478,11 +4478,11 @@ MEDFileCMesh *MEDFileCMesh::New(const char *fileName) throw(INTERP_KERNEL::Excep * \throw If there is no mesh with given attributes in the file. * \throw If the mesh in the file is not a Cartesian one. */ -MEDFileCMesh *MEDFileCMesh::New(const char *fileName, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception) +MEDFileCMesh *MEDFileCMesh::New(const char *fileName, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception) { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - return new MEDFileCMesh(fid,mName,dt,it); + return new MEDFileCMesh(fid,mName,dt,it,mrs); } std::size_t MEDFileCMesh::getHeapMemorySize() const @@ -4594,17 +4594,17 @@ MEDFileCMesh::MEDFileCMesh() { } -MEDFileCMesh::MEDFileCMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception) +MEDFileCMesh::MEDFileCMesh(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception) try { - loadCMeshFromFile(fid,mName,dt,it); + loadCMeshFromFile(fid,mName,dt,it,mrs); } catch(INTERP_KERNEL::Exception& e) { throw e; } -void MEDFileCMesh::loadCMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception) +void MEDFileCMesh::loadCMeshFromFile(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception) { ParaMEDMEM::MEDCouplingMeshType meshType; int dummy0,dummy1; @@ -4701,7 +4701,7 @@ MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New() return new MEDFileCurveLinearMesh; } -MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const char *fileName) throw(INTERP_KERNEL::Exception) +MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const char *fileName, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception) { std::vector ms=MEDLoader::GetMeshNames(fileName); if(ms.empty()) @@ -4715,14 +4715,14 @@ MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const char *fileName) throw( ParaMEDMEM::MEDCouplingMeshType meshType; std::string dummy2; MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2); - return new MEDFileCurveLinearMesh(fid,ms.front().c_str(),dt,it); + return new MEDFileCurveLinearMesh(fid,ms.front().c_str(),dt,it,mrs); } -MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const char *fileName, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception) +MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const char *fileName, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception) { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - return new MEDFileCurveLinearMesh(fid,mName,dt,it); + return new MEDFileCurveLinearMesh(fid,mName,dt,it,mrs); } std::size_t MEDFileCurveLinearMesh::getHeapMemorySize() const @@ -4842,10 +4842,10 @@ MEDFileCurveLinearMesh::MEDFileCurveLinearMesh() { } -MEDFileCurveLinearMesh::MEDFileCurveLinearMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception) +MEDFileCurveLinearMesh::MEDFileCurveLinearMesh(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception) try { - loadCLMeshFromFile(fid,mName,dt,it); + loadCLMeshFromFile(fid,mName,dt,it,mrs); } catch(INTERP_KERNEL::Exception& e) { @@ -4886,7 +4886,7 @@ void MEDFileCurveLinearMesh::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exc MEDFileStructuredMesh::writeStructuredLL(fid,maa); } -void MEDFileCurveLinearMesh::loadCLMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception) +void MEDFileCurveLinearMesh::loadCLMeshFromFile(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception) { ParaMEDMEM::MEDCouplingMeshType meshType; int dummy0,dummy1; diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index c501e45ad..590ef84fb 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -326,8 +326,8 @@ namespace ParaMEDMEM friend class MEDFileMesh; public: static MEDFileCMesh *New(); - static MEDFileCMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception); - static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception); + static MEDFileCMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); + static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); std::size_t getHeapMemorySize() const; MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception); MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception); @@ -344,8 +344,8 @@ namespace ParaMEDMEM void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); MEDFileCMesh(); void synchronizeTinyInfoOnLeaves() const; - MEDFileCMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception); - void loadCMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception); + MEDFileCMesh(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception); + void loadCMeshFromFile(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception); private: MEDCouplingAutoRefCountObjectPtr _cmesh; }; @@ -355,8 +355,8 @@ namespace ParaMEDMEM friend class MEDFileMesh; public: static MEDFileCurveLinearMesh *New(); - static MEDFileCurveLinearMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception); - static MEDFileCurveLinearMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception); + static MEDFileCurveLinearMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); + static MEDFileCurveLinearMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); std::size_t getHeapMemorySize() const; MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception); MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception); @@ -370,11 +370,11 @@ namespace ParaMEDMEM void setMesh(MEDCouplingCurveLinearMesh *m) throw(INTERP_KERNEL::Exception); private: MEDFileCurveLinearMesh(); - MEDFileCurveLinearMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception); + MEDFileCurveLinearMesh(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception); const MEDCouplingStructuredMesh *getStructuredMesh() const; void synchronizeTinyInfoOnLeaves() const; void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); - void loadCLMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);//to imp + void loadCLMeshFromFile(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception);//to imp private: MEDCouplingAutoRefCountObjectPtr _clmesh; }; diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 487b91b4d..ab758d651 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -529,16 +529,6 @@ namespace ParaMEDMEM virtual DataArrayInt *getNodeFamiliesArr(const std::vector& fams, bool renum=false) const throw(INTERP_KERNEL::Exception); %extend { - MEDFileMesh(const char *fileName) throw(INTERP_KERNEL::Exception) - { - return MEDFileMesh::New(fileName); - } - - MEDFileMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception) - { - return MEDFileMesh::New(fileName,mName,dt,it); - } - std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -664,8 +654,8 @@ namespace ParaMEDMEM class MEDFileUMesh : public MEDFileMesh { public: - static MEDFileUMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception); - static MEDFileUMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception); + static MEDFileUMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); + static MEDFileUMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); static MEDFileUMesh *New(); ~MEDFileUMesh(); int getSpaceDimension() const throw(INTERP_KERNEL::Exception); @@ -708,14 +698,14 @@ namespace ParaMEDMEM DataArrayInt *zipCoords() throw(INTERP_KERNEL::Exception); %extend { - MEDFileUMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception) + MEDFileUMesh(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileUMesh::New(fileName,mName,dt,it); + return MEDFileUMesh::New(fileName,mName,dt,it,mrs); } - MEDFileUMesh(const char *fileName) throw(INTERP_KERNEL::Exception) + MEDFileUMesh(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileUMesh::New(fileName); + return MEDFileUMesh::New(fileName,mrs); } MEDFileUMesh() @@ -788,8 +778,8 @@ namespace ParaMEDMEM { public: static MEDFileCMesh *New(); - static MEDFileCMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception); - static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception); + static MEDFileCMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); + static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); void setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception); %extend { @@ -798,14 +788,14 @@ namespace ParaMEDMEM return MEDFileCMesh::New(); } - MEDFileCMesh(const char *fileName) throw(INTERP_KERNEL::Exception) + MEDFileCMesh(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileCMesh::New(fileName); + return MEDFileCMesh::New(fileName,mrs); } - MEDFileCMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception) + MEDFileCMesh(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileCMesh::New(fileName,mName,dt,it); + return MEDFileCMesh::New(fileName,mName,dt,it,mrs); } PyObject *getMesh() const throw(INTERP_KERNEL::Exception) @@ -822,8 +812,8 @@ namespace ParaMEDMEM { public: static MEDFileCurveLinearMesh *New(); - static MEDFileCurveLinearMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception); - static MEDFileCurveLinearMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception); + static MEDFileCurveLinearMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); + static MEDFileCurveLinearMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); void setMesh(MEDCouplingCurveLinearMesh *m) throw(INTERP_KERNEL::Exception); %extend { @@ -832,14 +822,14 @@ namespace ParaMEDMEM return MEDFileCurveLinearMesh::New(); } - MEDFileCurveLinearMesh(const char *fileName) throw(INTERP_KERNEL::Exception) + MEDFileCurveLinearMesh(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileCurveLinearMesh::New(fileName); + return MEDFileCurveLinearMesh::New(fileName,mrs); } - MEDFileCurveLinearMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception) + MEDFileCurveLinearMesh(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileCurveLinearMesh::New(fileName,mName,dt,it); + return MEDFileCurveLinearMesh::New(fileName,mName,dt,it,mrs); } PyObject *getMesh() const throw(INTERP_KERNEL::Exception) diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 2627ad21e..38cc037b5 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -1316,9 +1316,9 @@ class MEDLoaderTest(unittest.TestCase): def testBasicConstructors(self): fname="Pyfile18.med" - m=MEDFileMesh(fname) - m=MEDFileMesh(fname,"ExampleOfMultiDimW",-1,-1) - m=MEDFileMesh(fname) + m=MEDFileMesh.New(fname) + m=MEDFileMesh.New(fname,"ExampleOfMultiDimW",-1,-1) + m=MEDFileMesh.New(fname) m=MEDFileUMesh(fname,"ExampleOfMultiDimW",-1,-1) m=MEDFileUMesh(fname) m=MEDFileUMesh() -- 2.39.2