Salome HOME
Correction after merge
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis.hxx
1 //  Copyright (C) 2007-2008  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.
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 // File    : BLSURFPlugin_Hypothesis.hxx
21 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
22 //           & Aurelien ALLEAUME (DISTENE)
23 //           Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
24 // ---
25 //
26 #ifndef _BLSURFPlugin_Hypothesis_HXX_
27 #define _BLSURFPlugin_Hypothesis_HXX_
28
29 #include "SMESH_Hypothesis.hxx"
30 #include <vector>
31 #include <map>
32 #include <set>
33 #include <stdexcept>
34 #include <string>
35
36 //  Parameters for work of BLSURF
37
38 class BLSURFPlugin_Hypothesis: public SMESH_Hypothesis
39 {
40 public:
41   BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen);
42
43   enum Topology {
44     FromCAD,
45     Process,
46     Process2
47   };
48
49   enum PhysicalMesh {
50     DefaultSize,
51     PhysicalUserDefined
52   };
53
54   enum GeometricMesh {
55     DefaultGeom,
56     UserDefined
57   };
58
59   void SetTopology(Topology theTopology);
60   Topology GetTopology() const { return _topology; }
61
62   void SetPhysicalMesh(PhysicalMesh thePhysicalMesh);
63   PhysicalMesh GetPhysicalMesh() const { return _physicalMesh; }
64
65   void SetPhySize(double thePhySize);
66   double GetPhySize() const { return _phySize; }
67
68   void SetPhyMin(double theMinSize);
69   double GetPhyMin() const { return _phyMin; }
70
71   void SetPhyMax(double theMaxSize);
72   double GetPhyMax() const { return _phyMax; }
73
74   void SetGeometricMesh(GeometricMesh theGeometricMesh);
75   GeometricMesh GetGeometricMesh() const { return _geometricMesh; }
76
77   void SetAngleMeshS(double theAngle);
78   double GetAngleMeshS() const { return _angleMeshS; }
79
80   void SetAngleMeshC(double theAngle);
81   double GetAngleMeshC() const { return _angleMeshC; }
82
83   void SetGeoMin(double theMinSize);
84   double GetGeoMin() const { return _hgeoMin; }
85
86   void SetGeoMax(double theMaxSize);
87   double GetGeoMax() const { return _hgeoMax; }
88
89   void SetGradation(double theGradation);
90   double GetGradation() const { return _gradation; }
91
92   void SetQuadAllowed(bool theVal);
93   bool GetQuadAllowed() const { return _quadAllowed; }
94
95   void SetDecimesh(bool theVal);
96   bool GetDecimesh() const { return _decimesh; }
97
98   void SetVerbosity(int theVal);
99   int GetVerbosity() const { return _verb; }
100   
101   void ClearEntry(const std::string& entry);
102   void ClearSizeMaps();
103
104   typedef std::map<std::string,std::string> TSizeMap;
105
106   void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap );
107   std::string  GetSizeMapEntry(const std::string& entry);
108   const TSizeMap& _GetSizeMapEntries() const { return _sizeMap; }
109   /*!
110    * \brief Return the size maps
111    */
112   static TSizeMap GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp);
113
114
115   void SetAttractorEntry(const std::string& entry,const std::string& attractor );
116   std::string GetAttractorEntry(const std::string& entry);
117   const TSizeMap& _GetAttractorEntries() const { return _attractors; };
118   /*!
119    * \brief Return the attractors
120    */
121   static TSizeMap GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
122
123
124 /*
125   void SetCustomSizeMapEntry(const std::string& entry,const std::string& sizeMap );
126   std::string  GetCustomSizeMapEntry(const std::string& entry);
127   void UnsetCustomSizeMap(const std::string& entry);
128   const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; }
129  */
130
131   /*!
132    * To set/get/unset an enforced vertex
133    */
134   typedef std::vector<double> TEnforcedVertex;
135   typedef std::set< TEnforcedVertex > TEnforcedVertexList;
136   typedef std::map< std::string, TEnforcedVertexList > TEnforcedVertexMap;
137   
138   void SetEnforcedVertex(const std::string& entry, double x, double y, double z);
139 //   void SetEnforcedVertexList(const std::string& entry, const TEnforcedVertexList vertexList);
140   TEnforcedVertexList GetEnforcedVertices(const std::string& entry) throw (std::invalid_argument);
141   void ClearEnforcedVertex(const std::string& entry, double x, double y, double z) throw (std::invalid_argument);
142 //   void ClearEnforcedVertexList(const std::string& entry, TEnforcedVertexList vertexList) throw (std::invalid_argument);
143   void ClearEnforcedVertices(const std::string& entry) throw (std::invalid_argument);
144
145   void ClearAllEnforcedVertices();
146   const TEnforcedVertexMap _GetAllEnforcedVertices() const { return _enforcedVertices; }
147
148   /*!
149    * \brief Return the enforced vertices
150    */
151   static TEnforcedVertexMap GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp);
152
153
154   static Topology        GetDefaultTopology();
155   static PhysicalMesh    GetDefaultPhysicalMesh();
156   static double          GetDefaultPhySize();
157   static double          GetDefaultMaxSize();
158   static double          GetDefaultMinSize();
159   static GeometricMesh   GetDefaultGeometricMesh();
160   static double          GetDefaultAngleMeshS();
161   static double          GetDefaultAngleMeshC() { return GetDefaultAngleMeshS(); }
162   static double          GetDefaultGradation();
163   static bool            GetDefaultQuadAllowed();
164   static bool            GetDefaultDecimesh();
165   static int             GetDefaultVerbosity() { return 10; }
166   static TSizeMap        GetDefaultSizeMap() { return TSizeMap();}
167   static TEnforcedVertexMap GetDefaultEnforcedVertexMap() { return TEnforcedVertexMap(); }
168
169   static double undefinedDouble() { return -1.0; }
170
171   typedef std::map< std::string, std::string > TOptionValues;
172   typedef std::set< std::string >              TOptionNames;
173
174   void SetOptionValue(const std::string& optionName,
175                       const std::string& optionValue) throw (std::invalid_argument);
176   std::string GetOptionValue(const std::string& optionName) throw (std::invalid_argument);
177   void ClearOption(const std::string& optionName);
178   const TOptionValues& GetOptionValues() const { return _option2value; }
179
180   // Persistence
181   virtual std::ostream & SaveTo(std::ostream & save);
182   virtual std::istream & LoadFrom(std::istream & load);
183   friend std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp);
184   friend std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp);
185
186   /*!
187    * \brief Does nothing
188    * \param theMesh - the built mesh
189    * \param theShape - the geometry of interest
190    * \retval bool - always false
191    */
192   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
193
194   /*!
195    * \brief Initialize my parameter values by default parameters.
196    *  \retval bool - true if parameter values have been successfully defined
197    */
198   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
199
200 private:
201   Topology        _topology;
202   PhysicalMesh    _physicalMesh;
203   double          _phySize, _phyMin, _phyMax;
204   GeometricMesh   _geometricMesh;
205   double          _angleMeshS, _angleMeshC, _hgeoMin, _hgeoMax;
206   double          _gradation;
207   bool            _quadAllowed;
208   bool            _decimesh;
209   int             _verb;
210   TOptionValues   _option2value;
211   TOptionNames    _doubleOptions, _charOptions;
212   TSizeMap        _sizeMap;
213   TSizeMap        _attractors;
214   TEnforcedVertexMap _enforcedVertices;
215 /*
216   TSizeMap      _customSizeMap;
217 */
218 };
219
220 #endif