1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : HexoticPlugin_Hypothesis.hxx
22 // Author : Lioka RAZAFINDRAZAKA (CEA)
25 #ifndef _HexoticPlugin_Hypothesis_HXX_
26 #define _HexoticPlugin_Hypothesis_HXX_
28 #include "HexoticPlugin_Defs.hxx"
30 #include "SMESH_Hypothesis.hxx"
31 #include "Utils_SALOME_Exception.hxx"
37 // class HexoticSizeMap
40 // SizeMap(const TopoDS_Shape& theShape, double theSize)
45 // TopoDS_Shape shape;
48 // Parameters for work of MG-Hexa
51 class HEXOTICPLUGIN_EXPORT HexoticPlugin_Hypothesis: public SMESH_Hypothesis
55 HexoticPlugin_Hypothesis(int hypId, SMESH_Gen* gen);
57 static const char* GetHypType() { return "MG-Hexa Parameters"; }
59 void SetHexesMinLevel(int theVal);
60 int GetHexesMinLevel() const { return _hexesMinLevel; }
62 void SetHexesMaxLevel(int theVal);
63 int GetHexesMaxLevel() const { return _hexesMaxLevel; }
65 void SetMinSize(double theVal);
66 double GetMinSize() const { return _minSize; }
68 void SetMaxSize(double theVal);
69 double GetMaxSize() const { return _maxSize; }
71 void SetGeomApproxAngle(double angle);
72 double GetGeomApproxAngle() const { return _approxAngle; }
74 void SetHexoticIgnoreRidges(bool theVal);
75 bool GetHexoticIgnoreRidges() const { return _hexoticIgnoreRidges; }
77 void SetHexoticInvalidElements(bool theVal);
78 bool GetHexoticInvalidElements() const { return _hexoticInvalidElements; }
80 void SetHexoticSharpAngleThreshold(double theVal);
81 double GetHexoticSharpAngleThreshold() const { return _hexoticSharpAngleThreshold; }
83 void SetHexoticNbProc(int theVal);
84 int GetHexoticNbProc() const { return _hexoticNbProc; }
86 void SetHexoticWorkingDirectory(const std::string& path);
87 std::string GetHexoticWorkingDirectory() const { return _hexoticWorkingDirectory; }
89 void SetHexoticSdMode(int theVal);
90 int GetHexoticSdMode() const { return _hexoticSdMode; }
92 void SetHexoticVerbosity(int theVal);
93 int GetHexoticVerbosity() const { return _hexoticVerbosity; }
95 void SetHexoticMaxMemory(int theVal);
96 int GetHexoticMaxMemory() const { return _hexoticMaxMemory; }
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; }
106 typedef std::map< std::string, std::string > TOptionValues;
107 typedef std::set< std::string > TOptionNames;
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
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);
126 typedef std::map<std::string,double> THexoticSizeMaps;
128 // For the GUI HexoticPluginGUI_HypothesisCreator::storeParamToHypo
129 const THexoticSizeMaps& GetSizeMaps() const { return _sizeMaps; }
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);
135 void SetNbLayers(int theVal);
136 int GetNbLayers() const { return _nbLayers; }
138 void SetFirstLayerSize(double theVal);
139 double GetFirstLayerSize() const { return _firstLayerSize; }
141 void SetDirection(bool theVal);
142 bool GetDirection() const { return _direction; }
144 void SetGrowth(double theVal);
145 double GetGrowth() const { return _growth; }
147 bool SetFacesWithLayers(const std::vector<int>& theVal);
148 const std::vector<int>& GetFacesWithLayers() const { return _facesWithLayers; }
150 bool SetImprintedFaces(const std::vector<int>& theVal);
151 const std::vector<int>& GetImprintedFaces() const { return _imprintedFaces; }
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; }
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);
186 * \brief Does nothing
187 * \param theMesh - the built mesh
188 * \param theShape - the geometry of interest
189 * \retval bool - always false
191 virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
194 * \brief Initialize my parameter values by default parameters.
195 * \retval bool - true if parameter values have been successfully defined
197 virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
205 bool _hexoticIgnoreRidges;
206 bool _hexoticInvalidElements;
207 double _hexoticSharpAngleThreshold;
210 int _hexoticVerbosity;
211 int _hexoticMaxMemory;
212 THexoticSizeMaps _sizeMaps;
214 TOptionValues _option2value, _customOption2value; // user defined values
215 TOptionValues _defaultOptionValues; // default values
216 TOptionNames _doubleOptions, _charOptions, _boolOptions; // to find a type of option
218 std::string _hexoticWorkingDirectory;
219 bool _logInStandardOutput;
220 bool _removeLogOnSuccess;
224 double _firstLayerSize;
227 std::vector<int> _facesWithLayers;
228 std::vector<int> _imprintedFaces;