Salome HOME
les champs par medcoupling
authorGERALD NICOLAS <D68518@dsp0864451.atlas.edf.fr>
Wed, 10 Feb 2021 15:31:01 +0000 (16:31 +0100)
committerGERALD NICOLAS <D68518@dsp0864451.atlas.edf.fr>
Wed, 10 Feb 2021 15:31:01 +0000 (16:31 +0100)
src/SMESH/MG_ADAPT.cxx
src/SMESH/MG_ADAPT.hxx
src/SMESHGUI/CMakeLists.txt
src/SMESHGUI/MG_ADAPTGUI.cxx
src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h

index e73758b5d5d56258b76d2d533fb3c851c7776692..d22075995b0d0e683e09b62e8785713881f24109 100644 (file)
@@ -1152,22 +1152,31 @@ void MgAdapt::copyMgAdaptHypothesisData( const MgAdaptHypothesisData* from)
   data->myVerboseLevel = from->myVerboseLevel;
 }
 
+std::vector<std::string> MgAdapt::getListFieldsNames(std::string fileIn)
+{
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(fileIn);
+  std::vector<std::string> listFieldsNames(mfd->getFields()->getFieldsNames());
+  return listFieldsNames ;
+}
+
 bool MgAdapt::checkFieldName(std::string fileIn)
 {
   bool ret = false ;
-  MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(fileIn);
-  std::vector<std::string> fieldNames(mfd->getFields()->getFieldsNames());
-  std::size_t jaux(fieldNames.size());
+  std::vector<std::string> listFieldsNames = getListFieldsNames(fileIn);
+  std::size_t jaux(listFieldsNames.size());
   for(std::size_t j=0;j<jaux;j++)
   {
-    if ( fieldName == fieldNames[j] )
-    { ret = true ; }
+    if ( fieldName == listFieldsNames[j] )
+    {
+      ret = true ;
+      break ;
+    }
   }
   if ( ! ret )
   {
     std::cout << "Available field names:" << std::endl;
     for(std::size_t j=0;j<jaux;j++)
-    { std::cout << fieldNames[j] << std::endl;}
+    { std::cout << listFieldsNames[j] << std::endl;}
     SALOME::ExceptionStruct es;
     es.type = SALOME::BAD_PARAM;
     std::string text = "Field " + fieldName + " is not found." ;
@@ -1190,7 +1199,10 @@ bool MgAdapt::checkTimeStepRank(std::string fileIn)
   for(std::size_t j=0;j<jaux;j++)
   {
     if ( ( timeStep == timesteprank[j].first ) & ( rank == timesteprank[j].second ) )
-    { ret = true ; }
+    {
+      ret = true ;
+      break ;
+    }
   }
   if ( ! ret )
   {
index be289729a6b5acb8f08ea7eed48ecb1b4427fde1..9364add2937ca6367e97773bd0526d46bd0a392e 100644 (file)
@@ -328,6 +328,7 @@ private :
   void execCmd( const char* cmd, int& err);
   void cleanUp();
   void appendMsgToLogFile(std::string& msg);
+  std::vector<std::string> getListFieldsNames(std::string fileIn) ;
   bool checkFieldName(std::string fileIn) ;
   bool checkTimeStepRank(std::string fileIn) ;
 
index 5b5bd4a8c6f8f41847d2208787735b8e56c24630..237f63801af93a9f2685296bf3e33412b340e579 100644 (file)
@@ -42,7 +42,6 @@ INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/Controls
   ${PROJECT_SOURCE_DIR}/src/SMESHClient
   ${PROJECT_SOURCE_DIR}/src/MEDWrapper
-  ${PROJECT_SOURCE_DIR}/src/ADAPT
   ${PROJECT_BINARY_DIR}
   ${PROJECT_BINARY_DIR}/idl
   ${MEDCOUPLING_INCLUDE_DIRS}
index 8e7a593b1ad42c2fcfc7d9da55e25c7542af21a9..401b97484b38125e97016274611627160ca733d8 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "MG_ADAPTGUI.hxx"
 
+#include "MEDFileData.hxx"
+
 #include "SUIT_Desktop.h"
 #include "SUIT_Application.h"
 #include "SUIT_Session.h"
@@ -1363,21 +1365,13 @@ std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage)
   std::map<QString, int> ListeChamp ;
 
   med_err erreur = 0 ;
-  med_idt medIdt ;
 
   while ( erreur == 0 )
   {
-    // Ouverture du fichier
-    SCRUTE(aFile.toStdString());
-    medIdt = OuvrirFichier(aFile);
-    if ( medIdt < 0 )
-    {
-      erreur = 1 ;
-      break ;
-    }
-    // Lecture du nombre de champs
-    med_int ncha = MEDnField(medIdt) ;
-    if (ncha < 1 )
+    MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(aFile.toStdString());
+    std::vector<std::string> listFieldsNames(mfd->getFields()->getFieldsNames());
+    std::size_t jaux(listFieldsNames.size());
+    if (jaux < 1 )
     {
       if(errorMessage)
       {
@@ -1387,40 +1381,14 @@ std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage)
       erreur = 2 ;
       break ;
     }
-    // Lecture des caracteristiques des champs
-    for (int i=0; i< ncha; i++)
+    med_int nbofcstp = 1;
+    for(std::size_t j=0;j<jaux;j++)
     {
-//       Lecture du nombre de composantes
-      med_int ncomp = MEDfieldnComponent(medIdt,i+1);
-//       Lecture du type du champ, des noms des composantes et du nom de l'unite
-      char nomcha  [MED_NAME_SIZE+1];
-      char meshname[MED_NAME_SIZE+1];
-      char * comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
-      char * unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
-      char dtunit[MED_SNAME_SIZE+1];
-      med_bool local;
-      med_field_type typcha;
-      med_int nbofcstp;
-      erreur = MEDfieldInfo(medIdt,i+1,nomcha,meshname,&local,&typcha,comp,unit,dtunit,&nbofcstp) ;
-      free(comp);
-      free(unit);
-      if ( erreur < 0 )
-      {
-        if(errorMessage)
-        {
-          QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
-                                    QObject::tr("MG_ADAPT_MED_FILE_6") );
-        }
-        break ;
-      }
-
-      ListeChamp.insert(std::pair<QString, int> (QString(nomcha), nbofcstp));
-
+//       std::cout << listFieldsNames[j] << std::endl;
+      ListeChamp.insert(std::pair<QString, int> (QString(listFieldsNames[j].c_str()), nbofcstp));
     }
     break ;
   }
-    // Fermeture du fichier
-  if ( medIdt > 0 ) MEDfileClose(medIdt);
 
   return ListeChamp;
 }
index f68398525e382d9cc8938d9504093591abf70f19..20e09dd956131b1891ed15cace105efd6821f120 100644 (file)
@@ -43,9 +43,7 @@
 #include <med.h>
 #include <QObject>
 // model
-//~#include "MG_ADAPT.h"
 #include "MG_ADAPTGUI.hxx"
-//~#include "MG_ADAPT.hxx"
 
 #include CORBA_SERVER_HEADER(MG_ADAPT)