From: GERALD NICOLAS Date: Wed, 10 Feb 2021 17:01:16 +0000 (+0100) Subject: Usage de medcoupling pour le nom du maillage X-Git-Tag: V9_7_0a1~18^2~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=36da8034494ef9123c793a446e79eee7080fa29c;p=modules%2Fsmesh.git Usage de medcoupling pour le nom du maillage --- diff --git a/src/SMESHGUI/MG_ADAPTGUI.cxx b/src/SMESHGUI/MG_ADAPTGUI.cxx index 401b97484..c1df37aa7 100644 --- a/src/SMESHGUI/MG_ADAPTGUI.cxx +++ b/src/SMESHGUI/MG_ADAPTGUI.cxx @@ -24,6 +24,7 @@ #include "MG_ADAPTGUI.hxx" #include "MEDFileData.hxx" +#include "MEDLoader.hxx" #include "SUIT_Desktop.h" #include "SUIT_Application.h" @@ -1278,82 +1279,32 @@ med_idt OuvrirFichier(QString aFile) QString lireNomMaillage(QString aFile, med_int& meshdim) { QString nomMaillage = QString::null ; - int erreur = 0 ; - med_idt medIdt ; - // Ouverture du fichier - medIdt = OuvrirFichier(aFile); - if ( medIdt < 0 ) - { - erreur = 1 ; - return nomMaillage; - } - med_int numberOfMeshes = MEDnMesh(medIdt) ; + std::vector listMeshesNames = MEDCoupling::GetMeshNames(aFile.toStdString()); + + std::size_t numberOfMeshes(listMeshesNames.size()); +// std::cout << "numberOfMeshes:" << numberOfMeshes << std::endl; if (numberOfMeshes == 0 ) { QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), QObject::tr("MG_ADAPT_MED_FILE_2") ); - erreur = 2 ; return nomMaillage; } if (numberOfMeshes > 1 ) { QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), QObject::tr("MG_ADAPT_MED_FILE_3") ); - erreur = 3 ; return nomMaillage; } - nomMaillage = lireNomMaillage2(medIdt,1, meshdim); - // Fermeture du fichier - if ( medIdt > 0 ) MEDfileClose(medIdt); +// std::cout << "numberOfMeshes:" << numberOfMeshes << std::endl; + std::cout << "nomMaillage:" << listMeshesNames[0] << std::endl; + nomMaillage = QString(listMeshesNames[0].c_str()); return nomMaillage; } // ======================================================================= -// ======================================================================= -QString lireNomMaillage2(med_idt medIdt,int meshId, med_int& meshdim ) -{ - QString NomMaillage=QString::null; - char meshname[MED_NAME_SIZE+1]; - med_int spacedim; - med_mesh_type meshtype; - char descriptionription[MED_COMMENT_SIZE+1]; - char dtunit[MED_SNAME_SIZE+1]; - med_sorting_type sortingtype; - med_int nstep; - med_axis_type axistype; - int naxis = MEDmeshnAxis(medIdt,1); - char *axisname=new char[naxis*MED_SNAME_SIZE+1]; - char *axisunit=new char[naxis*MED_SNAME_SIZE+1]; - med_err aRet = MEDmeshInfo(medIdt, - meshId, - meshname, - &spacedim, - &meshdim, - &meshtype, - descriptionription, - dtunit, - &sortingtype, - &nstep, - &axistype, - axisname, - axisunit); - - if ( aRet < 0 ) { - QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), \ - QObject::tr("MG_ADAPT_MED_FILE_4") ); - } - else { - NomMaillage=QString(meshname); - } - - delete[] axisname ; - delete[] axisunit ; - - return NomMaillage; -} // ======================================================================= std::map GetListeChamps(QString aFile, bool errorMessage) diff --git a/src/SMESHGUI/MG_ADAPTGUI.hxx b/src/SMESHGUI/MG_ADAPTGUI.hxx index 823a5afa9..7be0fdbc4 100644 --- a/src/SMESHGUI/MG_ADAPTGUI.hxx +++ b/src/SMESHGUI/MG_ADAPTGUI.hxx @@ -99,7 +99,6 @@ class QFileDialog; std::map GetListeChamps(QString aFile, bool errorMessage = true); QString lireNomMaillage(QString aFile, med_int& meshDim); -QString lireNomMaillage2(med_idt medIdt,int meshId, med_int& meshDim); med_idt OuvrirFichier(QString aFile); std::string remove_extension(const std::string& filename); diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index fcac5cfe7..32fb70b88 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -396,10 +396,6 @@ MG_ADAPT_MED_FILE_5 No field in this MED file. - - MG_ADAPT_MED_FILE_6 - The field(s) in this MED file cannot be read. - MG_ADAPT_ERROR Error diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index 9cdbdd649..b69f4650a 100644 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -396,10 +396,6 @@ MG_ADAPT_MED_FILE_5 Ce fichier MED ne contient aucun champ. - - MG_ADAPT_MED_FILE_6 - Impossible de lire le(s) champ(s) de ce fichier MED. - MG_ADAPT_ERROR Erreur