1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : BLSURFPlugin_Hypothesis.cxx
21 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
24 #include "BLSURFPlugin_Hypothesis_i.hxx"
25 #include "SMESH_Gen.hxx"
26 #include "SMESH_PythonDump.hxx"
28 #include "Utils_CorbaException.hxx"
29 #include "utilities.h"
33 //=============================================================================
35 * BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i
39 //=============================================================================
40 BLSURFPlugin_Hypothesis_i::
41 BLSURFPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
43 ::SMESH_Gen* theGenImpl)
44 : SALOME::GenericObj_i( thePOA ),
45 SMESH_Hypothesis_i( thePOA )
47 MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" );
48 myBaseImpl = new ::BLSURFPlugin_Hypothesis (theGenImpl->GetANewId(),
53 //=============================================================================
55 * BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i
59 //=============================================================================
60 BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i()
62 MESSAGE( "BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i" );
66 * BLSURFPlugin_Hypothesis_i::SetTopology
71 //=============================================================================
72 void BLSURFPlugin_Hypothesis_i::SetTopology (CORBA::Long theValue)
74 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTopology");
76 this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology)theValue);
77 SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
80 //=============================================================================
82 * BLSURFPlugin_Hypothesis_i::GetTopology
86 //=============================================================================
87 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology()
89 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTopology");
91 return this->GetImpl()->GetTopology();
94 //=============================================================================
96 //=============================================================================
98 * BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
103 //=============================================================================
104 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh (CORBA::Long theValue)
106 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhysicalMesh");
108 this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh)theValue);
109 SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
112 //=============================================================================
114 * BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
118 //=============================================================================
119 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh()
121 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhysicalMesh");
123 return this->GetImpl()->GetPhysicalMesh();
126 //=============================================================================
128 * BLSURFPlugin_Hypothesis_i::SetPhySize
132 //=============================================================================
133 void BLSURFPlugin_Hypothesis_i::SetPhySize (CORBA::Double theValue)
135 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize");
137 this->GetImpl()->SetPhySize(theValue);
138 SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
141 //=============================================================================
143 * BLSURFPlugin_Hypothesis_i::GetPhySize
147 //=============================================================================
148 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize()
150 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize");
152 return this->GetImpl()->GetPhySize();
155 //=============================================================================
156 void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize)
159 if ( GetPhyMin() != theMinSize ) {
160 this->GetImpl()->SetPhyMin(theMinSize);
161 SMESH::TPythonDump() << _this() << ".SetPhyMin( " << theMinSize << " )";
165 //=============================================================================
166 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin()
169 return this->GetImpl()->GetPhyMin();
173 //=============================================================================
174 void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize)
177 if ( GetPhyMax() != theMaxSize ) {
178 this->GetImpl()->SetPhyMax(theMaxSize);
179 SMESH::TPythonDump() << _this() << ".SetPhyMax( " << theMaxSize << " )";
183 //=============================================================================
184 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax()
187 return this->GetImpl()->GetPhyMax();
191 //=============================================================================
193 * BLSURFPlugin_Hypothesis_i::SetGeometricMesh
198 //=============================================================================
199 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh (CORBA::Long theValue)
201 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGeometricMesh");
203 this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh)theValue);
204 SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
207 //=============================================================================
209 * BLSURFPlugin_Hypothesis_i::GetGeometricMesh
213 //=============================================================================
214 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh()
216 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGeometricMesh");
218 return this->GetImpl()->GetGeometricMesh();
221 //=============================================================================
223 * BLSURFPlugin_Hypothesis_i::SetAngleMeshS
227 //=============================================================================
228 void BLSURFPlugin_Hypothesis_i::SetAngleMeshS (CORBA::Double theValue)
230 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAngleMeshS");
232 this->GetImpl()->SetAngleMeshS(theValue);
233 SMESH::TPythonDump() << _this() << ".SetAngleMeshS( " << theValue << " )";
236 //=============================================================================
238 * BLSURFPlugin_Hypothesis_i::GetAngleMeshS
242 //=============================================================================
243 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS()
245 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAngleMeshS");
247 return this->GetImpl()->GetAngleMeshS();
250 //=============================================================================
251 void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle)
254 this->GetImpl()->SetAngleMeshC(angle);
255 SMESH::TPythonDump() << _this() << ".SetAngleMeshC( " << angle << " )";
258 //=============================================================================
259 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC()
262 return this->GetImpl()->GetAngleMeshC();
265 //=============================================================================
266 void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize)
269 if ( GetGeoMin() != theMinSize ) {
270 this->GetImpl()->SetGeoMin(theMinSize);
271 SMESH::TPythonDump() << _this() << ".SetGeoMin( " << theMinSize << " )";
275 //=============================================================================
276 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin()
279 return this->GetImpl()->GetGeoMin();
282 //=============================================================================
283 void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize)
286 if ( GetGeoMax() != theMaxSize ) {
287 this->GetImpl()->SetGeoMax(theMaxSize);
288 SMESH::TPythonDump() << _this() << ".SetGeoMax( " << theMaxSize << " )";
292 //=============================================================================
293 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax()
296 return this->GetImpl()->GetGeoMax();
299 //=============================================================================
301 * BLSURFPlugin_Hypothesis_i::SetGradation
305 //=============================================================================
306 void BLSURFPlugin_Hypothesis_i::SetGradation (CORBA::Double theValue)
308 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGradation");
310 this->GetImpl()->SetGradation(theValue);
311 SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
314 //=============================================================================
316 * BLSURFPlugin_Hypothesis_i::GetGradation
320 //=============================================================================
321 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation()
323 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGradation");
325 return this->GetImpl()->GetGradation();
328 //=============================================================================
330 * BLSURFPlugin_Hypothesis_i::SetQuadAllowed
334 //=============================================================================
335 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue)
337 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadAllowed");
339 this->GetImpl()->SetQuadAllowed(theValue);
340 SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
343 //=============================================================================
345 * BLSURFPlugin_Hypothesis_i::GetQuadAllowed
349 //=============================================================================
350 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed()
352 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadAllowed");
354 return this->GetImpl()->GetQuadAllowed();
357 //=============================================================================
359 * BLSURFPlugin_Hypothesis_i::SetDecimesh
363 //=============================================================================
364 void BLSURFPlugin_Hypothesis_i::SetDecimesh (CORBA::Boolean theValue)
366 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetDecimesh");
368 this->GetImpl()->SetDecimesh(theValue);
369 SMESH::TPythonDump() << _this() << ".SetDecimesh( " << theValue << " )";
372 //=============================================================================
374 * BLSURFPlugin_Hypothesis_i::GetDecimesh
378 //=============================================================================
379 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh()
381 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetDecimesh");
383 return this->GetImpl()->GetDecimesh();
386 //=============================================================================
387 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal)
388 throw (SALOME::SALOME_Exception)
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 << " )";
397 //=============================================================================
399 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity()
402 return (CORBA::Short) this->GetImpl()->GetVerbosity();
405 //=============================================================================
407 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName,
408 const char* optionValue)
409 throw (SALOME::SALOME_Exception)
412 bool valueChanged = false;
414 valueChanged = ( this->GetImpl()->GetOptionValue(optionName) != optionValue );
416 this->GetImpl()->SetOptionValue(optionName, optionValue);
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);
426 catch (SALOME_Exception& ex) {
427 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
430 SMESH::TPythonDump() << _this() << ".SetOptionValue( '"
431 << optionName << "', '" << optionValue << "' )";
434 //=============================================================================
436 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
437 throw (SALOME::SALOME_Exception)
441 return CORBA::string_dup( this->GetImpl()->GetOptionValue(optionName).c_str() );
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);
451 catch (SALOME_Exception& ex) {
452 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
457 //=============================================================================
459 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName)
462 this->GetImpl()->ClearOption(optionName);
463 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
466 //=============================================================================
468 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues()
471 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
473 const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
474 result->length( opts.size() );
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() ) {
481 name_value += opIt->second;
483 result[i] = CORBA::string_dup(name_value.c_str());
485 return result._retn();
488 //=============================================================================
490 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
491 throw (SALOME::SALOME_Exception)
494 for (int i = 0; i < options.length(); ++i)
496 string name_value = options[i].in();
497 int colonPos = name_value.find( ':' );
499 if ( colonPos == string::npos ) // ':' not found
502 name = name_value.substr( 0, colonPos);
503 if ( colonPos < name_value.size()-1 && name_value[colonPos] != ' ')
504 value = name_value.substr( colonPos+1 );
506 SetOptionValue( name.c_str(), value.c_str() );
510 //=============================================================================
512 * BLSURFPlugin_Hypothesis_i::GetImpl
516 //=============================================================================
517 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl()
519 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
520 return (::BLSURFPlugin_Hypothesis*)myBaseImpl;
523 //================================================================================
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
529 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
531 //================================================================================
532 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
534 return type == SMESH::DIM_2D;