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