Salome HOME
50fa33c5dd5c4f8e376d9a485d65c2424c3c602c
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_Hypothesis_2D_i.cxx
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_2D_i.cxx
25 // Author    : Michael Sazonov (OCN)
26 // Date      : 03/04/2006
27 // Project   : SALOME
28 //=============================================================================
29 //
30 #include "NETGENPlugin_Hypothesis_2D_i.hxx"
31
32 #include <SMESH_Gen.hxx>
33 #include <SMESH_Gen_i.hxx>
34 #include <SMESH_Group_i.hxx>
35 #include <SMESH_Group.hxx>
36 #include <SMESH_PythonDump.hxx>
37
38 //=============================================================================
39 /*!
40  *  NETGENPlugin_Hypothesis_2D_i::NETGENPlugin_Hypothesis_2D_i
41  *
42  *  Constructor
43  */
44 //=============================================================================
45 NETGENPlugin_Hypothesis_2D_i::
46 NETGENPlugin_Hypothesis_2D_i (PortableServer::POA_ptr thePOA,
47                               ::SMESH_Gen*            theGenImpl)
48   : SALOME::GenericObj_i( thePOA ),
49     SMESH_Hypothesis_i( thePOA ),
50     NETGENPlugin_Hypothesis_i( thePOA, theGenImpl )
51 {
52   if (myBaseImpl)
53     delete (::NETGENPlugin_Hypothesis*)myBaseImpl;
54   myBaseImpl = new ::NETGENPlugin_Hypothesis_2D (theGenImpl->GetANewId(),
55                                                  theGenImpl);
56 }
57
58 //=============================================================================
59 /*!
60  *  NETGENPlugin_Hypothesis_2D_i::~NETGENPlugin_Hypothesis_2D_i
61  *
62  *  Destructor
63  */
64 //=============================================================================
65 NETGENPlugin_Hypothesis_2D_i::~NETGENPlugin_Hypothesis_2D_i()
66 {
67 }
68
69 //=============================================================================
70 /*!
71  *  NETGENPlugin_Hypothesis_2D_i::GetImpl
72  *
73  *  Get implementation
74  */
75 //=============================================================================
76 ::NETGENPlugin_Hypothesis_2D* NETGENPlugin_Hypothesis_2D_i::GetImpl()
77 {
78   return (::NETGENPlugin_Hypothesis_2D*)myBaseImpl;
79 }
80
81 //================================================================================
82 /*!
83  * \brief Verify whether hypothesis supports given entity type 
84   * \param type - dimension (see SMESH::Dimension enumeration)
85   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
86  * 
87  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
88  */
89 //================================================================================  
90 CORBA::Boolean NETGENPlugin_Hypothesis_2D_i::IsDimSupported( SMESH::Dimension type )
91 {
92   return type == SMESH::DIM_2D;
93 }
94
95
96 //=============================================================================
97 /*!
98  *  NETGENPlugin_RemesherHypothesis_2D_i::NETGENPlugin_RemesherHypothesis_2D_i
99  *
100  *  Constructor
101  */
102 //=============================================================================
103 NETGENPlugin_RemesherHypothesis_2D_i::
104 NETGENPlugin_RemesherHypothesis_2D_i (PortableServer::POA_ptr thePOA,
105                                       ::SMESH_Gen*            theGenImpl)
106   : SALOME::GenericObj_i( thePOA ),
107     SMESH_Hypothesis_i( thePOA ),
108     NETGENPlugin_Hypothesis_2D_i( thePOA, theGenImpl )
109 {
110   myBaseImpl = new ::NETGENPlugin_RemesherHypothesis_2D (theGenImpl->GetANewId(),
111                                                          theGenImpl);
112 }
113
114 //================================================================================
115 /*!
116  * \brief Verify whether hypothesis supports given entity type
117  * \param type - dimension (see SMESH::Dimension enumeration)
118  * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
119  *
120  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
121  */
122 //================================================================================
123 CORBA::Boolean NETGENPlugin_RemesherHypothesis_2D_i::IsDimSupported( SMESH::Dimension type )
124 {
125   return type == SMESH::DIM_2D;
126 }
127
128 //=============================================================================
129 /*!
130  *  NETGENPlugin_RemesherHypothesis_2D_i::GetImpl
131  *
132  *  Get implementation
133  */
134 //=============================================================================
135 ::NETGENPlugin_RemesherHypothesis_2D* NETGENPlugin_RemesherHypothesis_2D_i::GetImpl()
136 {
137   return (::NETGENPlugin_RemesherHypothesis_2D*)myBaseImpl;
138 }
139
140 //================================================================================
141 /*!
142  * \brief Set ridge angle
143  */
144 //================================================================================
145
146 void NETGENPlugin_RemesherHypothesis_2D_i::SetRidgeAngle( CORBA::Double angle )
147 {
148   if ( GetRidgeAngle() != angle )
149   {
150     GetImpl()->SetRidgeAngle( angle );
151
152     SMESH::TPythonDump() << _this() << ".SetRidgeAngle( " << SMESH::TVar(angle) << " )";
153   }
154 }
155
156 //================================================================================
157 /*!
158  * \brief Return ridge angle
159  */
160 //================================================================================
161
162 CORBA::Double NETGENPlugin_RemesherHypothesis_2D_i::GetRidgeAngle()
163 {
164   return GetImpl()->GetRidgeAngle();
165 }
166
167 void NETGENPlugin_RemesherHypothesis_2D_i::SetEdgeCornerAngle(CORBA::Double angle )
168 {
169   if ( GetEdgeCornerAngle() != angle )
170   {
171     GetImpl()->SetEdgeCornerAngle( angle );
172
173     SMESH::TPythonDump() << _this() << ".SetEdgeCornerAngle( " << SMESH::TVar(angle) << " )";
174   }
175 }
176
177 CORBA::Double NETGENPlugin_RemesherHypothesis_2D_i::GetEdgeCornerAngle()
178 {
179   return GetImpl()->GetEdgeCornerAngle();
180 }
181
182 void NETGENPlugin_RemesherHypothesis_2D_i::SetChartAngle(CORBA::Double angle )
183 {
184   if ( GetChartAngle() != angle )
185   {
186     GetImpl()->SetChartAngle( angle );
187
188     SMESH::TPythonDump() << _this() << ".SetChartAngle( " << SMESH::TVar(angle) << " )";
189   }
190 }
191
192 CORBA::Double NETGENPlugin_RemesherHypothesis_2D_i::GetChartAngle()
193 {
194   return GetImpl()->GetChartAngle();
195 }
196
197 void NETGENPlugin_RemesherHypothesis_2D_i::SetOuterChartAngle(CORBA::Double angle )
198 {
199   if ( GetOuterChartAngle() != angle )
200   {
201     GetImpl()->SetOuterChartAngle( angle );
202
203     SMESH::TPythonDump() << _this() << ".SetOuterChartAngle( " << SMESH::TVar(angle) << " )";
204   }
205 }
206
207 CORBA::Double NETGENPlugin_RemesherHypothesis_2D_i::GetOuterChartAngle()
208 {
209   return GetImpl()->GetOuterChartAngle();
210 }
211
212 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHChartDistFactor(CORBA::Double f )
213 {
214   if ( GetRestHChartDistFactor() != f )
215   {
216     GetImpl()->SetRestHChartDistFactor( f );
217
218     SMESH::TPythonDump() << _this() << ".SetRestHChartDistFactor( " << SMESH::TVar(f) << " )";
219   }
220 }
221
222 CORBA::Double NETGENPlugin_RemesherHypothesis_2D_i::GetRestHChartDistFactor()
223 {
224   return GetImpl()->GetRestHChartDistFactor();
225 }
226
227 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHChartDistEnable(CORBA::Boolean enable )
228 {
229   if ( GetRestHChartDistEnable() != enable )
230   {
231     GetImpl()->SetRestHChartDistEnable( enable );
232
233     SMESH::TPythonDump() << _this() << ".SetRestHChartDistEnable( " << enable << " )";
234   }
235 }
236
237 CORBA::Boolean NETGENPlugin_RemesherHypothesis_2D_i::GetRestHChartDistEnable()
238 {
239   return GetImpl()->GetRestHChartDistEnable();
240 }
241
242 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHLineLengthFactor(CORBA::Double f )
243 {
244   if ( GetRestHLineLengthFactor() != f )
245   {
246     GetImpl()->SetRestHLineLengthFactor( f );
247
248     SMESH::TPythonDump() << _this() << ".SetRestHLineLengthFactor( " << SMESH::TVar(f) << " )";
249   }
250 }
251
252 CORBA::Double NETGENPlugin_RemesherHypothesis_2D_i::GetRestHLineLengthFactor()
253 {
254   return GetImpl()->GetRestHLineLengthFactor();
255 }
256
257 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHLineLengthEnable(CORBA::Boolean enable )
258 {
259   if ( GetRestHLineLengthEnable() != enable )
260   {
261     GetImpl()->SetRestHLineLengthEnable( enable );
262
263     SMESH::TPythonDump() << _this() << ".SetRestHLineLengthEnable( " << enable << " )";
264   }
265 }
266
267 CORBA::Boolean NETGENPlugin_RemesherHypothesis_2D_i::GetRestHLineLengthEnable()
268 {
269   return GetImpl()->GetRestHLineLengthEnable();
270 }
271
272 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHCloseEdgeFactor(CORBA::Double f )
273 {
274   if ( GetRestHCloseEdgeFactor() != f )
275   {
276     GetImpl()->SetRestHCloseEdgeFactor( f );
277
278     SMESH::TPythonDump() << _this() << ".SetRestHCloseEdgeFactor( " << SMESH::TVar(f) << " )";
279   }
280 }
281
282 CORBA::Double NETGENPlugin_RemesherHypothesis_2D_i::GetRestHCloseEdgeFactor()
283 {
284   return GetImpl()->GetRestHCloseEdgeFactor();
285 }
286
287 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHCloseEdgeEnable(CORBA::Boolean enable )
288 {
289   if ( GetRestHCloseEdgeEnable() != enable )
290   {
291     GetImpl()->SetRestHCloseEdgeEnable( enable );
292
293     SMESH::TPythonDump() << _this() << ".SetRestHCloseEdgeEnable( " << enable << " )";
294   }
295 }
296
297 CORBA::Boolean NETGENPlugin_RemesherHypothesis_2D_i::GetRestHCloseEdgeEnable()
298 {
299   return GetImpl()->GetRestHCloseEdgeEnable();
300 }
301
302 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHSurfCurvFactor(CORBA::Double f )
303 {
304   if ( GetRestHSurfCurvFactor() != f )
305   {
306     GetImpl()->SetRestHSurfCurvFactor( f );
307
308     SMESH::TPythonDump() << _this() << ".SetRestHSurfCurvFactor( " << SMESH::TVar(f) << " )";
309   }
310 }
311
312 CORBA::Double NETGENPlugin_RemesherHypothesis_2D_i::GetRestHSurfCurvFactor()
313 {
314   return GetImpl()->GetRestHSurfCurvFactor();
315 }
316
317 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHSurfCurvEnable(CORBA::Boolean enable )
318 {
319   if ( GetRestHSurfCurvEnable() != enable )
320   {
321     GetImpl()->SetRestHSurfCurvEnable( enable );
322
323     SMESH::TPythonDump() << _this() << ".SetRestHSurfCurvEnable( " << enable << " )";
324   }
325 }
326
327 CORBA::Boolean NETGENPlugin_RemesherHypothesis_2D_i::GetRestHSurfCurvEnable()
328 {
329   return GetImpl()->GetRestHSurfCurvEnable();
330 }
331
332 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHEdgeAngleFactor(CORBA::Double f )
333 {
334   if ( GetRestHEdgeAngleFactor() != f )
335   {
336     GetImpl()->SetRestHEdgeAngleFactor( f );
337
338     SMESH::TPythonDump() << _this() << ".SetRestHEdgeAngleFactor( " << SMESH::TVar(f) << " )";
339   }
340 }
341
342 CORBA::Double NETGENPlugin_RemesherHypothesis_2D_i::GetRestHEdgeAngleFactor()
343 {
344   return GetImpl()->GetRestHEdgeAngleFactor();
345 }
346
347 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHEdgeAngleEnable(CORBA::Boolean enable )
348 {
349   if ( GetRestHEdgeAngleEnable() != enable )
350   {
351     GetImpl()->SetRestHEdgeAngleEnable( enable );
352
353     SMESH::TPythonDump() << _this() << ".SetRestHEdgeAngleEnable( " << enable << " )";
354   }
355 }
356
357 CORBA::Boolean NETGENPlugin_RemesherHypothesis_2D_i::GetRestHEdgeAngleEnable()
358 {
359   return GetImpl()->GetRestHEdgeAngleEnable();
360 }
361
362 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHSurfMeshCurvFactor(CORBA::Double f )
363 {
364   if ( GetRestHSurfMeshCurvFactor() != f )
365   {
366     GetImpl()->SetRestHSurfMeshCurvFactor( f );
367
368     SMESH::TPythonDump() << _this() << ".SetRestHSurfMeshCurvFactor( " << SMESH::TVar(f) << " )";
369   }
370 }
371
372 CORBA::Double NETGENPlugin_RemesherHypothesis_2D_i::GetRestHSurfMeshCurvFactor()
373 {
374   return GetImpl()->GetRestHSurfMeshCurvFactor();
375 }
376
377 void NETGENPlugin_RemesherHypothesis_2D_i::SetRestHSurfMeshCurvEnable(CORBA::Boolean enable )
378 {
379   if ( GetRestHSurfMeshCurvEnable() != enable )
380   {
381     GetImpl()->SetRestHSurfMeshCurvEnable( enable );
382
383     SMESH::TPythonDump() << _this() << ".SetRestHSurfMeshCurvEnable( " << enable << " )";
384   }
385 }
386
387 CORBA::Boolean NETGENPlugin_RemesherHypothesis_2D_i::GetRestHSurfMeshCurvEnable()
388 {
389   return GetImpl()->GetRestHSurfMeshCurvEnable();
390 }
391
392 void NETGENPlugin_RemesherHypothesis_2D_i::SetKeepExistingEdges( CORBA::Boolean toKeep )
393 {
394   if ( GetKeepExistingEdges() != toKeep )
395   {
396     GetImpl()->SetKeepExistingEdges( toKeep );
397
398     SMESH::TPythonDump() << _this() << ".SetKeepExistingEdges( " << toKeep << " )";
399   }
400 }
401
402 CORBA::Boolean NETGENPlugin_RemesherHypothesis_2D_i::GetKeepExistingEdges()
403 {
404   return GetImpl()->GetKeepExistingEdges();
405 }
406
407 void NETGENPlugin_RemesherHypothesis_2D_i::SetMakeGroupsOfSurfaces( CORBA::Boolean toMake )
408 {
409   if ( GetMakeGroupsOfSurfaces() != toMake )
410   {
411     GetImpl()->SetMakeGroupsOfSurfaces( toMake );
412
413     SMESH::TPythonDump() << _this() << ".SetMakeGroupsOfSurfaces( " << toMake << " )";
414   }
415 }
416
417 CORBA::Boolean NETGENPlugin_RemesherHypothesis_2D_i::GetMakeGroupsOfSurfaces()
418 {
419   return GetImpl()->GetMakeGroupsOfSurfaces();
420 }
421
422 void
423 NETGENPlugin_RemesherHypothesis_2D_i::SetFixedEdgeGroup( SMESH::SMESH_GroupBase_ptr edgeGroup )
424 {
425   const SMESH_Group * group = 0;
426   if ( SMESH_GroupBase_i* group_i = SMESH::DownCast< SMESH_GroupBase_i* >( edgeGroup ))
427   {
428     if ( group_i->GetType() == SMESH::EDGE )
429       group = group_i->GetSmeshGroup();
430   }
431
432   int id = group ? group->GetID() : -1;
433   if ( id != GetImpl()->GetFixedEdgeGroupID() )
434   {
435     GetImpl()->SetFixedEdgeGroup( group );
436     SMESH::TPythonDump() << _this() << ".SetFixedEdgeGroup( " << edgeGroup << " )";
437   }
438 }
439
440 SMESH::SMESH_GroupBase_ptr
441 NETGENPlugin_RemesherHypothesis_2D_i::GetFixedEdgeGroup( SMESH::SMESH_Mesh_ptr mesh )
442 {
443   SMESH::SMESH_GroupBase_var resGroup;
444   if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( mesh ))
445   {
446     const std::map<int, SMESH::SMESH_GroupBase_ptr>& groups = mesh_i->getGroups();
447     std::map<int, SMESH::SMESH_GroupBase_ptr>::const_iterator i_gr =
448       groups.find( GetImpl()->GetFixedEdgeGroupID() );
449     if ( i_gr != groups.end() && i_gr->second->GetType() == SMESH::EDGE )
450       resGroup = SMESH::SMESH_GroupBase::_duplicate( i_gr->second );
451   }
452   return resGroup._retn();
453 }
454
455 void NETGENPlugin_RemesherHypothesis_2D_i::SetLoadMeshOnCancel( CORBA::Boolean toMake )
456 {
457   if ( GetLoadMeshOnCancel() != toMake )
458   {
459     GetImpl()->SetLoadMeshOnCancel( toMake );
460
461     SMESH::TPythonDump() << _this() << ".SetLoadMeshOnCancel( " << toMake << " )";
462   }
463 }
464
465 CORBA::Boolean NETGENPlugin_RemesherHypothesis_2D_i::GetLoadMeshOnCancel()
466 {
467   return GetImpl()->GetLoadMeshOnCancel();
468 }