1 // Copyright (C) 2007-2010 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
21 // File : BLSURFPlugin_Hypothesis.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
26 #include "BLSURFPlugin_Hypothesis_i.hxx"
27 #include "SMESH_Gen.hxx"
28 #include "SMESH_PythonDump.hxx"
29 #include "GEOM_Object.hxx"
31 #include "Utils_CorbaException.hxx"
32 #include "utilities.h"
35 #include "boost/regex.hpp"
37 //=============================================================================
39 * BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i
43 //=============================================================================
44 BLSURFPlugin_Hypothesis_i::
45 BLSURFPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
47 ::SMESH_Gen* theGenImpl)
48 : SALOME::GenericObj_i( thePOA ),
49 SMESH_Hypothesis_i( thePOA )
51 MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" );
52 myBaseImpl = new ::BLSURFPlugin_Hypothesis (theGenImpl->GetANewId(),
57 //=============================================================================
59 * BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i
63 //=============================================================================
64 BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i()
66 MESSAGE( "BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i" );
70 * BLSURFPlugin_Hypothesis_i::SetTopology
75 //=============================================================================
76 void BLSURFPlugin_Hypothesis_i::SetTopology (CORBA::Long theValue)
78 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTopology");
80 this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology)theValue);
81 SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
84 //=============================================================================
86 * BLSURFPlugin_Hypothesis_i::GetTopology
90 //=============================================================================
91 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology()
93 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTopology");
95 return this->GetImpl()->GetTopology();
98 //=============================================================================
100 //=============================================================================
102 * BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
107 //=============================================================================
108 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh (CORBA::Long theValue)
110 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhysicalMesh");
112 this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh)theValue);
113 SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
116 //=============================================================================
118 * BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
122 //=============================================================================
123 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh()
125 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhysicalMesh");
127 return this->GetImpl()->GetPhysicalMesh();
130 //=============================================================================
132 * BLSURFPlugin_Hypothesis_i::SetPhySize
136 //=============================================================================
137 void BLSURFPlugin_Hypothesis_i::SetPhySize (CORBA::Double theValue)
139 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize");
141 this->GetImpl()->SetPhySize(theValue);
142 SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
145 //=============================================================================
147 * BLSURFPlugin_Hypothesis_i::GetPhySize
151 //=============================================================================
152 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize()
154 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize");
156 return this->GetImpl()->GetPhySize();
159 //=============================================================================
160 void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize)
163 if ( GetPhyMin() != theMinSize ) {
164 this->GetImpl()->SetPhyMin(theMinSize);
165 SMESH::TPythonDump() << _this() << ".SetPhyMin( " << theMinSize << " )";
169 //=============================================================================
170 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin()
173 return this->GetImpl()->GetPhyMin();
177 //=============================================================================
178 void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize)
181 if ( GetPhyMax() != theMaxSize ) {
182 this->GetImpl()->SetPhyMax(theMaxSize);
183 SMESH::TPythonDump() << _this() << ".SetPhyMax( " << theMaxSize << " )";
187 //=============================================================================
188 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax()
191 return this->GetImpl()->GetPhyMax();
195 //=============================================================================
197 * BLSURFPlugin_Hypothesis_i::SetGeometricMesh
202 //=============================================================================
203 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh (CORBA::Long theValue)
205 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGeometricMesh");
207 this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh)theValue);
208 SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
211 //=============================================================================
213 * BLSURFPlugin_Hypothesis_i::GetGeometricMesh
217 //=============================================================================
218 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh()
220 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGeometricMesh");
222 return this->GetImpl()->GetGeometricMesh();
225 //=============================================================================
227 * BLSURFPlugin_Hypothesis_i::SetAngleMeshS
231 //=============================================================================
232 void BLSURFPlugin_Hypothesis_i::SetAngleMeshS (CORBA::Double theValue)
234 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAngleMeshS");
236 this->GetImpl()->SetAngleMeshS(theValue);
237 SMESH::TPythonDump() << _this() << ".SetAngleMeshS( " << theValue << " )";
240 //=============================================================================
242 * BLSURFPlugin_Hypothesis_i::GetAngleMeshS
246 //=============================================================================
247 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS()
249 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAngleMeshS");
251 return this->GetImpl()->GetAngleMeshS();
254 //=============================================================================
255 void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle)
258 this->GetImpl()->SetAngleMeshC(angle);
259 SMESH::TPythonDump() << _this() << ".SetAngleMeshC( " << angle << " )";
262 //=============================================================================
263 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC()
266 return this->GetImpl()->GetAngleMeshC();
269 //=============================================================================
270 void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize)
273 if ( GetGeoMin() != theMinSize ) {
274 this->GetImpl()->SetGeoMin(theMinSize);
275 SMESH::TPythonDump() << _this() << ".SetGeoMin( " << theMinSize << " )";
279 //=============================================================================
280 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin()
283 return this->GetImpl()->GetGeoMin();
286 //=============================================================================
287 void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize)
290 if ( GetGeoMax() != theMaxSize ) {
291 this->GetImpl()->SetGeoMax(theMaxSize);
292 SMESH::TPythonDump() << _this() << ".SetGeoMax( " << theMaxSize << " )";
296 //=============================================================================
297 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax()
300 return this->GetImpl()->GetGeoMax();
303 //=============================================================================
305 * BLSURFPlugin_Hypothesis_i::SetGradation
309 //=============================================================================
310 void BLSURFPlugin_Hypothesis_i::SetGradation (CORBA::Double theValue)
312 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGradation");
314 this->GetImpl()->SetGradation(theValue);
315 SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
318 //=============================================================================
320 * BLSURFPlugin_Hypothesis_i::GetGradation
324 //=============================================================================
325 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation()
327 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGradation");
329 return this->GetImpl()->GetGradation();
332 //=============================================================================
334 * BLSURFPlugin_Hypothesis_i::SetQuadAllowed
338 //=============================================================================
339 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue)
341 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadAllowed");
343 this->GetImpl()->SetQuadAllowed(theValue);
344 SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
347 //=============================================================================
349 * BLSURFPlugin_Hypothesis_i::GetQuadAllowed
353 //=============================================================================
354 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed()
356 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadAllowed");
358 return this->GetImpl()->GetQuadAllowed();
361 //=============================================================================
363 * BLSURFPlugin_Hypothesis_i::SetDecimesh
367 //=============================================================================
368 void BLSURFPlugin_Hypothesis_i::SetDecimesh (CORBA::Boolean theValue)
370 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetDecimesh");
372 this->GetImpl()->SetDecimesh(theValue);
373 SMESH::TPythonDump() << _this() << ".SetDecimesh( " << theValue << " )";
376 //=============================================================================
378 * BLSURFPlugin_Hypothesis_i::GetDecimesh
382 //=============================================================================
383 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh()
385 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetDecimesh");
387 return this->GetImpl()->GetDecimesh();
390 //=============================================================================
391 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal)
392 throw (SALOME::SALOME_Exception)
395 if ( theVal < 0 || theVal > 100 )
396 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM );
397 this->GetImpl()->SetVerbosity(theVal);
398 SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )";
401 //=============================================================================
403 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity()
406 return (CORBA::Short) this->GetImpl()->GetVerbosity();
409 //=============================================================================
411 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName,
412 const char* optionValue)
413 throw (SALOME::SALOME_Exception)
416 bool valueChanged = false;
418 valueChanged = ( this->GetImpl()->GetOptionValue(optionName) != optionValue );
420 this->GetImpl()->SetOptionValue(optionName, optionValue);
422 catch (const std::invalid_argument& ex) {
423 SALOME::ExceptionStruct ExDescription;
424 ExDescription.text = ex.what();
425 ExDescription.type = SALOME::BAD_PARAM;
426 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetOptionValue(name,value)";
427 ExDescription.lineNumber = 0;
428 throw SALOME::SALOME_Exception(ExDescription);
430 catch (SALOME_Exception& ex) {
431 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
434 SMESH::TPythonDump() << _this() << ".SetOptionValue( '"
435 << optionName << "', '" << optionValue << "' )";
438 //=============================================================================
440 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
441 throw (SALOME::SALOME_Exception)
445 return CORBA::string_dup( this->GetImpl()->GetOptionValue(optionName).c_str() );
447 catch (const std::invalid_argument& ex) {
448 SALOME::ExceptionStruct ExDescription;
449 ExDescription.text = ex.what();
450 ExDescription.type = SALOME::BAD_PARAM;
451 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetOptionValue(name)";
452 ExDescription.lineNumber = 0;
453 throw SALOME::SALOME_Exception(ExDescription);
455 catch (SALOME_Exception& ex) {
456 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
461 //=============================================================================
463 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName)
466 this->GetImpl()->ClearOption(optionName);
467 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
470 //=============================================================================
472 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues()
475 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
477 const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
478 result->length( opts.size() );
480 ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
481 for ( int i = 0 ; opIt != opts.end(); ++opIt, ++i ) {
482 string name_value = opIt->first;
483 if ( !opIt->second.empty() ) {
485 name_value += opIt->second;
487 result[i] = CORBA::string_dup(name_value.c_str());
489 return result._retn();
492 //=============================================================================
494 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
495 throw (SALOME::SALOME_Exception)
498 for (int i = 0; i < options.length(); ++i)
500 string name_value = options[i].in();
501 int colonPos = name_value.find( ':' );
503 if ( colonPos == string::npos ) // ':' not found
506 name = name_value.substr( 0, colonPos);
507 if ( colonPos < name_value.size()-1 && name_value[colonPos] != ' ')
508 value = name_value.substr( colonPos+1 );
510 SetOptionValue( name.c_str(), value.c_str() );
514 //=============================================================================
516 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry,const char* sizeMap)
517 throw (SALOME::SALOME_Exception)
520 MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry);
521 bool valueChanged = false;
523 valueChanged = ( this->GetImpl()->GetSizeMapEntry(entry) != sizeMap );
525 this->GetImpl()->SetSizeMapEntry(entry, sizeMap);
527 catch (const std::invalid_argument& ex) {
528 SALOME::ExceptionStruct ExDescription;
529 ExDescription.text = ex.what();
530 ExDescription.type = SALOME::BAD_PARAM;
531 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
532 ExDescription.lineNumber = 0;
533 throw SALOME::SALOME_Exception(ExDescription);
535 catch (SALOME_Exception& ex) {
536 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
538 MESSAGE("ENGINE : SETSIZEMAP END ENTRY : " << entry);
540 SMESH::TPythonDump() << _this() << ".SetSizeMap("
541 << entry << ", '" << sizeMap << "' )";
544 //=============================================================================
546 void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* attractor )
547 throw (SALOME::SALOME_Exception)
550 MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry);
551 bool valueChanged = false;
553 valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor );
554 if ( valueChanged ) {
555 boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$");
556 if (!boost::regex_match(string(attractor), re))
557 throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False)");
558 this->GetImpl()->SetAttractorEntry(entry, attractor);
561 catch (const std::invalid_argument& ex) {
562 SALOME::ExceptionStruct ExDescription;
563 ExDescription.text = ex.what();
564 ExDescription.type = SALOME::BAD_PARAM;
565 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)";
566 ExDescription.lineNumber = 0;
567 throw SALOME::SALOME_Exception(ExDescription);
569 catch (SALOME_Exception& ex) {
570 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
572 MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry);
574 SMESH::TPythonDump() << _this() << ".SetAttractor("
575 << entry << ", '" << attractor << "' )";
579 //=============================================================================
581 char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry)
582 throw (SALOME::SALOME_Exception)
586 return CORBA::string_dup( this->GetImpl()->GetSizeMapEntry(entry).c_str());
588 catch (const std::invalid_argument& ex) {
589 SALOME::ExceptionStruct ExDescription;
590 ExDescription.text = ex.what();
591 ExDescription.type = SALOME::BAD_PARAM;
592 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)";
593 ExDescription.lineNumber = 0;
594 throw SALOME::SALOME_Exception(ExDescription);
596 catch (SALOME_Exception& ex) {
597 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
602 //=============================================================================
604 char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry)
605 throw (SALOME::SALOME_Exception)
609 return CORBA::string_dup( this->GetImpl()->GetAttractorEntry(entry).c_str());
611 catch (const std::invalid_argument& ex) {
612 SALOME::ExceptionStruct ExDescription;
613 ExDescription.text = ex.what();
614 ExDescription.type = SALOME::BAD_PARAM;
615 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetAttractorEntry(name)";
616 ExDescription.lineNumber = 0;
617 throw SALOME::SALOME_Exception(ExDescription);
619 catch (SALOME_Exception& ex) {
620 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
625 //=============================================================================
627 void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry)
630 this->GetImpl()->ClearEntry(entry);
631 // SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";
634 //=============================================================================
636 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries()
639 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
641 const ::BLSURFPlugin_Hypothesis::TSizeMap sizeMaps= this->GetImpl()->_GetSizeMapEntries();
642 result->length( sizeMaps.size() );
644 ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin();
645 for ( int i = 0 ; smIt != sizeMaps.end(); ++smIt, ++i ) {
646 string entry_sizemap = smIt->first;
647 if ( !smIt->second.empty() ) {
648 entry_sizemap += "|";
649 entry_sizemap += smIt->second;
651 result[i] = CORBA::string_dup(entry_sizemap.c_str());
653 return result._retn();
656 //=============================================================================
658 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries()
661 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
663 const ::BLSURFPlugin_Hypothesis::TSizeMap attractors= this->GetImpl()->_GetAttractorEntries();
664 result->length( attractors.size() );
666 ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin();
667 for ( int i = 0 ; atIt != attractors.end(); ++atIt, ++i ) {
668 string entry_attractor = atIt->first;
669 if ( !atIt->second.empty() ) {
670 entry_attractor += "|";
671 entry_attractor += atIt->second;
673 result[i] = CORBA::string_dup(entry_attractor.c_str());
675 return result._retn();
678 //=============================================================================
680 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)
681 throw (SALOME::SALOME_Exception)
684 for (int i = 0; i < sizeMaps.length(); ++i)
686 string entry_sizemap = sizeMaps[i].in();
687 int colonPos = entry_sizemap.find( '|' );
688 string entry, sizemap;
689 if ( colonPos == string::npos ) // '|' separator not found
690 entry = entry_sizemap;
692 entry = entry_sizemap.substr( 0, colonPos);
693 if ( colonPos < entry_sizemap.size()-1 && entry_sizemap[colonPos] != ' ')
694 sizemap = entry_sizemap.substr( colonPos+1 );
696 this->GetImpl()->SetSizeMapEntry( entry.c_str(), sizemap.c_str() );
700 //=============================================================================
702 void BLSURFPlugin_Hypothesis_i::ClearSizeMaps()
705 this->GetImpl()->ClearSizeMaps();
709 //=============================================================================
711 void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj,const char* sizeMap)
715 entry=GeomObj->GetStudyEntry();
716 MESSAGE("IDL : GetName : " << GeomObj->GetName());
717 MESSAGE("IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")");
718 SetSizeMapEntry( entry.c_str(),sizeMap);
721 //=============================================================================
722 void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj)
726 entry=GeomObj->GetStudyEntry();
727 MESSAGE("IDL : GetName : " << GeomObj->GetName());
728 MESSAGE("IDL : UNSETSIZEMAP ( "<< entry << ")");
729 UnsetEntry( entry.c_str());
730 SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )";
734 void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor)
738 entry=GeomObj->GetStudyEntry();
739 MESSAGE("IDL : GetName : " << GeomObj->GetName());
740 MESSAGE("IDL : SETATTRACTOR ( "<< entry << " , " << attractor << ")");
741 SetAttractorEntry( entry.c_str(),attractor);
744 void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj)
748 entry=GeomObj->GetStudyEntry();
749 MESSAGE("IDL : GetName : " << GeomObj->GetName());
750 MESSAGE("IDL : UNSETATTRACTOR ( "<< entry << ")");
751 UnsetEntry( entry.c_str());
752 SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
759 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
762 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj)
765 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap ) throw (SALOME::SALOME_Exception)
768 char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception)
771 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry)
774 this->GetImpl()->UnsetCustomSizeMap(entry);
775 SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )";
779 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries()
785 ///////////////////////
786 // ENFORCED VERTEXES //
787 ///////////////////////
789 BLSURFPlugin::TEnforcedVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices()
791 MESSAGE("IDL: GetAllEnforcedVertices()");
793 BLSURFPlugin::TEnforcedVertexMap_var resultMap = new BLSURFPlugin::TEnforcedVertexMap();
794 const ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap enforcedVertexMap = this->GetImpl()->_GetAllEnforcedVertices();
795 resultMap->length(enforcedVertexMap.size());
796 MESSAGE("Enforced Vertex map size is " << enforcedVertexMap.size());
798 ::BLSURFPlugin_Hypothesis::TEnforcedVertexList enforcedVertexList;
799 ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap::const_iterator evmIt = enforcedVertexMap.begin();
800 for ( int i = 0 ; evmIt != enforcedVertexMap.end(); ++evmIt, ++i ) {
801 string entry = evmIt->first;
802 MESSAGE("Entry: " << entry);
803 enforcedVertexList = evmIt->second;
805 BLSURFPlugin::TEnforcedVertexMapElement_var mapElement = new BLSURFPlugin::TEnforcedVertexMapElement();
807 BLSURFPlugin::TEnforcedVertexList_var vertexList = new BLSURFPlugin::TEnforcedVertexList();
808 vertexList->length(enforcedVertexList.size());
809 MESSAGE("Number of enforced vertices: " << enforcedVertexList.size());
811 ::BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = enforcedVertexList.begin();
812 for ( int j = 0 ; evlIt != enforcedVertexList.end(); ++evlIt, ++j ) {
813 MESSAGE("Enforced Vertex #" << j);
814 BLSURFPlugin::TEnforcedVertex_var enforcedVertex = new BLSURFPlugin::TEnforcedVertex();
815 enforcedVertex->length(3);
816 enforcedVertex[0] = (*evlIt)[0];
817 enforcedVertex[1] = (*evlIt)[1];
818 enforcedVertex[2] = (*evlIt)[2];
819 vertexList[j] = enforcedVertex;
820 MESSAGE("Enforced vertex: " << enforcedVertex[0] << ", " << enforcedVertex[1] << ", " << enforcedVertex[2]);
823 mapElement->entry = CORBA::string_dup(entry.c_str());
824 mapElement->vertexList = vertexList;
826 resultMap[i] = mapElement;
829 return resultMap._retn();
832 void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices()
835 this->GetImpl()->ClearAllEnforcedVertices();
836 SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVertices()";
840 * Set/get/unset an enforced vertex on geom object
842 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
843 throw (SALOME::SALOME_Exception)
846 // TODO check that GeomObj is a face => in engine ?
847 string entry = GeomObj->GetStudyEntry();
848 MESSAGE("IDL : GetName : " << GeomObj->GetName());
849 MESSAGE("IDL : SetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
851 SetEnforcedVertexEntry(entry.c_str(), x, y, z);
853 catch (SALOME_Exception& ex) {
854 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
859 BLSURFPlugin::TEnforcedVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj)
860 throw (SALOME::SALOME_Exception)
863 string entry = GeomObj->GetStudyEntry();
864 MESSAGE("IDL : GetName : " << GeomObj->GetName());
865 MESSAGE("IDL : GetEnforcedVertexList ( "<< entry << ")");
867 return GetEnforcedVerticesEntry(entry.c_str());
869 catch (SALOME_Exception& ex) {
870 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
875 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
876 throw (SALOME::SALOME_Exception)
879 string entry = GeomObj->GetStudyEntry();
880 MESSAGE("IDL : GetName : " << GeomObj->GetName());
881 MESSAGE("IDL : UnsetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
884 UnsetEnforcedVertexEntry(entry.c_str(), x, y, z);
886 catch (SALOME_Exception& ex) {
887 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
892 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj)
893 throw (SALOME::SALOME_Exception)
896 string entry = GeomObj->GetStudyEntry();
897 MESSAGE("IDL : GetName : " << GeomObj->GetName());
898 MESSAGE("IDL : UnsetEnforcedVertices ( "<< entry << ")");
901 UnsetEnforcedVerticesEntry(entry.c_str());
903 catch (SALOME_Exception& ex) {
904 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
910 * Set/get/unset an enforced vertex on geom object given by entry
912 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* entry, double x, double y, double z)
913 throw (SALOME::SALOME_Exception)
916 MESSAGE("IDL : SETENFORCEDVERTEX START - ENTRY: " << entry << " VERTEX: " << x << " " << y << " " << z);
917 bool newValue = false;
920 ::BLSURFPlugin_Hypothesis::TEnforcedVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry);
921 ::BLSURFPlugin_Hypothesis::TEnforcedVertex vertex;
925 if (vertexList.find(vertex) == vertexList.end()) {
926 MESSAGE("Vertex not found: add it in vertexList")
930 MESSAGE("Vertex already found")
932 catch (const std::invalid_argument& ex) {
933 // no enforced vertex for entry
934 MESSAGE("Entry not found : add it to the list")
937 catch (SALOME_Exception& ex) {
938 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
942 this->GetImpl()->SetEnforcedVertex(entry, x, y, z);
943 SMESH::TPythonDump() << _this() << ".SetEnforcedVertex("
949 MESSAGE("IDL : SETENFORCEDVERTEX END - ENTRY: " << entry);
952 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList)
953 throw (SALOME::SALOME_Exception)
959 BLSURFPlugin::TEnforcedVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry)
960 throw (SALOME::SALOME_Exception)
963 MESSAGE("ENGINE : GETENFORCEDVERTICES START ENTRY : " << entry);
966 BLSURFPlugin::TEnforcedVertexList_var vertexList = new BLSURFPlugin::TEnforcedVertexList();
967 ::BLSURFPlugin_Hypothesis::TEnforcedVertexList _vList = this->GetImpl()->GetEnforcedVertices(entry);
968 vertexList->length(_vList.size());
969 MESSAGE("Number of enforced vertices: " << _vList.size());
970 ::BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = _vList.begin();
971 for ( int i = 0; evlIt != _vList.end() ; ++evlIt, ++i ) {
972 BLSURFPlugin::TEnforcedVertex_var enforcedVertex = new BLSURFPlugin::TEnforcedVertex();
973 enforcedVertex->length(3);
974 MESSAGE("Enforced vertex #" << i << ": "<< (*evlIt)[0] << ", " << (*evlIt)[1] << ", " << (*evlIt)[2]);
975 enforcedVertex[0] = (*evlIt)[0];
976 enforcedVertex[1] = (*evlIt)[1];
977 enforcedVertex[2] = (*evlIt)[2];
978 vertexList[i] = enforcedVertex;
980 return vertexList._retn();
982 catch (const std::invalid_argument& ex) {
983 SALOME::ExceptionStruct ExDescription;
984 ExDescription.text = ex.what();
985 ExDescription.type = SALOME::BAD_PARAM;
986 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)";
987 ExDescription.lineNumber = 945;
988 throw SALOME::SALOME_Exception(ExDescription);
990 catch(const std::exception& ex) {
991 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
994 MESSAGE("ENGINE : GETENFORCEDVERTICES END ENTRY : " << entry);
998 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z)
999 throw (SALOME::SALOME_Exception)
1002 MESSAGE("ENGINE : UNSETENFORCEDVERTEX START ENTRY : " << entry);
1005 this->GetImpl()->ClearEnforcedVertex(entry, x, y, z);
1006 SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex("
1012 catch (const std::invalid_argument& ex) {
1013 SALOME::ExceptionStruct ExDescription;
1014 ExDescription.text = ex.what();
1015 ExDescription.type = SALOME::BAD_PARAM;
1016 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(entry,x,y,z)";
1017 ExDescription.lineNumber = 1003;
1018 throw SALOME::SALOME_Exception(ExDescription);
1020 catch(const std::exception& ex) {
1021 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1024 MESSAGE("ENGINE : UNSETENFORCEDVERTEX END ENTRY : " << entry);
1027 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList)
1028 throw (SALOME::SALOME_Exception)
1033 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* entry)
1034 throw (SALOME::SALOME_Exception)
1037 MESSAGE("ENGINE : UNSETENFORCEDVERTICES START ENTRY : " << entry);
1040 this->GetImpl()->ClearEnforcedVertices(entry);
1041 SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << entry << ")";
1043 catch (const std::invalid_argument& ex) {
1044 SALOME::ExceptionStruct ExDescription;
1045 ExDescription.text = ex.what();
1046 ExDescription.type = SALOME::BAD_PARAM;
1047 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(entry)";
1048 ExDescription.lineNumber = 1051;
1049 throw SALOME::SALOME_Exception(ExDescription);
1051 catch(const std::exception& ex) {
1052 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1055 MESSAGE("ENGINE : UNSETENFORCEDVERTICES END ENTRY : " << entry);
1059 ///////////////////////
1065 //=============================================================================
1067 * BLSURFPlugin_Hypothesis_i::GetImpl
1069 * Get implementation
1071 //=============================================================================
1072 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl()
1074 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
1075 return (::BLSURFPlugin_Hypothesis*)myBaseImpl;
1078 //================================================================================
1080 * \brief Verify whether hypothesis supports given entity type
1081 * \param type - dimension (see SMESH::Dimension enumeration)
1082 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
1084 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
1086 //================================================================================
1087 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1089 return type == SMESH::DIM_2D;