Salome HOME
Update copyrights
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_Hypothesis_i.hxx
1 // Copyright (C) 2007-2019  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_i.hxx
25 // Author    : Michael Sazonov (OCN)
26 // Date      : 03/04/2006
27 // Project   : SALOME
28 //=============================================================================
29 //
30 #ifndef _NETGENPlugin_Hypothesis_i_HXX_
31 #define _NETGENPlugin_Hypothesis_i_HXX_
32
33 #include "NETGENPlugin_Defs.hxx"
34
35 #include <SALOMEconfig.h>
36 #include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm)
37
38 #include "SMESH_Hypothesis_i.hxx"
39 #include "NETGENPlugin_Hypothesis.hxx"
40
41 class SMESH_Gen;
42 //class GEOM_Object;
43
44 // NETGENPlugin parameters hypothesis
45
46 class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i:
47   public virtual POA_NETGENPlugin::NETGENPlugin_Hypothesis,
48   public virtual SMESH_Hypothesis_i
49 {
50  public:
51   // Constructor
52   NETGENPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
53                              ::SMESH_Gen*            theGenImpl);
54   // Destructor
55   virtual ~NETGENPlugin_Hypothesis_i();
56
57   void SetMaxSize(CORBA::Double theSize);
58   CORBA::Double GetMaxSize();
59
60   void SetMinSize(CORBA::Double theSize);
61   CORBA::Double GetMinSize();
62
63   void SetSecondOrder(CORBA::Boolean theVal);
64   CORBA::Boolean GetSecondOrder();
65
66   void SetOptimize(CORBA::Boolean theVal);
67   CORBA::Boolean GetOptimize();
68
69   void SetFineness(CORBA::Long theFineness);
70   CORBA::Long GetFineness();
71
72   void SetGrowthRate(CORBA::Double theRate);
73   CORBA::Double GetGrowthRate();
74
75   void SetNbSegPerEdge(CORBA::Double theVal);
76   CORBA::Double GetNbSegPerEdge();
77
78   void SetNbSegPerRadius(CORBA::Double theVal);
79   CORBA::Double GetNbSegPerRadius();
80
81   void SetChordalErrorEnabled(CORBA::Boolean value);
82   CORBA::Boolean GetChordalErrorEnabled();
83   void SetChordalError(CORBA::Double value);
84   CORBA::Double GetChordalError();
85
86   void SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double localSize)
87     throw (SALOME::SALOME_Exception);
88   void SetLocalSizeOnEntry(const char* entry, CORBA::Double localSize);
89   CORBA::Double GetLocalSizeOnEntry(const char* entry);
90   NETGENPlugin::string_array* GetLocalSizeEntries();
91   void UnsetLocalSizeOnEntry(const char* entry);
92
93   void SetMeshSizeFile(const char* fileName);
94   char* GetMeshSizeFile();
95
96   void SetQuadAllowed(CORBA::Boolean theVal);
97   CORBA::Boolean GetQuadAllowed();
98
99   void SetUseSurfaceCurvature(CORBA::Boolean theVal);
100   CORBA::Boolean GetUseSurfaceCurvature();
101
102   void SetFuseEdges(CORBA::Boolean theVal);
103   CORBA::Boolean GetFuseEdges();
104
105   void    SetNbSurfOptSteps(CORBA::Short nb );
106   CORBA::Short GetNbSurfOptSteps();
107
108   void    SetNbVolOptSteps(CORBA::Short nb );
109   CORBA::Short GetNbVolOptSteps();
110
111   void    SetElemSizeWeight(CORBA::Double size );
112   CORBA::Double GetElemSizeWeight();
113
114   void    SetWorstElemMeasure(CORBA::Short val );
115   CORBA::Short GetWorstElemMeasure();
116
117   void    SetUseDelauney(CORBA::Boolean toUse);
118   CORBA::Boolean GetUseDelauney();
119
120   void    SetCheckOverlapping(CORBA::Boolean toCheck );
121   CORBA::Boolean GetCheckOverlapping();
122
123   void    SetCheckChartBoundary(CORBA::Boolean toCheck );
124   CORBA::Boolean GetCheckChartBoundary();
125
126   // Get implementation
127   ::NETGENPlugin_Hypothesis* GetImpl();
128
129   // Verify whether hypothesis supports given entity type 
130   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
131
132
133   // Methods for copying mesh definition to other geometry
134
135   // Return geometry this hypothesis depends on. Return false if there is no geometry parameter
136   virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
137                                    std::vector< int >         & subIDArray ) const;
138
139   // Set new geometry instead of that returned by getObjectsDependOn()
140   virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
141                                    std::vector< int >         & subIDArray );
142
143  protected:
144
145   // to remember whether a parameter is already set (issue 0021364)
146   enum SettingMethod
147   {
148     METH_SetMaxSize             = 1,
149     METH_SetMinSize             = 2,
150     METH_SetSecondOrder         = 4,
151     METH_SetOptimize            = 8,
152     METH_SetFineness            = 16,
153     METH_SetGrowthRate          = 32,
154     METH_SetNbSegPerEdge        = 64,
155     METH_SetNbSegPerRadius      = 128,
156     METH_SetLocalSizeOnEntry    = 256,
157     METH_SetQuadAllowed         = METH_SetLocalSizeOnEntry * 2,
158     METH_SetSurfaceCurvature    = METH_SetQuadAllowed * 2,
159     METH_SetFuseEdges           = METH_SetSurfaceCurvature * 2,
160     METH_SetChordalErrorEnabled = METH_SetFuseEdges * 2,
161     METH_SetChordalError        = METH_SetChordalErrorEnabled * 2,
162     METH_LAST                   = METH_SetChordalError
163   };
164   int mySetMethodFlags;
165
166   // Return true if a parameter is not yet set, else return true if a parameter changes.
167   // PythonDumping depends on the result of this function.
168   // Checking only change of a parameter is not enough because then the default values are
169   // not dumped and if the defaults will change then the behaviour of scripts
170   // created without dump of the default parameters will also change what is not good.
171   template<typename T>
172     bool isToSetParameter(T curValue, T newValue, /*SettingMethod*/int meth)
173   {
174     if ( mySetMethodFlags & meth ) // already set, check if a value is changing
175       return ( curValue != newValue );
176     else
177       return ( mySetMethodFlags |= meth ); // == return true
178   }
179
180  public:
181   // method intended to remove explicit treatment of Netgen hypotheses from
182   // SMESH_NoteBook to assure backward compatibility after implemeneting
183   // issue 0021308: Remove hard-coded dependency of the external mesh plugins
184   virtual int getParamIndex(const TCollection_AsciiString& method, int nbVars) const;
185
186   // method used to convert variable parameters stored in an old study
187   // into myMethod2VarParams. It should return a method name for an index of
188   // variable parameters. Index is countered from zero
189   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
190 };
191
192 #endif