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