Salome HOME
de5af169f83168846dc585318dd0637646b8c869
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis.hxx
1 //  Copyright (C) 2007-2008  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.
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 // File    : BLSURFPlugin_Hypothesis.hxx
21 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
22 //           & Aurelien ALLEAUME (DISTENE)
23 //           Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
24 // ---
25 //
26 #ifndef _BLSURFPlugin_Hypothesis_HXX_
27 #define _BLSURFPlugin_Hypothesis_HXX_
28
29 #include "SMESH_Hypothesis.hxx"
30 #include <map>
31 #include <set>
32 #include <stdexcept>
33 #include <string>
34
35 //  Parameters for work of BLSURF
36
37 class BLSURFPlugin_Hypothesis: public SMESH_Hypothesis
38 {
39 public:
40   BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen);
41
42   enum Topology {
43     FromCAD,
44     Process,
45     Process2
46   };
47
48   enum PhysicalMesh {
49     DefaultSize,
50     PhysicalUserDefined
51   };
52
53   enum GeometricMesh {
54     DefaultGeom,
55     UserDefined
56   };
57
58   void SetTopology(Topology theTopology);
59   Topology GetTopology() const { return _topology; }
60
61   void SetPhysicalMesh(PhysicalMesh thePhysicalMesh);
62   PhysicalMesh GetPhysicalMesh() const { return _physicalMesh; }
63
64   void SetPhySize(double thePhySize);
65   double GetPhySize() const { return _phySize; }
66
67   void SetPhyMin(double theMinSize);
68   double GetPhyMin() const { return _phyMin; }
69
70   void SetPhyMax(double theMaxSize);
71   double GetPhyMax() const { return _phyMax; }
72
73   void SetGeometricMesh(GeometricMesh theGeometricMesh);
74   GeometricMesh GetGeometricMesh() const { return _geometricMesh; }
75
76   void SetAngleMeshS(double theAngle);
77   double GetAngleMeshS() const { return _angleMeshS; }
78
79   void SetAngleMeshC(double theAngle);
80   double GetAngleMeshC() const { return _angleMeshC; }
81
82   void SetGeoMin(double theMinSize);
83   double GetGeoMin() const { return _hgeoMin; }
84
85   void SetGeoMax(double theMaxSize);
86   double GetGeoMax() const { return _hgeoMax; }
87
88   void SetGradation(double theGradation);
89   double GetGradation() const { return _gradation; }
90
91   void SetQuadAllowed(bool theVal);
92   bool GetQuadAllowed() const { return _quadAllowed; }
93
94   void SetDecimesh(bool theVal);
95   bool GetDecimesh() const { return _decimesh; }
96
97   void SetVerbosity(int theVal);
98   int GetVerbosity() const { return _verb; }
99   
100   void ClearEntry(const std::string& entry);
101   void ClearSizeMaps();  
102
103   typedef std::map<std::string,std::string> TSizeMap;
104
105   void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap );
106   std::string  GetSizeMapEntry(const std::string& entry);
107   const TSizeMap& GetSizeMapEntries() const { return _sizeMap; }  
108
109
110   void SetAttractorEntry(const std::string& entry,const std::string& attractor );
111   std::string GetAttractorEntry(const std::string& entry);
112   const TSizeMap& GetAttractorEntries() const { return _attractors; };
113
114
115 /*
116   void SetCustomSizeMapEntry(const std::string& entry,const std::string& sizeMap );
117   std::string  GetCustomSizeMapEntry(const std::string& entry);
118   void UnsetCustomSizeMap(const std::string& entry);
119   const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; }
120  */
121
122   static Topology      GetDefaultTopology();
123   static PhysicalMesh  GetDefaultPhysicalMesh();
124   static double        GetDefaultPhySize();
125   static double        GetDefaultMaxSize();
126   static double        GetDefaultMinSize();
127   static GeometricMesh GetDefaultGeometricMesh();
128   static double        GetDefaultAngleMeshS();
129   static double        GetDefaultAngleMeshC() { return GetDefaultAngleMeshS(); }
130   static double        GetDefaultGradation();
131   static bool          GetDefaultQuadAllowed();
132   static bool          GetDefaultDecimesh();
133   static int           GetDefaultVerbosity() { return 10; }
134
135   static double undefinedDouble() { return -1.0; }
136
137   typedef std::map< std::string, std::string > TOptionValues;
138   typedef std::set< std::string >              TOptionNames;
139
140   void SetOptionValue(const std::string& optionName,
141                       const std::string& optionValue) throw (std::invalid_argument);
142   std::string GetOptionValue(const std::string& optionName) throw (std::invalid_argument);
143   void ClearOption(const std::string& optionName);
144   const TOptionValues& GetOptionValues() const { return _option2value; }
145
146   // Persistence
147   virtual std::ostream & SaveTo(std::ostream & save);
148   virtual std::istream & LoadFrom(std::istream & load);
149   friend std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp);
150   friend std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp);
151
152   /*!
153    * \brief Does nothing
154    * \param theMesh - the built mesh
155    * \param theShape - the geometry of interest
156    * \retval bool - always false
157    */
158   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
159
160   /*!
161    * \brief Initialize my parameter values by default parameters.
162    *  \retval bool - true if parameter values have been successfully defined
163    */
164   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
165
166 private:
167   Topology      _topology;
168   PhysicalMesh  _physicalMesh;
169   double        _phySize, _phyMin, _phyMax;
170   GeometricMesh _geometricMesh;
171   double        _angleMeshS, _angleMeshC, _hgeoMin, _hgeoMax;
172   double        _gradation;
173   bool          _quadAllowed;
174   bool          _decimesh;
175   int           _verb;
176   TOptionValues _option2value;
177   TOptionNames  _doubleOptions, _charOptions;
178   TSizeMap      _sizeMap;
179   TSizeMap      _attractors;
180 /*
181   TSizeMap      _customSizeMap;
182 */
183 };
184
185 #endif