Salome HOME
Revert "Merge branch 'yan/parallel_mesh2'"
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_Hypothesis.hxx
1 // Copyright (C) 2007-2022  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 class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis: public SMESH_Hypothesis
43 {
44 public:
45
46   NETGENPlugin_Hypothesis(int hypId, SMESH_Gen * gen);
47
48   void   SetMaxSize(double theSize);
49   double GetMaxSize() const { return _maxSize; }
50
51   void   SetMinSize(double theSize);
52   double GetMinSize() const { return _minSize; }
53
54   void   SetSecondOrder(bool theVal);
55   bool   GetSecondOrder() const { return _secondOrder; }
56
57   void   SetOptimize(bool theVal);
58   bool   GetOptimize() const { return _optimize; }
59
60   enum Fineness
61   {
62     VeryCoarse,
63     Coarse,
64     Moderate,
65     Fine,
66     VeryFine,
67     UserDefined
68   };
69
70   void   SetFineness(Fineness theFineness);
71   Fineness GetFineness() const { return _fineness; }
72
73   // the following 3 parameters are controlled by Fineness
74
75   void   SetGrowthRate(double theRate);
76   double GetGrowthRate() const { return _growthRate; }
77
78   void   SetNbSegPerEdge(double theVal);
79   double GetNbSegPerEdge() const { return _nbSegPerEdge; }
80
81   void   SetNbSegPerRadius(double theVal);
82   double GetNbSegPerRadius() const { return _nbSegPerRadius; }
83
84   void   SetChordalErrorEnabled(bool value);
85   double GetChordalErrorEnabled() const { return _chordalErrorEnabled; }
86   void   SetChordalError(double value);
87   double GetChordalError() const { return _chordalError; }
88
89   typedef std::map<std::string, double> TLocalSize;
90   void   SetLocalSizeOnEntry(const std::string& entry, double localSize);
91   double GetLocalSizeOnEntry(const std::string& entry);
92   const TLocalSize& GetLocalSizesAndEntries() const { return _localSize; }
93   void   UnsetLocalSizeOnEntry(const std::string& entry);
94
95   void   SetMeshSizeFile(const std::string& fileName);
96   const std::string& GetMeshSizeFile() const { return _meshSizeFile; }
97
98   void   SetQuadAllowed(bool theVal);
99   bool   GetQuadAllowed() const { return _quadAllowed; }
100
101   void   SetSurfaceCurvature(bool theVal);
102   bool   GetSurfaceCurvature() const { return _surfaceCurvature; }
103
104   void   SetFuseEdges(bool theVal);
105   bool   GetFuseEdges() const { return _fuseEdges; }
106
107   void   SetNbSurfOptSteps( int nb );
108   int    GetNbSurfOptSteps() const { return _nbSurfOptSteps; }
109
110   void   SetNbVolOptSteps( int nb );
111   int    GetNbVolOptSteps() const { return _nbVolOptSteps; }
112
113   void   SetElemSizeWeight( double size );
114   double GetElemSizeWeight() const { return _elemSizeWeight; }
115
116   void   SetWorstElemMeasure( int val );
117   int    GetWorstElemMeasure() const { return _worstElemMeasure; }
118
119   void   SetUseDelauney( bool toUse);
120   bool   GetUseDelauney() const { return _useDelauney; }
121
122   void   SetCheckOverlapping( bool toCheck );
123   bool   GetCheckOverlapping() const { return _checkOverlapping; }
124
125   void   SetCheckChartBoundary( bool toCheck );
126   bool   GetCheckChartBoundary() const { return _checkChartBoundary; }
127
128   // the default values (taken from NETGEN 4.5 sources)
129
130   static Fineness GetDefaultFineness()          { return Moderate; }
131   static bool     GetDefaultSecondOrder()       { return false; }
132   static bool     GetDefaultQuadAllowed()       { return false; }
133   static double   GetDefaultMaxSize()           { return 1000; }
134   static double   GetDefaultGrowthRate()        { return 0.3; }
135   static double   GetDefaultNbSegPerRadius()    { return 2; }
136   static double   GetDefaultNbSegPerEdge()      { return 1; }
137   static double   GetDefaultChordalError()      { return -1; } // disabled by default
138   static bool     GetDefaultOptimize()          { return true; }
139   static int      GetDefaultNbSurfOptSteps()    { return 3; }
140   static int      GetDefaultNbVolOptSteps()     { return 3; }
141   static double   GetDefaultElemSizeWeight()    { return 0.2; }
142   static int      GetDefaultWorstElemMeasure()  { return 2; }
143   static bool     GetDefaultSurfaceCurvature()  { return true; }
144   static bool     GetDefaultUseDelauney()       { return true; }
145   static bool     GetDefaultCheckOverlapping()  { return true; }
146   static bool     GetDefaultCheckChartBoundary(){ return true; }
147   static bool     GetDefaultFuseEdges()         { return true; }
148
149   // Persistence
150   virtual std::ostream & SaveTo  (std::ostream & save);
151   virtual std::istream & LoadFrom(std::istream & load);
152
153   /*!
154    * \brief Does nothing
155    * \param theMesh - the built mesh
156    * \param theShape - the geometry of interest
157    * \retval bool - always false
158    */
159   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
160
161   /*!
162    * \brief Initialize my parameter values by default parameters.
163    *  \retval bool - true if parameter values have been successfully defined
164    */
165   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
166
167 private:
168
169   // General
170   Fineness      _fineness;
171   bool          _secondOrder;
172   bool          _quadAllowed;
173
174   // Mesh size
175   double        _maxSize, _minSize;
176   double        _growthRate;
177   std::string   _meshSizeFile;
178   double        _nbSegPerRadius;
179   double        _nbSegPerEdge;
180   // (SALOME additions)
181   TLocalSize    _localSize;
182   bool          _chordalErrorEnabled;
183   double        _chordalError;
184
185   // Optimizer
186   bool          _optimize;
187   int           _nbSurfOptSteps;
188   int           _nbVolOptSteps;
189   double        _elemSizeWeight;
190   int           _worstElemMeasure;
191
192   // Insider
193   bool          _surfaceCurvature;
194   bool          _useDelauney;
195   bool          _checkOverlapping;
196   bool          _checkChartBoundary;
197   //bool          _blockFilling; -- not used by netgen
198   // (SALOME additions)
199   bool          _fuseEdges;
200 };
201
202 #endif