Salome HOME
a9009b8ace4cfca97b4bd8ec4662a3da73f1ded4
[plugins/hexoticplugin.git] / src / HexoticPlugin / HexoticPlugin_Hypothesis.hxx
1 // Copyright (C) 2007-2015  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 <vector>
35
36 // class HexoticSizeMap
37 // {
38 // public:
39 //   SizeMap(const TopoDS_Shape& theShape, double theSize)
40 //   {
41 //     shape=theShape;
42 //     size=theSize;
43 //   };
44 //   TopoDS_Shape shape;
45 //   double size;
46 // }
47 //  Parameters for work of MG-Hexa
48 //
49
50 class HEXOTICPLUGIN_EXPORT HexoticPlugin_Hypothesis: public SMESH_Hypothesis
51 {
52 public:
53
54   HexoticPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen* gen);
55
56   static const char* GetHypType() { return "MG-Hexa Parameters"; }
57
58   void SetHexesMinLevel(int theVal);
59   int GetHexesMinLevel() const { return _hexesMinLevel; }
60
61   void SetHexesMaxLevel(int theVal);
62   int GetHexesMaxLevel() const { return _hexesMaxLevel; }
63
64   void SetMinSize(double theVal);
65   double GetMinSize() const { return _minSize; }
66
67   void SetMaxSize(double theVal);
68   double GetMaxSize() const { return _maxSize; }
69
70   void SetHexoticIgnoreRidges(bool theVal);
71   bool GetHexoticIgnoreRidges() const { return _hexoticIgnoreRidges; }
72
73   void SetHexoticInvalidElements(bool theVal);
74   bool GetHexoticInvalidElements() const { return _hexoticInvalidElements; }
75    
76   void SetHexoticSharpAngleThreshold(double theVal);
77   double GetHexoticSharpAngleThreshold() const { return _hexoticSharpAngleThreshold; }
78    
79   void SetHexoticNbProc(int theVal);
80   int GetHexoticNbProc() const { return _hexoticNbProc; }
81   
82   void SetHexoticWorkingDirectory(const std::string& path);
83   std::string GetHexoticWorkingDirectory() const { return _hexoticWorkingDirectory; }
84
85   void SetHexoticSdMode(int theVal);
86   int GetHexoticSdMode() const { return _hexoticSdMode; }
87
88   void SetHexoticVerbosity(int theVal);
89   int GetHexoticVerbosity() const { return _hexoticVerbosity; }
90
91   void SetHexoticMaxMemory(int theVal);
92   int GetHexoticMaxMemory() const { return _hexoticMaxMemory; }
93   
94   void SetTextOptions(const std::string& theOptions);
95   std::string GetTextOptions() const { return _textOptions; }
96
97   // Size Maps
98   typedef std::map<std::string,double> THexoticSizeMaps;
99   
100   // For the GUI HexoticPluginGUI_HypothesisCreator::storeParamToHypo
101   THexoticSizeMaps GetSizeMaps() const { return _sizeMaps; }; 
102   
103   // Add one size map to the collection of size maps (user interface)
104   bool AddSizeMap(std::string theEntry, double theSize);
105   bool UnsetSizeMap(std::string theEntry);
106
107   void SetNbLayers(int theVal);
108   int GetNbLayers() const { return _nbLayers; }
109
110   void SetFirstLayerSize(double theVal);
111   double GetFirstLayerSize() const { return _firstLayerSize; }
112
113   void SetDirection(bool theVal);
114   bool GetDirection() const { return _direction; }
115
116   void SetGrowth(double theVal);
117   double GetGrowth() const { return _growth; }
118
119   bool SetFacesWithLayers(const std::vector<int>& theVal);
120   std::vector<int> GetFacesWithLayers() const { return _facesWithLayers; }
121
122   bool SetImprintedFaces(const std::vector<int>& theVal);
123   std::vector<int> GetImprintedFaces() const { return _imprintedFaces; }
124
125   // the parameters default values 
126   static int GetDefaultHexesMinLevel();
127   static int GetDefaultHexesMaxLevel();
128   static double GetDefaultMinSize();
129   static double GetDefaultMaxSize();
130   static bool GetDefaultHexoticIgnoreRidges();
131   static bool GetDefaultHexoticInvalidElements();
132   static double GetDefaultHexoticSharpAngleThreshold();
133   static int GetDefaultHexoticNbProc();
134   static std::string GetDefaultHexoticWorkingDirectory();
135   static int GetDefaultHexoticSdMode();
136   static int GetDefaultHexoticVerbosity();
137   static int GetDefaultHexoticMaxMemory();
138   static std::string GetDefaultTextOptions();
139   static THexoticSizeMaps GetDefaultHexoticSizeMaps();
140   static int GetDefaultNbLayers();
141   static double GetDefaultFirstLayerSize();
142   static bool GetDefaultDirection();
143   static double GetDefaultGrowth();
144   static std::vector<int> GetDefaultFacesWithLayers();
145   static std::vector<int> GetDefaultImprintedFaces();
146
147   // Persistence
148   virtual std::ostream& SaveTo(std::ostream& save);
149   virtual std::istream& LoadFrom(std::istream& load);
150   friend  std::ostream& operator <<(std::ostream& save, HexoticPlugin_Hypothesis& hyp);
151   friend  std::istream& operator >>(std::istream& load, HexoticPlugin_Hypothesis& hyp);
152
153   /*!
154    * \brief Does nothing
155    * \param theMesh - the built mesh
156    * \param theShape - the geometry of interest
157    * \retval bool - always false
158    */
159   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
160
161   /*!
162    * \brief Initialize my parameter values by default parameters.
163    *  \retval bool - true if parameter values have been successfully defined
164    */
165   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
166
167 private:
168   int    _hexesMinLevel;
169   int    _hexesMaxLevel;
170   double _minSize;
171   double _maxSize;
172   bool   _hexoticIgnoreRidges;
173   bool   _hexoticInvalidElements;
174   double _hexoticSharpAngleThreshold;
175   int    _hexoticNbProc;
176   int    _hexoticSdMode;
177   int    _hexoticVerbosity;
178   int    _hexoticMaxMemory;
179   std::string _textOptions;
180   THexoticSizeMaps _sizeMaps;
181   std::string _hexoticWorkingDirectory;
182   int    _nbLayers;
183   double _firstLayerSize;
184   bool   _direction;
185   double _growth;
186   std::vector<int> _facesWithLayers;
187   std::vector<int> _imprintedFaces;
188 };
189
190 #endif