]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message *** V5_1_5rc2
authorageay <ageay>
Wed, 3 Nov 2010 10:41:31 +0000 (10:41 +0000)
committerageay <ageay>
Wed, 3 Nov 2010 10:41:31 +0000 (10:41 +0000)
src/MEDLoader/MEDLoader.cxx
src/MEDLoader/MEDLoader.hxx
src/MEDLoader/Swig/MEDLoaderTest.py
src/MEDLoader/Swig/libMEDLoader_Swig.i
src/MEDLoader/Test/MEDLoaderTest.cxx

index eb89ed9d095c2850a6e03dad67f657b5d905be3e..1c08abd9429e20415e16e781fa1e71c4688dc99b 100644 (file)
@@ -348,6 +348,57 @@ std::vector<std::string> MEDLoader::GetMeshNames(const char *fileName) throw(INT
   return ret;
 }
 
+std::vector<std::string> MEDLoader::GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+{
+  CheckFileForRead(fileName);
+  std::vector<std::string> 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<nbFields;i++)
+    {
+      med_int ncomp=MEDnChamp(fid,i+1);
+      char *comp=new char[ncomp*MED_TAILLE_PNOM+1];
+      char *unit=new char[ncomp*MED_TAILLE_PNOM+1];
+      MEDchampInfo(fid,i+1,nomcha,&typcha,comp,unit,ncomp);
+      std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_TAILLE_NOM+1);
+      delete [] comp;
+      delete [] unit;
+      if(curFieldName==fieldName)
+        {
+          bool found=false;
+          for(int j=0;j<MED_NBR_GEOMETRIE_MAILLE+2 && !found;j++)
+            {
+              med_int nbPdt=MEDnPasdetemps(fid,nomcha,MED_MAILLE,typmai[j]);
+              for(int k=0;k<nbPdt;k++)
+                {
+                  MEDpasdetempsInfo(fid,nomcha,MED_MAILLE,typmai[j],k+1, &ngauss, &numdt, &numo, dt_unit,&dt, maa_ass, &local, &nbrefmaa);
+                  std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_TAILLE_NOM+1);
+                  if(std::find(ret.begin(),ret.end(),curMeshName)==ret.end())
+                    ret.push_back(curMeshName);
+                }
+            }
+        }
+    }
+  delete [] maa_ass;
+  delete [] dt_unit;
+  delete [] nomcha;
+  MEDfermer(fid);
+  return ret;
+}
+
 std::vector<std::string> MEDLoader::GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception)
 {
   CheckFileForRead(fileName);
index 68e1a0ab945a8f54fc0bf596eec9d6c0f57fff4b..d262c04a34814505f708da4e76aa1ad890c4ad79 100644 (file)
@@ -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<std::string> GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
   static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
   static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
   static std::vector<std::string> GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception);
index 2d566c0e7ace3ae00b8b93d3415596ecf089d930..e0c9a080ab9885a7e9c872ca6fdc8ebbf2f8e03e 100644 (file)
@@ -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);
index 9ab3b142383288b17cf457bd8a9d9e1a200aa171..ddf0c24c0afc1cbbe190c017c937bf4830b09a23 100644 (file)
@@ -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<std::string> GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
   static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
   static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
   static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
index ab58c843ac311513b8d0066b5bc7057bcc10c9d0..6dadebf4835764ec2f52e21bfeab2e10d0666f35 100644 (file)
@@ -193,6 +193,10 @@ void MEDLoaderTest::testFieldRW3()
   f1->setTime(10.55,28,29);
   tmp[0]=3*VAL1;
   MEDLoader::WriteField(fileName,f1,false);
+  std::vector<std::string> 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);