1 // BLSURFPlugin : C++ implementation
3 // Copyright (C) 2006 OPEN CASCADE, CEA/DEN, EDF R&D
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.
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.
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
19 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : BLSURFPlugin_Hypothesis_i.cxx
23 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
26 //=============================================================================
29 #include "BLSURFPlugin_Hypothesis_i.hxx"
30 #include "SMESH_Gen.hxx"
31 #include "SMESH_PythonDump.hxx"
33 #include "Utils_CorbaException.hxx"
34 #include "utilities.h"
36 //=============================================================================
38 * BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i
42 //=============================================================================
43 BLSURFPlugin_Hypothesis_i::
44 BLSURFPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
46 ::SMESH_Gen* theGenImpl)
47 : SALOME::GenericObj_i( thePOA ),
48 SMESH_Hypothesis_i( thePOA )
50 MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" );
51 myBaseImpl = new ::BLSURFPlugin_Hypothesis (theGenImpl->GetANewId(),
56 //=============================================================================
58 * BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i
62 //=============================================================================
63 BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i()
65 MESSAGE( "BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i" );
69 * BLSURFPlugin_Hypothesis_i::SetTopology
74 //=============================================================================
75 void BLSURFPlugin_Hypothesis_i::SetTopology (CORBA::Long theValue)
77 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTopology");
79 this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology)theValue);
80 SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
83 //=============================================================================
85 * BLSURFPlugin_Hypothesis_i::GetTopology
89 //=============================================================================
90 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology()
92 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTopology");
94 return this->GetImpl()->GetTopology();
97 //=============================================================================
99 //=============================================================================
101 * BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
106 //=============================================================================
107 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh (CORBA::Long theValue)
109 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhysicalMesh");
111 this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh)theValue);
112 SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
115 //=============================================================================
117 * BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
121 //=============================================================================
122 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh()
124 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhysicalMesh");
126 return this->GetImpl()->GetPhysicalMesh();
129 //=============================================================================
131 * BLSURFPlugin_Hypothesis_i::SetPhySize
135 //=============================================================================
136 void BLSURFPlugin_Hypothesis_i::SetPhySize (CORBA::Double theValue)
138 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize");
140 this->GetImpl()->SetPhySize(theValue);
141 SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
144 //=============================================================================
146 * BLSURFPlugin_Hypothesis_i::GetPhySize
150 //=============================================================================
151 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize()
153 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize");
155 return this->GetImpl()->GetPhySize();
158 //=============================================================================
159 void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize)
162 this->GetImpl()->SetPhyMin(theMinSize);
163 SMESH::TPythonDump() << _this() << ".SetPhyMin( " << theMinSize << " )";
166 //=============================================================================
167 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin()
170 return this->GetImpl()->GetPhyMin();
174 //=============================================================================
175 void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize)
178 this->GetImpl()->SetPhyMax(theMaxSize);
179 SMESH::TPythonDump() << _this() << ".SetPhyMax( " << theMaxSize << " )";
182 //=============================================================================
183 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax()
186 return this->GetImpl()->GetPhyMax();
190 //=============================================================================
192 * BLSURFPlugin_Hypothesis_i::SetGeometricMesh
197 //=============================================================================
198 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh (CORBA::Long theValue)
200 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGeometricMesh");
202 this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh)theValue);
203 SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
206 //=============================================================================
208 * BLSURFPlugin_Hypothesis_i::GetGeometricMesh
212 //=============================================================================
213 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh()
215 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGeometricMesh");
217 return this->GetImpl()->GetGeometricMesh();
220 //=============================================================================
222 * BLSURFPlugin_Hypothesis_i::SetAngleMeshS
226 //=============================================================================
227 void BLSURFPlugin_Hypothesis_i::SetAngleMeshS (CORBA::Double theValue)
229 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAngleMeshS");
231 this->GetImpl()->SetAngleMeshS(theValue);
232 SMESH::TPythonDump() << _this() << ".SetAngleMeshS( " << theValue << " )";
235 //=============================================================================
237 * BLSURFPlugin_Hypothesis_i::GetAngleMeshS
241 //=============================================================================
242 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS()
244 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAngleMeshS");
246 return this->GetImpl()->GetAngleMeshS();
249 //=============================================================================
250 void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle)
253 this->GetImpl()->SetAngleMeshC(angle);
254 SMESH::TPythonDump() << _this() << ".SetAngleMeshC( " << angle << " )";
257 //=============================================================================
258 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC()
261 return this->GetImpl()->GetAngleMeshC();
264 //=============================================================================
265 void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize)
267 this->GetImpl()->SetGeoMin(theMinSize);
268 SMESH::TPythonDump() << _this() << ".SetGeoMin( " << theMinSize << " )";
271 //=============================================================================
272 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin()
275 return this->GetImpl()->GetGeoMin();
278 //=============================================================================
279 void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize)
281 this->GetImpl()->SetGeoMax(theMaxSize);
282 SMESH::TPythonDump() << _this() << ".SetGeoMax( " << theMaxSize << " )";
285 //=============================================================================
286 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax()
289 return this->GetImpl()->GetGeoMax();
292 //=============================================================================
294 * BLSURFPlugin_Hypothesis_i::SetGradation
298 //=============================================================================
299 void BLSURFPlugin_Hypothesis_i::SetGradation (CORBA::Double theValue)
301 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGradation");
303 this->GetImpl()->SetGradation(theValue);
304 SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
307 //=============================================================================
309 * BLSURFPlugin_Hypothesis_i::GetGradation
313 //=============================================================================
314 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation()
316 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGradation");
318 return this->GetImpl()->GetGradation();
321 //=============================================================================
323 * BLSURFPlugin_Hypothesis_i::SetQuadAllowed
327 //=============================================================================
328 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue)
330 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadAllowed");
332 this->GetImpl()->SetQuadAllowed(theValue);
333 SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
336 //=============================================================================
338 * BLSURFPlugin_Hypothesis_i::GetQuadAllowed
342 //=============================================================================
343 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed()
345 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadAllowed");
347 return this->GetImpl()->GetQuadAllowed();
350 //=============================================================================
352 * BLSURFPlugin_Hypothesis_i::SetDecimesh
356 //=============================================================================
357 void BLSURFPlugin_Hypothesis_i::SetDecimesh (CORBA::Boolean theValue)
359 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetDecimesh");
361 this->GetImpl()->SetDecimesh(theValue);
362 SMESH::TPythonDump() << _this() << ".SetDecimesh( " << theValue << " )";
365 //=============================================================================
367 * BLSURFPlugin_Hypothesis_i::GetDecimesh
371 //=============================================================================
372 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh()
374 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetDecimesh");
376 return this->GetImpl()->GetDecimesh();
379 //=============================================================================
380 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal)
381 throw (SALOME::SALOME_Exception)
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 << " )";
390 //=============================================================================
392 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity()
395 return (CORBA::Short) this->GetImpl()->GetVerbosity();
398 //=============================================================================
400 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName,
401 const char* optionValue)
402 throw (SALOME::SALOME_Exception)
405 bool valueChanged = false;
407 valueChanged = ( this->GetImpl()->GetOptionValue(optionName) != optionValue );
409 this->GetImpl()->SetOptionValue(optionName, optionValue);
411 catch (SALOME_Exception& ex) {
412 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
414 SMESH::TPythonDump() << _this() << ".SetOptionValue( '"
415 << optionName << "', '" << optionValue << "' )";
418 //=============================================================================
420 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
421 throw (SALOME::SALOME_Exception)
425 return CORBA::string_dup( this->GetImpl()->GetOptionValue(optionName).c_str() );
427 catch (SALOME_Exception& ex) {
428 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
433 //=============================================================================
435 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName)
438 this->GetImpl()->ClearOption(optionName);
439 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
442 //=============================================================================
444 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues()
447 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
449 const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
450 result->length( opts.size() );
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() ) {
457 name_value += opIt->second;
459 result[i] = CORBA::string_dup(name_value.c_str());
461 return result._retn();
464 //=============================================================================
466 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
467 throw (SALOME::SALOME_Exception)
470 for (int i = 0; i < options.length(); ++i)
472 string name_value = options[i].in();
473 int colonPos = name_value.find( ':' );
475 if ( colonPos == string::npos ) // ':' not found
478 name = name_value.substr( 0, colonPos);
479 if ( colonPos < name_value.size()-1 && name_value[colonPos] != ' ')
480 value = name_value.substr( colonPos );
482 SetOptionValue( name.c_str(), value.c_str() );
486 //=============================================================================
488 * BLSURFPlugin_Hypothesis_i::GetImpl
492 //=============================================================================
493 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl()
495 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
496 return (::BLSURFPlugin_Hypothesis*)myBaseImpl;
499 //================================================================================
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
505 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
507 //================================================================================
508 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
510 return type == SMESH::DIM_2D;