Salome HOME
Update copyright
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_Hypothesis_i.cxx
1 // Copyright (C) 2007-2011  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.
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.cxx
25 // Author    : Michael Sazonov (OCN)
26 // Date      : 03/04/2006
27 // Project   : SALOME
28 // $Header$
29 //=============================================================================
30 //
31 #include "NETGENPlugin_Hypothesis_i.hxx"
32 #include "SMESH_Gen.hxx"
33 #include "SMESH_PythonDump.hxx"
34 #include "GEOM_Object.hxx"
35
36 #include "Utils_CorbaException.hxx"
37 #include "utilities.h"
38
39 using namespace std;
40
41 //=============================================================================
42 /*!
43  *  NETGENPlugin_Hypothesis_i::NETGENPlugin_Hypothesis_i
44  *
45  *  Constructor
46  */
47 //=============================================================================
48 NETGENPlugin_Hypothesis_i::
49 NETGENPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
50                            int                     theStudyId,
51                            ::SMESH_Gen*            theGenImpl)
52   : SALOME::GenericObj_i( thePOA ), 
53     SMESH_Hypothesis_i( thePOA )
54 {
55   MESSAGE( "NETGENPlugin_Hypothesis_i::NETGENPlugin_Hypothesis_i" );
56   myBaseImpl = new ::NETGENPlugin_Hypothesis (theGenImpl->GetANewId(),
57                                               theStudyId,
58                                               theGenImpl);
59 }
60
61 //=============================================================================
62 /*!
63  *  NETGENPlugin_Hypothesis_i::~NETGENPlugin_Hypothesis_i
64  *
65  *  Destructor
66  */
67 //=============================================================================
68 NETGENPlugin_Hypothesis_i::~NETGENPlugin_Hypothesis_i()
69 {
70   MESSAGE( "NETGENPlugin_Hypothesis_i::~NETGENPlugin_Hypothesis_i" );
71 }
72
73 //=============================================================================
74 /*!
75  *  NETGENPlugin_Hypothesis_i::SetMaxSize
76  *
77  *  Set MaxSize
78  */
79 //=============================================================================
80 void NETGENPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue)
81 {
82   MESSAGE("NETGENPlugin_Hypothesis_i::SetMaxSize");
83   ASSERT(myBaseImpl);
84   this->GetImpl()->SetMaxSize(theValue);
85   SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )";
86 }
87
88 //=============================================================================
89 /*!
90  *  NETGENPlugin_Hypothesis_i::GetMaxSize
91  *
92  *  Get MaxSize
93  */
94 //=============================================================================
95 CORBA::Double NETGENPlugin_Hypothesis_i::GetMaxSize()
96 {
97   MESSAGE("NETGENPlugin_Hypothesis_i::GetMaxSize");
98   ASSERT(myBaseImpl);
99   return this->GetImpl()->GetMaxSize();
100 }
101
102 //=============================================================================
103 /*!
104  *  NETGENPlugin_Hypothesis_i::SetSecondOrder
105  *
106  *  Set SecondOrder flag
107  */
108 //=============================================================================
109 void NETGENPlugin_Hypothesis_i::SetSecondOrder (CORBA::Boolean theValue)
110 {
111   MESSAGE("NETGENPlugin_Hypothesis_i::SetSecondOrder");
112   ASSERT(myBaseImpl);
113   this->GetImpl()->SetSecondOrder(theValue);
114   SMESH::TPythonDump() << _this() << ".SetSecondOrder( " << theValue << " )";
115 }
116
117 //=============================================================================
118 /*!
119  *  NETGENPlugin_Hypothesis_i::GetSecondOrder
120  *
121  *  Get SecondOrder flag
122  */
123 //=============================================================================
124 CORBA::Boolean NETGENPlugin_Hypothesis_i::GetSecondOrder()
125 {
126   MESSAGE("NETGENPlugin_Hypothesis_i::GetSecondOrder");
127   ASSERT(myBaseImpl);
128   return this->GetImpl()->GetSecondOrder();
129 }
130
131 //=============================================================================
132 /*!
133  *  NETGENPlugin_Hypothesis_i::SetOptimize
134  *
135  *  Set Optimize flag
136  */
137 //=============================================================================
138 void NETGENPlugin_Hypothesis_i::SetOptimize (CORBA::Boolean theValue)
139 {
140   MESSAGE("NETGENPlugin_Hypothesis_i::SetOptimize");
141   ASSERT(myBaseImpl);
142   this->GetImpl()->SetOptimize(theValue);
143   SMESH::TPythonDump() << _this() << ".SetOptimize( " << theValue << " )";
144 }
145
146 //=============================================================================
147 /*!
148  *  NETGENPlugin_Hypothesis_i::GetOptimize
149  *
150  *  Get Optimize flag
151  */
152 //=============================================================================
153 CORBA::Boolean NETGENPlugin_Hypothesis_i::GetOptimize()
154 {
155   MESSAGE("NETGENPlugin_Hypothesis_i::GetOptimize");
156   ASSERT(myBaseImpl);
157   return this->GetImpl()->GetOptimize();
158 }
159
160 //=============================================================================
161 /*!
162  *  NETGENPlugin_Hypothesis_i::SetFineness
163  *
164  *  Set Fineness
165  */
166 //=============================================================================
167 void NETGENPlugin_Hypothesis_i::SetFineness (CORBA::Long theValue)
168 {
169   MESSAGE("NETGENPlugin_Hypothesis_i::SetFineness");
170   ASSERT(myBaseImpl);
171   this->GetImpl()->SetFineness((::NETGENPlugin_Hypothesis::Fineness)theValue);
172   SMESH::TPythonDump() << _this() << ".SetFineness( " << theValue << " )";
173 }
174
175 //=============================================================================
176 /*!
177  *  NETGENPlugin_Hypothesis_i::GetFineness
178  *
179  *  Get Fineness
180  */
181 //=============================================================================
182 CORBA::Long NETGENPlugin_Hypothesis_i::GetFineness()
183 {
184   MESSAGE("NETGENPlugin_Hypothesis_i::GetFineness");
185   ASSERT(myBaseImpl);
186   return this->GetImpl()->GetFineness();
187 }
188
189 //=============================================================================
190 /*!
191  *  NETGENPlugin_Hypothesis_i::SetGrowthRate
192  *
193  *  Set GrowthRate
194  */
195 //=============================================================================
196 void NETGENPlugin_Hypothesis_i::SetGrowthRate (CORBA::Double theValue)
197 {
198   MESSAGE("NETGENPlugin_Hypothesis_i::SetGrowthRate");
199   ASSERT(myBaseImpl);
200   this->GetImpl()->SetGrowthRate(theValue);
201   SMESH::TPythonDump() << _this() << ".SetGrowthRate( " << theValue << " )";
202 }
203
204 //=============================================================================
205 /*!
206  *  NETGENPlugin_Hypothesis_i::GetGrowthRate
207  *
208  *  Get GrowthRate
209  */
210 //=============================================================================
211 CORBA::Double NETGENPlugin_Hypothesis_i::GetGrowthRate()
212 {
213   MESSAGE("NETGENPlugin_Hypothesis_i::GetGrowthRate");
214   ASSERT(myBaseImpl);
215   return this->GetImpl()->GetGrowthRate();
216 }
217
218 //=============================================================================
219 /*!
220  *  NETGENPlugin_Hypothesis_i::SetNbSegPerEdge
221  *
222  *  Set NbSegPerEdge
223  */
224 //=============================================================================
225 void NETGENPlugin_Hypothesis_i::SetNbSegPerEdge (CORBA::Double theValue)
226 {
227   MESSAGE("NETGENPlugin_Hypothesis_i::SetNbSegPerEdge");
228   ASSERT(myBaseImpl);
229   this->GetImpl()->SetNbSegPerEdge(theValue);
230   SMESH::TPythonDump() << _this() << ".SetNbSegPerEdge( " << theValue << " )";
231 }
232
233 //=============================================================================
234 /*!
235  *  NETGENPlugin_Hypothesis_i::GetNbSegPerEdge
236  *
237  *  Get NbSegPerEdge
238  */
239 //=============================================================================
240 CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerEdge()
241 {
242   MESSAGE("NETGENPlugin_Hypothesis_i::GetNbSegPerEdge");
243   ASSERT(myBaseImpl);
244   return this->GetImpl()->GetNbSegPerEdge();
245 }
246
247 //=============================================================================
248 /*!
249  *  NETGENPlugin_Hypothesis_i::SetNbSegPerRadius
250  *
251  *  Set NbSegPerRadius
252  */
253 //=============================================================================
254 void NETGENPlugin_Hypothesis_i::SetNbSegPerRadius (CORBA::Double theValue)
255 {
256   MESSAGE("NETGENPlugin_Hypothesis_i::SetNbSegPerRadius");
257   ASSERT(myBaseImpl);
258   this->GetImpl()->SetNbSegPerRadius(theValue);
259   SMESH::TPythonDump() << _this() << ".SetNbSegPerRadius( " << theValue << " )";
260 }
261
262 //=============================================================================
263 /*!
264  *  NETGENPlugin_Hypothesis_i::GetNbSegPerRadius
265  *
266  *  Get NbSegPerRadius
267  */
268 //=============================================================================
269 CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerRadius()
270 {
271   MESSAGE("NETGENPlugin_Hypothesis_i::GetNbSegPerRadius");
272   ASSERT(myBaseImpl);
273   return this->GetImpl()->GetNbSegPerRadius();
274 }
275
276 //=============================================================================
277
278 void NETGENPlugin_Hypothesis_i::SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double localSize)
279 {
280   string entry;
281   entry = GeomObj->GetStudyEntry();
282   SetLocalSizeOnEntry(entry.c_str(), localSize);
283 }
284
285 //=============================================================================
286
287 void NETGENPlugin_Hypothesis_i::SetLocalSizeOnEntry(const char* entry, CORBA::Double localSize)
288 {
289   bool valueChanged = false;
290   valueChanged = ( this->GetImpl()->GetLocalSizeOnEntry(entry) != localSize );
291   if ( valueChanged )
292     this->GetImpl()->SetLocalSizeOnEntry(entry, localSize);
293   if ( valueChanged )
294     SMESH::TPythonDump() << _this() << ".SetLocalSizeOnShape(" << entry << ", " << localSize << ")";
295 }
296
297 //=============================================================================
298
299 CORBA::Double NETGENPlugin_Hypothesis_i::GetLocalSizeOnEntry(const char* entry)
300 {
301   return this->GetImpl()->GetLocalSizeOnEntry(entry);
302 }
303
304 //=============================================================================
305
306 NETGENPlugin::string_array* NETGENPlugin_Hypothesis_i::GetLocalSizeEntries()
307 {
308   NETGENPlugin::string_array_var result = new NETGENPlugin::string_array();
309   const ::NETGENPlugin_Hypothesis::TLocalSize localSizes = this->GetImpl()->GetLocalSizesAndEntries();
310   result->length(localSizes.size());
311   ::NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
312   for (int i=0 ; it != localSizes.end() ; i++, it++)
313     {
314       string entry = (*it).first;
315       result[i] = CORBA::string_dup(entry.c_str());
316     }
317   return result._retn();
318 }
319
320 //=============================================================================
321
322 void NETGENPlugin_Hypothesis_i::UnsetLocalSizeOnEntry(const char* entry)
323 {
324   this->GetImpl()->UnsetLocalSizeOnEntry(entry);
325   SMESH::TPythonDump() << _this() << ".UnsetLocalSizeOnEntry(" << entry << ")";
326 }
327
328 //=============================================================================
329 /*!
330  *  NETGENPlugin_Hypothesis_i::GetImpl
331  *
332  *  Get implementation
333  */
334 //=============================================================================
335 ::NETGENPlugin_Hypothesis* NETGENPlugin_Hypothesis_i::GetImpl()
336 {
337   MESSAGE("NETGENPlugin_Hypothesis_i::GetImpl");
338   return (::NETGENPlugin_Hypothesis*)myBaseImpl;
339 }
340
341 //================================================================================
342 /*!
343  * \brief Verify whether hypothesis supports given entity type 
344   * \param type - dimension (see SMESH::Dimension enumeration)
345   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
346  * 
347  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
348  */
349 //================================================================================  
350 CORBA::Boolean NETGENPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
351 {
352   return type == SMESH::DIM_3D;
353 }