Salome HOME
bos #20256: [CEA 18523] Porting SMESH to int 64 bits
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis.hxx
1 // Copyright (C) 2007-2021  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    : 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 <smIdType.hxx>
40 #include "BLSURFPlugin_Attractor.hxx"
41
42 //  Parameters for work of MG-CADSurf
43
44 class BLSURFPlugin_Hypothesis: public SMESH_Hypothesis
45 {
46 public:
47   BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen, bool hasgeom);
48
49   enum Topology {
50     FromCAD,
51     Process,
52     Process2,
53     PreCAD
54   };
55
56   enum PhysicalMesh {
57     DefaultSize,
58     PhysicalGlobalSize,
59     PhysicalLocalSize
60   };
61
62   enum GeometricMesh {
63     DefaultGeom,
64     GeometricalGlobalSize,
65     GeometricalLocalSize
66   };
67
68   enum ElementType {
69     Triangles,
70     QuadrangleDominant,
71     Quadrangles
72   };
73
74   static const char* GetHypType(bool hasgeom)
75   { return hasgeom ? "MG-CADSurf Parameters" : "MG-CADSurf Parameters_NOGEOM"; }
76
77   TopoDS_Shape entryToShape(std::string entry);
78
79   static std::string GetMeshGemsVersion();
80
81   void SetPhysicalMesh(PhysicalMesh thePhysicalMesh);
82   PhysicalMesh GetPhysicalMesh() const { return _physicalMesh; }
83
84   void SetGeometricMesh(GeometricMesh theGeometricMesh);
85   GeometricMesh GetGeometricMesh() const { return _geometricMesh; }
86
87   void SetPhySize(double thePhySize, bool isRelative = false);
88   double GetPhySize() const { return _phySize; }
89   bool IsPhySizeRel() const { return _phySizeRel; }
90
91   void SetMinSize(double theMinSize, bool isRelative = false);
92   double GetMinSize() const { return _minSize; }
93   bool IsMinSizeRel() const { return _minSizeRel; }
94
95   void SetMaxSize(double theMaxSize, bool isRelative = false);
96   double GetMaxSize() const { return _maxSize; }
97   bool IsMaxSizeRel() const { return _maxSizeRel; }
98
99   void SetUseGradation(bool toUse);
100   bool GetUseGradation() const { return _useGradation; }
101   void SetGradation(double theGradation);
102   double GetGradation() const { return _gradation; }
103
104   void SetUseVolumeGradation(bool toUse);
105   bool GetUseVolumeGradation() const { return _useVolumeGradation; }
106   void SetVolumeGradation(double theGradation);
107   double GetVolumeGradation() const { return _volumeGradation; }
108
109   void SetElementType(ElementType theElementType);
110   ElementType GetElementType() const { return _elementType; }
111
112   void SetAngleMesh(double theAngle);
113   double GetAngleMesh() const { return _angleMesh; }
114
115   void SetChordalError(double theDistance);
116   double GetChordalError() const { return _chordalError; }
117
118   void SetAnisotropic(bool theVal);
119   bool GetAnisotropic() const { return _anisotropic; }
120
121   void SetAnisotropicRatio(double theVal);
122   double GetAnisotropicRatio() const { return _anisotropicRatio; }
123
124   void SetRemoveTinyEdges(bool theVal);
125   bool GetRemoveTinyEdges() const { return _removeTinyEdges; }
126
127   void SetTinyEdgeLength(double theVal);
128   double GetTinyEdgeLength() const { return _tinyEdgeLength; }
129
130   void SetOptimiseTinyEdges(bool theVal);
131   bool GetOptimiseTinyEdges() const { return _optimiseTinyEdges; }
132
133   void SetTinyEdgeOptimisationLength(double theVal);
134   double GetTinyEdgeOptimisationLength() const { return _tinyEdgeOptimisationLength; }
135
136   void SetCorrectSurfaceIntersection(bool theVal);
137   bool GetCorrectSurfaceIntersection() const { return _correctSurfaceIntersec; }
138
139   void SetCorrectSurfaceIntersectionMaxCost(double theVal);
140   double GetCorrectSurfaceIntersectionMaxCost() const { return _corrSurfaceIntersCost; }
141
142   void SetBadElementRemoval(bool theVal);
143   bool GetBadElementRemoval() const { return _badElementRemoval; }
144
145   void SetBadElementAspectRatio(double theVal);
146   double GetBadElementAspectRatio() const { return _badElementAspectRatio; }
147
148   void SetOptimizeMesh(bool theVal);
149   bool GetOptimizeMesh() const { return _optimizeMesh; }
150
151   void SetQuadraticMesh(bool theVal);
152   bool GetQuadraticMesh() const { return _quadraticMesh; }
153
154   void SetTopology(Topology theTopology);
155   Topology GetTopology() const { return _topology; }
156
157   bool GetUseSurfaceProximity() const { return _useSurfaceProximity; }
158   void SetUseSurfaceProximity( bool toUse );
159
160   int GetNbSurfaceProximityLayers() const { return _nbSurfaceProximityLayers; }
161   void SetNbSurfaceProximityLayers( int nbLayers );
162
163   double GetSurfaceProximityRatio() const { return _surfaceProximityRatio; }
164   void SetSurfaceProximityRatio( double ratio );
165
166   bool GetUseVolumeProximity() const { return _useVolumeProximity; }
167   void SetUseVolumeProximity( bool toUse );
168
169   int GetNbVolumeProximityLayers() const { return _nbVolumeProximityLayers; }
170   void SetNbVolumeProximityLayers( int nbLayers );
171
172   double GetVolumeProximityRatio() const { return _volumeProximityRatio; }
173   void SetVolumeProximityRatio( double ratio );
174
175   void SetVerbosity(int theVal);
176   int GetVerbosity() const { return _verb; }
177
178   void ClearEntry(const std::string& entry, const char * attEntry = 0);
179   void ClearSizeMaps();
180
181   void SetEnforceCadEdgesSize( bool toEnforce );
182   bool GetEnforceCadEdgesSize();
183
184   void SetJacobianRectificationRespectGeometry( bool allowRectification );
185   bool GetJacobianRectificationRespectGeometry();
186
187   void SetUseDeprecatedPatchMesher( bool useDeprecatedPatchMesher );
188   bool GetUseDeprecatedPatchMesher();
189
190   void SetJacobianRectification( bool allowRectification );
191   bool GetJacobianRectification();
192
193   void SetMaxNumberOfPointsPerPatch( int nb );
194   int  GetMaxNumberOfPointsPerPatch();
195
196   void SetMaxNumberOfThreads( int nb );
197   int  GetMaxNumberOfThreads();
198
199   void SetRespectGeometry( bool toRespect );
200   bool GetRespectGeometry();
201
202   void SetTinyEdgesAvoidSurfaceIntersections( bool toAvoidIntersection );
203   bool GetTinyEdgesAvoidSurfaceIntersections();
204
205   void SetClosedGeometry( bool isClosed );
206   bool GetClosedGeometry();
207
208   void SetDebug( bool isDebug );
209   bool GetDebug();
210
211   void SetPeriodicTolerance( double tol );
212   double GetPeriodicTolerance();
213
214   void SetRequiredEntities( const std::string& howToTreat );
215   std::string GetRequiredEntities();
216
217   void SetSewingTolerance( double tol );
218   double GetSewingTolerance();
219
220   void SetTags( const std::string& howToTreat );
221   std::string GetTags();
222
223   // Hyper-patches
224   typedef std::set< int > THyperPatchTags;
225   typedef std::vector< THyperPatchTags > THyperPatchList;
226   typedef std::set< std::string > THyperPatchEntries;
227   typedef std::vector< THyperPatchEntries > THyperPatchEntriesList;
228
229   void SetHyperPatches(const THyperPatchList& hpl, bool notifyMesh=true);
230   void SetHyperPatches(const THyperPatchEntriesList& hpl);
231   void SetHyperPatchIDsByEntry( const TopoDS_Shape&                          mainShape,
232                                 const std::map< std::string, TopoDS_Shape >& entryToShape);
233   const THyperPatchList&        GetHyperPatches() const { return _hyperPatchList; }
234   const THyperPatchEntriesList& GetHyperPatchEntries() const { return _hyperPatchEntriesList; }
235   static int GetHyperPatchTag( int faceTag, const BLSURFPlugin_Hypothesis* hyp, int* iPatch=0 );
236
237
238   void SetPreCADMergeEdges(bool theVal);
239   bool GetPreCADMergeEdges() const { return _preCADMergeEdges; }
240
241   void SetPreCADRemoveDuplicateCADFaces(bool theVal);
242   bool GetPreCADRemoveDuplicateCADFaces() const { return _preCADRemoveDuplicateCADFaces; }
243
244   void SetPreCADProcess3DTopology(bool theVal);
245   bool GetPreCADProcess3DTopology() const { return _preCADProcess3DTopology; }
246
247   void SetPreCADDiscardInput(bool theVal);
248   bool GetPreCADDiscardInput() const { return _preCADDiscardInput; }
249
250   static bool HasPreCADOptions(const BLSURFPlugin_Hypothesis* hyp);
251     
252   typedef std::map<std::string,std::string> TSizeMap;
253
254   void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap );
255   std::string  GetSizeMapEntry(const std::string& entry);
256   const TSizeMap& _GetSizeMapEntries() const { return _sizeMap; }
257   /*!
258    * \brief Return the size maps
259    */
260   static TSizeMap GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp);
261
262
263   void SetAttractorEntry(const std::string& entry,const std::string& attractor );
264   std::string GetAttractorEntry(const std::string& entry);
265   const TSizeMap& _GetAttractorEntries() const { return _attractors; };
266   /*!
267    * \brief Return the attractors
268    */
269   static TSizeMap GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
270
271
272 /*
273   void SetCustomSizeMapEntry(const std::string& entry,const std::string& sizeMap );
274   std::string  GetCustomSizeMapEntry(const std::string& entry);
275   void UnsetCustomSizeMap(const std::string& entry);
276   const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; }
277  */
278   
279   typedef std::multimap< std::string, BLSURFPlugin_Attractor* > TAttractorMap;
280   typedef std::map< std::string, std::vector<double> > TParamsMap; //TODO ?? finir 
281   
282   void SetClassAttractorEntry(const std::string& entry, const std::string& att_entry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius);
283   std::string  GetClassAttractorEntry(const std::string& entry);
284   const TAttractorMap& _GetClassAttractorEntries() const { return _classAttractors; }
285   /*!
286    * \brief Return the attractors entries
287    */
288   static TAttractorMap GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
289
290   /*!
291    * To set/get/unset an enforced vertex
292    */
293   // Name
294   typedef std::string TEnfName;
295   // Entry
296   typedef std::string TEntry;
297   // List of entries
298   typedef std::set<TEntry> TEntryList;
299   // Group name
300   typedef std::string TEnfGroupName;
301   // Coordinates
302   typedef std::vector<double> TEnfVertexCoords;
303   typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
304
305   // Enforced vertex
306   struct TEnfVertex {
307     TEnfName name;
308     TEntry geomEntry;
309     TEnfVertexCoords coords;
310     TEnfGroupName grpName;
311     TEntryList faceEntries;
312     TopoDS_Vertex vertex;
313   };
314     
315   struct CompareEnfVertices
316   {
317     bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
318       if (e1 && e2) {
319         if (e1->coords.size() && e2->coords.size())
320           return (e1->coords < e2->coords);
321         else
322           return (e1->geomEntry < e2->geomEntry);
323       }
324       return false;
325     }
326   };
327
328   // PreCad Face and Edge periodicity
329   struct TPreCadPeriodicity {
330     TEntry shape1Entry;
331     TEntry shape2Entry;
332     std::vector<std::string> theSourceVerticesEntries;
333     std::vector<std::string> theTargetVerticesEntries;
334   };
335
336   // Edge periodicity
337   struct TEdgePeriodicity {
338     TEntry theFace1Entry;
339     TEntry theEdge1Entry;
340     TEntry theFace2Entry;
341     TEntry theEdge2Entry;
342     int edge_orientation;
343   };
344
345   // Vertex periodicity
346   struct TVertexPeriodicity {
347     TEntry theEdge1Entry;
348     TEntry theVertex1Entry;
349     TEntry theEdge2Entry;
350     TEntry theVertex2Entry;
351   };
352
353   typedef std::pair< TEntry, TEntry > TFacesPeriodicity;
354
355   // List of enforced vertices
356   typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
357
358   // Map Face Entry / List of enforced vertices
359   typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
360
361   // List of Face Entry with internal enforced vertices activated
362   typedef std::set< TEntry > TFaceEntryInternalVerticesList;
363
364   // Map Face Entry / List of coords
365   typedef std::map< TEntry, TEnfVertexCoordsList > TFaceEntryCoordsListMap;
366
367   // Map Face Entry / List of Vertex entry
368   typedef std::map< TEntry, TEntryList > TFaceEntryEnfVertexEntryListMap;
369   
370   // Map Coords / Enforced vertex
371   typedef std::map< TEnfVertexCoords, TEnfVertex* > TCoordsEnfVertexMap;
372
373   // Map Vertex entry / Enforced vertex
374   typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap;
375
376   typedef std::map< TEnfGroupName, std::set<smIdType> > TGroupNameNodeIDMap;
377   /* TODO GROUPS
378   // Map Group Name / List of enforced vertices
379   typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap;
380   */
381
382   // Vector of pairs of entries
383   typedef std::vector< TPreCadPeriodicity > TPreCadPeriodicityVector;
384   typedef std::vector< TFacesPeriodicity > TFacesPeriodicityVector;
385   typedef std::vector< TEdgePeriodicity > TEdgesPeriodicityVector;
386   typedef std::vector< TVertexPeriodicity > TVerticesPeriodicityVector;
387   
388
389   bool                  SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, TEnfGroupName theGroupName,
390                                           double x = 0.0, double y = 0.0, double z = 0.0);
391   TEnfVertexList        GetEnfVertexList(const TEntry& theFaceEntry);
392   TEnfVertexCoordsList  GetEnfVertexCoordsList(const TEntry& theFaceEntry);
393   TEntryList            GetEnfVertexEntryList (const TEntry& theFaceEntry);
394   TEnfVertex*           GetEnfVertex(TEnfVertexCoords coords);
395   TEnfVertex*           GetEnfVertex(const TEntry& theEnfVertexEntry);
396   void                  AddEnfVertexNodeID(TEnfGroupName theGroupName,smIdType theNodeID);
397   std::set<smIdType>    GetEnfVertexNodeIDs(TEnfGroupName theGroupName);
398   void                  RemoveEnfVertexNodeID(TEnfGroupName theGroupName,smIdType theNodeID);
399   
400   bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="");
401   bool ClearEnforcedVertices(const TEntry& theFaceEntry);
402
403   void ClearAllEnforcedVertices();
404   void AddEnforcedVertex( const TEntry& theFaceEntry, TEnfVertex * theEnfVertex );
405
406   const TFaceEntryEnfVertexListMap&  _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; }
407   const TEnfVertexList&              _GetAllEnforcedVertices() const { return _enfVertexList; }
408
409   const TFaceEntryCoordsListMap&     _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; }
410   const TCoordsEnfVertexMap&         _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; }
411
412   const TFaceEntryEnfVertexEntryListMap& _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; }
413   const TEnfVertexEntryEnfVertexMap&     _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; }
414
415 //   TODO GROUPS
416 //   const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; }
417   
418
419   /*!
420    * \brief Return the enforced vertices
421    */
422   static TFaceEntryEnfVertexListMap       GetAllEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp);
423   static TEnfVertexList                   GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp);
424
425   static TFaceEntryCoordsListMap          GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp);
426   static TCoordsEnfVertexMap              GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp);
427
428   static TFaceEntryEnfVertexEntryListMap  GetAllEnfVertexEntriesByFace(const BLSURFPlugin_Hypothesis* hyp);
429   static TEnfVertexEntryEnfVertexMap      GetAllEnforcedVerticesByEnfVertexEntry(const BLSURFPlugin_Hypothesis* hyp);
430
431   /*!
432    * \brief Internal enforced vertices
433    */
434   void SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices);
435   bool _GetInternalEnforcedVertexAllFaces() const { return _enforcedInternalVerticesAllFaces; }
436   static bool GetInternalEnforcedVertexAllFaces( const BLSURFPlugin_Hypothesis* hyp );
437   void SetInternalEnforcedVertexAllFacesGroup(TEnfGroupName theGroupName);
438   const TEnfGroupName _GetInternalEnforcedVertexAllFacesGroup() const { return _enforcedInternalVerticesAllFacesGroup; }
439   static TEnfGroupName GetInternalEnforcedVertexAllFacesGroup( const BLSURFPlugin_Hypothesis* hyp );
440
441 //  Enable internal enforced vertices on specific face if requested by user
442 //  static TFaceEntryInternalVerticesList GetDefaultFaceEntryInternalVerticesMap() { return TFaceEntryInternalVerticesList(); }
443 //  const TFaceEntryInternalVerticesList  _GetAllInternalEnforcedVerticesByFace() const { return _faceEntryInternalVerticesList; }
444 //  static TFaceEntryInternalVerticesList GetAllInternalEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp);
445 //  void SetInternalEnforcedVertex(TEntry theFaceEntry, bool toEnforceInternalVertices, TEnfGroupName theGroupName);
446 //  bool GetInternalEnforcedVertex(const TEntry& theFaceEntry);
447
448   static PhysicalMesh    GetDefaultPhysicalMesh() { return PhysicalGlobalSize; }
449   static GeometricMesh   GetDefaultGeometricMesh() { return GeometricalGlobalSize; }
450   static double          GetDefaultPhySize(double diagonal, double bbSegmentation);
451   static double          GetDefaultPhySize() { return undefinedDouble(); }
452   static bool            GetDefaultPhySizeRel() { return false; }
453   static double          GetDefaultMinSize(double diagonal);
454   static double          GetDefaultMinSize() { return undefinedDouble(); }
455   static bool            GetDefaultMinSizeRel() { return false; }
456   static double          GetDefaultMaxSize(double diagonal);
457   static double          GetDefaultMaxSize() { return undefinedDouble(); }
458   static bool            GetDefaultMaxSizeRel() { return false; }
459   static bool            GetDefaultUseGradation() { return true; }
460   static double          GetDefaultGradation() { return 1.3; }
461   static bool            GetDefaultUseVolumeGradation() { return false; }
462   static double          GetDefaultVolumeGradation() { return 2; }
463   static ElementType     GetDefaultElementType() { return Triangles; }
464   static double          GetDefaultAngleMesh() { return 8.0; }
465   static bool            GetDefaultUseSurfaceProximity() { return false; }
466   static int             GetDefaultNbSurfaceProximityLayers() { return 1; }
467   static double          GetDefaultSurfaceProximityRatio() { return 1.; }
468   static bool            GetDefaultUseVolumeProximity() { return false; }
469   static int             GetDefaultNbVolumeProximityLayers() { return 1; }
470   static double          GetDefaultVolumeProximityRatio() { return 1.; }
471
472   static double          GetDefaultChordalError(double diagonal);
473   static double          GetDefaultChordalError() { return undefinedDouble(); }
474   static bool            GetDefaultAnisotropic() { return false; }
475   static double          GetDefaultAnisotropicRatio() { return 0.0; }
476   static bool            GetDefaultRemoveTinyEdges() { return false; }
477   static double          GetDefaultTinyEdgeLength(double diagonal);
478   static double          GetDefaultTinyEdgeLength() { return undefinedDouble(); }
479   static bool            GetDefaultOptimiseTinyEdges() { return false; }
480   static double          GetDefaultTinyEdgeOptimisationLength(double diagonal);
481   static double          GetDefaultTinyEdgeOptimisationLength() { return undefinedDouble(); }
482   static bool            GetDefaultCorrectSurfaceIntersection() { return true; }
483   static double          GetDefaultCorrectSurfaceIntersectionMaxCost() { return 15.; }
484   static bool            GetDefaultBadElementRemoval() { return false; }
485   static double          GetDefaultBadElementAspectRatio() {return 1000.0; }
486   static bool            GetDefaultOptimizeMesh() { return true; }
487   static bool            GetDefaultQuadraticMesh() { return false; }
488
489   static int             GetDefaultVerbosity() { return 3; }
490   static Topology        GetDefaultTopology() { return FromCAD; }
491   // PreCAD
492   static bool            GetDefaultPreCADMergeEdges() { return false; }
493   static bool            GetDefaultPreCADRemoveDuplicateCADFaces() { return false; }
494   static bool            GetDefaultPreCADProcess3DTopology() { return false; }
495   static bool            GetDefaultPreCADDiscardInput() { return false; }
496
497   static TSizeMap        GetDefaultSizeMap() { return TSizeMap();}
498   static TAttractorMap   GetDefaultAttractorMap() { return TAttractorMap(); }
499
500   static TFaceEntryEnfVertexListMap       GetDefaultFaceEntryEnfVertexListMap() { return TFaceEntryEnfVertexListMap(); }
501   static TEnfVertexList                   GetDefaultEnfVertexList() { return TEnfVertexList(); }
502   static TFaceEntryCoordsListMap          GetDefaultFaceEntryCoordsListMap() { return TFaceEntryCoordsListMap(); }
503   static TCoordsEnfVertexMap              GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); }
504   static TFaceEntryEnfVertexEntryListMap  GetDefaultFaceEntryEnfVertexEntryListMap() { return TFaceEntryEnfVertexEntryListMap(); }
505   static TEnfVertexEntryEnfVertexMap      GetDefaultEnfVertexEntryEnfVertexMap() { return TEnfVertexEntryEnfVertexMap(); }
506   static TGroupNameNodeIDMap              GetDefaultGroupNameNodeIDMap() { return TGroupNameNodeIDMap(); }
507
508   static bool            GetDefaultInternalEnforcedVertex() { return false; }
509
510   /* TODO GROUPS
511   static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); }
512   static TEnfVertexGroupNameMap     GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); }
513   */
514
515 //  const TPreCadPeriodicityEntriesVector _GetPreCadFacesPeriodicityEntries() const { return _preCadFacesPeriodicityEntriesVector; }
516
517   static TPreCadPeriodicityVector GetDefaultPreCadFacesPeriodicityVector() { return TPreCadPeriodicityVector(); }
518   const TPreCadPeriodicityVector&  _GetPreCadFacesPeriodicityVector() const { return _preCadFacesPeriodicityVector; }
519   static TPreCadPeriodicityVector GetPreCadFacesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
520
521   static TPreCadPeriodicityVector GetDefaultPreCadEdgesPeriodicityVector() { return TPreCadPeriodicityVector(); }
522   const TPreCadPeriodicityVector&  _GetPreCadEdgesPeriodicityVector() const { return _preCadEdgesPeriodicityVector; }
523   static TPreCadPeriodicityVector GetPreCadEdgesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
524
525   static TFacesPeriodicityVector GetDefaultFacesPeriodicityVector() { return TFacesPeriodicityVector(); }
526   const TFacesPeriodicityVector&  _GetFacesPeriodicityVector() const { return _facesPeriodicityVector; }
527   static TFacesPeriodicityVector GetFacesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
528
529   static TEdgesPeriodicityVector GetDefaultEdgesPeriodicityVector() { return TEdgesPeriodicityVector(); }
530   const TEdgesPeriodicityVector&  _GetEdgesPeriodicityVector() const { return _edgesPeriodicityVector; }
531   static TEdgesPeriodicityVector GetEdgesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
532
533   static TVerticesPeriodicityVector GetDefaultVerticesPeriodicityVector() { return TVerticesPeriodicityVector(); }
534   const TVerticesPeriodicityVector&  _GetVerticesPeriodicityVector() const { return _verticesPeriodicityVector; }
535   static TVerticesPeriodicityVector GetVerticesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
536
537   void ClearPreCadPeriodicityVectors();
538
539   void AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
540       std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries);
541   void AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
542       std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries);
543
544   static double undefinedDouble() { return -1.0; }
545
546   typedef std::map< std::string, std::string > TOptionValues;
547   typedef std::set< std::string >              TOptionNames;
548
549   void SetOptionValue(const std::string& optionName,
550                       const std::string& optionValue);
551   void SetPreCADOptionValue(const std::string& optionName,
552                             const std::string& optionValue);
553   std::string GetOptionValue(const std::string& optionName, bool* isDefault=0) const;
554   std::string GetPreCADOptionValue(const std::string& optionName, bool* isDefault=0) const;
555   void ClearOption(const std::string& optionName);
556   void ClearPreCADOption(const std::string& optionName);
557   TOptionValues        GetOptionValues()       const;
558   TOptionValues        GetPreCADOptionValues() const;
559   const TOptionValues& GetCustomOptionValues() const { return _customOption2value; }
560
561   void AddOption(const std::string& optionName, const std::string& optionValue);
562   void AddPreCADOption(const std::string& optionName, const std::string& optionValue);
563   std::string GetOption(const std::string& optionName) const;
564   std::string GetPreCADOption(const std::string& optionName) const;
565
566   static bool  ToBool(const std::string& str, bool* isOk=0);
567   static double ToDbl(const std::string& str, bool* isOk=0);
568   static int    ToInt(const std::string& str, bool* isOk=0);
569
570   /*!
571     * Sets the file for export resulting mesh in GMF format
572     */
573 //   void SetGMFFile(const std::string& theFileName, bool isBinary);
574   void SetGMFFile(const std::string& theFileName);
575   std::string GetGMFFile() const { return _GMFFileName; }
576   static std::string GetDefaultGMFFile() { return "";}
577 //   bool GetGMFFileMode() const { return _GMFFileMode; }
578   
579   // Persistence
580   virtual std::ostream & SaveTo(std::ostream & save);
581   virtual std::istream & LoadFrom(std::istream & load);
582   friend std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp);
583   friend std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp);
584
585   /*!
586    * \brief Does nothing
587    * \param theMesh - the built mesh
588    * \param theShape - the geometry of interest
589    * \retval bool - always false
590    */
591   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
592
593   /*!
594    * \brief Initialize my parameter values by default parameters.
595    *  \retval bool - true if parameter values have been successfully defined
596    */
597   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
598
599
600 private:
601   PhysicalMesh    _physicalMesh;
602   GeometricMesh   _geometricMesh;
603   double          _phySize;
604   bool            _phySizeRel;
605   double          _minSize, _maxSize;
606   bool            _minSizeRel, _maxSizeRel;
607   bool            _useGradation;
608   double          _gradation;
609   bool            _useVolumeGradation;
610   double          _volumeGradation;
611   ElementType     _elementType;
612   double          _angleMesh;
613   double          _chordalError;
614   bool            _anisotropic;
615   double          _anisotropicRatio;
616   bool            _removeTinyEdges;
617   double          _tinyEdgeLength;
618   bool            _optimiseTinyEdges;
619   double          _tinyEdgeOptimisationLength;
620   bool            _correctSurfaceIntersec;
621   double          _corrSurfaceIntersCost;
622   bool            _badElementRemoval;
623   double          _badElementAspectRatio;
624   bool            _optimizeMesh;
625   bool            _quadraticMesh;
626   int             _verb;
627   Topology        _topology;
628   bool            _useSurfaceProximity;
629   int             _nbSurfaceProximityLayers;
630   double          _surfaceProximityRatio;
631   bool            _useVolumeProximity;
632   int             _nbVolumeProximityLayers;
633   double          _volumeProximityRatio;
634
635   bool            _preCADMergeEdges;
636   bool            _preCADRemoveDuplicateCADFaces;
637   bool            _preCADProcess3DTopology;
638   bool            _preCADDiscardInput;
639   double          _preCADEpsNano;
640
641   TOptionValues   _option2value, _preCADoption2value, _customOption2value; // user defined values
642   TOptionValues   _defaultOptionValues;               // default values
643   TOptionNames    _doubleOptions, _charOptions, _boolOptions; // to find a type of option
644   TOptionNames    _preCADdoubleOptions, _preCADcharOptions;
645
646   TSizeMap        _sizeMap;
647   TSizeMap        _attractors;
648   TAttractorMap   _classAttractors;
649
650   TFaceEntryEnfVertexListMap      _faceEntryEnfVertexListMap;
651   TEnfVertexList                  _enfVertexList;
652   // maps to get "manual" enf vertex (through their coordinates)
653   TFaceEntryCoordsListMap         _faceEntryCoordsListMap;
654   TCoordsEnfVertexMap             _coordsEnfVertexMap;
655   // maps to get "geom" enf vertex (through their geom entries)
656   TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap;
657   TEnfVertexEntryEnfVertexMap     _enfVertexEntryEnfVertexMap;
658   TGroupNameNodeIDMap             _groupNameNodeIDMap;
659   
660 //  Enable internal enforced vertices on specific face if requested by user
661 //  TFaceEntryInternalVerticesList  _faceEntryInternalVerticesList;
662   bool            _enforcedInternalVerticesAllFaces;
663   TEnfGroupName   _enforcedInternalVerticesAllFacesGroup;
664   
665   TPreCadPeriodicityVector _preCadFacesPeriodicityVector;
666   TPreCadPeriodicityVector _preCadEdgesPeriodicityVector;
667
668   TFacesPeriodicityVector    _facesPeriodicityVector;
669   TEdgesPeriodicityVector    _edgesPeriodicityVector;
670   TVerticesPeriodicityVector _verticesPeriodicityVector;
671
672   THyperPatchList        _hyperPatchList;
673   THyperPatchEntriesList _hyperPatchEntriesList;
674
675   // Called by SaveTo to store content of _preCadFacesPeriodicityVector and _preCadEdgesPeriodicityVector
676   void SavePreCADPeriodicity(std::ostream & save, const char* shapeType);
677
678   // Called by LoadFrom to fill _preCadFacesPeriodicityVector and _preCadEdgesPeriodicityVector
679   void LoadPreCADPeriodicity(std::istream & load, const char* shapeType);
680
681   // Called by LoadFrom to fill _facesPeriodicityVector
682   void LoadFacesPeriodicity(std::istream & load);
683
684   // Called by LoadFrom to fill _edgesPeriodicityVector
685   void LoadEdgesPeriodicity(std::istream & load);
686
687   // Called by LoadFrom to fill _verticesPeriodicityVector
688   void LoadVerticesPeriodicity(std::istream & load);
689
690   // Called by SaveTo to store content of _facesPeriodicityVector
691   void SaveFacesPeriodicity(std::ostream & save);
692
693   // Called by SaveTo to store content of _edgesPeriodicityVector
694   void SaveEdgesPeriodicity(std::ostream & save);
695
696   // Called by SaveTo to store content of _verticesPeriodicityVector
697   void SaveVerticesPeriodicity(std::ostream & save);
698
699   std::string     _GMFFileName;
700 //   bool            _GMFFileMode;
701
702 //   TSizeMap      _customSizeMap;
703 };
704
705 #endif