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