Salome HOME
Merge branch 'V9_9_BR'
[modules/smesh.git] / src / SMESH / MG_ADAPT.hxx
index ba128314bd9f15c6eddcaf1879379f499315fe60..97a23375c30b68031d58c96d99a4dccb64a32e08 100644 (file)
@@ -1,4 +1,4 @@
-// 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,
@@ -57,57 +54,8 @@ struct MgAdaptHypothesisData
   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:
@@ -202,18 +150,18 @@ 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 */
@@ -233,7 +181,6 @@ public:
   static bool  defaultUseLastTimeStep();
   static bool  defaultUseChosenTimeStep();
   static double  defaultMaximumMemory();
-  static bool isFileExist(const std::string& fName);
 
   enum Status {
     DRS_OK,
@@ -246,27 +193,20 @@ public:
     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) {}
   };
 
 
@@ -303,8 +243,8 @@ private :
   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;
@@ -320,11 +260,9 @@ private :
   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);
@@ -335,6 +273,6 @@ private :
 
 };
 
-}
+} // namespace MG_ADAPT
 
 #endif // MG_ADAPT_HXX