]> SALOME platform Git repositories - plugins/blsurfplugin.git/blob - src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx
Salome HOME
Merge from BR_EDF_PAL_1456
[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 #include <cstring>
37 #include <sstream>
38 #include <utilities.h>
39
40 //  Parameters for work of BLSURF
41
42 class BLSURFPlugin_Hypothesis: public SMESH_Hypothesis
43 {
44 public:
45   BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen);
46
47   enum Topology {
48     FromCAD,
49     Process,
50     Process2
51   };
52
53   enum PhysicalMesh {
54     DefaultSize,
55     PhysicalUserDefined
56   };
57
58   enum GeometricMesh {
59     DefaultGeom,
60     UserDefined
61   };
62
63   void SetTopology(Topology theTopology);
64   Topology GetTopology() const { return _topology; }
65
66   void SetPhysicalMesh(PhysicalMesh thePhysicalMesh);
67   PhysicalMesh GetPhysicalMesh() const { return _physicalMesh; }
68
69   void SetPhySize(double thePhySize);
70   double GetPhySize() const { return _phySize; }
71
72   void SetPhyMin(double theMinSize);
73   double GetPhyMin() const { return _phyMin; }
74
75   void SetPhyMax(double theMaxSize);
76   double GetPhyMax() const { return _phyMax; }
77
78   void SetGeometricMesh(GeometricMesh theGeometricMesh);
79   GeometricMesh GetGeometricMesh() const { return _geometricMesh; }
80
81   void SetAngleMeshS(double theAngle);
82   double GetAngleMeshS() const { return _angleMeshS; }
83
84   void SetAngleMeshC(double theAngle);
85   double GetAngleMeshC() const { return _angleMeshC; }
86
87   void SetGeoMin(double theMinSize);
88   double GetGeoMin() const { return _hgeoMin; }
89
90   void SetGeoMax(double theMaxSize);
91   double GetGeoMax() const { return _hgeoMax; }
92
93   void SetGradation(double theGradation);
94   double GetGradation() const { return _gradation; }
95
96   void SetQuadAllowed(bool theVal);
97   bool GetQuadAllowed() const { return _quadAllowed; }
98
99   void SetDecimesh(bool theVal);
100   bool GetDecimesh() const { return _decimesh; }
101
102   void SetVerbosity(int theVal);
103   int GetVerbosity() const { return _verb; }
104   
105   void ClearEntry(const std::string& entry);
106   void ClearSizeMaps();
107
108   typedef std::map<std::string,std::string> TSizeMap;
109
110   void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap );
111   std::string  GetSizeMapEntry(const std::string& entry);
112   const TSizeMap& _GetSizeMapEntries() const { return _sizeMap; }
113   /*!
114    * \brief Return the size maps
115    */
116   static TSizeMap GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp);
117
118
119   void SetAttractorEntry(const std::string& entry,const std::string& attractor );
120   std::string GetAttractorEntry(const std::string& entry);
121   const TSizeMap& _GetAttractorEntries() const { return _attractors; };
122   /*!
123    * \brief Return the attractors
124    */
125   static TSizeMap GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
126
127
128 /*
129   void SetCustomSizeMapEntry(const std::string& entry,const std::string& sizeMap );
130   std::string  GetCustomSizeMapEntry(const std::string& entry);
131   void UnsetCustomSizeMap(const std::string& entry);
132   const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; }
133  */
134
135   /*!
136    * To set/get/unset an enforced vertex
137    */
138   // Entry
139   typedef std::string TEntry;
140   // List of entries
141   typedef std::set<TEntry> TEntryList;
142   // Name
143   typedef std::string TEnfName;
144   // Group name
145   typedef std::string TEnfGroupName;
146   // Coordinates
147   typedef std::vector<double> TEnfVertexCoords;
148   typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
149
150   // Enforced vertex
151   struct TEnfVertex {
152     TEnfName name;
153     TEntry geomEntry;
154     TEnfVertexCoords coords;
155     TEnfGroupName grpName;
156     TEntryList faceEntries;
157   };
158     
159   struct CompareEnfVertices
160   {
161     bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
162       if (e1 && e2) {
163         if (e1->coords.size() && e2->coords.size())
164           return (e1->coords < e2->coords);
165         else
166           return (e1->geomEntry < e2->geomEntry);
167       }
168       return false;
169     }
170   };
171
172   // List of enforced vertices
173   typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
174
175   // Map Face Entry / List of enforced vertices
176   typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
177
178   // Map Face Entry / List of coords
179   typedef std::map< TEntry, TEnfVertexCoordsList > TFaceEntryCoordsListMap;
180
181   // Map Face Entry / List of Vertex entry
182   typedef std::map< TEntry, TEntryList > TFaceEntryEnfVertexEntryListMap;
183   
184   // Map Coords / Enforced vertex
185   typedef std::map< TEnfVertexCoords, TEnfVertex* > TCoordsEnfVertexMap;
186
187   // Map Vertex entry / Enforced vertex
188   typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap;
189
190   typedef std::map< TEnfGroupName, std::set<int> > TGroupNameNodeIDMap;
191   /* TODO GROUPS
192   // Map Group Name / List of enforced vertices
193   typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap;
194   */
195
196   
197 //   TODO GROUPS
198 //   void SetEnforcedVertex(const TEntry& entry, double x, double y, double z, const TEnfGroupName& groupName="");
199   bool                  SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, TEnfGroupName theGroupName,
200                                           double x = 0.0, double y = 0.0, double z = 0.0);
201   TEnfVertexList        GetEnfVertexList(const TEntry& theFaceEntry) throw (std::invalid_argument);
202   TEnfVertexCoordsList  GetEnfVertexCoordsList(const TEntry& theFaceEntry) throw (std::invalid_argument);
203   TEntryList            GetEnfVertexEntryList (const TEntry& theFaceEntry) throw (std::invalid_argument);
204   TEnfVertex*           GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument);
205   TEnfVertex*           GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument);
206   void                  AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID);
207   std::set<int>         GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument);
208   void                  RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument);
209   
210   bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument);
211   bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument);
212
213   void ClearAllEnforcedVertices();
214
215   const TFaceEntryEnfVertexListMap  _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; }
216   const TEnfVertexList              _GetAllEnforcedVertices() const { return _enfVertexList; }
217
218   const TFaceEntryCoordsListMap     _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; }
219   const TCoordsEnfVertexMap         _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; }
220
221   const TFaceEntryEnfVertexEntryListMap _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; }
222   const TEnfVertexEntryEnfVertexMap     _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; }
223
224 //   TODO GROUPS
225 //   const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; }
226   
227
228   /*!
229    * \brief Return the enforced vertices
230    */
231   static TFaceEntryEnfVertexListMap       GetAllEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp);
232   static TEnfVertexList                   GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp);
233
234   static TFaceEntryCoordsListMap          GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp);
235   static TCoordsEnfVertexMap              GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp);
236
237   static TFaceEntryEnfVertexEntryListMap  GetAllEnfVertexEntriesByFace(const BLSURFPlugin_Hypothesis* hyp);
238   static TEnfVertexEntryEnfVertexMap      GetAllEnforcedVerticesByEnfVertexEntry(const BLSURFPlugin_Hypothesis* hyp);
239
240   
241   /*!
242     * \brief Set/get node group to an enforced vertex
243     */
244   /* TODO GROUPS
245   void SetEnforcedVertexGroupName(double x, double y, double z, const TEnfGroupName& groupName) throw (std::invalid_argument);
246   TEnfGroupName GetEnforcedVertexGroupName(double x, double y, double z) throw (std::invalid_argument);
247   TEnfVertexList GetEnforcedVertexByGroupName(TEnfGroupName& groupName) throw (std::invalid_argument);
248   */
249
250   static Topology        GetDefaultTopology();
251   static PhysicalMesh    GetDefaultPhysicalMesh();
252   static double          GetDefaultPhySize();
253   static double          GetDefaultMaxSize();
254   static double          GetDefaultMinSize();
255   static GeometricMesh   GetDefaultGeometricMesh();
256   static double          GetDefaultAngleMeshS();
257   static double          GetDefaultAngleMeshC() { return GetDefaultAngleMeshS(); }
258   static double          GetDefaultGradation();
259   static bool            GetDefaultQuadAllowed();
260   static bool            GetDefaultDecimesh();
261   static int             GetDefaultVerbosity() { return 10; }
262   static TSizeMap        GetDefaultSizeMap() { return TSizeMap();}
263
264   static TFaceEntryEnfVertexListMap       GetDefaultFaceEntryEnfVertexListMap() { return TFaceEntryEnfVertexListMap(); }
265   static TEnfVertexList                   GetDefaultEnfVertexList() { return TEnfVertexList(); }
266   static TFaceEntryCoordsListMap          GetDefaultFaceEntryCoordsListMap() { return TFaceEntryCoordsListMap(); }
267   static TCoordsEnfVertexMap              GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); }
268   static TFaceEntryEnfVertexEntryListMap  GetDefaultFaceEntryEnfVertexEntryListMap() { return TFaceEntryEnfVertexEntryListMap(); }
269   static TEnfVertexEntryEnfVertexMap      GetDefaultEnfVertexEntryEnfVertexMap() { return TEnfVertexEntryEnfVertexMap(); }
270   static TGroupNameNodeIDMap              GetDefaultGroupNameNodeIDMap() { return TGroupNameNodeIDMap(); }
271
272   /* TODO GROUPS
273   static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); }
274   static TEnfVertexGroupNameMap     GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); }
275   */
276
277   static double undefinedDouble() { return -1.0; }
278
279   typedef std::map< std::string, std::string > TOptionValues;
280   typedef std::set< std::string >              TOptionNames;
281
282   void SetOptionValue(const std::string& optionName,
283                       const std::string& optionValue) throw (std::invalid_argument);
284   std::string GetOptionValue(const std::string& optionName) throw (std::invalid_argument);
285   void ClearOption(const std::string& optionName);
286   const TOptionValues& GetOptionValues() const { return _option2value; }
287
288   // Persistence
289   virtual std::ostream & SaveTo(std::ostream & save);
290   virtual std::istream & LoadFrom(std::istream & load);
291   friend std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp);
292   friend std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp);
293
294   /*!
295    * \brief Does nothing
296    * \param theMesh - the built mesh
297    * \param theShape - the geometry of interest
298    * \retval bool - always false
299    */
300   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
301
302   /*!
303    * \brief Initialize my parameter values by default parameters.
304    *  \retval bool - true if parameter values have been successfully defined
305    */
306   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
307
308
309 private:
310   Topology        _topology;
311   PhysicalMesh    _physicalMesh;
312   double          _phySize, _phyMin, _phyMax;
313   GeometricMesh   _geometricMesh;
314   double          _angleMeshS, _angleMeshC, _hgeoMin, _hgeoMax;
315   double          _gradation;
316   bool            _quadAllowed;
317   bool            _decimesh;
318   int             _verb;
319   TOptionValues   _option2value;
320   TOptionNames    _doubleOptions, _charOptions;
321   TSizeMap        _sizeMap;
322   TSizeMap        _attractors;
323
324   TFaceEntryEnfVertexListMap  _faceEntryEnfVertexListMap;
325   TEnfVertexList              _enfVertexList;
326   // maps to get "manual" enf vertex (through their coordinates)
327   TFaceEntryCoordsListMap     _faceEntryCoordsListMap;
328   TCoordsEnfVertexMap         _coordsEnfVertexMap;
329   // maps to get "geom" enf vertex (through their geom entries)
330   TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap;
331   TEnfVertexEntryEnfVertexMap     _enfVertexEntryEnfVertexMap;
332   TGroupNameNodeIDMap             _groupNameNodeIDMap;
333   
334   /* TODO GROUPS
335   TGroupNameEnfVertexListMap _groupNameEnfVertexListMap;
336   */
337 //   TSizeMap      _customSizeMap;
338 };
339
340 #endif