]> SALOME platform Git repositories - plugins/blsurfplugin.git/blob - src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx
Salome HOME
Increment version number (prepare SALOME version 7.0.0)
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis.hxx
1 // Copyright (C) 2007-2012  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 #include "BLSURFPlugin_Attractor.hxx"
40
41 //  Parameters for work of BLSURF
42
43 class BLSURFPlugin_Hypothesis: public SMESH_Hypothesis
44 {
45 public:
46   BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen);
47
48   enum Topology {
49     FromCAD,
50     Process,
51     Process2,
52     PreCAD
53   };
54
55   enum PhysicalMesh {
56     DefaultSize,
57     PhysicalUserDefined,
58     SizeMap
59   };
60
61   enum GeometricMesh {
62     DefaultGeom,
63     UserDefined
64   };
65
66   static const char* GetHypType() { return "BLSURF_Parameters"; }
67   
68   TopoDS_Shape entryToShape(std::string entry);
69
70   void SetTopology(Topology theTopology);
71   Topology GetTopology() const { return _topology; }
72
73   void SetPhysicalMesh(PhysicalMesh thePhysicalMesh);
74   PhysicalMesh GetPhysicalMesh() const { return _physicalMesh; }
75
76   void SetPhySize(double thePhySize);
77   double GetPhySize() const { return _phySize; }
78
79   void SetPhyMin(double theMinSize);
80   double GetPhyMin() const { return _phyMin; }
81
82   void SetPhyMax(double theMaxSize);
83   double GetPhyMax() const { return _phyMax; }
84
85   void SetGeometricMesh(GeometricMesh theGeometricMesh);
86   GeometricMesh GetGeometricMesh() const { return _geometricMesh; }
87
88   void SetAngleMeshS(double theAngle);
89   double GetAngleMeshS() const { return _angleMeshS; }
90
91   void SetAngleMeshC(double theAngle);
92   double GetAngleMeshC() const { return _angleMeshC; }
93
94   void SetGeoMin(double theMinSize);
95   double GetGeoMin() const { return _hgeoMin; }
96
97   void SetGeoMax(double theMaxSize);
98   double GetGeoMax() const { return _hgeoMax; }
99
100   void SetGradation(double theGradation);
101   double GetGradation() const { return _gradation; }
102
103   void SetQuadAllowed(bool theVal);
104   bool GetQuadAllowed() const { return _quadAllowed; }
105
106   void SetDecimesh(bool theVal);
107   bool GetDecimesh() const { return _decimesh; }
108
109   void SetVerbosity(int theVal);
110   int GetVerbosity() const { return _verb; }
111   
112   void ClearEntry(const std::string& entry);
113   void ClearSizeMaps();
114
115   void SetPreCADMergeEdges(bool theVal);
116   bool GetPreCADMergeEdges() const { return _preCADMergeEdges; }
117
118   void SetPreCADRemoveNanoEdges(bool theVal);
119   bool GetPreCADRemoveNanoEdges() const { return _preCADRemoveNanoEdges; }
120
121   void SetPreCADDiscardInput(bool theVal);
122   bool GetPreCADDiscardInput() const { return _preCADDiscardInput; }
123
124   void SetPreCADEpsNano(double theVal);
125   double GetPreCADEpsNano() const { return _preCADEpsNano; }
126     
127   typedef std::map<std::string,std::string> TSizeMap;
128
129   void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap );
130   std::string  GetSizeMapEntry(const std::string& entry);
131   const TSizeMap& _GetSizeMapEntries() const { return _sizeMap; }
132   /*!
133    * \brief Return the size maps
134    */
135   static TSizeMap GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp);
136
137
138   void SetAttractorEntry(const std::string& entry,const std::string& attractor );
139   std::string GetAttractorEntry(const std::string& entry);
140   const TSizeMap& _GetAttractorEntries() const { return _attractors; };
141   /*!
142    * \brief Return the attractors
143    */
144   static TSizeMap GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
145
146
147 /*
148   void SetCustomSizeMapEntry(const std::string& entry,const std::string& sizeMap );
149   std::string  GetCustomSizeMapEntry(const std::string& entry);
150   void UnsetCustomSizeMap(const std::string& entry);
151   const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; }
152  */
153   
154   typedef std::map< std::string, BLSURFPlugin_Attractor* > TAttractorMap;
155   typedef std::map< std::string, std::vector<double> > TParamsMap; //TODO à finir 
156   
157   void SetClassAttractorEntry(const std::string& entry, const std::string& att_entry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius);
158   std::string  GetClassAttractorEntry(const std::string& entry);
159   const TAttractorMap& _GetClassAttractorEntries() const { return _classAttractors; }
160   /*!
161    * \brief Return the attractors entries
162    */
163   static TAttractorMap GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
164
165   /*!
166    * To set/get/unset an enforced vertex
167    */
168   // Name
169   typedef std::string TEnfName;
170   // Entry
171   typedef std::string TEntry;
172   // List of entries
173   typedef std::set<TEntry> TEntryList;
174   // Group name
175   typedef std::string TEnfGroupName;
176   // Coordinates
177   typedef std::vector<double> TEnfVertexCoords;
178   typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
179
180   // Enforced vertex
181   struct TEnfVertex {
182     TEnfName name;
183     TEntry geomEntry;
184     TEnfVertexCoords coords;
185     TEnfGroupName grpName;
186     TEntryList faceEntries;
187   };
188     
189   struct CompareEnfVertices
190   {
191     bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
192       if (e1 && e2) {
193         if (e1->coords.size() && e2->coords.size())
194           return (e1->coords < e2->coords);
195         else
196           return (e1->geomEntry < e2->geomEntry);
197       }
198       return false;
199     }
200   };
201
202   // List of enforced vertices
203   typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
204
205   // Map Face Entry / List of enforced vertices
206   typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
207
208   // List of Face Entry with internal enforced vertices activated
209   typedef std::set< TEntry > TFaceEntryInternalVerticesList;
210
211   // Map Face Entry / List of coords
212   typedef std::map< TEntry, TEnfVertexCoordsList > TFaceEntryCoordsListMap;
213
214   // Map Face Entry / List of Vertex entry
215   typedef std::map< TEntry, TEntryList > TFaceEntryEnfVertexEntryListMap;
216   
217   // Map Coords / Enforced vertex
218   typedef std::map< TEnfVertexCoords, TEnfVertex* > TCoordsEnfVertexMap;
219
220   // Map Vertex entry / Enforced vertex
221   typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap;
222
223   typedef std::map< TEnfGroupName, std::set<int> > TGroupNameNodeIDMap;
224   /* TODO GROUPS
225   // Map Group Name / List of enforced vertices
226   typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap;
227   */
228
229   
230   bool                  SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, TEnfGroupName theGroupName,
231                                           double x = 0.0, double y = 0.0, double z = 0.0);
232   TEnfVertexList        GetEnfVertexList(const TEntry& theFaceEntry) throw (std::invalid_argument);
233   TEnfVertexCoordsList  GetEnfVertexCoordsList(const TEntry& theFaceEntry) throw (std::invalid_argument);
234   TEntryList            GetEnfVertexEntryList (const TEntry& theFaceEntry) throw (std::invalid_argument);
235   TEnfVertex*           GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument);
236   TEnfVertex*           GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument);
237   void                  AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID);
238   std::set<int>         GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument);
239   void                  RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument);
240   
241   bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument);
242   bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument);
243
244   void ClearAllEnforcedVertices();
245
246   const TFaceEntryEnfVertexListMap  _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; }
247   const TEnfVertexList              _GetAllEnforcedVertices() const { return _enfVertexList; }
248
249   const TFaceEntryCoordsListMap     _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; }
250   const TCoordsEnfVertexMap         _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; }
251
252   const TFaceEntryEnfVertexEntryListMap _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; }
253   const TEnfVertexEntryEnfVertexMap     _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; }
254
255 //   TODO GROUPS
256 //   const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; }
257   
258
259   /*!
260    * \brief Return the enforced vertices
261    */
262   static TFaceEntryEnfVertexListMap       GetAllEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp);
263   static TEnfVertexList                   GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp);
264
265   static TFaceEntryCoordsListMap          GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp);
266   static TCoordsEnfVertexMap              GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp);
267
268   static TFaceEntryEnfVertexEntryListMap  GetAllEnfVertexEntriesByFace(const BLSURFPlugin_Hypothesis* hyp);
269   static TEnfVertexEntryEnfVertexMap      GetAllEnforcedVerticesByEnfVertexEntry(const BLSURFPlugin_Hypothesis* hyp);
270
271   /*!
272    * \brief Internal enforced vertices
273    */
274   void SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices);
275   const bool _GetInternalEnforcedVertexAllFaces() const { return _enforcedInternalVerticesAllFaces; }
276   static bool GetInternalEnforcedVertexAllFaces( const BLSURFPlugin_Hypothesis* hyp );
277   void SetInternalEnforcedVertexAllFacesGroup(TEnfGroupName theGroupName);
278   const TEnfGroupName _GetInternalEnforcedVertexAllFacesGroup() const { return _enforcedInternalVerticesAllFacesGroup; }
279   static TEnfGroupName GetInternalEnforcedVertexAllFacesGroup( const BLSURFPlugin_Hypothesis* hyp );
280
281 //  Enable internal enforced vertices on specific face if requested by user
282 //  static TFaceEntryInternalVerticesList GetDefaultFaceEntryInternalVerticesMap() { return TFaceEntryInternalVerticesList(); }
283 //  const TFaceEntryInternalVerticesList  _GetAllInternalEnforcedVerticesByFace() const { return _faceEntryInternalVerticesList; }
284 //  static TFaceEntryInternalVerticesList GetAllInternalEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp);
285 //  void SetInternalEnforcedVertex(TEntry theFaceEntry, bool toEnforceInternalVertices, TEnfGroupName theGroupName);
286 //  bool GetInternalEnforcedVertex(const TEntry& theFaceEntry);
287
288   static Topology        GetDefaultTopology();
289   static PhysicalMesh    GetDefaultPhysicalMesh();
290   static double          GetDefaultPhySize();
291   static double          GetDefaultMaxSize();
292   static double          GetDefaultMinSize();
293   static GeometricMesh   GetDefaultGeometricMesh();
294   static double          GetDefaultAngleMeshS();
295   static double          GetDefaultAngleMeshC() { return GetDefaultAngleMeshS(); }
296   static double          GetDefaultGradation();
297   static bool            GetDefaultQuadAllowed();
298   static bool            GetDefaultDecimesh();
299   static int             GetDefaultVerbosity() { return 10; }
300   // PreCAD
301   static bool            GetDefaultPreCADMergeEdges() { return false; }
302   static bool            GetDefaultPreCADRemoveNanoEdges() { return false; }
303   static bool            GetDefaultPreCADDiscardInput() { return false; }
304   static double          GetDefaultPreCADEpsNano();
305   
306   static TSizeMap        GetDefaultSizeMap() { return TSizeMap();}
307   static TAttractorMap   GetDefaultAttractorMap() { return TAttractorMap(); }
308
309   static TFaceEntryEnfVertexListMap       GetDefaultFaceEntryEnfVertexListMap() { return TFaceEntryEnfVertexListMap(); }
310   static TEnfVertexList                   GetDefaultEnfVertexList() { return TEnfVertexList(); }
311   static TFaceEntryCoordsListMap          GetDefaultFaceEntryCoordsListMap() { return TFaceEntryCoordsListMap(); }
312   static TCoordsEnfVertexMap              GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); }
313   static TFaceEntryEnfVertexEntryListMap  GetDefaultFaceEntryEnfVertexEntryListMap() { return TFaceEntryEnfVertexEntryListMap(); }
314   static TEnfVertexEntryEnfVertexMap      GetDefaultEnfVertexEntryEnfVertexMap() { return TEnfVertexEntryEnfVertexMap(); }
315   static TGroupNameNodeIDMap              GetDefaultGroupNameNodeIDMap() { return TGroupNameNodeIDMap(); }
316
317   static bool            GetDefaultInternalEnforcedVertex();
318
319   /* TODO GROUPS
320   static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); }
321   static TEnfVertexGroupNameMap     GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); }
322   */
323
324   static double undefinedDouble() { return -1.0; }
325
326   typedef std::map< std::string, std::string > TOptionValues;
327   typedef std::set< std::string >              TOptionNames;
328
329   void SetOptionValue(const std::string& optionName,
330                       const std::string& optionValue) throw (std::invalid_argument);
331   void SetPreCADOptionValue(const std::string& optionName,
332                             const std::string& optionValue) throw (std::invalid_argument);
333   std::string GetOptionValue(const std::string& optionName) throw (std::invalid_argument);
334   std::string GetPreCADOptionValue(const std::string& optionName) throw (std::invalid_argument);
335   void ClearOption(const std::string& optionName);
336   void ClearPreCADOption(const std::string& optionName);
337   const TOptionValues& GetOptionValues() const { return _option2value; }
338   const TOptionValues& GetPreCADOptionValues() const { return _preCADoption2value; }
339
340   /*!
341     * Sets the file for export resulting mesh in GMF format
342     */
343 //   void SetGMFFile(const std::string& theFileName, bool isBinary);
344   void SetGMFFile(const std::string& theFileName);
345   std::string GetGMFFile() const { return _GMFFileName; }
346   static std::string GetDefaultGMFFile();
347 //   bool GetGMFFileMode() const { return _GMFFileMode; }
348   
349   // Persistence
350   virtual std::ostream & SaveTo(std::ostream & save);
351   virtual std::istream & LoadFrom(std::istream & load);
352   friend std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp);
353   friend std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp);
354
355   /*!
356    * \brief Does nothing
357    * \param theMesh - the built mesh
358    * \param theShape - the geometry of interest
359    * \retval bool - always false
360    */
361   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
362
363   /*!
364    * \brief Initialize my parameter values by default parameters.
365    *  \retval bool - true if parameter values have been successfully defined
366    */
367   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
368
369
370 private:
371   Topology        _topology;
372   PhysicalMesh    _physicalMesh;
373   double          _phySize, _phyMin, _phyMax;
374   GeometricMesh   _geometricMesh;
375   double          _angleMeshS, _angleMeshC, _hgeoMin, _hgeoMax;
376   double          _gradation;
377   bool            _quadAllowed;
378   bool            _decimesh;
379   int             _verb;
380   
381   bool            _preCADMergeEdges;
382   bool            _preCADRemoveNanoEdges;
383   bool            _preCADDiscardInput;
384   double          _preCADEpsNano;
385   
386   TOptionValues   _option2value, _preCADoption2value;
387   TOptionNames    _doubleOptions, _charOptions, _preCADdoubleOptions, _preCADcharOptions;
388   TSizeMap        _sizeMap;
389   TSizeMap        _attractors;
390   TAttractorMap   _classAttractors;
391   TSizeMap        _attEntry;
392   TParamsMap      _attParams;
393
394   TFaceEntryEnfVertexListMap  _faceEntryEnfVertexListMap;
395   TEnfVertexList              _enfVertexList;
396   // maps to get "manual" enf vertex (through their coordinates)
397   TFaceEntryCoordsListMap     _faceEntryCoordsListMap;
398   TCoordsEnfVertexMap         _coordsEnfVertexMap;
399   // maps to get "geom" enf vertex (through their geom entries)
400   TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap;
401   TEnfVertexEntryEnfVertexMap     _enfVertexEntryEnfVertexMap;
402   TGroupNameNodeIDMap             _groupNameNodeIDMap;
403   
404 //  Enable internal enforced vertices on specific face if requested by user
405 //  TFaceEntryInternalVerticesList  _faceEntryInternalVerticesList;
406   bool            _enforcedInternalVerticesAllFaces;
407   TEnfGroupName   _enforcedInternalVerticesAllFacesGroup;
408   
409   std::string     _GMFFileName;
410 //   bool            _GMFFileMode;
411
412 //   TSizeMap      _customSizeMap;
413 };
414
415 #endif