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