1/ Remove explicit memory leaks (e.g. CORBA ptr are not destroyed).
2/ Remove redundant includes.
4/ Fix architectural problems: avoid raising CORBA exceptions from low level, instead catch and rethrow exceptions from upper level.
7/ Fix declarations - IDL stubs overrides must not be declared as raising std exceptions.
10/ Remove redundant code duplication. In particular class ToComment to be replaced by existing SMESH_Comment.
11/ Clean-up unused member fields.
12/ Fix errors in documentation.
MG_Adapt
========
-.. literalinclude:: ../../../examples/adaptation_ex01.py
+.. literalinclude:: ../../../examples/MGAdaptTests_without_session.py
:language: python
-:download:`Download this script <../../../examples/adaptation_ex01.py>`
+:download:`Download this script <../../../examples/MGAdaptTests_without_session.py>`
**See Also** the GUI :ref:`adaptation_page`.
module SMESH{
- typedef sequence<string> str_array ;
struct MgAdaptHypothesisData
{
string myFileInDir, myMeshFileIn, myInMeshName, myMeshFileBackground, myOutMeshName,
interface MG_ADAPT : SALOME::GenericObj
{
- //MG_ADAPT CreateMG_ADAPT(in PortableServer::POA_var poa);
void setData( inout MgAdaptHypothesisData data);
void setMedFileIn(in string MedFileIn );
boolean hasOptionDefined( in string optionName ) ;
void setOptionValue(in string optionName, in string optionValue) raises (SALOME::SALOME_Exception);
string getOptionValue(in string optionName, inout boolean isDefault) raises (SALOME::SALOME_Exception);
- str_array getCustomOptionValuesStrVec() ;
- str_array getOptionValuesStrVec() ;
+ SMESH::string_array getCustomOptionValuesStrVec() ;
+ SMESH::string_array getOptionValuesStrVec() ;
};
typedef MG_ADAPT MG_ADAPT_HYPOTHESIS;
#include "MG_ADAPT.hxx"
-#include "MeshFormatReader.hxx"
-#include "MeshFormatWriter.hxx"
-#include "MEDFileMesh.hxx"
-#include "MCAuto.hxx"
-#include "MEDFileData.hxx"
-#include "MEDFileField.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-
-#include <SALOME_NamingService.hxx>
+#include "SMESH_File.hxx"
+#include "SMESH_Comment.hxx"
+
+#include <MEDFileData.hxx>
+#include <MEDFileField.hxx>
+#include <MEDFileMesh.hxx>
+#include <MeshFormatReader.hxx>
+#include <MeshFormatWriter.hxx>
+
#include <Utils_SALOME_Exception.hxx>
-#include "Utils_CorbaException.hxx"
-#include <utilities.h>
-#include <iostream>
-#include <unistd.h>
-#include <TCollection_AsciiString.hxx>
-#include <cstring>
-#include <cstdlib>
-#include <boost/filesystem.hpp>
+#include <unistd.h> // getpid()
+#include <memory> // unique_ptr
+
+typedef SMESH_Comment ToComment;
using namespace MG_ADAPT;
static std::string removeFile(std::string fileName, int& notOk)
return errStr;
}
-std::string remove_extension(const std::string& filename) {
+std::string MG_ADAPT::remove_extension(const std::string& filename) {
size_t lastdot = filename.find_last_of(".");
if (lastdot == std::string::npos) return filename;
return filename.substr(0, lastdot);
}
namespace
{
+
+ bool isFileExist( const std::string& fName )
+ {
+ return SMESH_File( fName ).exists();
+ }
+
+// =======================================================================
+med_idt openMedFile(const std::string aFile)
+// =======================================================================
+// renvoie le medId associe au fichier Med apres ouverture
+{
+ med_idt medIdt = MEDfileOpen(aFile.c_str(),MED_ACC_RDONLY);
+ if (medIdt <0)
+ {
+ THROW_SALOME_EXCEPTION("\nThe med file " << aFile << " cannot be opened.\n");
+ }
+ return medIdt;
+}
+
+
+// =======================================================================
+void getTimeStepInfos(std::string aFile, med_int& numdt, med_int& numit, std::string fieldName)
+// =======================================================================
+{
+// Il faut voir si plusieurs maillages
+
+ herr_t erreur = 0 ;
+ med_idt medIdt ;
+
+
+ // Ouverture du fichier
+ //~SCRUTE(aFile.toStdString());
+ medIdt = openMedFile(aFile);
+ if ( medIdt < 0 ) return ;
+ // Lecture du nombre de champs
+ med_int ncha = MEDnField(medIdt) ;
+ if (ncha < 1 )
+ {
+ //~addMessage( ToComment(" error: there is no field in ") << aFile, /*fatal=*/true );
+ return;
+ }
+ // Lecture des caracteristiques du champs
+
+ // Lecture du type du champ, des noms des composantes et du nom de l'unite
+ char nomcha [MED_NAME_SIZE+1];
+ strcpy(nomcha, fieldName.c_str());
+// Lecture du nombre de composantes
+ med_int ncomp = MEDfieldnComponentByName(medIdt, nomcha);
+ 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 = MEDfieldInfoByName (medIdt, nomcha, meshname,&local,&typcha,comp,unit,dtunit, &nbofcstp);
+ free(comp);
+ free(unit);
+ if ( erreur < 0 )
+ {
+ //~addMessage( ToComment(" error: error while reading field ") << nomcha << " in file " << aFile , /*fatal=*/true );
+ return;
+ }
+
+ med_float dt;
+ med_int tmp_numdt, tmp_numit;
+
+ //~med_int step = data->myUseLastTimeStep ? nbofcstp : data->myTimeStep+1;
+ //~myPrint("step ", step);
+ erreur = MEDfieldComputingStepInfo ( medIdt, nomcha, 1, &numdt, &numit, &dt );
+ for( int step = 1; step <= nbofcstp; step++ )
+ {
+ erreur = MEDfieldComputingStepInfo ( medIdt, nomcha, step, &tmp_numdt, &tmp_numit, &dt );
+ if(tmp_numdt > numdt)
+ {
+ numdt = tmp_numdt;
+ numit = tmp_numit;
+ }
+ }
+ if ( erreur < 0 )
+ {
+ //~addMessage( ToComment(" error: error while reading field ") << nomcha << "step (numdt, numit) = " <<"("<< numdt<< ", "
+ //numit<< ")" <<" in file " << aFile , /*fatal=*/true );
+ return;
+ }
+
+ // Fermeture du fichier
+ if ( medIdt > 0 ) MEDfileClose(medIdt);
+
+}
+
struct GET_DEFAULT // struct used to get default value from GetOptionValue()
{
bool isDefault;
return &isDefault;
}
};
+
+class outFileStream : public std::ofstream{
+public:
+ ~outFileStream(){close();} //to close file at dtor
+};
}
//----------------------------------------------------------------------------------------
}
else
{
- SALOME::ExceptionStruct es;
- es.type = SALOME::BAD_PARAM;
- std::string text = "\nThe file " + fileName + " does not exist.\n" ;
- es.text = CORBA::string_dup(text.c_str());
- throw SALOME::SALOME_Exception(es);
+ THROW_SALOME_EXCEPTION("\nThe file "<< fileName <<" does not exist.\n");
}
}
}
else
{
- SALOME::ExceptionStruct es;
- es.type = SALOME::BAD_PARAM;
- std::string text = "\nThe file " + mapFile + " does not exist.\n" ;
- es.text = CORBA::string_dup(text.c_str());
- throw SALOME::SALOME_Exception(es);
+ THROW_SALOME_EXCEPTION("\nThe file "<< mapFile <<" does not exist.\n");
}
}
std::string MgAdapt::getSizeMapFile()
//=============================================================================
void MgAdapt::setOptionValue(const std::string& optionName,
const std::string& optionValue)
-throw (std::invalid_argument)
{
// INFOS("setOptionValue");
// std::cout << "optionName: " << optionName << ", optionValue: " << optionValue << std::endl;
// strip white spaces
while (ptr[0] == ' ')
ptr++;
- int i = strlen(ptr);
+ size_t i = strlen(ptr);
while (i != 0 && ptr[i - 1] == ' ')
i--;
// check value type
// then *isDefault == true. If isDefault is not provided, the value will be
// empty if it equals a default one.
std::string MgAdapt::getOptionValue(const std::string& optionName, bool* isDefault) const
-throw (std::invalid_argument)
{
// INFOS("getOptionValue");
// std::cout << "optionName: " << optionName << ", isDefault: " << isDefault << std::endl;
//================================================================================
double MgAdapt::toDbl(const std::string& str, bool* isOk )
-throw (std::invalid_argument)
{
if ( str.empty() ) throw std::invalid_argument("Empty value provided");
{
std::string s = str;
for ( size_t i = 0; i <= s.size(); ++i )
- s[i] = tolower( s[i] );
+ s[i] = (char) tolower( s[i] );
return s;
}
//================================================================================
//================================================================================
bool MgAdapt::toBool(const std::string& str, bool* isOk )
-throw (std::invalid_argument)
{
std::string s = str;
if ( isOk ) *isOk = true;
for ( size_t i = 0; i <= s.size(); ++i )
- s[i] = tolower( s[i] );
+ s[i] = (char) tolower( s[i] );
if ( s == "1" || s == "true" || s == "active" || s == "yes" )
return true;
//================================================================================
int MgAdapt::toInt(const std::string& str, bool* isOk )
-throw (std::invalid_argument)
{
if ( str.empty() ) throw std::invalid_argument("Empty value provided");
}
//================================================================================
/*!
- * \brief Return command to run MG-Tetra mesher excluding file prefix (-f)
+ * \brief Return command to run MG-Adapt mesher excluding file prefix (-f)
*/
//================================================================================
return hyp ? hyp->getCommandToRun() : ToComment("error with hypothesis!");
}
-
-
int MgAdapt::compute(std::string& errStr)
{
std::string cmd = getCommandToRun();
{
errStr = ToComment("system(mg-adapt.exe ...) command failed with error: ") << strerror( errno );
}
+ else if ( !isFileExist( meshFormatOutputMesh ))
+ {
+ errStr = ToComment(" failed to find file ") << meshFormatOutputMesh
+ << " output from MG-Adapt run";
+ }
else
{
convertMeshFile(meshFormatOutputMesh, solFormatOutput);
err = 1;
std::array <char, 128> buffer;
std::streambuf* buf;
-outFileStream fileStream;
+ outFileStream fileStream;
if (printLogInFile)
{
- fileStream.open(logFile);
- buf = fileStream.rdbuf();
+ fileStream.open(logFile);
+ buf = fileStream.rdbuf();
}
else
{
return cmd;
}
-bool MgAdapt::isFileExist(const std::string& fName)
-{
-
- if ( fName.empty() ) return false;
-
- boost::system::error_code err;
- bool res = boost::filesystem::exists( fName, err );
-
- return err ? false : res;
-}
//=======================================================================
//function : defaultMaximumMemory
//=======================================================================
if ( err == 0 )
{
long ramMB = si.totalram * si.mem_unit / 1024 / 1024;
- return ( 0.7 * ramMB );
+ return ( 0.7 * double( ramMB ));
}
#endif
return 1024;
std::string MgAdapt::defaultWorkingDirectory()
{
- TCollection_AsciiString aTmpDir;
+ std::string aTmpDir;
char *Tmp_dir = getenv("SALOME_TMP_DIR");
if(Tmp_dir != NULL)
}
else {
#ifdef WIN32
- aTmpDir = TCollection_AsciiString("C:\\");
+ aTmpDir = "C:\\";
#else
- aTmpDir = TCollection_AsciiString("/tmp/");
+ aTmpDir = "/tmp/";
#endif
}
- return aTmpDir.ToCString();
+ return aTmpDir;
}
//================================================================================
/*!
if(lastChar != '/') aTmpDir+='/';
#endif
- TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str();
- aGenericName += "MgAdapt_";
- aGenericName += getpid();
- aGenericName += "_";
- aGenericName += Abs((Standard_Integer)(long) aGenericName.ToCString());
+ SMESH_Comment aGenericName( aTmpDir );
+ aGenericName << "MgAdapt_";
+ aGenericName << getpid();
+ aGenericName << "_";
+ aGenericName << std::abs((int)(long) aGenericName.data());
- return aGenericName.ToCString();
+ return aGenericName;
}
//=======================================================================
//function : defaultLogFile
{
if ( optionValue != "surface" )
{
- SALOME::ExceptionStruct es;
- es.type = SALOME::BAD_PARAM;
- std::string text = "Mesh dimension is 2; the option should be 'surface' instead of '" + optionValue + "'." ;
- es.text = CORBA::string_dup(text.c_str());
- throw SALOME::SALOME_Exception(es);
+ THROW_SALOME_EXCEPTION("Mesh dimension is 2; the option should be 'surface'"
+ " instead of '" << optionValue << "'.");
}
}
}
std::cout << "Available field names:" << std::endl;
for(std::size_t j=0;j<jaux;j++)
{ std::cout << listFieldsNames[j] << std::endl;}
- SALOME::ExceptionStruct es;
- es.type = SALOME::BAD_PARAM;
- std::string text = "Field " + fieldName + " is not found." ;
- es.text = CORBA::string_dup(text.c_str());
- throw SALOME::SALOME_Exception(es);
+ THROW_SALOME_EXCEPTION( "Field " << fieldName << " is not found.");
}
}
std::cout << "Available (Time step, Rank):" << std::endl;
for(std::size_t j=0;j<jaux;j++)
{ std::cout << "(Time step = " << timesteprank[j].first << ", Rank = " << timesteprank[j].second << ")" << std::endl;}
- SALOME::ExceptionStruct es;
- es.type = SALOME::BAD_PARAM;
- std::string text = "(Time step = " + std::to_string(timeStep) + ", Rank = " + std::to_string(rank) + ") is not found." ;
- es.text = CORBA::string_dup(text.c_str());
- throw SALOME::SALOME_Exception(es);
+ THROW_SALOME_EXCEPTION("(Time step = " << timeStep << ", Rank = " << rank << ") is not found.");
}
}
for ( ; g2ff != grpFams.end(); ++g2ff )
{
- std::string groupName = g2ff->first;
+ std::string groupName = g2ff->first;
std::vector<std::string> famNames = g2ff->second;
if ( famNames.empty() ) continue;
- std::size_t k = 0;
- std::vector< mcIdType> famListId;
+ std::vector< int> famListId;
for ( size_t i = 0; i < famNames.size(); ++i )
{
- famListId.push_back( fileMesh->getFamilyId( famNames[i].c_str() ) );
+ famListId.push_back( FromIdType<int>( fileMesh->getFamilyId( famNames[i].c_str() )));
}
group grp(groupName, famListId, famNames);
groupVec.push_back(grp);
for ( ; f != grpFams.end(); ++f )
{
if(!f->second) continue; // FAMILLE_ZERO
- family fs(f->first, f->second);
+ family fs(f->first, FromIdType<int>( f->second ));
famVec.push_back(fs);
}
fileMesh->setGroupInfo(info);
}
-void MgAdapt::buildConstantSizeMapSolFile(const std::string& solFormatFieldFileName, const int dim, const int version, const mcIdType nbNodes) const
+void MgAdapt::buildConstantSizeMapSolFile(const std::string& solFormatFieldFileName, const int dim, const int version, const size_t nbNodes) const
{
MeshFormat::Localizer loc;
MeshFormat::MeshFormatParser writer;
int fileId = writer.GmfOpenMesh( solFormatFieldFileName.c_str(), GmfWrite, version, dim);
int typTab[] = {GmfSca};
writer.GmfSetKwd(fileId, MeshFormat::GmfSolAtVertices, (int)nbNodes, 1, typTab);
- for (mcIdType i = 0; i<nbNodes; i++)
+ for (size_t i = 0; i<nbNodes; i++)
{
double valTab[1] = {constantValue};
writer.GmfSetLin( fileId, MeshFormat::GmfSolAtVertices, valTab);
tmpWriter.setMEDFileDS(tmpMfd);
tmpWriter.write();
}
-// =======================================================================
-med_idt MgAdapt::openMedFile(const std::string aFile)
-// =======================================================================
-// renvoie le medId associe au fichier Med apres ouverture
-{
- med_idt medIdt = MEDfileOpen(aFile.c_str(),MED_ACC_RDONLY);
- if (medIdt <0)
- {
- SALOME::ExceptionStruct es;
- es.type = SALOME::BAD_PARAM;
- std::string text = "\nThe med file " + aFile + " cannot be opened.\n" ;
- es.text = CORBA::string_dup(text.c_str());
- throw SALOME::SALOME_Exception(es);
- }
- return medIdt;
-}
MgAdapt::Status MgAdapt::addMessage(const std::string& msg,
const bool isFatal/*=false*/)
return ( _myStatus = isFatal ? MgAdapt::DRS_FAIL : MgAdapt::DRS_WARN_SKIP_ELEM );
}
-// =======================================================================
-void MgAdapt::getTimeStepInfos(std::string aFile, med_int& numdt, med_int& numit)
-// =======================================================================
-{
-// Il faut voir si plusieurs maillages
-
- herr_t erreur = 0 ;
- med_idt medIdt ;
-
-
- // Ouverture du fichier
- //~SCRUTE(aFile.toStdString());
- medIdt = openMedFile(aFile);
- if ( medIdt < 0 ) return ;
- // Lecture du nombre de champs
- med_int ncha = MEDnField(medIdt) ;
- if (ncha < 1 )
- {
- //~addMessage( ToComment(" error: there is no field in ") << aFile, /*fatal=*/true );
- return;
- }
- // Lecture des caracteristiques du champs
-
- // Lecture du type du champ, des noms des composantes et du nom de l'unite
- char nomcha [MED_NAME_SIZE+1];
- strcpy(nomcha, fieldName.c_str());
-// Lecture du nombre de composantes
- med_int ncomp = MEDfieldnComponentByName(medIdt, nomcha);
- 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 = MEDfieldInfoByName (medIdt, nomcha, meshname,&local,&typcha,comp,unit,dtunit, &nbofcstp);
- free(comp);
- free(unit);
- if ( erreur < 0 )
- {
- //~addMessage( ToComment(" error: error while reading field ") << nomcha << " in file " << aFile , /*fatal=*/true );
- return;
- }
-
- med_float dt;
- med_int tmp_numdt, tmp_numit;
-
- //~med_int step = data->myUseLastTimeStep ? nbofcstp : data->myTimeStep+1;
- //~myPrint("step ", step);
- erreur = MEDfieldComputingStepInfo ( medIdt, nomcha, 1, &numdt, &numit, &dt );
- for(med_int step = 1; step <= nbofcstp; step++ )
- {
- erreur = MEDfieldComputingStepInfo ( medIdt, nomcha, step, &tmp_numdt, &tmp_numit, &dt );
- if(tmp_numdt > numdt)
- {
- numdt = tmp_numdt;
- numit = tmp_numit;
- }
- }
- if ( erreur < 0 )
- {
- //~addMessage( ToComment(" error: error while reading field ") << nomcha << "step (numdt, numit) = " <<"("<< numdt<< ", " \
- numit<< ")" <<" in file " << aFile , /*fatal=*/true );
- return;
- }
-
- // Fermeture du fichier
- if ( medIdt > 0 ) MEDfileClose(medIdt);
-
-}
-
void MgAdapt::updateTimeStepRank()
{
else if (myUseLastTimeStep)
{
std::string fieldFile = useBackgroundMap ? sizeMapFile : medFileIn;
- getTimeStepInfos(fieldFile, tmst, arank);
+ getTimeStepInfos(fieldFile, tmst, arank, fieldName);
setRankTimeStep((int)tmst, (int)arank);
}
}
//
#ifndef MG_ADAPT_HXX
#define MG_ADAPT_HXX
+
#include <string>
-# include <sstream>
#include <map>
#include <vector>
#include <set>
-#include <fstream>
-
-#include "MCAuto.hxx"
-#include "MCType.hxx"
-#include "MEDFileMesh.hxx"
-
-#include <med.h>
-// SMESH includes
-//~#include <med.h>
-std::string remove_extension(const std::string& filename);
-namespace MG_ADAPT{
-class MgAdapt;
+namespace MEDCoupling
+{
+ class MEDFileMesh;
+}
+namespace MG_ADAPT
+{
typedef std::map< std::string, std::string > TOptionValues;
typedef std::set< std::string > TOptionNames;
+std::string remove_extension(const std::string& filename);
+
struct MgAdaptHypothesisData
{
std::string myFileInDir, myMeshFileIn, myInMeshName, myMeshFileBackground, myOutMeshName,
int myVerboseLevel;
};
-class outFileStream : public std::ofstream{
-public:
- ~outFileStream(){close();} //to close file at dtor
-};
-
-/*!
- * \brief Class to generate string from any type
- */
-class ToComment : public std::string
-{
- std::ostringstream _s ;
-
-public :
-
- ToComment():std::string("") {}
-
- ToComment(const ToComment& c):std::string() {
- _s << c.c_str() ;
- this->std::string::operator=( _s.str() );
- }
-
- ToComment & operator=(const ToComment& c) {
- _s << c.c_str() ;
- this->std::string::operator=( _s.str() );
- return *this;
- }
-
- template <class T>
- ToComment( const T &anything ) {
- _s << anything ;
- this->std::string::operator=( _s.str() );
- }
-
- template <class T>
- ToComment & operator<<( const T &anything ) {
- _s << anything ;
- this->std::string::operator=( _s.str() );
- return *this ;
- }
-
- operator char*() const {
- return (char*)c_str();
- }
-
- std::ostream& Stream() {
- return _s;
- }
-};
-
class MgAdapt
{
bool hasOptionDefined( const std::string& optionName ) const;
void setOptionValue(const std::string& optionName,
- const std::string& optionValue) throw (std::invalid_argument);
+ const std::string& optionValue);
std::string getOptionValue(const std::string& optionName,
- bool* isDefault=0) const throw (std::invalid_argument);
+ bool* isDefault=0) const;
std::vector <std::string> getCustomOptionValuesStrVec() const;
std::vector <std::string> getOptionValuesStrVec() const;
TOptionValues getOptionValues() const;
const TOptionValues& getCustomOptionValues() const ;
- static double toDbl(const std::string&, bool* isOk = 0) throw (std::invalid_argument);
- static bool toBool(const std::string&, bool* isOk = 0) throw (std::invalid_argument);
- static int toInt(const std::string&, bool* isOk = 0 ) throw (std::invalid_argument);
+ static double toDbl(const std::string&, bool* isOk = 0);
+ static bool toBool(const std::string&, bool* isOk = 0);
+ static int toInt(const std::string&, bool* isOk = 0 );
static std::string toLowerStr(const std::string& str);
/* default values */
static bool defaultUseLastTimeStep();
static bool defaultUseChosenTimeStep();
static double defaultMaximumMemory();
- static bool isFileExist(const std::string& fName);
enum Status {
DRS_OK,
DRS_NO_TIME_STEP // general failure (exception etc.)
};
- struct group {
-
- std::string _name;
- std::vector<MEDCoupling::mcIdType> _famListId;
+ struct group
+ {
+ std::string _name;
+ std::vector<int> _famListId;
std::vector<std::string> _famNames;
- group(std::string name, std::vector<MEDCoupling::mcIdType> famListId, std::vector<std::string> famNames):_name(name)
- {
- std::vector<MEDCoupling::mcIdType>::iterator it = famListId.begin();
- for (; it!=famListId.end(); ++it)
- _famListId.push_back(*it);
-
- std::vector<std::string>::iterator itt = famNames.begin();
- for (; itt!=famNames.end(); ++itt)
- _famNames.push_back(*itt);
- }
+ group(std::string name, std::vector<int> famListId, std::vector<std::string> famNames)
+ :_name(name), _famListId( famListId ), _famNames( famNames ) {}
};
- struct family {
+ struct family
+ {
std::string _famName;
- mcIdType _famId;
- family(std::string famName, MEDCoupling::mcIdType famId):_famName(famName), _famId(famId) {}
+ int _famId;
+ family(std::string famName, int famId):_famName(famName), _famId(famId) {}
};
void storeGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh);
void restoreGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh) const;
void convertMeshFile(std::string& meshFormatIn, std::vector< std::string>& solFieldFileNames) const ;
- void buildConstantSizeMapSolFile(const std::string& solFormatFieldFileName, const int dim, const int version, const mcIdType nbNodes) const;
+ void buildConstantSizeMapSolFile(const std::string& solFormatFieldFileName, const int dim, const int version, const size_t nbNodes) const;
void buildBackGroundMeshAndSolFiles(const std::vector<std::string>& fieldFileNames, const std::string& meshFormatsizeMapFile) const;
- void getTimeStepInfos(std::string aFile, med_int& numdt, med_int& numit);
Status addMessage(const std::string& msg, const bool isFatal = false);
- med_idt openMedFile(const std::string aFile) ;
void execCmd( const char* cmd, int& err);
void cleanUp();
void appendMsgToLogFile(std::string& msg);
};
-}
+} // namespace MG_ADAPT
#endif // MG_ADAPT_HXX
${PROJECT_SOURCE_DIR}/src/SMESH_I
${PROJECT_BINARY_DIR}
${PROJECT_BINARY_DIR}/idl
- ${MEDCOUPLING_INCLUDE_DIRS}
)
# additional preprocessor / compiler flags
SMESHControls
SMESHObject
SMESHEngine
- ${MEDCoupling_medloader}
)
# --- headers ---
SMESHGUI_SplitBiQuad.h
SMESHGUI_IdPreview.h
SMESHGUI_PreVisualObj.h
- SMESHGUI_AdaptDlg.h
SMESHGUI_MG_ADAPTDRIVER.h
- MG_ADAPTGUI.hxx # to replace in ../ADAPTGUI/
+ MG_ADAPTGUI.h
)
# header files / no moc processing
SMESHGUI_FileValidator.h
SMESHGUI_SelectionProxy.h
SMESH_SMESHGUI.hxx
- #~MG_ADAPT.hxx # to replace in ../ADAPT/
)
# header files / to install
SMESHGUI_SplitBiQuad.cxx
SMESHGUI_PreVisualObj.cxx
SMESHGUI_IdPreview.cxx
- SMESHGUI_AdaptDlg.cxx
SMESHGUI_MG_ADAPTDRIVER.cxx
- MG_ADAPTGUI.cxx # to replace in ../ADAPTGUI/
- #MG_ADAPT.cxx
+ MG_ADAPTGUI.cxx
)
# sources / to compile
//
// file : MG_ADAPTGUI.cxx
-#include "MG_ADAPTGUI.hxx"
+#include "MG_ADAPTGUI.h"
-#include "MEDFileData.hxx"
-#include "MEDLoader.hxx"
+#include "MED_Factory.hxx"
-#include "SUIT_Desktop.h"
-#include "SUIT_Application.h"
-#include "SUIT_Session.h"
-
-#include "SalomeApp_Application.h"
-#include "SalomeApp_Module.h"
-#include "SalomeApp_Study.h"
+#include <SalomeApp_Tools.h>
+#include <SalomeApp_Module.h>
#include <SUIT_MessageBox.h>
-#include <LightApp_SelectionMgr.h>
#include <SUIT_OverrideCursor.h>
-#include <SUIT_ResourceMgr.h>
-#include <SVTK_ViewWindow.h>
-#include <SALOME_ListIO.hxx>
#include <SUIT_FileDlg.h>
+
#include <QApplication>
#include <QButtonGroup>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDoubleSpinBox>
+#include <QFileDialog>
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
+#include <QHeaderView>
+#include <QItemDelegate>
#include <QKeyEvent>
#include <QLabel>
#include <QLineEdit>
-#include <QCheckBox>
+#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
-#include <QTabWidget>
-#include <QVBoxLayout>
-#include <QDoubleSpinBox>
+#include <QSpacerItem>
#include <QSpinBox>
+#include <QString>
+#include <QTabWidget>
#include <QTreeWidget>
#include <QTreeWidgetItem>
-#include <QSpacerItem>
-#include <QString>
-#include <QHeaderView>
-#include <QItemDelegate>
-#include <QFileDialog>
-#include <QMessageBox>
-#include <QComboBox>
+#include <QVBoxLayout>
-#include <vtkPoints.h>
-#include <vtkUnstructuredGrid.h>
-#include <vtkIdList.h>
-#include <vtkCellArray.h>
-#include <vtkUnsignedCharArray.h>
-#include <vtkDataSetMapper.h>
-#include <VTKViewer_CellLocationsArray.h>
-#include <vtkProperty.h>
-
-#include <ElCLib.hxx>
-// SALOME KERNEL includes
-#include <SALOMEDS_SComponent.hxx>
-#include <SALOMEDS_SObject.hxx>
-#include <SALOMEDS_Study.hxx>
-#include <SALOMEDS_wrap.hxx>
-#include "SalomeApp_Tools.h"
-#include <SALOMEconfig.h>
-#include <med.h>
-#include <utilities.h>
-
-#include <TCollection_AsciiString.hxx>
+//#include <SALOMEDS_wrap.hxx>
const int SPACING = 6; // layout spacing
const int MARGIN = 9; // layout margin
+namespace
+{
+
+ // ======================================================
+ QString lireNomDimMaillage(QString aFile, int& meshdim)
+ // ========================================================
+ {
+ QString nomMaillage = QString::null ;
+
+ try {
+ while ( true )
+ {
+
+ MED::PWrapper aMed = MED::CrWrapperR( aFile.toUtf8().data() );
+ MED::TInt numberOfMeshes = aMed->GetNbMeshes();
+
+ if (numberOfMeshes == 0 )
+ {
+ QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
+ QObject::tr("MG_ADAPT_MED_FILE_2") );
+ break ;
+ }
+ if (numberOfMeshes > 1 )
+ {
+ QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
+ QObject::tr("MG_ADAPT_MED_FILE_3") );
+ break ;
+ }
+
+ MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo( 1 );
+ nomMaillage = aMeshInfo->GetName().c_str();
+ meshdim = (int) aMeshInfo->GetDim();
+
+ break ;
+ }
+ }
+ catch ( const SALOME::SALOME_Exception & S_ex )
+ {
+ SalomeApp_Tools::QtCatchCorbaException(S_ex);
+ }
+
+ return nomMaillage;
+ }
+
+ // =======================================================================
+ std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage=true)
+ // =======================================================================
+ {
+ // Il faut voir si plusieurs maillages
+
+ std::map<QString, int> ListeChamp ;
+
+ try
+ {
+ while ( true )
+ {
+ MED::PWrapper aMed = MED::CrWrapperR( aFile.toUtf8().data() );
+ MED::TInt jaux = aMed->GetNbFields();
+ if (jaux < 1 )
+ {
+ if(errorMessage)
+ {
+ QMessageBox::critical( 0, QObject::tr("_ERROR"),
+ QObject::tr("HOM_MED_FILE_5") );
+ }
+ break ;
+ }
+ // nbofcstp inutile pour le moment
+ MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo( 1 );
+ int nbofcstp = 1;
+ for( MED::TInt j=0;j<jaux;j++)
+ {
+ MED::PFieldInfo aFiledInfo = aMed->GetPFieldInfo( aMeshInfo, j + 1 );
+ ListeChamp.insert({ QString( aFiledInfo->GetName().c_str()), nbofcstp });
+ }
+ break ;
+ }
+ }
+ catch ( const SALOME::SALOME_Exception & S_ex )
+ {
+ SalomeApp_Tools::QtCatchCorbaException(S_ex);
+ }
+
+ return ListeChamp;
+ }
+
+ // =======================================================================
+ std::string remove_extension(const std::string& filename)
+ // =======================================================================
+ {
+ size_t lastdot = filename.find_last_of(".");
+ if (lastdot == std::string::npos) return filename;
+ return filename.substr(0, lastdot);
+ }
+}
+
//=================================================================================
// function : SMESHGUI_MgAdaptDlg()
// purpose :
//=================================================================================
SMESHGUI_MgAdaptDlg::SMESHGUI_MgAdaptDlg( SalomeApp_Module* theModule, SMESH::MG_ADAPT_ptr myModel, QWidget* parent, bool isCreation )
- : mySMESHGUI( theModule ), QDialog(parent)
+ : QDialog(parent), mySMESHGUI( theModule )
{
//~model = new MgAdapt(*myModel);
model = SMESH::MG_ADAPT::_duplicate(myModel);
+ model->Register();
myData = model->getData();
buildDlg();
if (!isCreation) readParamsFromHypo();
// Arguments
myArgs = new SMESHGUI_MgAdaptArguments( myTabWidget );
- SMESH::str_array* str = model->getOptionValuesStrVec();
- SMESH::str_array* str2 = model->getCustomOptionValuesStrVec();
+ SMESH::string_array_var str = model->getOptionValuesStrVec();
+ SMESH::string_array_var str2 = model->getCustomOptionValuesStrVec();
std::vector<std::string> s;
- for (int i = 0; i< str->length(); i++) s.push_back( (*str)[i].in());
- for (int j = str->length(); j< str2->length(); j++) s.push_back((*str2)[ j - str->length() ].in() );
+ for (CORBA::ULong i = 0; i< str->length(); i++) s.push_back( str[i].in());
+ for (CORBA::ULong j = str->length(); j< str2->length(); j++) s.push_back(str[ j - str->length() ].in() );
//~str.insert( str.end(), str2.begin(), str2.end() );
myAdvOpt = new MgAdaptAdvWidget(myTabWidget, &s);
- int argsTab = myTabWidget->addTab( myArgs, tr( "Args" ) );
- int advTab = myTabWidget->addTab( myAdvOpt, tr( "ADVOP" ) );
+ /*int argsTab =*/ myTabWidget->addTab( myArgs, tr( "Args" ) );
+ /*int advTab =*/ myTabWidget->addTab( myAdvOpt, tr( "ADVOP" ) );
myAdvOpt->workingDirectoryLabel ->setText (tr( "WORKING_DIR" ));
myAdvOpt->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
if (myData->fromMedFile)
{
- *(myArgs->myFileInDir) = QString(myData->myFileInDir) ;
+ myArgs->myFileInDir = myData->myFileInDir;
myArgs->selectMedFileLineEdit->setText(QString(myData->myMeshFileIn)) ;
// myData->myInMeshName = // TODO
if(myData->myMeshOutMed)
{
- *(myArgs->myFileOutDir) = QString(myData->myFileOutDir);
- myArgs->selectOutMedFileLineEdit->setText(QString(myData->myMeshFileOut));
+ myArgs->myFileOutDir = QString(myData->myFileOutDir);
+ myArgs->selectOutMedFileLineEdit->setText(myData->myMeshFileOut.in());
}
else
{
- *(myArgs->myFileOutDir) = QString(""); //TODO
+ myArgs->myFileOutDir = ""; //TODO
}
myArgs->publishOut->setChecked(myData->myPublish);
if (myData->myUseBackgroundMap)
{
- *(myArgs->myFileSizeMapDir) = QString(myData->myFileSizeMapDir) ;
+ myArgs->myFileSizeMapDir = QString(myData->myFileSizeMapDir) ;
myArgs->selectMedFileBackgroundLineEdit->setText(QString(myData->myMeshFileBackground));
}
else
{
- *(myArgs->myFileSizeMapDir) = QString("") ; //TODO
+ myArgs->myFileSizeMapDir = ""; //TODO
myArgs->selectMedFileBackgroundLineEdit->setText(""); //TODO
}
bool SMESHGUI_MgAdaptDlg::readParamsFromWidgets()
{
- MESSAGE ("readParamsFromWidgets") ;
bool ret = true ;
- SMESH::MgAdaptHypothesisData* aData = new SMESH::MgAdaptHypothesisData();
+ SMESH::MgAdaptHypothesisData data, *aData = &data;
while ( ret )
{
// 1. Fichier du maillage de départ
aData->fromMedFile = myArgs->aMedfile->isChecked();
if (aData->fromMedFile)
{
- aData->myFileInDir = CORBA::string_dup(myArgs->myFileInDir->toStdString().c_str());
- aData->myMeshFileIn = CORBA::string_dup(myArgs->selectMedFileLineEdit->text().toStdString().c_str());
+ aData->myFileInDir = CORBA::string_dup(myArgs->myFileInDir.toUtf8().data());
+ aData->myMeshFileIn = CORBA::string_dup(myArgs->selectMedFileLineEdit->text().toUtf8().data());
// aData->myInMeshName = // TODO
}
else // TODO browser
aData->myMeshOutMed = myArgs->medFileCheckBox->isChecked();
if(aData->myMeshOutMed)
{
- aData->myFileOutDir = CORBA::string_dup(myArgs->myFileOutDir->toStdString().c_str());
- aData->myMeshFileOut = CORBA::string_dup(myArgs->selectOutMedFileLineEdit->text().toStdString().c_str());
+ aData->myFileOutDir = CORBA::string_dup(myArgs->myFileOutDir.toUtf8().data());
+ aData->myMeshFileOut = CORBA::string_dup(myArgs->selectOutMedFileLineEdit->text().toUtf8().data());
}
else
{
// 3.2. Arrière-plan
if (aData->myUseBackgroundMap)
{
- aData->myFileSizeMapDir = CORBA::string_dup(myArgs->myFileSizeMapDir->toStdString().c_str());
- aData->myMeshFileBackground = CORBA::string_dup(myArgs->selectMedFileBackgroundLineEdit->text().toStdString().c_str());
+ aData->myFileSizeMapDir = CORBA::string_dup(myArgs->myFileSizeMapDir.toUtf8().data());
+ aData->myMeshFileBackground = CORBA::string_dup(myArgs->selectMedFileBackgroundLineEdit->text().toUtf8().data());
}
else
{
break ;
}
- delete aData;
-
return ret;
}
bool SMESHGUI_MgAdaptDlg::storeParamsToHypo( const SMESH::MgAdaptHypothesisData& ) const
{
+ return true;
}
/*!
\brief Show help page
// purpose :
//=================================================================================
SMESHGUI_MgAdaptArguments::SMESHGUI_MgAdaptArguments( QWidget* parent )
- :QWidget(parent)
+ :QWidget(parent)
{
- myFileInDir = new QString("");
- myFileOutDir = new QString("");
- myFileSizeMapDir = new QString("");
if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
{
- *myFileInDir = QDir::currentPath();
- *myFileOutDir = QDir::currentPath();
- *myFileSizeMapDir = QDir::currentPath();
+ myFileInDir = QDir::currentPath();
+ myFileOutDir = QDir::currentPath();
+ myFileSizeMapDir = QDir::currentPath();
}
else
{
- *myFileInDir = SUIT_FileDlg::getLastVisitedPath();
- *myFileOutDir = SUIT_FileDlg::getLastVisitedPath();
- *myFileSizeMapDir = SUIT_FileDlg::getLastVisitedPath();
+ myFileInDir = SUIT_FileDlg::getLastVisitedPath();
+ myFileOutDir = SUIT_FileDlg::getLastVisitedPath();
+ myFileSizeMapDir = SUIT_FileDlg::getLastVisitedPath();
}
meshDim = 0;
timeStep->setValue(-1);
noTimeStep->setDisabled(disableOther);
}
-void SMESHGUI_MgAdaptArguments::onChosenTimeStep(bool disableOther, int vmax)
+void SMESHGUI_MgAdaptArguments::onChosenTimeStep(bool /*disableOther*/, int vmax)
{
chosenTimeStep->setChecked(true);
QString fileName = QFileDialog::getSaveFileName(this, tr("SAVE_MED"), QString(""), filtre);
QFileInfo myFileInfo(fileName);
selectOutMedFileLineEdit->setText(myFileInfo.fileName());
- *myFileOutDir = myFileInfo.path();
+ myFileOutDir = myFileInfo.path();
}
void SMESHGUI_MgAdaptArguments::onSelectMedFileBackgroundbutton()
timeStepGroupChanged(typeStepInField, false);
}
// Dimension du maillage de fonds
- MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(fileName.toStdString());
- meshDimBG = mfd->getMeshes()->getMeshAtPos(0)->getMeshDimension() ;
+ lireNomDimMaillage( fileName, meshDimBG );
valueAdaptation ();
}
}
}
QFileInfo myFileInfo(fileName);
- *myFileSizeMapDir = myFileInfo.path();
+ myFileSizeMapDir = myFileInfo.path();
selectMedFileBackgroundLineEdit->setText(myFileInfo.fileName());
}
QString fileName = getMedFileName(false);
if(fileName != QString::null)
{
- QString aMeshName = lireNomMaillage(fileName.trimmed(), meshDim);
- if (aMeshName == QString::null )
+ QString aMeshName = lireNomDimMaillage(fileName.trimmed(), meshDim);
+ if (aMeshName.isEmpty() )
{
QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
QObject::tr("MG_ADAPT_MED_FILE_2") );
}
QFileInfo myFileInfo(fileName);
- *myFileInDir = myFileInfo.path();
- *myFileOutDir = myFileInfo.path();
+ myFileInDir = myFileInfo.path();
+ myFileOutDir = myFileInfo.path();
selectMedFileLineEdit->setText(myFileInfo.fileName());
QString outF = fileName == QString::null ? myFileInfo.fileName() :
QString( remove_extension(myFileInfo.fileName().toStdString() ).c_str() )+ QString(".adapt.med");
// 2) retourne le nom du fichier asocie a l objet
// selectionne dans l arbre d etude
// =======================================================================
-QString SMESHGUI_MgAdaptArguments::getMedFileName(bool avertir)
+QString SMESHGUI_MgAdaptArguments::getMedFileName(bool /*avertir*/)
{
QString aFile = QString::null;
sizeMapField->setEnabled(true);
if (!selectMedFileLineEdit->text().isEmpty())
{
- QFileInfo myFileInfo(QDir(*myFileInDir), selectMedFileLineEdit->text());
+ QFileInfo myFileInfo(QDir(myFileInDir), selectMedFileLineEdit->text());
onLocalSelected(myFileInfo.filePath());
}
}
myOptionTable->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
myOptionTable->setItemDelegate( new ItemDelegate( myOptionTable ) );
- for ( int i = 0, nb = myOptions->size(); i < nb; ++i )
+ for ( size_t i = 0, nb = myOptions->size(); i < nb; ++i )
{
AddOption( (*myOptions)[i].c_str() );
}
}
QTreeWidget::keyPressEvent( e );
}
-
-// ======================================================
-// ========================================================
-QString lireNomMaillage(QString aFile, med_int& meshdim)
-{
- QString nomMaillage = QString::null ;
-
- while ( true )
- {
- std::vector<std::string> 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") );
- break ;
- }
- if (numberOfMeshes > 1 )
- {
- QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
- QObject::tr("MG_ADAPT_MED_FILE_3") );
- break ;
- }
-
-// std::cout << "nomMaillage:" << listMeshesNames[0] << std::endl;
- nomMaillage = QString(listMeshesNames[0].c_str());
-
- // Dimension du maillage
- MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(aFile.toStdString());
- meshdim = mfd->getMeshes()->getMeshAtPos(0)->getMeshDimension() ;
-// std::cout << "meshdim:" << meshdim << std::endl;
-
- break ;
- }
-
- return nomMaillage;
-}
-
-// =======================================================================
-std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage)
-// =======================================================================
-{
-// Il faut voir si plusieurs maillages
-
- std::map<QString, int> ListeChamp ;
-
- while ( true )
- {
- 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)
- {
- QMessageBox::critical( 0, QObject::tr("_ERROR"),
- QObject::tr("HOM_MED_FILE_5") );
- }
- break ;
- }
- // nbofcstp inutile pour le moment
- med_int nbofcstp = 1;
- for(std::size_t j=0;j<jaux;j++)
- {
-// std::cout << listFieldsNames[j] << std::endl;
- ListeChamp.insert(std::pair<QString, int> (QString(listFieldsNames[j].c_str()), nbofcstp));
- }
- break ;
- }
-
- return ListeChamp;
-}
-
-// =======================================================================
-std::string remove_extension(const std::string& filename)
-// =======================================================================
-{
- size_t lastdot = filename.find_last_of(".");
- if (lastdot == std::string::npos) return filename;
- return filename.substr(0, lastdot);
-}
+++ /dev/null
-// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE\r
-//\r
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
-//\r
-// This library is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU Lesser General Public\r
-// License as published by the Free Software Foundation; either\r
-// version 2.1 of the License, or (at your option) any later version.\r
-//\r
-// This library is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-// Lesser General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU Lesser General Public\r
-// License along with this library; if not, write to the Free Software\r
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
-//\r
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
-//\r
-// SMESH SMESHGUI : GUI for the adaptation in the SMESH component\r
-// File : MG_ADAPTGUI.hxx\r
-//\r
-#ifndef MG_ADAPTGUI_HXX\r
-#define MG_ADAPTGUI_HXX\r
-\r
-#include <set>\r
-// SMESH includes\r
-\r
-// Qt includes\r
-#include <QDialog>\r
-#include <QTreeWidget>\r
-#include<QItemDelegate>\r
-\r
-#include "LightApp_DataOwner.h"\r
-#include "SalomeApp_Application.h"\r
-#include <SALOMEconfig.h>\r
-#include <SALOME_ListIO.hxx>\r
-#include "SalomeApp_Module.h"\r
-#include "SalomeApp_Study.h"\r
-#include <med.h>\r
-#include <map>\r
-\r
-\r
-// model\r
-\r
-\r
-//~#include "MG_ADAPT.hxx"\r
-\r
-#include CORBA_SERVER_HEADER(MG_ADAPT)\r
-\r
-class SUIT_ViewWindow;\r
-class SUIT_Desktop;\r
-class SUIT_Study;\r
-class SUIT_ResourceMgr;\r
-\r
-class CAM_Module;\r
-\r
-class SALOMEDSClient_Study;\r
-class SALOMEDSClient_SObject;\r
-\r
-class SalomeApp_Study;\r
-class SalomeApp_Module;\r
-class LightApp_SelectionMgr;\r
-\r
-\r
-class QButtonGroup;\r
-class QLineEdit;\r
-class QGroupBox;\r
-class QRadioButton;\r
-class QLabel;\r
-class QCheckBox;\r
-class QGridLayout;\r
-class QTabWidget;\r
-class QDoubleSpinBox;\r
-class QSpinBox;\r
-class QTreeWidget;\r
-class QTreeWidgetItem;\r
-class QSpacerItem;\r
-class QHBoxLayout;\r
-class QItemDelegate;\r
-class QComboBox;\r
-\r
-// IDL includes\r
-#include <SALOMEconfig.h>\r
-\r
-class SVTK_ViewWindow;\r
-class SVTK_Selector;\r
-class SMESHGUI_MgAdaptDlg;\r
-class SMESHGUI_MgAdaptArguments;\r
-class SMESHGUI_SpinBox;\r
-class MgAdaptAdvWidgetTreeWidget;\r
-class MgAdaptAdvWidget;\r
-//~class MgAdapt;\r
-class QHeaderView;\r
-class QFileDialog;\r
-\r
-\r
-std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage = true);\r
-QString lireNomMaillage(QString aFile, med_int& meshDim);\r
-\r
-std::string remove_extension(const std::string& filename);\r
-\r
-enum ADAPTATION_MODE{\r
- SURFACE,\r
- VOLUME,\r
- BOTH\r
-};\r
-//=================================================================================\r
-// class : SMESHGUI_MgAdaptDlg\r
-// purpose :\r
-//=================================================================================\r
-class SMESHGUI_MgAdaptDlg : public QDialog\r
-{\r
- Q_OBJECT;\r
-public:\r
- //! Property type\r
- enum Mode { Arguments, AdvancedOptions};\r
- SMESHGUI_MgAdaptDlg( SalomeApp_Module*, SMESH::MG_ADAPT_ptr, QWidget* parent= 0,bool isCreation = true );\r
- ~SMESHGUI_MgAdaptDlg();\r
-\r
- void buildDlg();\r
- void reject();\r
- bool checkParams(QString& msg) ;\r
- //~void setModel(MgAdapt*);\r
- SMESH::MG_ADAPT_ptr getModel() const;\r
-\r
-public slots:\r
-\r
-protected slots:\r
- virtual bool PushOnApply();\r
-\r
-private slots:\r
- virtual void PushOnHelp();\r
- virtual void PushOnOK();\r
-\r
-protected :\r
-\r
- SMESHGUI_MgAdaptArguments* myArgs;\r
- MgAdaptAdvWidget* myAdvOpt;\r
- bool readParamsFromHypo( ) const ;\r
- bool readParamsFromWidgets( ) ;\r
- bool storeParamsToHypo( const SMESH::MgAdaptHypothesisData & ) const;\r
-\r
-private:\r
-\r
- SalomeApp_Module* mySMESHGUI; /* Current SMESHGUI object */\r
- QTabWidget* myTabWidget;\r
-\r
-\r
- SMESH::MgAdaptHypothesisData* myData;\r
- SMESH::MG_ADAPT_ptr model;\r
-\r
-};\r
-\r
-class SMESHGUI_MgAdaptArguments : public QWidget\r
-{\r
- Q_OBJECT;\r
-public:\r
- //! Property type\r
- enum Mode { Mesh, Browser};\r
- enum SIZEMAP { Local, Background, Constant};\r
- SMESHGUI_MgAdaptArguments( QWidget* parent);\r
- ~SMESHGUI_MgAdaptArguments();\r
- void setMode( const Mode, const SIZEMAP );\r
-\r
- QString* myFileInDir;\r
- QString* myFileOutDir;\r
- QString* myFileSizeMapDir;\r
- QGroupBox* aMeshIn ;\r
- QRadioButton* aMedfile;\r
- QRadioButton* aBrowser ;\r
- QLineEdit* aBrowserObject;\r
- QPushButton* selectMedFilebutton ;\r
- QSpacerItem* hspacer;\r
- QLineEdit* selectMedFileLineEdit ;\r
- QButtonGroup* meshInGroup ;\r
- QGridLayout* meshIn ;\r
-\r
- QGroupBox* aMeshOut ;\r
- QLabel* meshName;\r
- QLineEdit* meshNameLineEdit;\r
- QSpacerItem* secondHspacer;\r
- QCheckBox* medFileCheckBox;\r
- QPushButton* selectOutMedFilebutton;\r
- QLineEdit* selectOutMedFileLineEdit;\r
- QSpacerItem* thirdHspacer;\r
- QCheckBox* publishOut;\r
- QGridLayout* meshOut ;\r
-\r
- QGroupBox* sizeMapDefinition ;\r
- QRadioButton* localButton;\r
- QRadioButton* backgroundButton ;\r
- QRadioButton* constantButton ;\r
- QLabel* medFileBackground;\r
- QPushButton* selectMedFileBackgroundbutton;\r
- QLineEdit* selectMedFileBackgroundLineEdit;\r
- QLabel* valueLabel;\r
- QDoubleSpinBox* dvalue;\r
- QButtonGroup* sizeMapDefGroup ;\r
- QGridLayout* sizeMapDefGroupLayout;\r
-\r
-\r
- QGroupBox* sizeMapField;\r
- QLabel* fieldName;\r
- QComboBox* fieldNameCmb;\r
- QRadioButton* noTimeStep;\r
- QRadioButton* lastTimeStep ;\r
- QRadioButton* chosenTimeStep;\r
- QLabel* timeStepLabel;\r
- QSpinBox* timeStep;\r
- QLabel* rankLabel;\r
- QSpinBox* rankSpinBox;\r
- QButtonGroup* timeStepGroup;\r
- QGridLayout* sizeMapFieldGroupLayout;\r
-\r
-signals:\r
- void updateSelection();\r
- void toExportMED(const char *);\r
- void meshDimSignal(ADAPTATION_MODE aMode);\r
-public slots:\r
-\r
-protected slots:\r
-\r
-private slots:\r
- void modeChanged( int);\r
- void sizeMapDefChanged(int);\r
- void timeStepGroupChanged(int timeStepType, bool disableOther = false, int vmax = 0);\r
- void onSelectMedFilebuttonClicked();\r
- void clear();\r
- void onMedFileCheckBox(int);\r
- void onPublishOut(int);\r
- void onSelectOutMedFilebutton();\r
- void onSelectMedFileBackgroundbutton();\r
- void onLocalSelected(QString);\r
- void onNoTimeStep(bool disableOther = false);\r
- void onLastTimeStep(bool disableOther = false);\r
- void onChosenTimeStep(bool disableOther = false, int vmax = 0);\r
- void visibleTimeStepRankLabel(bool visible);\r
- void valueAdaptation ();\r
-\r
-private:\r
-\r
- QString getMedFileName(bool avertir);\r
- LightApp_SelectionMgr* selMgr ;\r
- med_int meshDim;\r
- med_int meshDimBG;\r
- std::map<QString, int> myFieldList;\r
-\r
-};\r
-enum {\r
- OPTION_ID_COLUMN = 0,\r
- OPTION_TYPE_COLUMN,\r
- OPTION_NAME_COLUMN = 0,\r
- OPTION_VALUE_COLUMN,\r
- NB_COLUMNS,\r
-};\r
-\r
-//////////////////////////////////////////\r
-// MgAdaptAdvWidget\r
-//////////////////////////////////////////\r
-class MgAdaptAdvWidget : public QWidget\r
-{\r
- Q_OBJECT\r
-\r
-public:\r
- MgAdaptAdvWidget( QWidget* = 0, std::vector <std::string> * = nullptr, Qt::WindowFlags = 0 );\r
- ~MgAdaptAdvWidget();\r
- std::vector < std::string > * myOptions;\r
- QGridLayout *gridLayout_4;\r
- MgAdaptAdvWidgetTreeWidget *myOptionTable;\r
- QPushButton *addBtn;\r
- QSpacerItem *horizontalSpacer;\r
- QGroupBox *logGroupBox;\r
- QGridLayout *gridLayout_2;\r
- QGridLayout *gridLayout;\r
- QLabel *workingDirectoryLabel;\r
- QLineEdit *workingDirectoryLineEdit;\r
- QPushButton *workingDirectoryPushButton;\r
- QLabel *verboseLevelLabel;\r
- QSpinBox *verboseLevelSpin;\r
- QHBoxLayout *horizontalLayout;\r
- QCheckBox *logInFileCheck;\r
- QCheckBox *removeLogOnSuccessCheck;\r
- QCheckBox *keepWorkingFilesCheck;\r
-\r
- void AddOption( const char* name_value_type, bool isCustom = false );\r
- void GetOptionAndValue( QTreeWidgetItem * tblRow, QString& option, QString& value, bool& dflt );\r
- void setupWidget();\r
-\r
-public slots:\r
- void onAddOption();\r
- void itemChanged(QTreeWidgetItem * tblRow, int column);\r
- void onMeshDimChanged(ADAPTATION_MODE aMode);\r
-private slots:\r
- void _onWorkingDirectoryPushButton();\r
-private:\r
- void setOptionValue(QString& option, QString& value);\r
- std::map<QString, QTreeWidgetItem *> optionTreeWidgetItem;\r
-\r
- QTreeWidgetItem* getNewQTreeWidgetItem(QTreeWidget* table, const char* option, QString& name, bool isCustom);\r
-\r
-};\r
-\r
-enum { EDITABLE_ROLE = Qt::UserRole + 1, PARAM_NAME,\r
- NAME_COL = 0, VALUE_COL\r
- };\r
-\r
-class ItemDelegate: public QItemDelegate\r
-{\r
-public:\r
-\r
- ItemDelegate(QObject* parent=0): QItemDelegate(parent) {}\r
- QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const;\r
-};\r
-\r
-class MgAdaptAdvWidgetTreeWidget : public QTreeWidget\r
-{\r
- Q_OBJECT\r
-public:\r
- MgAdaptAdvWidgetTreeWidget( QWidget* );\r
-\r
-protected:\r
- QModelIndex moveCursor( CursorAction, Qt::KeyboardModifiers );\r
- void keyPressEvent( QKeyEvent* );\r
-};\r
-\r
-#endif // MG_ADAPTGUI_HXX\r
// SMESH includes
#include "SMESHGUI.h"
-#include "SMESHGUI_AdaptDlg.h"
#include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
#include "SMESHGUI_AddMeshElementDlg.h"
#include "SMESHGUI_AddQuadraticElementDlg.h"
#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_HypothesesUtils.h"
+#include "SMESHGUI_MG_ADAPTDRIVER.h"
#include "SMESHGUI_Make2DFrom3DOp.h"
#include "SMESHGUI_MakeNodeAtPointDlg.h"
#include "SMESHGUI_Measurements.h"
#include <vtkRenderer.h>
// SALOME KERNEL includes
+#include <Basics_Utils.hxx>
#include <SALOMEDSClient_ClientFactory.hxx>
#include <SALOMEDSClient_IParameters.hxx>
#include <SALOMEDSClient_SComponent.hxx>
#include <SALOMEDSClient_StudyBuilder.hxx>
-#include <SALOMEDS_Study.hxx>
#include <SALOMEDS_SObject.hxx>
-#include "utilities.h"
+#include <SALOMEDS_Study.hxx>
+#include <SALOME_GenericObj_wrap.hxx>
#include <SALOME_LifeCycleCORBA.hxx>
+#include <utilities.h>
// OCCT includes
#include <Standard_ErrorHandler.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_DoubleMap.hxx>
-#include <Basics_Utils.hxx>
-
// Below macro, when uncommented, switches on simplified (more performant) algorithm
// of auto-color picking up
#define SIMPLE_AUTOCOLOR
// Adaptation - begin
case SMESHOp::OpMGAdapt:
{
- SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
- SMESHGUI_AdaptDlg *objet = new SMESHGUI_AdaptDlg( this, theCommandID, aMesh);
+ if ( isStudyLocked() )
+ break;
+ EmitSignalDeactivateDialog();
+
+ SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model = GetSMESHGen()->CreateMG_ADAPT();
+ bool isCreation = false;
+ ( new SMESHGUI_MG_ADAPTDRIVER( this, model, isCreation ))->show();
+ break;
}
// Adaptation - end
case SMESHOp::OpSplitBiQuadratic:
+++ /dev/null
-// Copyright (C) 2011-2020 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// SMESH SMESHGUI : GUI for the adaptation in the SMESH component
-// File : SMESHGUI_AdaptDlg.cxx
-// Author : Gerald NICOLAS, EDF
-
-// SMESH includes
-#include "SMESHGUI.h"
-#include "SMESHGUI_AdaptDlg.h"
-#include "SMESHGUI_MG_ADAPTDRIVER.h"
-//~#include "MG_ADAPT_i.hxx"
-//~#include "MG_ADAPT.hxx"
-
-// SALOME GUI includes
-#include <SUIT_Desktop.h>
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_Session.h>
-#include <SalomeApp_Application.h>
-#include <SalomeApp_Study.h>
-
-// SALOME KERNEL includes
-#include "utilities.h"
-#include <SALOME_LifeCycleCORBA.hxx>
-
-//=================================================================================
-// function : SMESHGUI_AdaptDlg()
-// purpose :
-//=================================================================================
-SMESHGUI_AdaptDlg::SMESHGUI_AdaptDlg( SMESHGUI* theModule,
- int theCommandID,
- SMESH::SMESH_Mesh_ptr theMesh )
- : mySMESHGUI( theModule )
-{
- action( theCommandID ) ;
-}
-
-//=================================================================================
-// function : ~SMESHGUI_AdaptDlg()
-// purpose : Destroys the object and frees any allocated resources
-//=================================================================================
-SMESHGUI_AdaptDlg::~SMESHGUI_AdaptDlg()
-{
-}
-
-/*!
- * \brief Pilote les actions d'adaption de maillage
- * \param
- * \return bool OK/notOK
-*/
-void SMESHGUI_AdaptDlg::action (int theCommandID)
-//=======================================================================
-{
-// std::cout << "SMESHGUI_AdaptDlg::action avec theCommandID : " << theCommandID << std::endl;
-
-// Preferences
-// recupPreferences();
-
-// Menus and actions
- bool ok = OnGUIEvent (theCommandID) ;
- if ( ! ok ) INFOS("Erreur");
-
- return ;
-}
-
-// /*!
-// * \brief Gets the preferences for the adaptation
-// * \param
-// * \return
-// *
-// * Pour chaque valeur, le defaut est la valeur definie dans ADAPT_Gen
-// * . Si la recuperation dans config/salome s'est bien passee a la creation de ADAPT_Gen
-// * ces valeurs sont les valeurs definies.
-// * . Si cela ne s'est pas bien passe, ce sont les valeurs par defaut de ADAPT_Gen
-// */
-// void SMESHGUI_AdaptDlg::recupPreferences()
-// {
-// INFOS("Début de recupPreferences")
-// //
-// // A. Declarations
-// //
-// SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
-// SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
-// Engines::EngineComponent_var comp = ls->FindOrLoad_Component("FactoryServer", "SMESH");
-// ADAPT::ADAPT_Gen_var adaptGen = ADAPT::ADAPT_Gen::_narrow(comp);
-// if (!CORBA::is_nil(adaptGen))
-// adaptGen->UpdateStudy();
-//
-// SUIT_ResourceMgr* resMgr = mySMESHGUI->getApp()->resourceMgr();
-//
-// }
-
-/*!
- * \brief Launches the GUI for the adaptation
- * \param theCommandID - the integer that references the operation
- * \return bool OK/notOK
-*/
-bool SMESHGUI_AdaptDlg::OnGUIEvent (int theCommandID)
-{
-// std::cout << "SMESHGUI_AdaptDlg:OnGUIEvent avec theCommandID : " << theCommandID << std::endl;
-// A. Controles
- SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
- if ( !app ) return false;
-
- SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*> ( app->activeStudy() );
- if ( !aStudy )
- {
- INFOS ( "FAILED to cast active study to SalomeApp_Study" );
- return false;
- }
-
- SUIT_Desktop* parent = SUIT_Session::session()->activeApplication()->desktop();
-
- SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
- Engines::EngineComponent_var comp = ls->FindOrLoad_Component("FactoryServer", "SMESH");
-// ADAPT::ADAPT_Gen_var adaptGen = ADAPT::ADAPT_Gen::_narrow(comp);
-// if (!CORBA::is_nil(adaptGen))
-// adaptGen->UpdateStudy();
-
- mySMESHGUI->getApp()->updateObjectBrowser();
-//
-// B. Choix selon les commandes
- bool ok = true ;
- SCRUTE(theCommandID);
- switch (theCommandID)
- {
- case 8020: // Adaptation avec MG-Adpat
- {
-// INFOS("Interface avec MG-Adapt" );
-
- SMESH::MG_ADAPT_ptr model = SMESHGUI::GetSMESHGen()->CreateMG_ADAPT();
- bool isCreation = false;
- if (mySMESHGUI->isStudyLocked()) break;
- mySMESHGUI->EmitSignalDeactivateDialog();
- SMESHGUI_MG_ADAPTDRIVER *mgAdapt = new SMESHGUI_MG_ADAPTDRIVER(mySMESHGUI, model, isCreation);
- mgAdapt->show();
- break;
- }
-
- }
- mySMESHGUI->getApp()->updateObjectBrowser();
- return ok;
-}
-
-
-
+++ /dev/null
-// Copyright (C) 2011-2020 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// SMESH SMESHGUI : GUI for the adaptation in the SMESH component
-// File : SMESHGUI_AdaptDlg.h
-// Author : Gérald NICOLAS, EDF
-//
-#ifndef SMESHGUI_ADAPTDLG_H
-#define SMESHGUI_ADAPTDLG_H
-
-// SMESH includes
-#include "SMESH_SMESHGUI.hxx"
-
-// Qt includes
-#include <QDialog>
-
-// IDL includes
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
-
-class SMESHGUI;
-
-//=================================================================================
-// class : SMESHGUI_AdaptDlg
-// purpose :
-//=================================================================================
-class SMESHGUI_EXPORT SMESHGUI_AdaptDlg : public QWidget
-{
-public:
- SMESHGUI_AdaptDlg( SMESHGUI*,
- int theCommandID,
- SMESH::SMESH_Mesh_ptr = SMESH::SMESH_Mesh::_nil() );
- ~SMESHGUI_AdaptDlg();
-
- void action (int theCommandID);
- virtual bool OnGUIEvent (int theCommandID);
-
-// static ADAPT::ADAPT_Gen_var InitAdaptGen(SalomeApp_Application*);
-
-public slots:
-
-protected slots:
-
-private slots:
-
-private:
-
-// void recupPreferences();
- SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
-
- QString _ObjectName;
- QString _LanguageShort ;
- int _PublisMeshIN ;
- int _PublisMeshOUT ;
- int _YACSMaxIter ;
- int _YACSMaxNode ;
- int _YACSMaxElem ;
- int _YACSTypeTest ;
-};
-
-#endif // SMESHGUI_ADAPTDLG_H
#include "SMESHGUI_MG_ADAPTDRIVER.h"
-#include "SUIT_Desktop.h"
-#include "SUIT_Application.h"
-#include "SUIT_Session.h"
-
-#include "SalomeApp_Application.h"
-#include "SalomeApp_Module.h"
-#include "SalomeApp_Study.h"
-
-#include "SMESH_Comment.hxx"
-#include "SMESH_Actor.h"
#include "SMESHGUI.h"
-#include "SMESHGUI_FilterDlg.h"
-#include "SMESHGUI_Selection.h"
-#include <SUIT_MessageBox.h>
-#include "SMESHGUI_IdValidator.h"
-#include "SMESHGUI_Utils.h"
-#include "SMESHGUI_MeshEditPreview.h"
#include "SMESHGUI_VTKUtils.h"
-#include <SMESH_TypeFilter.hxx>
-#include <SMESH_MeshAlgos.hxx>
-#include <SMESH_LogicalFilter.hxx>
-#include <SMDS_Mesh.hxx>
-#include <SMDS_MeshNode.hxx>
-#include "SMESHGUI_SpinBox.h"
+#include "SMESHGUI_MeshUtils.h"
+#include "SMESH_TryCatch.hxx"
#include <LightApp_SelectionMgr.h>
-#include <SUIT_OverrideCursor.h>
-#include <SUIT_ResourceMgr.h>
+#include <SUIT_Application.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Session.h>
#include <SVTK_ViewWindow.h>
-#include <SALOME_ListIO.hxx>
-#include <SUIT_FileDlg.h>
-#include "SMESHGUI_MeshUtils.h"
-
+#include <SalomeApp_Application.h>
-#include <QApplication>
-#include <QButtonGroup>
-#include <QGridLayout>
-#include <QGroupBox>
-#include <QHBoxLayout>
-#include <QKeyEvent>
-#include <QLabel>
#include <QLineEdit>
-#include <QCheckBox>
-#include <QPushButton>
#include <QRadioButton>
-#include <QTabWidget>
-#include <QVBoxLayout>
-#include <QDoubleSpinBox>
-#include <QSpinBox>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-#include <QSpacerItem>
-#include <QString>
-#include <QHeaderView>
-#include <QItemDelegate>
-#include <QFileDialog>
-#include <QMessageBox>
-#include <QComboBox>
-
-#include <vtkPoints.h>
-#include <vtkUnstructuredGrid.h>
-#include <vtkIdList.h>
-#include <vtkCellArray.h>
-#include <vtkUnsignedCharArray.h>
-#include <vtkDataSetMapper.h>
-#include <VTKViewer_CellLocationsArray.h>
-#include <vtkProperty.h>
-
-#include <ElCLib.hxx>
-// SALOME KERNEL includes
-#include <SALOMEDS_SComponent.hxx>
-#include <SALOMEDS_SObject.hxx>
-#include <SALOMEDS_Study.hxx>
-#include <SALOMEDS_wrap.hxx>
-#include "SalomeApp_Tools.h"
-#include <SALOMEconfig.h>
-#include <med.h>
-#include <utilities.h>
+#include <QKeyEvent>
-#include <TCollection_AsciiString.hxx>
+// SALOME KERNEL includes
const int SPACING = 6; // layout spacing
const int MARGIN = 9; // layout margin
-SALOME_ListIO mySelected;
-
-
-//================================================================
-// Function : firstIObject
-// Purpose : Return the first selected object in the selected object list
-//================================================================
-Handle(SALOME_InteractiveObject) firstIObject()
-{
- const SALOME_ListIO& aList = selectedIO();
- return aList.Extent() > 0 ? aList.First() : Handle(SALOME_InteractiveObject)();
-}
-//================================================================
-// Function : selectedIO
-// Return the list of selected SALOME_InteractiveObject's
-//================================================================
-const SALOME_ListIO& selectedIO()
-{
- SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* > ( SUIT_Session::session()->activeApplication() );
- LightApp_SelectionMgr* aSelectionMgr = app->selectionMgr();
- if( aSelectionMgr )
- {
- aSelectionMgr->selectedObjects( mySelected );
- for (SALOME_ListIteratorOfListIO it (mySelected); it.More(); it.Next())
- SCRUTE(it.Value()->getEntry());
- };
- return mySelected;
-}
-//================================================================
-// Function : getStudy
-// Returne un pointeur sur l'etude active
-//================================================================
-_PTR(Study) getStudy()
-{
- static _PTR(Study) _study;
- if(!_study)
- _study = SalomeApp_Application::getStudy();
- return _study;
-}
-
-bool createAndPublishMed(QString fileName)
-{
-
- SMESH::DriverMED_ReadStatus res;
- SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
- // SMESHGUI aGui;
-
- aMeshes = SMESHGUI::GetSMESHGen()->CreateMeshesFromMED( fileName.toUtf8().constData(), res );
- _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[0] );
- _PTR(Study) aStudy = SMESH::getStudy();
- QStringList anEntryList;
- // bool isEmpty;
- if ( aMeshSO )
- {
- _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
- _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
- aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
- anEntryList.append( aMeshSO->GetID().c_str() );
- }
- else
- {
- // isEmpty = true;
- return false;
- }
- SMESHGUI::GetSMESHGUI()->updateObjBrowser();
-
- // browse to the published meshes
- if( LightApp_Application* anApp =
- dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
- anApp->browseObjects( anEntryList );
- return true;
-}
-bool createMgAdaptObject(MgAdapt *myMgAdapt )
-{
- // SMESH::SMESH_Mesh_var newMesh = SMESHGUI::GetSMESHGen()->CreateEmptyMesh();
-
- // _PTR(SObject) aHypothesis;
- _PTR(Study) aStudy = SMESH::getStudy();
- QStringList anEntryList;
- _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
- _PTR(SComponent) mgadapt = aStudy->FindComponent("MG-ADAPT");
- _PTR(GenericAttribute) ga;
- if (!aBuilder->FindAttribute(mgadapt, ga, "AttributeName") )
- {
- mgadapt = aBuilder->NewComponent("MG-ADAPT");
- _PTR(AttributeName) Name = aBuilder->FindOrCreateAttribute(mgadapt, "AttributeName");
- Name->SetValue("MG-ADAPT");
- _PTR(AttributePixMap) myPixmap = aBuilder->FindOrCreateAttribute( mgadapt, "AttributePixMap" );
- myPixmap->SetPixMap( "ICON_MG_ADAPT" );
- anEntryList.append( mgadapt->GetID().c_str() );
- }
-
- _PTR(SObject) obj = aBuilder->NewObject(mgadapt);
- _PTR(AttributeName) myName = aBuilder->FindOrCreateAttribute(obj, "AttributeName");
- myName->SetValue("hypo");
- _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( obj, "AttributePixMap" );
- aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" );
- anEntryList.append( obj->GetID().c_str() );
-
- SMESHGUI::GetSMESHGUI()->updateObjBrowser();
-
- // // browse to the published meshes
- if( LightApp_Application* anApp =
- dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
- anApp->browseObjects( anEntryList );
- return true;
-}
-
-
-// MG ADAPT UTILS
-//================================================================
-// Function : IObjectCount
-// Return the number of selected objects
-//================================================================
-int IObjectCount()
-{
- SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
- LightApp_SelectionMgr* aSelectionMgr = app->selectionMgr();
- if( aSelectionMgr )
- {
- aSelectionMgr->selectedObjects( mySelected );
- SCRUTE(mySelected.Extent());
- return mySelected.Extent();
- }
- return 0;
-}
-
+// bool createMgAdaptObject(MgAdapt *myMgAdapt )
+// {
+// // SMESH::SMESH_Mesh_var newMesh = SMESHGUI::GetSMESHGen()->CreateEmptyMesh();
+
+// // _PTR(SObject) aHypothesis;
+// _PTR(Study) aStudy = SMESH::getStudy();
+// QStringList anEntryList;
+// _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+// _PTR(SComponent) mgadapt = aStudy->FindComponent("MG-ADAPT");
+// _PTR(GenericAttribute) ga;
+// if (!aBuilder->FindAttribute(mgadapt, ga, "AttributeName") )
+// {
+// mgadapt = aBuilder->NewComponent("MG-ADAPT");
+// _PTR(AttributeName) Name = aBuilder->FindOrCreateAttribute(mgadapt, "AttributeName");
+// Name->SetValue("MG-ADAPT");
+// _PTR(AttributePixMap) myPixmap = aBuilder->FindOrCreateAttribute( mgadapt, "AttributePixMap" );
+// myPixmap->SetPixMap( "ICON_MG_ADAPT" );
+// anEntryList.append( mgadapt->GetID().c_str() );
+// }
+
+// _PTR(SObject) obj = aBuilder->NewObject(mgadapt);
+// _PTR(AttributeName) myName = aBuilder->FindOrCreateAttribute(obj, "AttributeName");
+// myName->SetValue("hypo");
+// _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( obj, "AttributePixMap" );
+// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" );
+// anEntryList.append( obj->GetID().c_str() );
+
+// SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+
+// // // browse to the published meshes
+// if( LightApp_Application* anApp =
+// dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+// anApp->browseObjects( anEntryList );
+// return true;
+// }
SMESHGUI_MG_ADAPTDRIVER::SMESHGUI_MG_ADAPTDRIVER( SMESHGUI* theModule, SMESH::MG_ADAPT_ptr myModel, bool isCreation )
- : mySMESHGUI( theModule ),
- myFilterDlg(0),
- myIsApplyAndClose( false ),
- SMESHGUI_MgAdaptDlg((SalomeApp_Module*)theModule, myModel, SMESHGUI::desktop(), isCreation)
+ : SMESHGUI_MgAdaptDlg((SalomeApp_Module*)theModule, myModel, SMESHGUI::desktop(), isCreation),
+ mySMESHGUI( theModule ),
+ myIsApplyAndClose( false )
{
- resMgr = resourceMgr();
+ //resMgr = mySMESHGUI->resourceMgr();
selMgr = selectionMgr();
connect(myArgs, SIGNAL(toExportMED(const char*)), this, SLOT(exportMED(const char*)));
}
-SUIT_ResourceMgr* SMESHGUI_MG_ADAPTDRIVER::resourceMgr()
-{
- return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
-}
+// SUIT_ResourceMgr* SMESHGUI_MG_ADAPTDRIVER::resourceMgr()
+// {
+// return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
+// }
LightApp_SelectionMgr* SMESHGUI_MG_ADAPTDRIVER::selectionMgr()
{
disconnect( selMgr, 0, this, 0 );
selMgr->clearFilters();
- SMESH::SetPointRepresentation( true );
+ SMESH::SetPointRepresentation( false );
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
- aViewWindow->SetSelectionMode( ActorSelection );
+ aViewWindow->SetSelectionMode( ActorSelection );
if (myArgs->aBrowser->isChecked())
{
connect( selMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ));
{
myMesh = mesh;
- mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
- if ( mySelectedObject->_is_nil() )
- return;
+ SMESH::SMESH_IDSource_var sSelectedObj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
+ if ( sSelectedObj->_is_nil() )
+ return;
}
else
- return;
+ return;
SMESH::GetNameOfSelectedIObjects( selMgr, aString );
if ( aString.isEmpty() ) aString = " ";
else aString = aString.trimmed();
- bool ok = !aString.isEmpty();
+ //bool ok = !aString.isEmpty();
if ( !mesh->_is_nil() )
{
myArgs->aBrowserObject->setText( aString );
// std::cout << "SMESHGUI_MG_ADAPTDRIVER::PushOnOK ret : " <<ret<<std::endl;
if ( ret ) reject();
}
+
bool SMESHGUI_MG_ADAPTDRIVER::PushOnApply()
{
- MESSAGE("PushOnApply");
-
if ( SMESHGUI::isStudyLocked() )
return false;
if( !isValid() )
return ok;
}
+// macro used to initialize errStr by exception description
+// returned by SMESH_CATCH( SMESH::returnError )
+#undef SMESH_CAUGHT
+#define SMESH_CAUGHT errStr =
+
+#undef SMY_OWN_CATCH
+#define SMY_OWN_CATCH catch ( SALOME::SALOME_Exception & e ) { errStr = e.details.text; }
+
bool SMESHGUI_MG_ADAPTDRIVER::execute()
{
int err = 1;
- char* errStr;
- try
+ std::string errStr;
+ SMESH_TRY;
{
getModel()->compute();
err = 0;
- errStr = getModel()->getErrMsg();
- std::string msg = err == 0 ? " ok" : std::string("Not ok \n")+CORBA::string_dup(errStr) ;
+ errStr = SMESH::toStdStr( getModel()->getErrMsg() );
}
- catch (const std::exception& e)
- {
- std::cerr<<e.what();
- }
- return err == 0;
-}
-
-//=================================================================================
-// function : Init()
-// purpose :
-//=================================================================================
-void SMESHGUI_MG_ADAPTDRIVER::Init (bool ResetControls)
-{
- myBusy = false;
+ SMESH_CATCH( SMESH::returnError );
- if ( ResetControls )
+ std::string msg = " ok";
+ if ( !errStr.empty() || err != 0 )
{
- myLineEditElements->clear();
- myNbOkElements = 0;
-
- buttonOk->setEnabled(false);
- buttonApply->setEnabled(false);
-
- //~myActor = 0;
- myMesh = SMESH::SMESH_Mesh::_nil();
-
- myIdSourceCheck->setChecked(true);
-
- onConstructor( 0 );
+ msg = "Not ok \n" + errStr + "\n";
+ std::cerr << msg;
+ err = 1;
}
-
-}
-
-//=======================================================================
-//function : onConstructor
-//purpose : switch operation mode
-//=======================================================================
-
-void SMESHGUI_MG_ADAPTDRIVER::onConstructor( int withGeom )
-{
-
- myGeomLabel ->setVisible( withGeom );
- myGeomNameEdit ->setVisible( withGeom );
- myReuseHypCheck ->setVisible( withGeom );
- myCopyElementsCheck->setVisible( withGeom );
- myFilterBtn ->setVisible( !withGeom );
- myIdSourceCheck ->setVisible( !withGeom );
-
- if ( !withGeom )
- myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
-
+ return err == 0;
}
-
-//~void SMESHGUI_MG_ADAPTDRIVER::onSelectIdSource( bool )
-//~{}
+#undef SMESH_CAUGHT
+#define SMESH_CAUGHT
//=================================================================================
// function : enterEvent()
}
-//=======================================================================
-//function : getErrorMsg
-//purpose : Return an error message and entries of invalid smesh object
-//=======================================================================
-
-QString SMESHGUI_MG_ADAPTDRIVER::getErrorMsg( SMESH::string_array_var theInvalidEntries,
- QStringList & theEntriesToBrowse )
-{
-
- if ( theInvalidEntries->length() == 0 )
- return tr("OPERATION_FAILED");
-
- // theInvalidEntries - SObject's that hold geometry objects whose
- // counterparts are not found in the newGeometry, followed by SObject's
- // holding mesh sub-objects that are invalid because they depend on a not found
- // preceding sub-shape
-
- QString msg = tr("SUBSHAPES_NOT_FOUND_MSG") + "\n";
-
- QString objString;
- for ( CORBA::ULong i = 0; i < theInvalidEntries->length(); ++i )
- {
- _PTR(SObject) so = SMESH::getStudy()->FindObjectID( theInvalidEntries[i].in() );
-
- int objType = SMESHGUI_Selection::type( theInvalidEntries[i].in() );
- if ( objType < 0 ) // geom object
- {
- objString += "\n";
- if ( so )
- objString += so->GetName().c_str();
- else
- objString += theInvalidEntries[i].in(); // it's something like "FACE #2"
- }
- else // smesh object
- {
- theEntriesToBrowse.push_back( theInvalidEntries[i].in() );
-
- objString += "\n ";
- switch ( objType ) {
- case SMESH::MESH:
- objString += tr("SMESH_MESH");
- break;
- case SMESH::HYPOTHESIS:
- objString += tr("SMESH_HYPOTHESIS");
- break;
- case SMESH::ALGORITHM:
- objString += tr("SMESH_ALGORITHM");
- break;
- case SMESH::SUBMESH_VERTEX:
- case SMESH::SUBMESH_EDGE:
- case SMESH::SUBMESH_FACE:
- case SMESH::SUBMESH_SOLID:
- case SMESH::SUBMESH_COMPOUND:
- case SMESH::SUBMESH:
- objString += tr("SMESH_SUBMESH");
- break;
- case SMESH::GROUP:
- objString += tr("SMESH_GROUP");
- break;
- default:
- ;
- }
- objString += " \"";
- if ( so )
- objString += so->GetName().c_str();
- objString += "\" (";
- objString += theInvalidEntries[i].in();
- objString += ")";
- }
- }
- if ( !objString.isEmpty() )
- msg += objString;
-
- return msg;
-}
-
//=================================================================================
// function : isValid
// purpose :
bool SMESHGUI_MG_ADAPTDRIVER::createMeshInObjectBrowser()
{
- QString filename(getModel()->getMedFileOut());
+ QString filename( SMESH::toQStr( getModel()->getMedFileOut() ));
QStringList errors;
QStringList anEntryList;
bool isEmpty = false;
- bool ok = false;
+ // bool ok = false;
SMESH::SMESH_Gen_var SMESH_Gen_ptr = SMESHGUI::GetSMESHGen();
- if (!SMESH_Gen_ptr) {
- std::cerr << "Could not retrieve SMESH_Gen_ptr" << std::endl;
- throw SALOME_Exception(LOCALIZED("Could not retrieve SMESH::GetSMESHGen()"));
+ if ( SMESH_Gen_ptr->_is_nil() ) {
+ QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
+ QObject::tr("Could not retrieve SMESH_Gen_ptr") );
+ return false;
}
SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
aMeshes->length( 1 ); // one mesh only
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
// browse to the published meshes
if( LightApp_Application* anApp =
- dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
- anApp->browseObjects( anEntryList );
+ dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+ anApp->browseObjects( anEntryList );
// show Error message box if there were errors
if ( errors.count() > 0 ) {
SUIT_MessageBox::critical( SMESHGUI::desktop(),
- QObject::tr( "SMESH_ERROR" ),
- QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
+ QObject::tr( "SMESH_ERROR" ),
+ QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
}
// show warning message box, if some imported mesh is empty
if ( isEmpty ) {
SUIT_MessageBox::warning( SMESHGUI::desktop(),
- QObject::tr( "SMESH_WRN_WARNING" ),
- QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
+ QObject::tr( "SMESH_WRN_WARNING" ),
+ QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
}
return true;
}
void SMESHGUI_MG_ADAPTDRIVER::setIsApplyAndClose( const bool theFlag )
{
myIsApplyAndClose = theFlag;
-}//================================================================
+}
+//================================================================
// function : isApplyAndClose
// Purpose : Get value of the flag indicating that the dialog is
// accepted by Apply & Close button
//=================================================================================
void SMESHGUI_MG_ADAPTDRIVER::deactivateActiveDialog()
{
- if (ConstructorsBox->isEnabled())
- {
- ConstructorsBox->setEnabled(false);
- GroupArguments->setEnabled(false);
- GroupButtons->setEnabled(false);
- mySMESHGUI->ResetState();
- mySMESHGUI->SetActiveDialogBox(0);
- if ( selMgr )
- selMgr->removeFilter( myIdSourceFilter );
- }
+ // if (isEnabled())
+ // {
+ // mySMESHGUI->ResetState();
+ // mySMESHGUI->SetActiveDialogBox(0);
+ // setEnabled( false );
+ // }
}
//=================================================================================
// SelectionIntoArgument();
}
-
-//=================================================================================
-// function : setFilters()
-// purpose : SLOT. Called when "Filter" button pressed.
-//=================================================================================
-void SMESHGUI_MG_ADAPTDRIVER::setFilters()
-{
- if(myMesh->_is_nil())
- {
- SUIT_MessageBox::critical(this,
- tr("SMESH_ERROR"),
- tr("NO_MESH_SELECTED"));
- return;
- }
- if ( !myFilterDlg )
- myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
-
- QList<int> types;
- if ( myMesh->NbEdges() ) types << SMESH::EDGE;
- if ( myMesh->NbFaces() ) types << SMESH::FACE;
- if ( myMesh->NbVolumes() ) types << SMESH::VOLUME;
- if ( myMesh->NbBalls() ) types << SMESH::BALL;
- if ( myMesh->Nb0DElements()) types << SMESH::ELEM0D;
- if ( types.count() > 1 ) types << SMESH::ALL;
-
- myFilterDlg->Init( types );
- myFilterDlg->SetSelection();
- myFilterDlg->SetMesh( myMesh );
- myFilterDlg->SetSourceWg( myLineEditElements );
-
- myFilterDlg->show();
-}
-
-//=================================================================================
-// function : onOpenView()
-// purpose :
-//=================================================================================
-void SMESHGUI_MG_ADAPTDRIVER::onOpenView()
-{
- if ( mySelector ) {
- SMESH::SetPointRepresentation(false);
- }
- else {
- mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
- activateThisDialog();
- }
-}
-
-//=================================================================================
-// function : onCloseView()
-// purpose :
-//=================================================================================
-void SMESHGUI_MG_ADAPTDRIVER::onCloseView()
-{
- deactivateActiveDialog();
- mySelector = 0;
-}
#ifndef SMESHGUI_MG_ADAPTDRIVER_H
#define SMESHGUI_MG_ADAPTDRIVER_H
-#include <set>
-// SMESH includes
#include "SMESH_SMESHGUI.hxx"
-// Qt includes
-#include <QDialog>
-#include <QTreeWidget>
-#include<QItemDelegate>
-
-#include <QThread>
-
-#include "LightApp_DataOwner.h"
-#include "SalomeApp_Application.h"
-#include <SALOMEconfig.h>
-#include <SALOME_ListIO.hxx>
-#include "SalomeApp_Module.h"
-#include "SalomeApp_Study.h"
-#include <med.h>
-#include <QObject>
// model
-#include "MG_ADAPTGUI.hxx"
-
-#include CORBA_SERVER_HEADER(MG_ADAPT)
-
-class SUIT_ViewWindow;
-class SUIT_Desktop;
-class SUIT_Study;
-class SUIT_ResourceMgr;
-
-class CAM_Module;
-
-class SALOMEDSClient_Study;
-class SALOMEDSClient_SObject;
-
-class SalomeApp_Study;
-class SalomeApp_Module;
-class LightApp_SelectionMgr;
-class SUIT_SelectionFilter;
-
-
-class QButtonGroup;
-class QLineEdit;
-class QGroupBox;
-class QRadioButton;
-class QLabel;
-class QCheckBox;
-class QGridLayout;
-class QTabWidget;
-class QDoubleSpinBox;
-class QSpinBox;
-class QTreeWidget;
-class QTreeWidgetItem;
-class QSpacerItem;
-class QHBoxLayout;
-class QItemDelegate;
-class QComboBox;
-class QObject;
-
+#include "MG_ADAPTGUI.h"
// IDL includes
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
-#include CORBA_SERVER_HEADER(SMESH_Gen)
-class SMESHGUI;
-class SMESHGUI_MgAdaptDlg;
-class SMESHGUI_IdValidator;
-class SMESHGUI_FilterDlg;
-class MgAdapt;
-class QHeaderView;
-class QFileDialog;
+#include CORBA_SERVER_HEADER(MG_ADAPT)
+class SMESHGUI;
+class LightApp_SelectionMgr;
+//class MgAdapt;
-int IObjectCount();
-const SALOME_ListIO& selectedIO();
-_PTR(Study) getStudy();
-Handle(SALOME_InteractiveObject) firstIObject();
-bool createAndPublishMed(QString fileName);
-bool createMgAdaptObject(MgAdapt* myMgAdapt = 0);
+// int IObjectCount();
+// const SALOME_ListIO& selectedIO();
+// _PTR(Study) getStudy();
+// Handle(SALOME_InteractiveObject) firstIObject();
+// bool createAndPublishMed(QString fileName);
+// bool createMgAdaptObject(MgAdapt* myMgAdapt = 0);
class SMESHGUI_MG_ADAPTDRIVER : public SMESHGUI_MgAdaptDlg
{
- Q_OBJECT;
+ Q_OBJECT
public :
SMESHGUI_MG_ADAPTDRIVER( SMESHGUI*, SMESH::MG_ADAPT_ptr, bool isCreation = true );
private :
- SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
+ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
LightApp_SelectionMgr* selMgr ;
- SUIT_ResourceMgr* resMgr;
- SUIT_ResourceMgr* resourceMgr();
LightApp_SelectionMgr* selectionMgr();
- SMESH::SMESH_Mesh_var myMesh ;
-
-
+ SMESH::SMESH_Mesh_var myMesh ;
+ bool myIsApplyAndClose;
- void Init( bool = true );
void enterEvent( QEvent* ); /* mouse enter the QWidget */
void keyPressEvent( QKeyEvent* );
- QString getErrorMsg( SMESH::string_array_var invalidEntries,
- QStringList & entriesToBrowse );
bool isValid();
bool createMeshInObjectBrowser();
void setIsApplyAndClose( const bool theFlag );
bool isApplyAndClose() const;
bool execute();
- SMESHGUI_IdValidator* myIdValidator;
- int myNbOkElements; /* to check when elements are defined */
-
- SVTK_Selector* mySelector;
-
- bool myBusy;
- GEOM::GEOM_Object_var myNewGeometry;
- //~SMESH_Actor* myActor; //
- SUIT_SelectionFilter* myIdSourceFilter;
-
- SMESH::SMESH_IDSource_var mySelectedObject;
-
- QTabWidget* myTabWidget;
- QButtonGroup* GroupConstructors;
-
- QGroupBox* ConstructorsBox;
- QGroupBox* GroupArguments;
- QGroupBox* GroupButtons;
-
- QPushButton* buttonOk;
- QPushButton* buttonCancel;
- QPushButton* buttonApply;
- QPushButton* buttonHelp;
-
- QLabel* myTextLabelElements;
- QLabel* myGeomLabel;
- QLineEdit* myLineEditElements;
- QLineEdit* myMeshNameEdit;
- QLineEdit* myGeomNameEdit;
- QCheckBox* myIdSourceCheck;
- QCheckBox* myCopyGroupsCheck;
- QCheckBox* myReuseHypCheck;
- QCheckBox* myCopyElementsCheck;
- QCheckBox* myKeepIdsCheck;
- QPushButton* myFilterBtn;
- SMESHGUI_FilterDlg* myFilterDlg;
- QString myHelpFileName;
-
- bool myIsApplyAndClose;
-
- QString inputMeshName;
- QString outputMeshName;
private slots:
void selectionChanged();
void updateSelection();
virtual void PushOnOK();
virtual void PushOnHelp();
- void deactivateActiveDialog();
- void activateThisDialog();
- void onConstructor( int );
- //~void onTextChange( const QString& );
- //~void onSelectIdSource( bool );
- void setFilters();
- void onOpenView();
- void onCloseView();
-
-
+ void deactivateActiveDialog();
+ void activateThisDialog();
};
-
-
-
#endif // SMESHGUI_MG_ADAPTDRIVER_H
if ( findTriangles(aNode1,aNode2,tria1,tria2) )
{
- newIndices.push_back( aNode1->GetID() );
- newIndices.push_back( aNode2->GetID() );
-
+ newIndices.push_back( aNode1->GetID() );
+ newIndices.push_back( aNode2->GetID() );
+
myOkBtn->setEnabled(true);
myApplyBtn->setEnabled(true);
}
if(SMDS_Mesh* aMesh = aVisualObj->GetMesh())
{
const SMDS_MeshElement* tria[2];
-
- bool valid = false;
+
+ bool valid = false;
SVTK_IndexedMapOfIds anIds;
mySelector->GetCompositeIndex(anIO,anIds);
if( anIds.Extent() == 1 && anIds(1).size() == 2 ) {
- anId1 = anIds(1)[0];
- anId2 = anIds(1)[1];
- valid = true;
+ anId1 = anIds(1)[0];
+ anId2 = anIds(1)[1];
+ valid = true;
}
-
+
if( valid &&
findTriangles( aMesh->FindNode( anId1 ), aMesh->FindNode( anId2 ), tria[0],tria[1] ) )
{
QString aText = QString("%1-%2").arg(anId1).arg(anId2);
myEdge->setText(aText);
-
+
myOkBtn->setEnabled(true);
myApplyBtn->setEnabled(true);
}
${PROJECT_SOURCE_DIR}/src/SMESHUtils
${PROJECT_BINARY_DIR}
${PROJECT_BINARY_DIR}/idl
- ${MEDCOUPLING_INCLUDE_DIRS}
)
# additional preprocessor / compiler flags
SMESHDS
SMESHControls
MeshDriverMED
- ${MEDCoupling_medloader}
)
# --- headers ---
#include "MG_ADAPT_i.hxx"
-#include "string.h"
+#include "MG_ADAPT.hxx"
+#include "SMESH_File.hxx"
#include "SMESH_Gen_i.hxx"
-#include <SMESH_Gen.hxx>
-#include <SALOMEconfig.h>
-#include CORBA_CLIENT_HEADER(SALOMEDS)
-
-
-//=============================================================================
-/*!
- * SMESH_Gen_i::CreateMG_ADAPT
- *
- * Create measurement instance
- */
-//=============================================================================
-
+#include "SMESH_PythonDump.hxx"
+#include "SMESH_TryCatch.hxx"
using namespace SMESH;
+
void MG_ADAPT_i::copyHypothesisDataToImpl(const SMESH::MgAdaptHypothesisData& from, ::MG_ADAPT::MgAdaptHypothesisData* to) const
{
to->myFileInDir = from.myFileInDir;
to->myRemoveLogOnSuccess = from->myRemoveLogOnSuccess;
to->myVerboseLevel = from->myVerboseLevel;
}
+
+//=============================================================================
+/*!
+ * SMESH_Gen_i::CreateMG_ADAPT
+ *
+ * Create measurement instance
+ */
+//=============================================================================
+
SMESH::MG_ADAPT_ptr SMESH_Gen_i::CreateMG_ADAPT()
{
SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i();
SMESH::MG_ADAPT_OBJECT_var anObj = mg_adapt_object->_this();
return anObj._retn();
}
-
+ return SMESH::MG_ADAPT_OBJECT_ptr();
}
-//~SMESH::MG_ADAPT_ptr MG_ADAPT_i::CreateMG_ADAPT()
-//~{
-
- //~SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
- //~SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i(smeshGen_i->GetPOA());
- //~SMESH::MG_ADAPT_var anObj = aMGadapt->_this();
- //~return anObj._retn();
-//~}
//=============================================================================
/*!
* standard constructor
{
myMgAdapt = new ::MG_ADAPT::MgAdapt();
}
-//~MG_ADAPT_i::MG_ADAPT_i(PortableServer::POA_var myPoa): SALOME::GenericObj_i( myPoa )
-//~{
- //~myMgAdapt = new ::MG_ADAPT::MgAdapt();
-//~}
-
-//=============================================================================
-/*!
- * standard constructor
- */
-//=============================================================================
-//~MG_ADAPT_i::MG_ADAPT_i( CORBA::ORB_ptr orb,
- //~ADAPT::ADAPT_Gen_var engine )
-//~{
-
- //~_gen_i = engine;
- //~_orb = orb;
- //~myMgAdapt = new MgAdapt();
-//~}
//=============================================================================
/*!
//=============================================================================
MG_ADAPT_i::~MG_ADAPT_i()
{
+ delete myMgAdapt;
}
void MG_ADAPT_i::setData( SMESH::MgAdaptHypothesisData& data)
{
}
bool MG_ADAPT_i::getRemoveOnSuccess()
{
- myMgAdapt->getRemoveOnSuccess();
+ return myMgAdapt->getRemoveOnSuccess();
}
SMESH::MgAdaptHypothesisData* MG_ADAPT_i::getData()
{
return CORBA::string_dup(myMgAdapt->getCommandToRun().c_str());
}
+// macro used to initialize excStr by exception description
+// returned by SMESH_CATCH( SMESH::returnError )
+#undef SMESH_CAUGHT
+#define SMESH_CAUGHT excStr =
+
void MG_ADAPT_i::compute()
{
+ SMESH::TPythonDump noDumpSoFar;
+
errStr = "";
- try
+ std::string excStr;
+ SMESH_TRY;
+
+ myMgAdapt->compute(errStr);
+
+ SMESH_CATCH( SMESH::returnError );
+
+ SMESH_Comment errMsg;
+ if ( !excStr.empty() )
+ {
+ errMsg << "Exception thrown on MG_ADAPT_i::compute invocation with error message \""
+ << errStr << "\" with exception \"" << excStr << "\"";
+ }
+ else if ( !errStr.empty() )
{
- myMgAdapt->compute(errStr);
+ errMsg << "MG_ADAPT_i::compute invocation returned error message \"" << errStr << "\"";
}
- catch (const std::exception& e)
+ if ( !errMsg.empty() )
{
- std::ostringstream oss; oss << "Exception thrown on MG_ADAPT_i::compute invocation with error message \"" << errStr
- << "\" with exception message \"" << e.what() << "\"";
- THROW_SALOME_CORBA_EXCEPTION(oss.str().c_str(),SALOME::INTERNAL_ERROR);
+ THROW_SALOME_CORBA_EXCEPTION( errMsg.c_str(), SALOME::INTERNAL_ERROR);
}
+
if(myMgAdapt->getPublish())
{
SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
smeshGen_i->CreateMeshesFromMED(myMgAdapt->getMedFileOut().c_str(), theStatus);
}
}
+#undef SMESH_CAUGHT
+#define SMESH_CAUGHT
+
char* MG_ADAPT_i::getErrMsg()
{
return CORBA::string_dup(errStr.c_str());
return myMgAdapt->hasOptionDefined(optionName);
}
void MG_ADAPT_i::setOptionValue(const char* optionName,
- const char* optionValue) throw (std::invalid_argument)
+ const char* optionValue)
{
+ SMESH_TRY;
myMgAdapt->setOptionValue(optionName, optionValue);
+ SMESH_CATCH( SMESH::throwCorbaException );
}
char* MG_ADAPT_i::getOptionValue(const char* optionName,
- bool& isDefault) throw (std::invalid_argument)
+ bool& isDefault)
{
+ SMESH_TRY;
return CORBA::string_dup(myMgAdapt->getOptionValue(optionName, &isDefault).c_str());
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
}
-str_array* MG_ADAPT_i::getCustomOptionValuesStrVec()
+SMESH::string_array* MG_ADAPT_i::getCustomOptionValuesStrVec()
{
- SMESH::str_array_var result = new SMESH::str_array();
+ SMESH::string_array_var result = new SMESH::string_array();
std::vector <std::string> vals = myMgAdapt->getCustomOptionValuesStrVec();
- result->length(vals.size());
- for (int i = 0; i<vals.size(); i++) result[i] = CORBA::string_dup(vals[i].c_str());
+ result->length((CORBA::ULong) vals.size()) ;
+ for (CORBA::ULong i = 0; i<vals.size(); i++) result[i] = CORBA::string_dup(vals[i].c_str());
return result._retn();
}
-str_array* MG_ADAPT_i::getOptionValuesStrVec()
+SMESH::string_array* MG_ADAPT_i::getOptionValuesStrVec()
{
- SMESH::str_array_var result = new SMESH::str_array();
+ SMESH::string_array_var result = new SMESH::string_array();
std::vector <std::string> vals = myMgAdapt->getOptionValuesStrVec();
- result->length(vals.size());
- for (int i = 0; i<vals.size(); i++) result[i] = CORBA::string_dup(vals[i].c_str());
+ result->length((CORBA::ULong) vals.size());
+ for (CORBA::ULong i = 0; i<vals.size(); i++) result[i] = CORBA::string_dup(vals[i].c_str());
return result._retn();
}
mg->setMedFileOut(medFileOut.c_str());
mg->setSizeMapFile(medFileBackground.c_str());
hypothesis = SMESH::MG_ADAPT::_duplicate(mg);
+ hypothesis->Register();
}
CORBA::Long MG_ADAPT_OBJECT_i::Compute(bool publish)
{
+ SMESH::TPythonDump noDumpSoFar;
+
if(!checkMeshFileIn()){
std::cerr<< "\n Error : Please check the MED file input or mesh input. \n";
return -1;
bool MG_ADAPT_OBJECT_i::checkMeshFileIn()
{
+ SMESH::TPythonDump noDumpSoFar;
+
bool ret = false; // 1 ok , 0 nook
- if(!::MG_ADAPT::MgAdapt::isFileExist(medFileIn))
+ if ( !( ret = SMESH_File( medFileIn ).exists()))
{
if(!myMesh->_is_nil())
{
bool toOverwrite = true;
bool toFindOutDim = true;
- medFileIn = hypothesis->getFileName();
+ medFileIn = (CORBA::String_var( hypothesis->getFileName() )).in();
medFileIn+= ".med";
myMesh->ExportMED(medFileIn.c_str(), false, -1, toOverwrite, toFindOutDim);
hypothesis->setMedFileIn(medFileIn.c_str());
ret = true;
}
}
- else
- ret = true;
return ret;
}
#ifndef MG_ADAPT_I_HXX
#define MG_ADAPT_I_HXX
-#include "MG_ADAPT.hxx"
#include "SMESH.hxx"
+
#include <SALOMEconfig.h>
-//~#include CORBA_SERVER_HEADER(ADAPT_Gen)
#include CORBA_SERVER_HEADER(MG_ADAPT)
-
#include "SALOME_GenericObj_i.hh"
-#include "SALOME_Component_i.hxx"
-#include "SALOME_NamingService.hxx"
-#include "Utils_CorbaException.hxx"
-#include <vector>
-#include <algorithm>
-#include <iterator>
+#include <SALOME_GenericObj_wrap.hxx>
+
#include <string>
-//~struct MgAdaptHypothesisData;
-//~static void copyHypothesisDataToImpl(SMESH::MgAdaptHypothesisData& from, MG_ADAPT::MgAdaptHypothesisData* to);
-//~static void copyHypothesisDataFromImpl(MG_ADAPT::MgAdaptHypothesisData* from, SMESH::MgAdaptHypothesisData& to);
-//~class MgAdapt;
+namespace MG_ADAPT
+{
+ class MgAdaptHypothesisData;
+ class MgAdapt;
+}
+
namespace SMESH
{
public virtual POA_SMESH::MG_ADAPT
{
public:
- //~MG_ADAPT_i( CORBA::ORB_ptr orb, ADAPT::ADAPT_Gen_var gen_i );
- //~static SMESH::MG_ADAPT_ptr CreateMG_ADAPT();
- //~MG_ADAPT_i(PortableServer::POA_var poa);
MG_ADAPT_i();
virtual ~MG_ADAPT_i();
- //~void setData( SMESH::MgAdaptHypothesisData* data);
void setData( SMESH::MgAdaptHypothesisData& data);
void setMedFileIn(const char* str);
bool hasOptionDefined( const char* optionName ) ;
void setOptionValue(const char* optionName,
- const char* optionValue) throw (std::invalid_argument);
+ const char* optionValue);
char* getOptionValue(const char* optionName,
- bool& isDefault) throw (std::invalid_argument);
- str_array* getCustomOptionValuesStrVec() ;
- str_array* getOptionValuesStrVec() ;
+ bool& isDefault);
+ SMESH::string_array* getCustomOptionValuesStrVec() ;
+ SMESH::string_array* getOptionValuesStrVec() ;
void copyHypothesisDataFromImpl(const ::MG_ADAPT::MgAdaptHypothesisData* from, SMESH::MgAdaptHypothesisData* to) const;
void copyHypothesisDataToImpl(const SMESH::MgAdaptHypothesisData& from, ::MG_ADAPT::MgAdaptHypothesisData* to) const;
//~TOptionValues getOptionValues() const;
//~const TOptionValues& getCustomOptionValues() const ;
char* getErrMsg();
private:
- ::MG_ADAPT::MgAdapt* myMgAdapt;
- std::string errStr;
- //~CORBA::ORB_ptr _orb;
- //~ADAPT::ADAPT_Gen_var _gen_i;
+ ::MG_ADAPT::MgAdapt* myMgAdapt;
+ std::string errStr;
};
std::string medFileIn, medFileOut, medFileBackground;
bool checkMeshFileIn();
bool publish;
-SMESH::SMESH_Mesh_ptr myMesh;
-SMESH::MG_ADAPT_ptr hypothesis;
+SMESH::SMESH_Mesh_var myMesh;
+SALOME::GenericObj_wrap<SMESH::MG_ADAPT> hypothesis;
};
}
for ( int i = 1; i <= idMap.Extent(); i++ ) {
myResult.push_back( std::make_pair( (int)idMap(i)[0], (int)idMap(i)[1]) );
- }
+ }
}
};