From: ageay Date: Wed, 3 Nov 2010 10:41:31 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: V5_1_5~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d99286d7ae8f10c104ffd21a7d5db53f3615cff2;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index eb89ed9d0..1c08abd94 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -348,6 +348,57 @@ std::vector MEDLoader::GetMeshNames(const char *fileName) throw(INT return ret; } +std::vector MEDLoader::GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception) +{ + CheckFileForRead(fileName); + std::vector ret; + med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); + med_int nbFields=MEDnChamp(fid,0); + // + med_type_champ typcha; + //med_int nbpdtnor=0,pflsize,*pflval,lnsize; + med_int ngauss=0; + med_int numdt=0,numo=0,nbrefmaa; + med_float dt=0.0; + med_booleen local; + //char pflname[MED_TAILLE_NOM+1]=""; + //char locname[MED_TAILLE_NOM+1]=""; + char *maa_ass=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM); + char *dt_unit=MEDLoaderBase::buildEmptyString(MED_TAILLE_PNOM); + char *nomcha=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM); + // + for(int i=0;i MEDLoader::GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) { CheckFileForRead(fileName); diff --git a/src/MEDLoader/MEDLoader.hxx b/src/MEDLoader/MEDLoader.hxx index 68e1a0ab9..d262c04a3 100644 --- a/src/MEDLoader/MEDLoader.hxx +++ b/src/MEDLoader/MEDLoader.hxx @@ -87,6 +87,7 @@ class MEDLOADER_EXPORT MEDLoader static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception); static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception); static std::vector GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception); + static std::vector GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); static std::vector GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); static std::vector GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); static std::vector GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/Swig/MEDLoaderTest.py b/src/MEDLoader/Swig/MEDLoaderTest.py index 2d566c0e7..e0c9a080a 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest.py +++ b/src/MEDLoader/Swig/MEDLoaderTest.py @@ -150,6 +150,10 @@ class MEDLoaderTest(unittest.TestCase): f1.setTime(10.55,28,29); f1.getArray().setIJ(0,0,3*VAL1); MEDLoader.WriteField(fileName,f1,False); + vec=MEDLoader.GetMeshNamesOnField(fileName,name1); + self.assertEqual(2,len(vec)); + self.assertTrue(vec[0]==name3); + self.assertTrue(vec[1]==name2); f1.setTime(10.66,38,39); f1.getArray().setIJ(0,0,3*VAL2); MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); diff --git a/src/MEDLoader/Swig/libMEDLoader_Swig.i b/src/MEDLoader/Swig/libMEDLoader_Swig.i index 9ab3b1423..ddf0c24c0 100644 --- a/src/MEDLoader/Swig/libMEDLoader_Swig.i +++ b/src/MEDLoader/Swig/libMEDLoader_Swig.i @@ -50,6 +50,7 @@ public: static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception); static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception); static std::vector GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception); + static std::vector GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); static std::vector GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); static std::vector GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); static std::vector GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/Test/MEDLoaderTest.cxx b/src/MEDLoader/Test/MEDLoaderTest.cxx index ab58c843a..6dadebf48 100644 --- a/src/MEDLoader/Test/MEDLoaderTest.cxx +++ b/src/MEDLoader/Test/MEDLoaderTest.cxx @@ -193,6 +193,10 @@ void MEDLoaderTest::testFieldRW3() f1->setTime(10.55,28,29); tmp[0]=3*VAL1; MEDLoader::WriteField(fileName,f1,false); + std::vector vec=MEDLoader::GetMeshNamesOnField(fileName,name1); + CPPUNIT_ASSERT_EQUAL(2,(int)vec.size()); + CPPUNIT_ASSERT(vec[0]==name3); + CPPUNIT_ASSERT(vec[1]==name2); f1->setTime(10.66,38,39); tmp[0]=3*VAL2; MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1);