Salome HOME
e8f54552487d7dffb0b1390ed73db54179e641d0
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_Hypothesis.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  NETGENPlugin : C++ implementation
24 // File      : NETGENPlugin_Hypothesis.hxx
25 // Author    : Michael Sazonov (OCN)
26 // Date      : 27/03/2006
27 // Project   : SALOME
28 //
29 #ifndef _NETGENPlugin_Hypothesis_HXX_
30 #define _NETGENPlugin_Hypothesis_HXX_
31
32 #include "NETGENPlugin_Defs.hxx"
33
34 #include "SMESH_Hypothesis.hxx"
35 #include "Utils_SALOME_Exception.hxx"
36
37 #include <map>
38
39 //  Parameters for work of NETGEN
40 //
41
42 using namespace std;
43
44 class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis: public SMESH_Hypothesis
45 {
46 public:
47
48   NETGENPlugin_Hypothesis(int hypId, SMESH_Gen * gen);
49
50   void   SetMaxSize(double theSize);
51   double GetMaxSize() const { return _maxSize; }
52
53   void   SetMinSize(double theSize);
54   double GetMinSize() const { return _minSize; }
55
56   void   SetSecondOrder(bool theVal);
57   bool   GetSecondOrder() const { return _secondOrder; }
58
59   void   SetOptimize(bool theVal);
60   bool   GetOptimize() const { return _optimize; }
61
62   enum Fineness
63   {
64     VeryCoarse,
65     Coarse,
66     Moderate,
67     Fine,
68     VeryFine,
69     UserDefined
70   };
71
72   void   SetFineness(Fineness theFineness);
73   Fineness GetFineness() const { return _fineness; }
74
75   // the following 3 parameters are controlled by Fineness
76
77   void   SetGrowthRate(double theRate);
78   double GetGrowthRate() const { return _growthRate; }
79
80   void   SetNbSegPerEdge(double theVal);
81   double GetNbSegPerEdge() const { return _nbSegPerEdge; }
82
83   void   SetNbSegPerRadius(double theVal);
84   double GetNbSegPerRadius() const { return _nbSegPerRadius; }
85
86   void   SetChordalErrorEnabled(bool value);
87   double GetChordalErrorEnabled() const { return _chordalErrorEnabled; }
88   void   SetChordalError(double value);
89   double GetChordalError() const { return _chordalError; }
90
91   typedef std::map<std::string, double> TLocalSize;
92   void   SetLocalSizeOnEntry(const std::string& entry, double localSize);
93   double GetLocalSizeOnEntry(const std::string& entry);
94   const TLocalSize& GetLocalSizesAndEntries() const { return _localSize; }
95   void   UnsetLocalSizeOnEntry(const std::string& entry);
96
97   void   SetMeshSizeFile(const std::string& fileName);
98   const std::string& GetMeshSizeFile() const { return _meshSizeFile; }
99
100   void   SetQuadAllowed(bool theVal);
101   bool   GetQuadAllowed() const { return _quadAllowed; }
102
103   void   SetSurfaceCurvature(bool theVal);
104   bool   GetSurfaceCurvature() const { return _surfaceCurvature; }
105
106   void   SetFuseEdges(bool theVal);
107   bool   GetFuseEdges() const { return _fuseEdges; }
108
109   void   SetNbSurfOptSteps( int nb );
110   int    GetNbSurfOptSteps() const { return _nbSurfOptSteps; }
111
112   void   SetNbVolOptSteps( int nb );
113   int    GetNbVolOptSteps() const { return _nbVolOptSteps; }
114
115   void   SetElemSizeWeight( double size );
116   double GetElemSizeWeight() const { return _elemSizeWeight; }
117
118   void   SetWorstElemMeasure( int val );
119   int    GetWorstElemMeasure() const { return _worstElemMeasure; }
120
121   void   SetUseDelauney( bool toUse);
122   bool   GetUseDelauney() const { return _useDelauney; }
123
124   void   SetCheckOverlapping( bool toCheck );
125   bool   GetCheckOverlapping() const { return _checkOverlapping; }
126
127   void   SetCheckChartBoundary( bool toCheck );
128   bool   GetCheckChartBoundary() const { return _checkChartBoundary; }
129
130   // the default values (taken from NETGEN 4.5 sources)
131
132   static Fineness GetDefaultFineness()          { return Moderate; }
133   static bool     GetDefaultSecondOrder()       { return false; }
134   static bool     GetDefaultQuadAllowed()       { return false; }
135   static double   GetDefaultMaxSize()           { return 1000; }
136   static double   GetDefaultGrowthRate()        { return 0.3; }
137   static double   GetDefaultNbSegPerRadius()    { return 2; }
138   static double   GetDefaultNbSegPerEdge()      { return 1; }
139   static double   GetDefaultChordalError()      { return -1; } // disabled by default
140   static bool     GetDefaultOptimize()          { return true; }
141   static int      GetDefaultNbSurfOptSteps()    { return 3; }
142   static int      GetDefaultNbVolOptSteps()     { return 3; }
143   static double   GetDefaultElemSizeWeight()    { return 0.2; }
144   static int      GetDefaultWorstElemMeasure()  { return 2; }
145   static bool     GetDefaultSurfaceCurvature()  { return true; }
146   static bool     GetDefaultUseDelauney()       { return true; }
147   static bool     GetDefaultCheckOverlapping()  { return true; }
148   static bool     GetDefaultCheckChartBoundary(){ return true; }
149   static bool     GetDefaultFuseEdges()         { return true; }
150
151   // Persistence
152   virtual std::ostream & SaveTo  (std::ostream & save);
153   virtual std::istream & LoadFrom(std::istream & load);
154
155   /*!
156    * \brief Does nothing
157    * \param theMesh - the built mesh
158    * \param theShape - the geometry of interest
159    * \retval bool - always false
160    */
161   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
162
163   /*!
164    * \brief Initialize my parameter values by default parameters.
165    *  \retval bool - true if parameter values have been successfully defined
166    */
167   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
168
169 private:
170
171   // General
172   Fineness      _fineness;
173   bool          _secondOrder;
174   bool          _quadAllowed;
175
176   // Mesh size
177   double        _maxSize, _minSize;
178   double        _growthRate;
179   std::string   _meshSizeFile;
180   double        _nbSegPerRadius;
181   double        _nbSegPerEdge;
182   // (SALOME additions)
183   TLocalSize    _localSize;
184   bool          _chordalErrorEnabled;
185   double        _chordalError;
186
187   // Optimizer
188   bool          _optimize;
189   int           _nbSurfOptSteps;
190   int           _nbVolOptSteps;
191   double        _elemSizeWeight;
192   int           _worstElemMeasure;
193
194   // Insider
195   bool          _surfaceCurvature;
196   bool          _useDelauney;
197   bool          _checkOverlapping;
198   bool          _checkChartBoundary;
199   //bool          _blockFilling; -- not used by netgen
200   // (SALOME additions)
201   bool          _fuseEdges;
202 };
203
204 #endif