mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-03 04:10:34 +05:00
les champs par medcoupling
This commit is contained in:
parent
58ca79c858
commit
b54385ddd4
@ -1152,22 +1152,31 @@ void MgAdapt::copyMgAdaptHypothesisData( const MgAdaptHypothesisData* from)
|
|||||||
data->myVerboseLevel = from->myVerboseLevel;
|
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 MgAdapt::checkFieldName(std::string fileIn)
|
||||||
{
|
{
|
||||||
bool ret = false ;
|
bool ret = false ;
|
||||||
MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(fileIn);
|
std::vector<std::string> listFieldsNames = getListFieldsNames(fileIn);
|
||||||
std::vector<std::string> fieldNames(mfd->getFields()->getFieldsNames());
|
std::size_t jaux(listFieldsNames.size());
|
||||||
std::size_t jaux(fieldNames.size());
|
|
||||||
for(std::size_t j=0;j<jaux;j++)
|
for(std::size_t j=0;j<jaux;j++)
|
||||||
{
|
{
|
||||||
if ( fieldName == fieldNames[j] )
|
if ( fieldName == listFieldsNames[j] )
|
||||||
{ ret = true ; }
|
{
|
||||||
|
ret = true ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( ! ret )
|
if ( ! ret )
|
||||||
{
|
{
|
||||||
std::cout << "Available field names:" << std::endl;
|
std::cout << "Available field names:" << std::endl;
|
||||||
for(std::size_t j=0;j<jaux;j++)
|
for(std::size_t j=0;j<jaux;j++)
|
||||||
{ std::cout << fieldNames[j] << std::endl;}
|
{ std::cout << listFieldsNames[j] << std::endl;}
|
||||||
SALOME::ExceptionStruct es;
|
SALOME::ExceptionStruct es;
|
||||||
es.type = SALOME::BAD_PARAM;
|
es.type = SALOME::BAD_PARAM;
|
||||||
std::string text = "Field " + fieldName + " is not found." ;
|
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++)
|
for(std::size_t j=0;j<jaux;j++)
|
||||||
{
|
{
|
||||||
if ( ( timeStep == timesteprank[j].first ) & ( rank == timesteprank[j].second ) )
|
if ( ( timeStep == timesteprank[j].first ) & ( rank == timesteprank[j].second ) )
|
||||||
{ ret = true ; }
|
{
|
||||||
|
ret = true ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( ! ret )
|
if ( ! ret )
|
||||||
{
|
{
|
||||||
|
@ -328,6 +328,7 @@ private :
|
|||||||
void execCmd( const char* cmd, int& err);
|
void execCmd( const char* cmd, int& err);
|
||||||
void cleanUp();
|
void cleanUp();
|
||||||
void appendMsgToLogFile(std::string& msg);
|
void appendMsgToLogFile(std::string& msg);
|
||||||
|
std::vector<std::string> getListFieldsNames(std::string fileIn) ;
|
||||||
bool checkFieldName(std::string fileIn) ;
|
bool checkFieldName(std::string fileIn) ;
|
||||||
bool checkTimeStepRank(std::string fileIn) ;
|
bool checkTimeStepRank(std::string fileIn) ;
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ INCLUDE_DIRECTORIES(
|
|||||||
${PROJECT_SOURCE_DIR}/src/Controls
|
${PROJECT_SOURCE_DIR}/src/Controls
|
||||||
${PROJECT_SOURCE_DIR}/src/SMESHClient
|
${PROJECT_SOURCE_DIR}/src/SMESHClient
|
||||||
${PROJECT_SOURCE_DIR}/src/MEDWrapper
|
${PROJECT_SOURCE_DIR}/src/MEDWrapper
|
||||||
${PROJECT_SOURCE_DIR}/src/ADAPT
|
|
||||||
${PROJECT_BINARY_DIR}
|
${PROJECT_BINARY_DIR}
|
||||||
${PROJECT_BINARY_DIR}/idl
|
${PROJECT_BINARY_DIR}/idl
|
||||||
${MEDCOUPLING_INCLUDE_DIRS}
|
${MEDCOUPLING_INCLUDE_DIRS}
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include "MG_ADAPTGUI.hxx"
|
#include "MG_ADAPTGUI.hxx"
|
||||||
|
|
||||||
|
#include "MEDFileData.hxx"
|
||||||
|
|
||||||
#include "SUIT_Desktop.h"
|
#include "SUIT_Desktop.h"
|
||||||
#include "SUIT_Application.h"
|
#include "SUIT_Application.h"
|
||||||
#include "SUIT_Session.h"
|
#include "SUIT_Session.h"
|
||||||
@ -1363,21 +1365,13 @@ std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage)
|
|||||||
std::map<QString, int> ListeChamp ;
|
std::map<QString, int> ListeChamp ;
|
||||||
|
|
||||||
med_err erreur = 0 ;
|
med_err erreur = 0 ;
|
||||||
med_idt medIdt ;
|
|
||||||
|
|
||||||
while ( erreur == 0 )
|
while ( erreur == 0 )
|
||||||
{
|
{
|
||||||
// Ouverture du fichier
|
MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(aFile.toStdString());
|
||||||
SCRUTE(aFile.toStdString());
|
std::vector<std::string> listFieldsNames(mfd->getFields()->getFieldsNames());
|
||||||
medIdt = OuvrirFichier(aFile);
|
std::size_t jaux(listFieldsNames.size());
|
||||||
if ( medIdt < 0 )
|
if (jaux < 1 )
|
||||||
{
|
|
||||||
erreur = 1 ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
// Lecture du nombre de champs
|
|
||||||
med_int ncha = MEDnField(medIdt) ;
|
|
||||||
if (ncha < 1 )
|
|
||||||
{
|
{
|
||||||
if(errorMessage)
|
if(errorMessage)
|
||||||
{
|
{
|
||||||
@ -1387,40 +1381,14 @@ std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage)
|
|||||||
erreur = 2 ;
|
erreur = 2 ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
// Lecture des caracteristiques des champs
|
med_int nbofcstp = 1;
|
||||||
for (int i=0; i< ncha; i++)
|
for(std::size_t j=0;j<jaux;j++)
|
||||||
{
|
{
|
||||||
// Lecture du nombre de composantes
|
// std::cout << listFieldsNames[j] << std::endl;
|
||||||
med_int ncomp = MEDfieldnComponent(medIdt,i+1);
|
ListeChamp.insert(std::pair<QString, int> (QString(listFieldsNames[j].c_str()), nbofcstp));
|
||||||
// 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));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
// Fermeture du fichier
|
|
||||||
if ( medIdt > 0 ) MEDfileClose(medIdt);
|
|
||||||
|
|
||||||
return ListeChamp;
|
return ListeChamp;
|
||||||
}
|
}
|
||||||
|
@ -43,9 +43,7 @@
|
|||||||
#include <med.h>
|
#include <med.h>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
// model
|
// model
|
||||||
//~#include "MG_ADAPT.h"
|
|
||||||
#include "MG_ADAPTGUI.hxx"
|
#include "MG_ADAPTGUI.hxx"
|
||||||
//~#include "MG_ADAPT.hxx"
|
|
||||||
|
|
||||||
#include CORBA_SERVER_HEADER(MG_ADAPT)
|
#include CORBA_SERVER_HEADER(MG_ADAPT)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user