From b54467923876de1c0c2b1d49e50640d08663790f Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 24 Aug 2011 12:28:40 +0000 Subject: [PATCH] *** empty log message *** --- src/MEDLoader/MEDFileField.hxx | 2 +- src/MEDLoader/MEDFileMesh.cxx | 13 +++++++++++++ src/MEDLoader/MEDFileMesh.hxx | 1 + src/MEDLoader/Swig/MEDLoader.i | 9 +++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index d48bbeb0f..91115902d 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -361,6 +361,7 @@ namespace ParaMEDMEM void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); std::string getName() const; std::vector< std::pair > getTimeSteps(std::vector& ret1) const throw(INTERP_KERNEL::Exception); + std::string getMeshName() const throw(INTERP_KERNEL::Exception); public: std::vector getPflsReallyUsed2() const; std::vector getLocsReallyUsed2() const; @@ -368,7 +369,6 @@ namespace ParaMEDMEM const MEDFileField1TSWithoutDAS& getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception); MEDFileField1TSWithoutDAS& getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception); const std::vector& getInfo() const throw(INTERP_KERNEL::Exception); - std::string getMeshName() const throw(INTERP_KERNEL::Exception); std::string getDtUnit() const throw(INTERP_KERNEL::Exception); MEDFileFieldMultiTSWithoutDAS(); MEDFileFieldMultiTSWithoutDAS(const char *fieldName); diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index daddc8bdc..01c8e136d 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -2216,6 +2216,19 @@ MEDFileMesh *MEDFileMeshes::getMeshAtPos(int i) const throw(INTERP_KERNEL::Excep return _meshes[i]->getOneTimeStep(); } +MEDFileMesh *MEDFileMeshes::getMeshWithName(const char *mname) const throw(INTERP_KERNEL::Exception) +{ + std::vector ms=getMeshesNames(); + std::vector::iterator it=std::find(ms.begin(),ms.end(),mname); + if(it==ms.end()) + { + std::ostringstream oss; oss << "MEDFileMeshes::getMeshWithName : Mesh \"" << mname << "\" does not exist in this ! Existing are : "; + std::copy(ms.begin(),ms.end(),std::ostream_iterator(oss," ")); + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + return getMeshAtPos((int)std::distance(ms.begin(),it)); +} + std::vector MEDFileMeshes::getMeshesNames() const throw(INTERP_KERNEL::Exception) { std::vector ret(_meshes.size()); diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index aed9e9c68..e15a5bc54 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -262,6 +262,7 @@ namespace ParaMEDMEM void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception); MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception); + MEDFileMesh *getMeshWithName(const char *mname) const throw(INTERP_KERNEL::Exception); std::vector getMeshesNames() const throw(INTERP_KERNEL::Exception); // void resize(int newSize) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index 7693f3404..59dd73948 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -77,6 +77,7 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileMeshMultiTS::getOneTimeStep; %newobject ParaMEDMEM::MEDFileMeshes::New; %newobject ParaMEDMEM::MEDFileMeshes::getMeshAtPos; +%newobject ParaMEDMEM::MEDFileMeshes::getMeshWithName; %newobject ParaMEDMEM::MEDFileFields::New; %newobject ParaMEDMEM::MEDFileFields::getField; @@ -523,6 +524,13 @@ namespace ParaMEDMEM ret->incrRef(); return ret; } + MEDFileMesh *getMeshWithName(const char *mname) const throw(INTERP_KERNEL::Exception) + { + MEDFileMesh *ret=self->getMeshWithName(mname); + if(ret) + ret->incrRef(); + return ret; + } } }; @@ -595,6 +603,7 @@ namespace ParaMEDMEM public: int getNumberOfTS() const; std::string getName() const; + std::string getMeshName() const throw(INTERP_KERNEL::Exception); %extend { PyObject *getIterations() const -- 2.39.2