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