Salome HOME
code improvement
[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, 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   static bool HasPreCADOptions(const BLSURFPlugin_Hypothesis* hyp);
205     
206   typedef std::map<std::string,std::string> TSizeMap;
207
208   void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap );
209   std::string  GetSizeMapEntry(const std::string& entry);
210   const TSizeMap& _GetSizeMapEntries() const { return _sizeMap; }
211   /*!
212    * \brief Return the size maps
213    */
214   static TSizeMap GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp);
215
216
217   void SetAttractorEntry(const std::string& entry,const std::string& attractor );
218   std::string GetAttractorEntry(const std::string& entry);
219   const TSizeMap& _GetAttractorEntries() const { return _attractors; };
220   /*!
221    * \brief Return the attractors
222    */
223   static TSizeMap GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
224
225
226 /*
227   void SetCustomSizeMapEntry(const std::string& entry,const std::string& sizeMap );
228   std::string  GetCustomSizeMapEntry(const std::string& entry);
229   void UnsetCustomSizeMap(const std::string& entry);
230   const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; }
231  */
232   
233   typedef std::multimap< std::string, BLSURFPlugin_Attractor* > TAttractorMap;
234   typedef std::map< std::string, std::vector<double> > TParamsMap; //TODO Ã  finir 
235   
236   void SetClassAttractorEntry(const std::string& entry, const std::string& att_entry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius);
237   std::string  GetClassAttractorEntry(const std::string& entry);
238   const TAttractorMap& _GetClassAttractorEntries() const { return _classAttractors; }
239   /*!
240    * \brief Return the attractors entries
241    */
242   static TAttractorMap GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
243
244   /*!
245    * To set/get/unset an enforced vertex
246    */
247   // Name
248   typedef std::string TEnfName;
249   // Entry
250   typedef std::string TEntry;
251   // List of entries
252   typedef std::set<TEntry> TEntryList;
253   // Group name
254   typedef std::string TEnfGroupName;
255   // Coordinates
256   typedef std::vector<double> TEnfVertexCoords;
257   typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
258
259   // Enforced vertex
260   struct TEnfVertex {
261     TEnfName name;
262     TEntry geomEntry;
263     TEnfVertexCoords coords;
264     TEnfGroupName grpName;
265     TEntryList faceEntries;
266     TopoDS_Vertex vertex;
267   };
268     
269   struct CompareEnfVertices
270   {
271     bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
272       if (e1 && e2) {
273         if (e1->coords.size() && e2->coords.size())
274           return (e1->coords < e2->coords);
275         else
276           return (e1->geomEntry < e2->geomEntry);
277       }
278       return false;
279     }
280   };
281
282   // PreCad Face and Edge periodicity
283   struct TPreCadPeriodicity {
284     TEntry shape1Entry;
285     TEntry shape2Entry;
286     std::vector<std::string> theSourceVerticesEntries;
287     std::vector<std::string> theTargetVerticesEntries;
288   };
289
290   // Edge periodicity
291   struct TEdgePeriodicity {
292     TEntry theFace1Entry;
293     TEntry theEdge1Entry;
294     TEntry theFace2Entry;
295     TEntry theEdge2Entry;
296     int edge_orientation;
297   };
298
299   // Vertex periodicity
300   struct TVertexPeriodicity {
301     TEntry theEdge1Entry;
302     TEntry theVertex1Entry;
303     TEntry theEdge2Entry;
304     TEntry theVertex2Entry;
305   };
306
307   typedef std::pair< TEntry, TEntry > TFacesPeriodicity;
308
309   // List of enforced vertices
310   typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
311
312   // Map Face Entry / List of enforced vertices
313   typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
314
315   // List of Face Entry with internal enforced vertices activated
316   typedef std::set< TEntry > TFaceEntryInternalVerticesList;
317
318   // Map Face Entry / List of coords
319   typedef std::map< TEntry, TEnfVertexCoordsList > TFaceEntryCoordsListMap;
320
321   // Map Face Entry / List of Vertex entry
322   typedef std::map< TEntry, TEntryList > TFaceEntryEnfVertexEntryListMap;
323   
324   // Map Coords / Enforced vertex
325   typedef std::map< TEnfVertexCoords, TEnfVertex* > TCoordsEnfVertexMap;
326
327   // Map Vertex entry / Enforced vertex
328   typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap;
329
330   typedef std::map< TEnfGroupName, std::set<int> > TGroupNameNodeIDMap;
331   /* TODO GROUPS
332   // Map Group Name / List of enforced vertices
333   typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap;
334   */
335
336   // Vector of pairs of entries
337   typedef std::vector< TPreCadPeriodicity > TPreCadPeriodicityVector;
338   typedef std::vector< TFacesPeriodicity > TFacesPeriodicityVector;
339   typedef std::vector< TEdgePeriodicity > TEdgesPeriodicityVector;
340   typedef std::vector< TVertexPeriodicity > TVerticesPeriodicityVector;
341   
342
343   bool                  SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, TEnfGroupName theGroupName,
344                                           double x = 0.0, double y = 0.0, double z = 0.0);
345   TEnfVertexList        GetEnfVertexList(const TEntry& theFaceEntry) throw (std::invalid_argument);
346   TEnfVertexCoordsList  GetEnfVertexCoordsList(const TEntry& theFaceEntry) throw (std::invalid_argument);
347   TEntryList            GetEnfVertexEntryList (const TEntry& theFaceEntry) throw (std::invalid_argument);
348   TEnfVertex*           GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument);
349   TEnfVertex*           GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument);
350   void                  AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID);
351   std::set<int>         GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument);
352   void                  RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument);
353   
354   bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument);
355   bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument);
356
357   void ClearAllEnforcedVertices();
358
359   const TFaceEntryEnfVertexListMap  _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; }
360   const TEnfVertexList              _GetAllEnforcedVertices() const { return _enfVertexList; }
361
362   const TFaceEntryCoordsListMap     _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; }
363   const TCoordsEnfVertexMap         _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; }
364
365   const TFaceEntryEnfVertexEntryListMap _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; }
366   const TEnfVertexEntryEnfVertexMap     _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; }
367
368 //   TODO GROUPS
369 //   const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; }
370   
371
372   /*!
373    * \brief Return the enforced vertices
374    */
375   static TFaceEntryEnfVertexListMap       GetAllEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp);
376   static TEnfVertexList                   GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp);
377
378   static TFaceEntryCoordsListMap          GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp);
379   static TCoordsEnfVertexMap              GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp);
380
381   static TFaceEntryEnfVertexEntryListMap  GetAllEnfVertexEntriesByFace(const BLSURFPlugin_Hypothesis* hyp);
382   static TEnfVertexEntryEnfVertexMap      GetAllEnforcedVerticesByEnfVertexEntry(const BLSURFPlugin_Hypothesis* hyp);
383
384   /*!
385    * \brief Internal enforced vertices
386    */
387   void SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices);
388   const bool _GetInternalEnforcedVertexAllFaces() const { return _enforcedInternalVerticesAllFaces; }
389   static bool GetInternalEnforcedVertexAllFaces( const BLSURFPlugin_Hypothesis* hyp );
390   void SetInternalEnforcedVertexAllFacesGroup(TEnfGroupName theGroupName);
391   const TEnfGroupName _GetInternalEnforcedVertexAllFacesGroup() const { return _enforcedInternalVerticesAllFacesGroup; }
392   static TEnfGroupName GetInternalEnforcedVertexAllFacesGroup( const BLSURFPlugin_Hypothesis* hyp );
393
394 //  Enable internal enforced vertices on specific face if requested by user
395 //  static TFaceEntryInternalVerticesList GetDefaultFaceEntryInternalVerticesMap() { return TFaceEntryInternalVerticesList(); }
396 //  const TFaceEntryInternalVerticesList  _GetAllInternalEnforcedVerticesByFace() const { return _faceEntryInternalVerticesList; }
397 //  static TFaceEntryInternalVerticesList GetAllInternalEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp);
398 //  void SetInternalEnforcedVertex(TEntry theFaceEntry, bool toEnforceInternalVertices, TEnfGroupName theGroupName);
399 //  bool GetInternalEnforcedVertex(const TEntry& theFaceEntry);
400
401   static PhysicalMesh    GetDefaultPhysicalMesh() { return PhysicalGlobalSize; }
402   static GeometricMesh   GetDefaultGeometricMesh() { return GeometricalGlobalSize; }
403   static double          GetDefaultPhySize(double diagonal, double bbSegmentation);
404   static double          GetDefaultPhySize() { return undefinedDouble(); }
405   static bool            GetDefaultPhySizeRel() { return false; }
406   static double          GetDefaultMinSize(double diagonal);
407   static double          GetDefaultMinSize() { return undefinedDouble(); }
408   static bool            GetDefaultMinSizeRel() { return false; }
409   static double          GetDefaultMaxSize(double diagonal);
410   static double          GetDefaultMaxSize() { return undefinedDouble(); }
411   static bool            GetDefaultMaxSizeRel() { return false; }
412   static bool            GetDefaultUseGradation() { return true; }
413   static double          GetDefaultGradation() { return 1.3; }
414   static bool            GetDefaultUseVolumeGradation() { return false; }
415   static double          GetDefaultVolumeGradation() { return 2; }
416   static bool            GetDefaultQuadAllowed() { return false; }
417   static double          GetDefaultAngleMesh() { return 8.0; }
418   
419   static double          GetDefaultChordalError(double diagonal);
420   static double          GetDefaultChordalError() { return undefinedDouble(); }
421   static bool            GetDefaultAnisotropic() { return false; }
422   static double          GetDefaultAnisotropicRatio() { return 0.0; }
423   static bool            GetDefaultRemoveTinyEdges() { return false; }
424   static double          GetDefaultTinyEdgeLength(double diagonal);
425   static double          GetDefaultTinyEdgeLength() { return undefinedDouble(); }
426   static bool            GetDefaultOptimiseTinyEdges() { return false; }
427   static double          GetDefaultTinyEdgeOptimisationLength(double diagonal);
428   static double          GetDefaultTinyEdgeOptimisationLength() { return undefinedDouble(); }
429   static bool            GetDefaultCorrectSurfaceIntersection() { return true; }
430   static double          GetDefaultCorrectSurfaceIntersectionMaxCost() { return 15.; }
431   static bool            GetDefaultBadElementRemoval() { return false; }
432   static double          GetDefaultBadElementAspectRatio() {return 1000.0; } 
433   static bool            GetDefaultOptimizeMesh() { return true; }
434   static bool            GetDefaultQuadraticMesh() { return false; }
435   
436   static int             GetDefaultVerbosity() { return 3; }
437   static Topology        GetDefaultTopology() { return FromCAD; }
438   // PreCAD
439   static bool            GetDefaultPreCADMergeEdges() { return false; }
440   static bool            GetDefaultPreCADRemoveTinyUVEdges() { return false; }
441   static bool            GetDefaultPreCADRemoveDuplicateCADFaces() { return false; }
442   static bool            GetDefaultPreCADProcess3DTopology() { return false; }
443   static bool            GetDefaultPreCADDiscardInput() { return false; }
444   
445   static TSizeMap        GetDefaultSizeMap() { return TSizeMap();}
446   static TAttractorMap   GetDefaultAttractorMap() { return TAttractorMap(); }
447
448   static TFaceEntryEnfVertexListMap       GetDefaultFaceEntryEnfVertexListMap() { return TFaceEntryEnfVertexListMap(); }
449   static TEnfVertexList                   GetDefaultEnfVertexList() { return TEnfVertexList(); }
450   static TFaceEntryCoordsListMap          GetDefaultFaceEntryCoordsListMap() { return TFaceEntryCoordsListMap(); }
451   static TCoordsEnfVertexMap              GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); }
452   static TFaceEntryEnfVertexEntryListMap  GetDefaultFaceEntryEnfVertexEntryListMap() { return TFaceEntryEnfVertexEntryListMap(); }
453   static TEnfVertexEntryEnfVertexMap      GetDefaultEnfVertexEntryEnfVertexMap() { return TEnfVertexEntryEnfVertexMap(); }
454   static TGroupNameNodeIDMap              GetDefaultGroupNameNodeIDMap() { return TGroupNameNodeIDMap(); }
455
456   static bool            GetDefaultInternalEnforcedVertex() { return false; }
457
458   /* TODO GROUPS
459   static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); }
460   static TEnfVertexGroupNameMap     GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); }
461   */
462
463 //  const TPreCadPeriodicityEntriesVector _GetPreCadFacesPeriodicityEntries() const { return _preCadFacesPeriodicityEntriesVector; }
464
465   static TPreCadPeriodicityVector GetDefaultPreCadFacesPeriodicityVector() { return TPreCadPeriodicityVector(); }
466   const TPreCadPeriodicityVector  _GetPreCadFacesPeriodicityVector() const { return _preCadFacesPeriodicityVector; }
467   static TPreCadPeriodicityVector GetPreCadFacesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
468
469   static TPreCadPeriodicityVector GetDefaultPreCadEdgesPeriodicityVector() { return TPreCadPeriodicityVector(); }
470   const TPreCadPeriodicityVector  _GetPreCadEdgesPeriodicityVector() const { return _preCadEdgesPeriodicityVector; }
471   static TPreCadPeriodicityVector GetPreCadEdgesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
472
473   static TFacesPeriodicityVector GetDefaultFacesPeriodicityVector() { return TFacesPeriodicityVector(); }
474   const TFacesPeriodicityVector  _GetFacesPeriodicityVector() const { return _facesPeriodicityVector; }
475   static TFacesPeriodicityVector GetFacesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
476
477   static TEdgesPeriodicityVector GetDefaultEdgesPeriodicityVector() { return TEdgesPeriodicityVector(); }
478   const TEdgesPeriodicityVector  _GetEdgesPeriodicityVector() const { return _edgesPeriodicityVector; }
479   static TEdgesPeriodicityVector GetEdgesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
480
481   static TVerticesPeriodicityVector GetDefaultVerticesPeriodicityVector() { return TVerticesPeriodicityVector(); }
482   const TVerticesPeriodicityVector  _GetVerticesPeriodicityVector() const { return _verticesPeriodicityVector; }
483   static TVerticesPeriodicityVector GetVerticesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
484
485   void ClearPreCadPeriodicityVectors();
486
487   void AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
488       std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries);
489   void AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
490       std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries);
491
492   static double undefinedDouble() { return -1.0; }
493
494   typedef std::map< std::string, std::string > TOptionValues;
495   typedef std::set< std::string >              TOptionNames;
496
497   void SetOptionValue(const std::string& optionName,
498                       const std::string& optionValue) throw (std::invalid_argument);
499   void SetPreCADOptionValue(const std::string& optionName,
500                             const std::string& optionValue) throw (std::invalid_argument);
501   std::string GetOptionValue(const std::string& optionName, bool* isDefault=0) const throw (std::invalid_argument);
502   std::string GetPreCADOptionValue(const std::string& optionName, bool* isDefault=0) const throw (std::invalid_argument);
503   void ClearOption(const std::string& optionName);
504   void ClearPreCADOption(const std::string& optionName);
505   TOptionValues        GetOptionValues()       const;
506   TOptionValues        GetPreCADOptionValues() const;
507   const TOptionValues& GetCustomOptionValues() const { return _customOption2value; }
508
509   void AddOption(const std::string& optionName, const std::string& optionValue);
510   void AddPreCADOption(const std::string& optionName, const std::string& optionValue);
511   std::string GetOption(const std::string& optionName) const;
512   std::string GetPreCADOption(const std::string& optionName) const;
513
514   static bool  ToBool(const std::string& str, bool* isOk=0) throw (std::invalid_argument);
515   static double ToDbl(const std::string& str, bool* isOk=0) throw (std::invalid_argument);
516   static int    ToInt(const std::string& str, bool* isOk=0) throw (std::invalid_argument);
517
518   /*!
519     * Sets the file for export resulting mesh in GMF format
520     */
521 //   void SetGMFFile(const std::string& theFileName, bool isBinary);
522   void SetGMFFile(const std::string& theFileName);
523   std::string GetGMFFile() const { return _GMFFileName; }
524   static std::string GetDefaultGMFFile() { return "";}
525 //   bool GetGMFFileMode() const { return _GMFFileMode; }
526   
527   // Persistence
528   virtual std::ostream & SaveTo(std::ostream & save);
529   virtual std::istream & LoadFrom(std::istream & load);
530   friend std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp);
531   friend std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp);
532
533   /*!
534    * \brief Does nothing
535    * \param theMesh - the built mesh
536    * \param theShape - the geometry of interest
537    * \retval bool - always false
538    */
539   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
540
541   /*!
542    * \brief Initialize my parameter values by default parameters.
543    *  \retval bool - true if parameter values have been successfully defined
544    */
545   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
546
547
548 private:
549   PhysicalMesh    _physicalMesh;
550   GeometricMesh   _geometricMesh;
551   double          _phySize;
552   bool            _phySizeRel;
553   double          _minSize, _maxSize;
554   bool            _minSizeRel, _maxSizeRel;
555   bool            _useGradation;
556   double          _gradation;
557   bool            _useVolumeGradation;
558   double          _volumeGradation;
559   bool            _quadAllowed;
560   double          _angleMesh;
561   double          _chordalError;
562   bool            _anisotropic;
563   double          _anisotropicRatio;
564   bool            _removeTinyEdges;
565   double          _tinyEdgeLength;
566   bool            _optimiseTinyEdges;
567   double          _tinyEdgeOptimisationLength;
568   bool            _correctSurfaceIntersec;
569   double          _corrSurfaceIntersCost;
570   bool            _badElementRemoval;
571   double          _badElementAspectRatio;
572   bool            _optimizeMesh;
573   bool            _quadraticMesh;
574   int             _verb;
575   Topology        _topology;
576   
577   bool            _preCADMergeEdges;
578   bool            _preCADRemoveTinyUVEdges;
579   bool            _preCADRemoveDuplicateCADFaces;
580   bool            _preCADProcess3DTopology;
581   bool            _preCADDiscardInput;
582   double          _preCADEpsNano;
583   
584   TOptionValues   _option2value, _preCADoption2value, _customOption2value; // user defined values
585   TOptionValues   _defaultOptionValues;               // default values
586   TOptionNames    _doubleOptions, _charOptions, _boolOptions; // to find a type of option
587   TOptionNames    _preCADdoubleOptions, _preCADcharOptions;
588
589   TSizeMap        _sizeMap;
590   TSizeMap        _attractors;
591   TAttractorMap   _classAttractors;
592   TSizeMap        _attEntry;
593   TParamsMap      _attParams;
594
595   TFaceEntryEnfVertexListMap      _faceEntryEnfVertexListMap;
596   TEnfVertexList                  _enfVertexList;
597   // maps to get "manual" enf vertex (through their coordinates)
598   TFaceEntryCoordsListMap         _faceEntryCoordsListMap;
599   TCoordsEnfVertexMap             _coordsEnfVertexMap;
600   // maps to get "geom" enf vertex (through their geom entries)
601   TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap;
602   TEnfVertexEntryEnfVertexMap     _enfVertexEntryEnfVertexMap;
603   TGroupNameNodeIDMap             _groupNameNodeIDMap;
604   
605 //  Enable internal enforced vertices on specific face if requested by user
606 //  TFaceEntryInternalVerticesList  _faceEntryInternalVerticesList;
607   bool            _enforcedInternalVerticesAllFaces;
608   TEnfGroupName   _enforcedInternalVerticesAllFacesGroup;
609   
610   TPreCadPeriodicityVector _preCadFacesPeriodicityVector;
611   TPreCadPeriodicityVector _preCadEdgesPeriodicityVector;
612
613   TFacesPeriodicityVector _facesPeriodicityVector;
614   TEdgesPeriodicityVector _edgesPeriodicityVector;
615   TVerticesPeriodicityVector _verticesPeriodicityVector;
616
617   // Called by SaveTo to store content of _preCadFacesPeriodicityVector and _preCadEdgesPeriodicityVector
618   void SavePreCADPeriodicity(std::ostream & save, const char* shapeType);
619
620   // Called by LoadFrom to fill _preCadFacesPeriodicityVector and _preCadEdgesPeriodicityVector
621   void LoadPreCADPeriodicity(std::istream & load, const char* shapeType);
622
623   // Called by LoadFrom to fill _facesPeriodicityVector
624   void LoadFacesPeriodicity(std::istream & load);
625
626   // Called by LoadFrom to fill _edgesPeriodicityVector
627   void LoadEdgesPeriodicity(std::istream & load);
628
629   // Called by LoadFrom to fill _verticesPeriodicityVector
630   void LoadVerticesPeriodicity(std::istream & load);
631
632   // Called by SaveTo to store content of _facesPeriodicityVector
633   void SaveFacesPeriodicity(std::ostream & save);
634
635   // Called by SaveTo to store content of _edgesPeriodicityVector
636   void SaveEdgesPeriodicity(std::ostream & save);
637
638   // Called by SaveTo to store content of _verticesPeriodicityVector
639   void SaveVerticesPeriodicity(std::ostream & save);
640
641   std::string     _GMFFileName;
642 //   bool            _GMFFileMode;
643
644 //   TSizeMap      _customSizeMap;
645 };
646
647 #endif