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