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