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"
27 #include "GEOM_Object.hxx"
29 #include "Utils_CorbaException.hxx"
30 #include "utilities.h"
34 //=============================================================================
36 * BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i
40 //=============================================================================
41 BLSURFPlugin_Hypothesis_i::
42 BLSURFPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
44 ::SMESH_Gen* theGenImpl)
45 : SALOME::GenericObj_i( thePOA ),
46 SMESH_Hypothesis_i( thePOA )
48 MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" );
49 myBaseImpl = new ::BLSURFPlugin_Hypothesis (theGenImpl->GetANewId(),
54 //=============================================================================
56 * BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i
60 //=============================================================================
61 BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i()
63 MESSAGE( "BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i" );
67 * BLSURFPlugin_Hypothesis_i::SetTopology
72 //=============================================================================
73 void BLSURFPlugin_Hypothesis_i::SetTopology (CORBA::Long theValue)
75 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTopology");
77 this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology)theValue);
78 SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
81 //=============================================================================
83 * BLSURFPlugin_Hypothesis_i::GetTopology
87 //=============================================================================
88 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology()
90 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTopology");
92 return this->GetImpl()->GetTopology();
95 //=============================================================================
97 //=============================================================================
99 * BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
104 //=============================================================================
105 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh (CORBA::Long theValue)
107 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhysicalMesh");
109 this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh)theValue);
110 SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
113 //=============================================================================
115 * BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
119 //=============================================================================
120 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh()
122 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhysicalMesh");
124 return this->GetImpl()->GetPhysicalMesh();
127 //=============================================================================
129 * BLSURFPlugin_Hypothesis_i::SetPhySize
133 //=============================================================================
134 void BLSURFPlugin_Hypothesis_i::SetPhySize (CORBA::Double theValue)
136 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize");
138 this->GetImpl()->SetPhySize(theValue);
139 SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
142 //=============================================================================
144 * BLSURFPlugin_Hypothesis_i::GetPhySize
148 //=============================================================================
149 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize()
151 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize");
153 return this->GetImpl()->GetPhySize();
156 //=============================================================================
157 void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize)
160 if ( GetPhyMin() != theMinSize ) {
161 this->GetImpl()->SetPhyMin(theMinSize);
162 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 if ( GetPhyMax() != theMaxSize ) {
179 this->GetImpl()->SetPhyMax(theMaxSize);
180 SMESH::TPythonDump() << _this() << ".SetPhyMax( " << theMaxSize << " )";
184 //=============================================================================
185 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax()
188 return this->GetImpl()->GetPhyMax();
192 //=============================================================================
194 * BLSURFPlugin_Hypothesis_i::SetGeometricMesh
199 //=============================================================================
200 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh (CORBA::Long theValue)
202 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGeometricMesh");
204 this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh)theValue);
205 SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
208 //=============================================================================
210 * BLSURFPlugin_Hypothesis_i::GetGeometricMesh
214 //=============================================================================
215 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh()
217 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGeometricMesh");
219 return this->GetImpl()->GetGeometricMesh();
222 //=============================================================================
224 * BLSURFPlugin_Hypothesis_i::SetAngleMeshS
228 //=============================================================================
229 void BLSURFPlugin_Hypothesis_i::SetAngleMeshS (CORBA::Double theValue)
231 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAngleMeshS");
233 this->GetImpl()->SetAngleMeshS(theValue);
234 SMESH::TPythonDump() << _this() << ".SetAngleMeshS( " << theValue << " )";
237 //=============================================================================
239 * BLSURFPlugin_Hypothesis_i::GetAngleMeshS
243 //=============================================================================
244 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS()
246 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAngleMeshS");
248 return this->GetImpl()->GetAngleMeshS();
251 //=============================================================================
252 void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle)
255 this->GetImpl()->SetAngleMeshC(angle);
256 SMESH::TPythonDump() << _this() << ".SetAngleMeshC( " << angle << " )";
259 //=============================================================================
260 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC()
263 return this->GetImpl()->GetAngleMeshC();
266 //=============================================================================
267 void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize)
270 if ( GetGeoMin() != theMinSize ) {
271 this->GetImpl()->SetGeoMin(theMinSize);
272 SMESH::TPythonDump() << _this() << ".SetGeoMin( " << theMinSize << " )";
276 //=============================================================================
277 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin()
280 return this->GetImpl()->GetGeoMin();
283 //=============================================================================
284 void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize)
287 if ( GetGeoMax() != theMaxSize ) {
288 this->GetImpl()->SetGeoMax(theMaxSize);
289 SMESH::TPythonDump() << _this() << ".SetGeoMax( " << theMaxSize << " )";
293 //=============================================================================
294 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax()
297 return this->GetImpl()->GetGeoMax();
300 //=============================================================================
302 * BLSURFPlugin_Hypothesis_i::SetGradation
306 //=============================================================================
307 void BLSURFPlugin_Hypothesis_i::SetGradation (CORBA::Double theValue)
309 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGradation");
311 this->GetImpl()->SetGradation(theValue);
312 SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
315 //=============================================================================
317 * BLSURFPlugin_Hypothesis_i::GetGradation
321 //=============================================================================
322 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation()
324 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGradation");
326 return this->GetImpl()->GetGradation();
329 //=============================================================================
331 * BLSURFPlugin_Hypothesis_i::SetQuadAllowed
335 //=============================================================================
336 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue)
338 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadAllowed");
340 this->GetImpl()->SetQuadAllowed(theValue);
341 SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
344 //=============================================================================
346 * BLSURFPlugin_Hypothesis_i::GetQuadAllowed
350 //=============================================================================
351 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed()
353 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadAllowed");
355 return this->GetImpl()->GetQuadAllowed();
358 //=============================================================================
360 * BLSURFPlugin_Hypothesis_i::SetDecimesh
364 //=============================================================================
365 void BLSURFPlugin_Hypothesis_i::SetDecimesh (CORBA::Boolean theValue)
367 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetDecimesh");
369 this->GetImpl()->SetDecimesh(theValue);
370 SMESH::TPythonDump() << _this() << ".SetDecimesh( " << theValue << " )";
373 //=============================================================================
375 * BLSURFPlugin_Hypothesis_i::GetDecimesh
379 //=============================================================================
380 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh()
382 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetDecimesh");
384 return this->GetImpl()->GetDecimesh();
387 //=============================================================================
388 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal)
389 throw (SALOME::SALOME_Exception)
392 if ( theVal < 0 || theVal > 100 )
393 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM );
394 this->GetImpl()->SetVerbosity(theVal);
395 SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )";
398 //=============================================================================
400 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity()
403 return (CORBA::Short) this->GetImpl()->GetVerbosity();
406 //=============================================================================
408 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName,
409 const char* optionValue)
410 throw (SALOME::SALOME_Exception)
413 bool valueChanged = false;
415 valueChanged = ( this->GetImpl()->GetOptionValue(optionName) != optionValue );
417 this->GetImpl()->SetOptionValue(optionName, optionValue);
419 catch (const std::invalid_argument& ex) {
420 SALOME::ExceptionStruct ExDescription;
421 ExDescription.text = ex.what();
422 ExDescription.type = SALOME::BAD_PARAM;
423 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetOptionValue(name,value)";
424 ExDescription.lineNumber = 0;
425 throw SALOME::SALOME_Exception(ExDescription);
427 catch (SALOME_Exception& ex) {
428 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
431 SMESH::TPythonDump() << _this() << ".SetOptionValue( '"
432 << optionName << "', '" << optionValue << "' )";
435 //=============================================================================
437 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
438 throw (SALOME::SALOME_Exception)
442 return CORBA::string_dup( this->GetImpl()->GetOptionValue(optionName).c_str() );
444 catch (const std::invalid_argument& ex) {
445 SALOME::ExceptionStruct ExDescription;
446 ExDescription.text = ex.what();
447 ExDescription.type = SALOME::BAD_PARAM;
448 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetOptionValue(name)";
449 ExDescription.lineNumber = 0;
450 throw SALOME::SALOME_Exception(ExDescription);
452 catch (SALOME_Exception& ex) {
453 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
458 //=============================================================================
460 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName)
463 this->GetImpl()->ClearOption(optionName);
464 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
467 //=============================================================================
469 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues()
472 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
474 const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
475 result->length( opts.size() );
477 ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
478 for ( int i = 0 ; opIt != opts.end(); ++opIt, ++i ) {
479 string name_value = opIt->first;
480 if ( !opIt->second.empty() ) {
482 name_value += opIt->second;
484 result[i] = CORBA::string_dup(name_value.c_str());
486 return result._retn();
489 //=============================================================================
491 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
492 throw (SALOME::SALOME_Exception)
495 for (int i = 0; i < options.length(); ++i)
497 string name_value = options[i].in();
498 int colonPos = name_value.find( ':' );
500 if ( colonPos == string::npos ) // ':' not found
503 name = name_value.substr( 0, colonPos);
504 if ( colonPos < name_value.size()-1 && name_value[colonPos] != ' ')
505 value = name_value.substr( colonPos+1 );
507 SetOptionValue( name.c_str(), value.c_str() );
511 //=============================================================================
513 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry,const char* sizeMap)
514 throw (SALOME::SALOME_Exception)
517 std::cout << "ENGINE : SETSIZEMAP START ENTRY : " << entry << std::endl;
518 bool valueChanged = false;
520 valueChanged = ( this->GetImpl()->GetSizeMapEntry(entry) != sizeMap );
522 this->GetImpl()->SetSizeMapEntry(entry, sizeMap);
524 catch (const std::invalid_argument& ex) {
525 SALOME::ExceptionStruct ExDescription;
526 ExDescription.text = ex.what();
527 ExDescription.type = SALOME::BAD_PARAM;
528 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
529 ExDescription.lineNumber = 0;
530 throw SALOME::SALOME_Exception(ExDescription);
532 catch (SALOME_Exception& ex) {
533 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
535 std::cout << "ENGINE : SETSIZEMAP END ENTRY : " << entry << std::endl;
537 SMESH::TPythonDump() << _this() << ".SetSizeMap("
538 << entry << ", '" << sizeMap << "' )";
541 //=============================================================================
543 char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry)
544 throw (SALOME::SALOME_Exception)
548 return CORBA::string_dup( this->GetImpl()->GetSizeMapEntry(entry).c_str());
550 catch (const std::invalid_argument& ex) {
551 SALOME::ExceptionStruct ExDescription;
552 ExDescription.text = ex.what();
553 ExDescription.type = SALOME::BAD_PARAM;
554 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)";
555 ExDescription.lineNumber = 0;
556 throw SALOME::SALOME_Exception(ExDescription);
558 catch (SALOME_Exception& ex) {
559 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
564 //=============================================================================
566 void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry)
569 this->GetImpl()->ClearEntry(entry);
570 SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";
573 //=============================================================================
575 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries()
578 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
580 const ::BLSURFPlugin_Hypothesis::TSizeMap & sizeMaps= this->GetImpl()->GetSizeMapEntries();
581 result->length( sizeMaps.size() );
583 ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin();
584 for ( int i = 0 ; smIt != sizeMaps.end(); ++smIt, ++i ) {
585 string entry_sizemap = smIt->first;
586 if ( !smIt->second.empty() ) {
587 entry_sizemap += "|";
588 entry_sizemap += smIt->second;
590 result[i] = CORBA::string_dup(entry_sizemap.c_str());
592 return result._retn();
595 //=============================================================================
597 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)
598 throw (SALOME::SALOME_Exception)
601 for (int i = 0; i < sizeMaps.length(); ++i)
603 string entry_sizemap = sizeMaps[i].in();
604 int colonPos = entry_sizemap.find( '|' );
605 string entry, sizemap;
606 if ( colonPos == string::npos ) // '|' separator not found
607 entry = entry_sizemap;
609 entry = entry_sizemap.substr( 0, colonPos);
610 if ( colonPos < entry_sizemap.size()-1 && entry_sizemap[colonPos] != ' ')
611 sizemap = entry_sizemap.substr( colonPos+1 );
613 this->GetImpl()->SetSizeMapEntry( entry.c_str(), sizemap.c_str() );
617 //=============================================================================
619 void BLSURFPlugin_Hypothesis_i::ClearSizeMaps()
622 this->GetImpl()->ClearSizeMaps();
626 //=============================================================================
628 void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj,const char* sizeMap)
632 entry=GeomObj->GetStudyEntry();
633 std::cout << "IDL : GetName : " << GeomObj->GetName() << std::endl;
634 std::cout << "IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")" << std::endl;
635 SetSizeMapEntry( entry.c_str(),sizeMap);
638 //=============================================================================
639 void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj)
643 entry=GeomObj->GetStudyEntry();
644 std::cout << "IDL : GetName : " << GeomObj->GetName() << std::endl;
645 std::cout << "IDL : UNSETSIZEMAP ( "<< entry << ")" << std::endl;
646 UnsetEntry( entry.c_str());
651 //=============================================================================
653 * BLSURFPlugin_Hypothesis_i::GetImpl
657 //=============================================================================
658 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl()
660 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
661 return (::BLSURFPlugin_Hypothesis*)myBaseImpl;
664 //================================================================================
666 * \brief Verify whether hypothesis supports given entity type
667 * \param type - dimension (see SMESH::Dimension enumeration)
668 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
670 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
672 //================================================================================
673 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
675 return type == SMESH::DIM_2D;