From: ageay Date: Wed, 10 Aug 2011 10:58:06 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: V6_main_FINAL~993 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ed0dd4fc955042bcfce13bd2d680a32836492a52;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 8f11c7819..daddc8bdc 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -2216,6 +2216,26 @@ MEDFileMesh *MEDFileMeshes::getMeshAtPos(int i) const throw(INTERP_KERNEL::Excep return _meshes[i]->getOneTimeStep(); } +std::vector MEDFileMeshes::getMeshesNames() const throw(INTERP_KERNEL::Exception) +{ + std::vector ret(_meshes.size()); + int i=0; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_meshes.begin();it!=_meshes.end();it++,i++) + { + const MEDFileMeshMultiTS *f=(*it); + if(f) + { + ret[i]=f->getName(); + } + else + { + std::ostringstream oss; oss << "MEDFileMeshes::getMeshesNames : At rank #" << i << " mesh is not defined !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + return ret; +} + void MEDFileMeshes::resize(int newSize) throw(INTERP_KERNEL::Exception) { _meshes.resize(newSize); diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index 8fc056629..aed9e9c68 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); + std::vector getMeshesNames() const throw(INTERP_KERNEL::Exception); // void resize(int newSize) throw(INTERP_KERNEL::Exception); void pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index 74cb1ce58..c79f64184 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -91,6 +91,8 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevelOld; %newobject ParaMEDMEM::MEDFileData::New; +%newobject ParaMEDMEM::MEDFileData::getMeshes; +%newobject ParaMEDMEM::MEDFileData::getFields; %feature("unref") MEDFileMesh "$this->decrRef();" %feature("unref") MEDFileUMesh "$this->decrRef();" @@ -100,6 +102,7 @@ using namespace ParaMEDMEM; %feature("unref") MEDFileField1TS "$this->decrRef();" %feature("unref") MEDFileFieldMultiTS "$this->decrRef();" %feature("unref") MEDFileFields "$this->decrRef();" +%feature("unref") MEDFileData "$this->decrRef();" class MEDLoader { @@ -503,6 +506,7 @@ namespace ParaMEDMEM static MEDFileMeshes *New(const char *fileName) throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception); + std::vector getMeshesNames() const throw(INTERP_KERNEL::Exception); // void resize(int newSize) throw(INTERP_KERNEL::Exception); void pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception); @@ -673,13 +677,29 @@ namespace ParaMEDMEM public: static MEDFileData *New(const char *fileName) throw(INTERP_KERNEL::Exception); static MEDFileData *New(); - MEDFileFields *getFields() const; - MEDFileMeshes *getMeshes() const; void setFields(MEDFileFields *fields) throw(INTERP_KERNEL::Exception); void setMeshes(MEDFileMeshes *meshes) throw(INTERP_KERNEL::Exception); int getNumberOfFields() const throw(INTERP_KERNEL::Exception); int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception); // void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileMeshes *getMeshes() const + { + MEDFileMeshes *ret=self->getMeshes(); + if(ret) + ret->incrRef(); + return ret; + } + + MEDFileFields *getFields() const + { + MEDFileFields *ret=self->getFields(); + if(ret) + ret->incrRef(); + return ret; + } + } }; } diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 59dededda..1cb70ef9c 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -504,6 +504,7 @@ class MEDLoaderTest(unittest.TestCase): mmm2=MEDFileMeshMultiTS.New() ; mmm2.setOneTimeStep(mm2) ms=MEDFileMeshes.New(); ms.setMeshAtPos(0,mm1) ; ms.setMeshAtPos(1,mm2) d.setMeshes(ms) + self.assertEqual(('1DMesh_1', '2DCurveMesh_1'),d.getMeshes().getMeshesNames()) # ff1=MEDFileFieldMultiTS.New() ff21=MEDFileFieldMultiTS.New()