-// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2020-2022 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : MG_ADAPT.hxx
-//
+
#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 "SMESH_SMESH.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
+class SMESH_EXPORT MgAdapt
{
public:
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) {}
};
TOptionValues _defaultOptionValues; // default values
TOptionNames _doubleOptions, _charOptions, _boolOptions; // to find a type of option
- std::vector <std::string> _myErrorMessages;
- Status _myStatus;
+ std::vector <std::string> _errorMessages;
+ Status _status;
std::string meshFormatOutputMesh;
std::vector< std::string> solFormatOutput;
std::vector <group> groupVec;
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);
std::vector<std::string> getListFieldsNames(std::string fileIn) ;
- void checkDimensionOption(std::string adpOpVal) ;
+ void checkDimensionOptionAdaptation() ;
void checkFieldName(std::string fileIn) ;
void checkTimeStepRank(std::string fileIn) ;
};
-}
+} // namespace MG_ADAPT
#endif // MG_ADAPT_HXX