Salome HOME
print output of BLSURF
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis_i.cxx
1 //  BLSURFPlugin : C++ implementation
2 //
3 //  Copyright (C) 2006  OPEN CASCADE, CEA/DEN, EDF R&D
4 // 
5 //  This library is free software; you can redistribute it and/or 
6 //  modify it under the terms of the GNU Lesser General Public 
7 //  License as published by the Free Software Foundation; either 
8 //  version 2.1 of the License. 
9 // 
10 //  This library is distributed in the hope that it will be useful, 
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
13 //  Lesser General Public License for more details. 
14 // 
15 //  You should have received a copy of the GNU Lesser General Public 
16 //  License along with this library; if not, write to the Free Software 
17 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
18 // 
19 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
20 //
21 //
22 // File      : BLSURFPlugin_Hypothesis_i.cxx
23 // Authors   : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
24 // Date      : 03/04/2006
25 // Project   : SALOME
26 //=============================================================================
27 using namespace std;
28
29 #include "BLSURFPlugin_Hypothesis_i.hxx"
30 #include "SMESH_Gen.hxx"
31 #include "SMESH_PythonDump.hxx"
32
33 #include "Utils_CorbaException.hxx"
34 #include "utilities.h"
35
36 //=============================================================================
37 /*!
38  *  BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i
39  *
40  *  Constructor
41  */
42 //=============================================================================
43 BLSURFPlugin_Hypothesis_i::
44 BLSURFPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
45                            int                     theStudyId,
46                            ::SMESH_Gen*            theGenImpl)
47   : SALOME::GenericObj_i( thePOA ), 
48     SMESH_Hypothesis_i( thePOA )
49 {
50   MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" );
51   myBaseImpl = new ::BLSURFPlugin_Hypothesis (theGenImpl->GetANewId(),
52                                               theStudyId,
53                                               theGenImpl);
54 }
55
56 //=============================================================================
57 /*!
58  *  BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i
59  *
60  *  Destructor
61  */
62 //=============================================================================
63 BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i()
64 {
65   MESSAGE( "BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i" );
66 }
67
68 /*!
69  *  BLSURFPlugin_Hypothesis_i::SetTopology
70  *
71  *  Set topology
72  */
73
74 //=============================================================================
75 void BLSURFPlugin_Hypothesis_i::SetTopology (CORBA::Long theValue)
76 {
77   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTopology");
78   ASSERT(myBaseImpl);
79   this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology)theValue);
80   SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
81 }
82
83 //=============================================================================
84 /*!
85  *  BLSURFPlugin_Hypothesis_i::GetTopology
86  *
87  *  Get Topology
88  */
89 //=============================================================================
90 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology()
91 {
92   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTopology");
93   ASSERT(myBaseImpl);
94   return this->GetImpl()->GetTopology();
95 }
96
97 //=============================================================================
98
99 //=============================================================================
100 /*!
101  *  BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
102  *
103  *  Set PhysicalMesh
104  */
105
106 //=============================================================================
107 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh (CORBA::Long theValue)
108 {
109   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhysicalMesh");
110   ASSERT(myBaseImpl);
111   this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh)theValue);
112   SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
113 }
114
115 //=============================================================================
116 /*!
117  *  BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
118  *
119  *  Get PhysicalMesh
120  */
121 //=============================================================================
122 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh()
123 {
124   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhysicalMesh");
125   ASSERT(myBaseImpl);
126   return this->GetImpl()->GetPhysicalMesh();
127 }
128
129 //=============================================================================
130 /*!
131  *  BLSURFPlugin_Hypothesis_i::SetPhySize
132  *
133  *  Set PhySize
134  */
135 //=============================================================================
136 void BLSURFPlugin_Hypothesis_i::SetPhySize (CORBA::Double theValue)
137 {
138   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize");
139   ASSERT(myBaseImpl);
140   this->GetImpl()->SetPhySize(theValue);
141   SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
142 }
143
144 //=============================================================================
145 /*!
146  *  BLSURFPlugin_Hypothesis_i::GetPhySize
147  *
148  *  Get PhySize
149  */
150 //=============================================================================
151 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize()
152 {
153   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize");
154   ASSERT(myBaseImpl);
155   return this->GetImpl()->GetPhySize();
156 }
157
158 //=============================================================================
159 void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize)
160 {
161   ASSERT(myBaseImpl);
162   this->GetImpl()->SetPhyMin(theMinSize);
163   SMESH::TPythonDump() << _this() << ".SetPhyMin( " << theMinSize << " )";
164 }
165
166 //=============================================================================
167 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin()
168 {
169   ASSERT(myBaseImpl);
170   return this->GetImpl()->GetPhyMin();
171 }
172
173
174 //=============================================================================
175 void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize)
176 {
177   ASSERT(myBaseImpl);
178   this->GetImpl()->SetPhyMax(theMaxSize);
179   SMESH::TPythonDump() << _this() << ".SetPhyMax( " << theMaxSize << " )";
180 }
181
182 //=============================================================================
183 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax()
184 {
185   ASSERT(myBaseImpl);
186   return this->GetImpl()->GetPhyMax();
187 }
188
189
190 //=============================================================================
191 /*!
192  *  BLSURFPlugin_Hypothesis_i::SetGeometricMesh
193  *
194  *  Set GeometricMesh
195  */
196
197 //=============================================================================
198 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh (CORBA::Long theValue)
199 {
200   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGeometricMesh");
201   ASSERT(myBaseImpl);
202   this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh)theValue);
203   SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
204 }
205
206 //=============================================================================
207 /*!
208  *  BLSURFPlugin_Hypothesis_i::GetGeometricMesh
209  *
210  *  Get GeometricMesh
211  */
212 //=============================================================================
213 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh()
214 {
215   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGeometricMesh");
216   ASSERT(myBaseImpl);
217   return this->GetImpl()->GetGeometricMesh();
218 }
219
220 //=============================================================================
221 /*!
222  *  BLSURFPlugin_Hypothesis_i::SetAngleMeshS
223  *
224  *  Set AngleMeshS
225  */
226 //=============================================================================
227 void BLSURFPlugin_Hypothesis_i::SetAngleMeshS (CORBA::Double theValue)
228 {
229   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAngleMeshS");
230   ASSERT(myBaseImpl);
231   this->GetImpl()->SetAngleMeshS(theValue);
232   SMESH::TPythonDump() << _this() << ".SetAngleMeshS( " << theValue << " )";
233 }
234
235 //=============================================================================
236 /*!
237  *  BLSURFPlugin_Hypothesis_i::GetAngleMeshS
238  *
239  *  Get AngleMeshS
240  */
241 //=============================================================================
242 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS()
243 {
244   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAngleMeshS");
245   ASSERT(myBaseImpl);
246   return this->GetImpl()->GetAngleMeshS();
247 }
248
249 //=============================================================================
250 void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle)
251 {
252   ASSERT(myBaseImpl);
253   this->GetImpl()->SetAngleMeshC(angle);
254   SMESH::TPythonDump() << _this() << ".SetAngleMeshC( " << angle << " )";
255 }
256
257 //=============================================================================
258 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC()
259 {
260   ASSERT(myBaseImpl);
261   return this->GetImpl()->GetAngleMeshC();
262 }
263
264 //=============================================================================
265 void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize)
266 {
267   this->GetImpl()->SetGeoMin(theMinSize);
268   SMESH::TPythonDump() << _this() << ".SetGeoMin( " << theMinSize << " )";
269 }
270
271 //=============================================================================
272 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin()
273 {
274   ASSERT(myBaseImpl);
275   return this->GetImpl()->GetGeoMin();
276 }
277
278 //=============================================================================
279 void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize)
280 {
281   this->GetImpl()->SetGeoMax(theMaxSize);
282   SMESH::TPythonDump() << _this() << ".SetGeoMax( " << theMaxSize << " )";
283 }
284
285 //=============================================================================
286 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax()
287 {
288   ASSERT(myBaseImpl);
289   return this->GetImpl()->GetGeoMax();
290 }
291
292 //=============================================================================
293 /*!
294  *  BLSURFPlugin_Hypothesis_i::SetGradation
295  *
296  *  Set Gradation
297  */
298 //=============================================================================
299 void BLSURFPlugin_Hypothesis_i::SetGradation (CORBA::Double theValue)
300 {
301   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGradation");
302   ASSERT(myBaseImpl);
303   this->GetImpl()->SetGradation(theValue);
304   SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
305 }
306
307 //=============================================================================
308 /*!
309  *  BLSURFPlugin_Hypothesis_i::GetGradation
310  *
311  *  Get Gradation
312  */
313 //=============================================================================
314 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation()
315 {
316   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGradation");
317   ASSERT(myBaseImpl);
318   return this->GetImpl()->GetGradation();
319 }
320
321 //=============================================================================
322 /*!
323  *  BLSURFPlugin_Hypothesis_i::SetQuadAllowed
324  *
325  *  Set true or false
326  */
327 //=============================================================================
328 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue)
329 {
330   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadAllowed");
331   ASSERT(myBaseImpl);
332   this->GetImpl()->SetQuadAllowed(theValue);
333   SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
334 }
335
336 //=============================================================================
337 /*!
338  *  BLSURFPlugin_Hypothesis_i::GetQuadAllowed
339  *
340  *  Get true or false
341  */
342 //=============================================================================
343 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed()
344 {
345   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadAllowed");
346   ASSERT(myBaseImpl);
347   return this->GetImpl()->GetQuadAllowed();
348 }
349
350 //=============================================================================
351 /*!
352  *  BLSURFPlugin_Hypothesis_i::SetDecimesh
353  *
354  *  Set true or false
355  */
356 //=============================================================================
357 void BLSURFPlugin_Hypothesis_i::SetDecimesh (CORBA::Boolean theValue)
358 {
359   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetDecimesh");
360   ASSERT(myBaseImpl);
361   this->GetImpl()->SetDecimesh(theValue);
362   SMESH::TPythonDump() << _this() << ".SetDecimesh( " << theValue << " )";
363 }
364
365 //=============================================================================
366 /*!
367  *  BLSURFPlugin_Hypothesis_i::GetDecimesh
368  *
369  *  Get true or false
370  */
371 //=============================================================================
372 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh()
373 {
374   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetDecimesh");
375   ASSERT(myBaseImpl);
376   return this->GetImpl()->GetDecimesh();
377 }
378
379 //=============================================================================
380 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal)
381   throw (SALOME::SALOME_Exception)
382 {
383   ASSERT(myBaseImpl);
384   if ( theVal < 0 || theVal > 100 )
385     THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM );
386   this->GetImpl()->SetVerbosity(theVal);
387   SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )";
388 }
389
390 //=============================================================================
391
392 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity()
393 {
394   ASSERT(myBaseImpl);
395   return (CORBA::Short) this->GetImpl()->GetVerbosity();
396 }
397
398 //=============================================================================
399
400 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName,
401                                                const char* optionValue)
402   throw (SALOME::SALOME_Exception)
403 {
404   ASSERT(myBaseImpl);
405   bool valueChanged = false;
406   try {
407     valueChanged = ( this->GetImpl()->GetOptionValue(optionName) != optionValue );
408     if ( valueChanged )
409       this->GetImpl()->SetOptionValue(optionName, optionValue);
410   }
411   catch (SALOME_Exception& ex) {
412     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
413   }
414   SMESH::TPythonDump() << _this() << ".SetOptionValue( '"
415                        << optionName << "', '" << optionValue << "' )";
416 }
417
418 //=============================================================================
419
420 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
421   throw (SALOME::SALOME_Exception)
422 {
423   ASSERT(myBaseImpl);
424   try {
425     return CORBA::string_dup( this->GetImpl()->GetOptionValue(optionName).c_str() );
426   }
427   catch (SALOME_Exception& ex) {
428     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
429   }
430   return 0;
431 }
432
433 //=============================================================================
434
435 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName)
436 {
437   ASSERT(myBaseImpl);
438   this->GetImpl()->ClearOption(optionName);
439   SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
440 }
441
442 //=============================================================================
443
444 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues()
445 {
446   ASSERT(myBaseImpl);
447   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
448
449   const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
450   result->length( opts.size() );
451
452   ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
453   for ( int i = 0 ; opIt != opts.end(); ++opIt, ++i ) {
454     string name_value = opIt->first;
455     if ( !opIt->second.empty() ) {
456       name_value += ":";
457       name_value += opIt->second;
458     }
459     result[i] = CORBA::string_dup(name_value.c_str());
460   }
461   return result._retn();
462 }
463
464 //=============================================================================
465
466 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
467   throw (SALOME::SALOME_Exception)
468 {
469   ASSERT(myBaseImpl);
470   for (int i = 0; i < options.length(); ++i)
471   {
472     string name_value = options[i].in();
473     int colonPos = name_value.find( ':' );
474     string name, value;
475     if ( colonPos == string::npos ) // ':' not found
476       name = name_value;
477     else {
478       name = name_value.substr( 0, colonPos);
479       if ( colonPos < name_value.size()-1 && name_value[colonPos] != ' ')
480         value = name_value.substr( colonPos );
481     }
482     SetOptionValue( name.c_str(), value.c_str() );
483   }
484 }
485
486 //=============================================================================
487 /*!
488  *  BLSURFPlugin_Hypothesis_i::GetImpl
489  *
490  *  Get implementation
491  */
492 //=============================================================================
493 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl()
494 {
495   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
496   return (::BLSURFPlugin_Hypothesis*)myBaseImpl;
497 }
498
499 //================================================================================
500 /*!
501  * \brief Verify whether hypothesis supports given entity type 
502   * \param type - dimension (see SMESH::Dimension enumeration)
503   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
504  * 
505  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
506  */
507 //================================================================================  
508 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
509 {
510   return type == SMESH::DIM_2D;
511 }