Salome HOME
updated copyright message
[plugins/hexoticplugin.git] / src / HexoticPlugin / HexoticPlugin_Hypothesis.hxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // ---
21 // File   : HexoticPlugin_Hypothesis.hxx
22 // Author : Lioka RAZAFINDRAZAKA (CEA)
23 // ---
24 //
25 #ifndef _HexoticPlugin_Hypothesis_HXX_
26 #define _HexoticPlugin_Hypothesis_HXX_
27
28 #include "HexoticPlugin_Defs.hxx"
29
30 #include "SMESH_Hypothesis.hxx"
31 #include "Utils_SALOME_Exception.hxx"
32
33 #include <map>
34 #include <set>
35 #include <vector>
36
37 // class HexoticSizeMap
38 // {
39 // public:
40 //   SizeMap(const TopoDS_Shape& theShape, double theSize)
41 //   {
42 //     shape=theShape;
43 //     size=theSize;
44 //   };
45 //   TopoDS_Shape shape;
46 //   double size;
47 // }
48 //  Parameters for work of MG-Hexa
49 //
50
51 class HEXOTICPLUGIN_EXPORT HexoticPlugin_Hypothesis: public SMESH_Hypothesis
52 {
53 public:
54
55   HexoticPlugin_Hypothesis(int hypId, SMESH_Gen* gen);
56
57   static const char* GetHypType() { return "MG-Hexa Parameters"; }
58
59   void SetHexesMinLevel(int theVal);
60   int GetHexesMinLevel() const { return _hexesMinLevel; }
61
62   void SetHexesMaxLevel(int theVal);
63   int GetHexesMaxLevel() const { return _hexesMaxLevel; }
64
65   void SetMinSize(double theVal);
66   double GetMinSize() const { return _minSize; }
67
68   void SetMaxSize(double theVal);
69   double GetMaxSize() const { return _maxSize; }
70
71   void SetGeomApproxAngle(double angle);
72   double GetGeomApproxAngle() const { return _approxAngle; }
73
74   void SetHexoticIgnoreRidges(bool theVal);
75   bool GetHexoticIgnoreRidges() const { return _hexoticIgnoreRidges; }
76
77   void SetHexoticInvalidElements(bool theVal);
78   bool GetHexoticInvalidElements() const { return _hexoticInvalidElements; }
79    
80   void SetHexoticSharpAngleThreshold(double theVal);
81   double GetHexoticSharpAngleThreshold() const { return _hexoticSharpAngleThreshold; }
82    
83   void SetHexoticNbProc(int theVal);
84   int GetHexoticNbProc() const { return _hexoticNbProc; }
85   
86   void SetHexoticWorkingDirectory(const std::string& path);
87   std::string GetHexoticWorkingDirectory() const { return _hexoticWorkingDirectory; }
88
89   void SetHexoticSdMode(int theVal);
90   int GetHexoticSdMode() const { return _hexoticSdMode; }
91
92   void SetHexoticVerbosity(int theVal);
93   int GetHexoticVerbosity() const { return _hexoticVerbosity; }
94
95   void SetHexoticMaxMemory(int theVal);
96   int GetHexoticMaxMemory() const { return _hexoticMaxMemory; }
97   
98   void SetKeepFiles(bool toKeep);
99   bool GetKeepFiles() const  { return _keepFiles; }
100   void SetStandardOutputLog(bool logInStandardOutput);
101   bool GetStandardOutputLog() const { return _logInStandardOutput; }
102   void SetRemoveLogOnSuccess(bool removeLogOnSuccess);
103   bool GetRemoveLogOnSuccess() const  { return _removeLogOnSuccess; }
104
105
106   typedef std::map< std::string, std::string > TOptionValues;
107   typedef std::set< std::string >              TOptionNames;
108
109   void SetOptionValue(const std::string& optionName,
110                       const std::string& optionValue);
111   std::string GetOptionValue(const std::string& optionName,
112                              bool*              isDefault=0) const;
113   bool HasOptionDefined( const std::string& optionName ) const;
114   void ClearOption(const std::string& optionName);
115   TOptionValues        GetOptionValues()       const;
116   const TOptionValues& GetCustomOptionValues() const { return _customOption2value; }
117   std::string GetAdvancedOption( bool customOnly = false ) const;
118   void SetAdvancedOption(const std::string& theOptions); // obsolete
119
120   static bool  ToBool(const std::string& str, bool* isOk=0);
121   static double ToDbl(const std::string& str, bool* isOk=0);
122   static int    ToInt(const std::string& str, bool* isOk=0);
123
124
125   // Size Maps
126   typedef std::map<std::string,double> THexoticSizeMaps;
127
128   // For the GUI HexoticPluginGUI_HypothesisCreator::storeParamToHypo
129   const THexoticSizeMaps& GetSizeMaps() const { return _sizeMaps; }
130
131   // Add one size map to the collection of size maps (user interface)
132   bool AddSizeMap(std::string theEntry, double theSize);
133   bool UnsetSizeMap(std::string theEntry);
134
135   void SetNbLayers(int theVal);
136   int GetNbLayers() const { return _nbLayers; }
137
138   void SetFirstLayerSize(double theVal);
139   double GetFirstLayerSize() const { return _firstLayerSize; }
140
141   void SetDirection(bool theVal);
142   bool GetDirection() const { return _direction; }
143
144   void SetGrowth(double theVal);
145   double GetGrowth() const { return _growth; }
146
147   bool SetFacesWithLayers(const std::vector<int>& theVal);
148   const std::vector<int>& GetFacesWithLayers() const { return _facesWithLayers; }
149
150   bool SetImprintedFaces(const std::vector<int>& theVal);
151   const std::vector<int>& GetImprintedFaces() const { return _imprintedFaces; }
152
153   // the parameters default values 
154   static int GetDefaultHexesMinLevel();
155   static int GetDefaultHexesMaxLevel();
156   static double GetDefaultMinSize();
157   static double GetDefaultMaxSize();
158   static double GetDefaultGeomApproxAngle() { return 0; }
159   static bool GetDefaultHexoticIgnoreRidges();
160   static bool GetDefaultHexoticInvalidElements();
161   static double GetDefaultHexoticSharpAngleThreshold();
162   static int GetDefaultHexoticNbProc();
163   static std::string GetDefaultHexoticWorkingDirectory();
164   static int GetDefaultHexoticSdMode();
165   static int GetDefaultHexoticVerbosity();
166   static int GetDefaultHexoticMaxMemory();
167   static std::string GetDefaultTextOptions();
168   static THexoticSizeMaps GetDefaultHexoticSizeMaps();
169   static int GetDefaultNbLayers();
170   static double GetDefaultFirstLayerSize();
171   static bool GetDefaultDirection();
172   static double GetDefaultGrowth();
173   static std::vector<int> GetDefaultFacesWithLayers();
174   static std::vector<int> GetDefaultImprintedFaces();
175   static bool   GetDefaultStandardOutputLog() { return false; }
176   static bool   GetDefaultRemoveLogOnSuccess() { return false; }
177   static bool   GetDefaultKeepFiles() { return false; }
178
179   // Persistence
180   virtual std::ostream& SaveTo(std::ostream& save);
181   virtual std::istream& LoadFrom(std::istream& load);
182   friend  std::ostream& operator <<(std::ostream& save, HexoticPlugin_Hypothesis& hyp);
183   friend  std::istream& operator >>(std::istream& load, HexoticPlugin_Hypothesis& hyp);
184
185   /*!
186    * \brief Does nothing
187    * \param theMesh - the built mesh
188    * \param theShape - the geometry of interest
189    * \retval bool - always false
190    */
191   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
192
193   /*!
194    * \brief Initialize my parameter values by default parameters.
195    *  \retval bool - true if parameter values have been successfully defined
196    */
197   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
198
199  private:
200   int    _hexesMinLevel;
201   int    _hexesMaxLevel;
202   double _minSize;
203   double _maxSize;
204   double _approxAngle;
205   bool   _hexoticIgnoreRidges;
206   bool   _hexoticInvalidElements;
207   double _hexoticSharpAngleThreshold;
208   int    _hexoticNbProc;
209   int    _hexoticSdMode;
210   int    _hexoticVerbosity;
211   int    _hexoticMaxMemory;
212   THexoticSizeMaps _sizeMaps;
213
214   TOptionValues _option2value, _customOption2value;         // user defined values
215   TOptionValues _defaultOptionValues;                       // default values
216   TOptionNames  _doubleOptions, _charOptions, _boolOptions; // to find a type of option
217
218   std::string _hexoticWorkingDirectory;
219   bool   _logInStandardOutput;
220   bool   _removeLogOnSuccess;
221   bool   _keepFiles;
222
223   int    _nbLayers;
224   double _firstLayerSize;
225   bool   _direction;
226   double _growth;
227   std::vector<int> _facesWithLayers;
228   std::vector<int> _imprintedFaces;
229 };
230
231 #endif