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"
36 #include "boost/regex.hpp"
38 //=============================================================================
40 * BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i
44 //=============================================================================
45 BLSURFPlugin_Hypothesis_i::
46 BLSURFPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
48 ::SMESH_Gen* theGenImpl)
49 : SALOME::GenericObj_i( thePOA ),
50 SMESH_Hypothesis_i( thePOA )
52 MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" );
53 myBaseImpl = new ::BLSURFPlugin_Hypothesis (theGenImpl->GetANewId(),
58 //=============================================================================
60 * BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i
64 //=============================================================================
65 BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i()
67 MESSAGE( "BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i" );
71 * BLSURFPlugin_Hypothesis_i::SetTopology
76 //=============================================================================
77 void BLSURFPlugin_Hypothesis_i::SetTopology (CORBA::Long theValue)
79 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTopology");
81 this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology)theValue);
82 SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
85 //=============================================================================
87 * BLSURFPlugin_Hypothesis_i::GetTopology
91 //=============================================================================
92 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology()
94 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTopology");
96 return this->GetImpl()->GetTopology();
99 //=============================================================================
101 //=============================================================================
103 * BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
108 //=============================================================================
109 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh (CORBA::Long theValue)
111 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhysicalMesh");
113 this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh)theValue);
114 SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
117 //=============================================================================
119 * BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
123 //=============================================================================
124 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh()
126 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhysicalMesh");
128 return this->GetImpl()->GetPhysicalMesh();
131 //=============================================================================
133 * BLSURFPlugin_Hypothesis_i::SetPhySize
137 //=============================================================================
138 void BLSURFPlugin_Hypothesis_i::SetPhySize (CORBA::Double theValue)
140 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize");
142 this->GetImpl()->SetPhySize(theValue);
143 SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
146 //=============================================================================
148 * BLSURFPlugin_Hypothesis_i::GetPhySize
152 //=============================================================================
153 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize()
155 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize");
157 return this->GetImpl()->GetPhySize();
160 //=============================================================================
161 void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize)
164 if ( GetPhyMin() != theMinSize ) {
165 this->GetImpl()->SetPhyMin(theMinSize);
166 SMESH::TPythonDump() << _this() << ".SetPhyMin( " << theMinSize << " )";
170 //=============================================================================
171 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin()
174 return this->GetImpl()->GetPhyMin();
178 //=============================================================================
179 void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize)
182 if ( GetPhyMax() != theMaxSize ) {
183 this->GetImpl()->SetPhyMax(theMaxSize);
184 SMESH::TPythonDump() << _this() << ".SetPhyMax( " << theMaxSize << " )";
188 //=============================================================================
189 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax()
192 return this->GetImpl()->GetPhyMax();
196 //=============================================================================
198 * BLSURFPlugin_Hypothesis_i::SetGeometricMesh
203 //=============================================================================
204 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh (CORBA::Long theValue)
206 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGeometricMesh");
208 this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh)theValue);
209 SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
212 //=============================================================================
214 * BLSURFPlugin_Hypothesis_i::GetGeometricMesh
218 //=============================================================================
219 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh()
221 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGeometricMesh");
223 return this->GetImpl()->GetGeometricMesh();
226 //=============================================================================
228 * BLSURFPlugin_Hypothesis_i::SetAngleMeshS
232 //=============================================================================
233 void BLSURFPlugin_Hypothesis_i::SetAngleMeshS (CORBA::Double theValue)
235 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAngleMeshS");
237 this->GetImpl()->SetAngleMeshS(theValue);
238 SMESH::TPythonDump() << _this() << ".SetAngleMeshS( " << theValue << " )";
241 //=============================================================================
243 * BLSURFPlugin_Hypothesis_i::GetAngleMeshS
247 //=============================================================================
248 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS()
250 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAngleMeshS");
252 return this->GetImpl()->GetAngleMeshS();
255 //=============================================================================
256 void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle)
259 this->GetImpl()->SetAngleMeshC(angle);
260 SMESH::TPythonDump() << _this() << ".SetAngleMeshC( " << angle << " )";
263 //=============================================================================
264 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC()
267 return this->GetImpl()->GetAngleMeshC();
270 //=============================================================================
271 void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize)
274 if ( GetGeoMin() != theMinSize ) {
275 this->GetImpl()->SetGeoMin(theMinSize);
276 SMESH::TPythonDump() << _this() << ".SetGeoMin( " << theMinSize << " )";
280 //=============================================================================
281 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin()
284 return this->GetImpl()->GetGeoMin();
287 //=============================================================================
288 void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize)
291 if ( GetGeoMax() != theMaxSize ) {
292 this->GetImpl()->SetGeoMax(theMaxSize);
293 SMESH::TPythonDump() << _this() << ".SetGeoMax( " << theMaxSize << " )";
297 //=============================================================================
298 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax()
301 return this->GetImpl()->GetGeoMax();
304 //=============================================================================
306 * BLSURFPlugin_Hypothesis_i::SetGradation
310 //=============================================================================
311 void BLSURFPlugin_Hypothesis_i::SetGradation (CORBA::Double theValue)
313 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGradation");
315 this->GetImpl()->SetGradation(theValue);
316 SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
319 //=============================================================================
321 * BLSURFPlugin_Hypothesis_i::GetGradation
325 //=============================================================================
326 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation()
328 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGradation");
330 return this->GetImpl()->GetGradation();
333 //=============================================================================
335 * BLSURFPlugin_Hypothesis_i::SetQuadAllowed
339 //=============================================================================
340 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue)
342 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadAllowed");
344 this->GetImpl()->SetQuadAllowed(theValue);
345 SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
348 //=============================================================================
350 * BLSURFPlugin_Hypothesis_i::GetQuadAllowed
354 //=============================================================================
355 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed()
357 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadAllowed");
359 return this->GetImpl()->GetQuadAllowed();
362 //=============================================================================
364 * BLSURFPlugin_Hypothesis_i::SetDecimesh
368 //=============================================================================
369 void BLSURFPlugin_Hypothesis_i::SetDecimesh (CORBA::Boolean theValue)
371 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetDecimesh");
373 this->GetImpl()->SetDecimesh(theValue);
374 SMESH::TPythonDump() << _this() << ".SetDecimesh( " << theValue << " )";
377 //=============================================================================
379 * BLSURFPlugin_Hypothesis_i::GetDecimesh
383 //=============================================================================
384 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh()
386 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetDecimesh");
388 return this->GetImpl()->GetDecimesh();
391 //=============================================================================
392 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal)
393 throw (SALOME::SALOME_Exception)
396 if ( theVal < 0 || theVal > 100 )
397 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM );
398 this->GetImpl()->SetVerbosity(theVal);
399 SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )";
402 //=============================================================================
404 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity()
407 return (CORBA::Short) this->GetImpl()->GetVerbosity();
410 //=============================================================================
412 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName,
413 const char* optionValue)
414 throw (SALOME::SALOME_Exception)
417 bool valueChanged = false;
419 valueChanged = ( this->GetImpl()->GetOptionValue(optionName) != optionValue );
421 this->GetImpl()->SetOptionValue(optionName, optionValue);
423 catch (const std::invalid_argument& ex) {
424 SALOME::ExceptionStruct ExDescription;
425 ExDescription.text = ex.what();
426 ExDescription.type = SALOME::BAD_PARAM;
427 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetOptionValue(name,value)";
428 ExDescription.lineNumber = 0;
429 throw SALOME::SALOME_Exception(ExDescription);
431 catch (SALOME_Exception& ex) {
432 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
435 SMESH::TPythonDump() << _this() << ".SetOptionValue( '"
436 << optionName << "', '" << optionValue << "' )";
439 //=============================================================================
441 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
442 throw (SALOME::SALOME_Exception)
446 return CORBA::string_dup( this->GetImpl()->GetOptionValue(optionName).c_str() );
448 catch (const std::invalid_argument& ex) {
449 SALOME::ExceptionStruct ExDescription;
450 ExDescription.text = ex.what();
451 ExDescription.type = SALOME::BAD_PARAM;
452 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetOptionValue(name)";
453 ExDescription.lineNumber = 0;
454 throw SALOME::SALOME_Exception(ExDescription);
456 catch (SALOME_Exception& ex) {
457 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
462 //=============================================================================
464 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName)
467 this->GetImpl()->ClearOption(optionName);
468 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
471 //=============================================================================
473 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues()
476 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
478 const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
479 result->length( opts.size() );
481 ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
482 for ( int i = 0 ; opIt != opts.end(); ++opIt, ++i ) {
483 string name_value = opIt->first;
484 if ( !opIt->second.empty() ) {
486 name_value += opIt->second;
488 result[i] = CORBA::string_dup(name_value.c_str());
490 return result._retn();
493 //=============================================================================
495 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
496 throw (SALOME::SALOME_Exception)
499 for (int i = 0; i < options.length(); ++i)
501 string name_value = options[i].in();
502 int colonPos = name_value.find( ':' );
504 if ( colonPos == string::npos ) // ':' not found
507 name = name_value.substr( 0, colonPos);
508 if ( colonPos < name_value.size()-1 && name_value[colonPos] != ' ')
509 value = name_value.substr( colonPos+1 );
511 SetOptionValue( name.c_str(), value.c_str() );
515 //=============================================================================
517 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry,const char* sizeMap)
518 throw (SALOME::SALOME_Exception)
521 MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry);
522 bool valueChanged = false;
524 valueChanged = ( this->GetImpl()->GetSizeMapEntry(entry) != sizeMap );
526 this->GetImpl()->SetSizeMapEntry(entry, sizeMap);
528 catch (const std::invalid_argument& ex) {
529 SALOME::ExceptionStruct ExDescription;
530 ExDescription.text = ex.what();
531 ExDescription.type = SALOME::BAD_PARAM;
532 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
533 ExDescription.lineNumber = 0;
534 throw SALOME::SALOME_Exception(ExDescription);
536 catch (SALOME_Exception& ex) {
537 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
539 MESSAGE("ENGINE : SETSIZEMAP END ENTRY : " << entry);
541 SMESH::TPythonDump() << _this() << ".SetSizeMap("
542 << entry << ", '" << sizeMap << "' )";
545 //=============================================================================
547 void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* attractor )
548 throw (SALOME::SALOME_Exception)
551 MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry);
552 bool valueChanged = false;
554 valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor );
555 if ( valueChanged ) {
556 boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$");
557 if (!boost::regex_match(string(attractor), re))
558 throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False)");
559 this->GetImpl()->SetAttractorEntry(entry, attractor);
562 catch (const std::invalid_argument& ex) {
563 SALOME::ExceptionStruct ExDescription;
564 ExDescription.text = ex.what();
565 ExDescription.type = SALOME::BAD_PARAM;
566 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)";
567 ExDescription.lineNumber = 0;
568 throw SALOME::SALOME_Exception(ExDescription);
570 catch (SALOME_Exception& ex) {
571 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
573 MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry);
575 SMESH::TPythonDump() << _this() << ".SetAttractor("
576 << entry << ", '" << attractor << "' )";
580 //=============================================================================
582 char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry)
583 throw (SALOME::SALOME_Exception)
587 return CORBA::string_dup( this->GetImpl()->GetSizeMapEntry(entry).c_str());
589 catch (const std::invalid_argument& ex) {
590 SALOME::ExceptionStruct ExDescription;
591 ExDescription.text = ex.what();
592 ExDescription.type = SALOME::BAD_PARAM;
593 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)";
594 ExDescription.lineNumber = 0;
595 throw SALOME::SALOME_Exception(ExDescription);
597 catch (SALOME_Exception& ex) {
598 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
603 //=============================================================================
605 char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry)
606 throw (SALOME::SALOME_Exception)
610 return CORBA::string_dup( this->GetImpl()->GetAttractorEntry(entry).c_str());
612 catch (const std::invalid_argument& ex) {
613 SALOME::ExceptionStruct ExDescription;
614 ExDescription.text = ex.what();
615 ExDescription.type = SALOME::BAD_PARAM;
616 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetAttractorEntry(name)";
617 ExDescription.lineNumber = 0;
618 throw SALOME::SALOME_Exception(ExDescription);
620 catch (SALOME_Exception& ex) {
621 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
626 //=============================================================================
628 void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry)
631 this->GetImpl()->ClearEntry(entry);
632 // SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";
635 //=============================================================================
637 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries()
640 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
642 const ::BLSURFPlugin_Hypothesis::TSizeMap sizeMaps= this->GetImpl()->_GetSizeMapEntries();
643 result->length( sizeMaps.size() );
645 ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin();
646 for ( int i = 0 ; smIt != sizeMaps.end(); ++smIt, ++i ) {
647 string entry_sizemap = smIt->first;
648 if ( !smIt->second.empty() ) {
649 entry_sizemap += "|";
650 entry_sizemap += smIt->second;
652 result[i] = CORBA::string_dup(entry_sizemap.c_str());
654 return result._retn();
657 //=============================================================================
659 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries()
662 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
664 const ::BLSURFPlugin_Hypothesis::TSizeMap attractors= this->GetImpl()->_GetAttractorEntries();
665 result->length( attractors.size() );
667 ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin();
668 for ( int i = 0 ; atIt != attractors.end(); ++atIt, ++i ) {
669 string entry_attractor = atIt->first;
670 if ( !atIt->second.empty() ) {
671 entry_attractor += "|";
672 entry_attractor += atIt->second;
674 result[i] = CORBA::string_dup(entry_attractor.c_str());
676 return result._retn();
679 //=============================================================================
681 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)
682 throw (SALOME::SALOME_Exception)
685 for (int i = 0; i < sizeMaps.length(); ++i)
687 string entry_sizemap = sizeMaps[i].in();
688 int colonPos = entry_sizemap.find( '|' );
689 string entry, sizemap;
690 if ( colonPos == string::npos ) // '|' separator not found
691 entry = entry_sizemap;
693 entry = entry_sizemap.substr( 0, colonPos);
694 if ( colonPos < entry_sizemap.size()-1 && entry_sizemap[colonPos] != ' ')
695 sizemap = entry_sizemap.substr( colonPos+1 );
697 this->GetImpl()->SetSizeMapEntry( entry.c_str(), sizemap.c_str() );
701 //=============================================================================
703 void BLSURFPlugin_Hypothesis_i::ClearSizeMaps()
706 this->GetImpl()->ClearSizeMaps();
710 //=============================================================================
712 void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj,const char* sizeMap)
716 entry=GeomObj->GetStudyEntry();
717 MESSAGE("IDL : GetName : " << GeomObj->GetName());
718 MESSAGE("IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")");
719 SetSizeMapEntry( entry.c_str(),sizeMap);
722 //=============================================================================
723 void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj)
727 entry=GeomObj->GetStudyEntry();
728 MESSAGE("IDL : GetName : " << GeomObj->GetName());
729 MESSAGE("IDL : UNSETSIZEMAP ( "<< entry << ")");
730 UnsetEntry( entry.c_str());
731 SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )";
735 void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor)
739 entry=GeomObj->GetStudyEntry();
740 MESSAGE("IDL : GetName : " << GeomObj->GetName());
741 MESSAGE("IDL : SETATTRACTOR ( "<< entry << " , " << attractor << ")");
742 SetAttractorEntry( entry.c_str(),attractor);
745 void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj)
749 entry=GeomObj->GetStudyEntry();
750 MESSAGE("IDL : GetName : " << GeomObj->GetName());
751 MESSAGE("IDL : UNSETATTRACTOR ( "<< entry << ")");
752 UnsetEntry( entry.c_str());
753 SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
760 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
763 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj)
766 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap ) throw (SALOME::SALOME_Exception)
769 char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception)
772 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry)
775 this->GetImpl()->UnsetCustomSizeMap(entry);
776 SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )";
780 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries()
786 ///////////////////////
787 // ENFORCED VERTEXES //
788 ///////////////////////
790 BLSURFPlugin::TEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices()
792 MESSAGE("IDL: GetAllEnforcedVertices()");
794 BLSURFPlugin::TEntryEnfVertexListMap_var resultMap = new BLSURFPlugin::TEntryEnfVertexListMap();
795 const ::BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap entryEnfVertexListMap = this->GetImpl()->_GetAllEnforcedVertices();
796 resultMap->length(entryEnfVertexListMap.size());
797 MESSAGE("Enforced Vertex map size is " << entryEnfVertexListMap.size());
799 ::BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList;
800 ::BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap::const_iterator evmIt = entryEnfVertexListMap.begin();
801 for ( int i = 0 ; evmIt != entryEnfVertexListMap.end(); ++evmIt, ++i ) {
802 std::string entry = evmIt->first;
803 MESSAGE("Entry: " << entry);
804 enfVertexList = evmIt->second;
806 BLSURFPlugin::TEntryEnfVertexListMapElement_var mapElement = new BLSURFPlugin::TEntryEnfVertexListMapElement();
808 BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList();
809 vertexList->length(enfVertexList.size());
810 MESSAGE("Number of enforced vertices: " << enfVertexList.size());
812 ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin();
813 for ( int j = 0 ; evlIt != enfVertexList.end(); ++evlIt, ++j ) {
814 MESSAGE("Enforced Vertex #" << j);
815 BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
816 enfVertex->length(3);
817 enfVertex[0] = (*evlIt)[0];
818 enfVertex[1] = (*evlIt)[1];
819 enfVertex[2] = (*evlIt)[2];
820 vertexList[j] = enfVertex;
821 MESSAGE("Enforced vertex: " << enfVertex[0] << ", " << enfVertex[1] << ", " << enfVertex[2]);
824 mapElement->entry = CORBA::string_dup(entry.c_str());
825 mapElement->vertexList = vertexList;
827 resultMap[i] = mapElement;
830 return resultMap._retn();
833 void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices()
836 this->GetImpl()->ClearAllEnforcedVertices();
837 SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVertices()";
841 * Set/get/unset an enforced vertex on geom object
843 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
844 throw (SALOME::SALOME_Exception)
847 // TODO check that GeomObj is a face => in engine ?
848 // TODO Affecter un nom de groupe vide
849 string entry = GeomObj->GetStudyEntry();
850 MESSAGE("IDL : GetName : " << GeomObj->GetName());
851 MESSAGE("IDL : SetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
853 SetEnforcedVertexEntry(entry.c_str(), x, y, z);
855 catch (SALOME_Exception& ex) {
856 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
861 * Set/get/unset an enforced vertex on geom object with group name
864 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr GeomObj,
865 CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName)
866 throw (SALOME::SALOME_Exception)
869 // TODO check that GeomObj is a face => in engine ?
870 string entry = GeomObj->GetStudyEntry();
871 MESSAGE("IDL : GetName : " << GeomObj->GetName());
872 MESSAGE("IDL : SetEnforcedVertexWithGroup ( "<< entry << ", " << x << ", " << y << ", " << z << ", " << groupName <<")");
874 SetEnforcedVertexEntryWithGroup(entry.c_str(), x, y, z, groupName);
876 catch (SALOME_Exception& ex) {
877 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
881 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj)
882 throw (SALOME::SALOME_Exception)
885 string entry = GeomObj->GetStudyEntry();
886 MESSAGE("IDL : GetName : " << GeomObj->GetName());
887 MESSAGE("IDL : GetEnforcedVertexList ( "<< entry << ")");
889 return GetEnforcedVerticesEntry(entry.c_str());
891 catch (SALOME_Exception& ex) {
892 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
897 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
898 throw (SALOME::SALOME_Exception)
901 string entry = GeomObj->GetStudyEntry();
902 MESSAGE("IDL : GetName : " << GeomObj->GetName());
903 MESSAGE("IDL : UnsetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
906 UnsetEnforcedVertexEntry(entry.c_str(), x, y, z);
908 catch (SALOME_Exception& ex) {
909 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
914 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj)
915 throw (SALOME::SALOME_Exception)
918 string entry = GeomObj->GetStudyEntry();
919 MESSAGE("IDL : GetName : " << GeomObj->GetName());
920 MESSAGE("IDL : UnsetEnforcedVertices ( "<< entry << ")");
923 UnsetEnforcedVerticesEntry(entry.c_str());
925 catch (SALOME_Exception& ex) {
926 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
932 * Set/get/unset an enforced vertex on geom object given by entry
934 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* entry, double x, double y, double z)
935 throw (SALOME::SALOME_Exception)
938 MESSAGE("IDL : SETENFORCEDVERTEX START - ENTRY: " << entry << " VERTEX: " << x << " " << y << " " << z);
939 bool newValue = false;
942 ::BLSURFPlugin_Hypothesis::TEnfVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry);
943 ::BLSURFPlugin_Hypothesis::TEnfVertex vertex;
947 if (vertexList.find(vertex) == vertexList.end()) {
948 MESSAGE("Vertex not found: add it in vertexList")
952 MESSAGE("Vertex already found")
954 catch (const std::invalid_argument& ex) {
955 // no enforced vertex for entry
956 MESSAGE("Entry not found : add it to the list")
959 catch (SALOME_Exception& ex) {
960 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
964 this->GetImpl()->SetEnforcedVertex(entry, x, y, z);
965 SMESH::TPythonDump() << _this() << ".SetEnforcedVertex("
971 MESSAGE("IDL : SETENFORCEDVERTEX END - ENTRY: " << entry);
975 * Set/get/unset an enforced vertex on geom object given by entry
978 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntryWithGroup(const char* entry,
979 double x, double y, double z, const char* groupName)
980 throw (SALOME::SALOME_Exception)
983 MESSAGE("IDL : SETENFORCEDVERTEXWITHGROUP START - ENTRY: " << entry << " VERTEX: "
984 << x << " " << y << " " << z << " group name: " << groupName);
985 bool newValue = false;
986 bool newGroupName = false;
988 ::BLSURFPlugin_Hypothesis::TEnfVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry);
989 ::BLSURFPlugin_Hypothesis::TEnfVertex vertex;
993 if (vertexList.find(vertex) == vertexList.end()) {
994 MESSAGE("Vertex not found: add it in vertexList");
998 MESSAGE("Vertex already found");
999 std::string oldGroupName = this->GetImpl()->GetEnforcedVertexGroupName(x,y,z);
1000 if (strcmp(oldGroupName.c_str(),groupName)!=0)
1001 newGroupName = true;
1004 catch (const std::invalid_argument& ex) {
1005 // no enforced vertex for entry
1006 MESSAGE("Entry not found : add it to the list");
1009 catch (SALOME_Exception& ex) {
1010 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1014 this->GetImpl()->SetEnforcedVertex(entry, x, y, z, groupName);
1015 SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup("
1020 << groupName << "')";
1024 this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName);
1025 SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName("
1029 << groupName << "')";
1032 MESSAGE("IDL : SETENFORCEDVERTEXWITHGROUP END - ENTRY: " << entry);
1036 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList)
1037 throw (SALOME::SALOME_Exception)
1043 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry)
1044 throw (SALOME::SALOME_Exception)
1047 MESSAGE("ENGINE : GETENFORCEDVERTICES START ENTRY : " << entry);
1050 BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList();
1051 ::BLSURFPlugin_Hypothesis::TEnfVertexList _vList = this->GetImpl()->GetEnforcedVertices(entry);
1052 vertexList->length(_vList.size());
1053 MESSAGE("Number of enforced vertices: " << _vList.size());
1054 ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin();
1055 for ( int i = 0; evlIt != _vList.end() ; ++evlIt, ++i ) {
1056 BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
1057 enfVertex->length(3);
1058 MESSAGE("Enforced vertex #" << i << ": "<< (*evlIt)[0] << ", " << (*evlIt)[1] << ", " << (*evlIt)[2]);
1059 enfVertex[0] = (*evlIt)[0];
1060 enfVertex[1] = (*evlIt)[1];
1061 enfVertex[2] = (*evlIt)[2];
1062 vertexList[i] = enfVertex;
1064 return vertexList._retn();
1066 catch (const std::invalid_argument& ex) {
1067 SALOME::ExceptionStruct ExDescription;
1068 ExDescription.text = ex.what();
1069 ExDescription.type = SALOME::BAD_PARAM;
1070 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)";
1071 ExDescription.lineNumber = 1048;
1072 throw SALOME::SALOME_Exception(ExDescription);
1074 catch(const std::exception& ex) {
1075 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1078 MESSAGE("ENGINE : GETENFORCEDVERTICES END ENTRY : " << entry);
1082 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z)
1083 throw (SALOME::SALOME_Exception)
1086 MESSAGE("ENGINE : UNSETENFORCEDVERTEX START ENTRY : " << entry);
1089 this->GetImpl()->ClearEnforcedVertex(entry, x, y, z);
1090 SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex("
1096 catch (const std::invalid_argument& ex) {
1097 SALOME::ExceptionStruct ExDescription;
1098 ExDescription.text = ex.what();
1099 ExDescription.type = SALOME::BAD_PARAM;
1100 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(entry,x,y,z)";
1101 ExDescription.lineNumber = 1086;
1102 throw SALOME::SALOME_Exception(ExDescription);
1104 catch(const std::exception& ex) {
1105 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1108 MESSAGE("ENGINE : UNSETENFORCEDVERTEX END ENTRY : " << entry);
1111 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList)
1112 throw (SALOME::SALOME_Exception)
1117 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* entry)
1118 throw (SALOME::SALOME_Exception)
1121 MESSAGE("ENGINE : UNSETENFORCEDVERTICES START ENTRY : " << entry);
1124 this->GetImpl()->ClearEnforcedVertices(entry);
1125 SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << entry << ")";
1127 catch (const std::invalid_argument& ex) {
1128 SALOME::ExceptionStruct ExDescription;
1129 ExDescription.text = ex.what();
1130 ExDescription.type = SALOME::BAD_PARAM;
1131 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(entry)";
1132 ExDescription.lineNumber = 1121;
1133 throw SALOME::SALOME_Exception(ExDescription);
1135 catch(const std::exception& ex) {
1136 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1139 MESSAGE("ENGINE : UNSETENFORCEDVERTICES END ENTRY : " << entry);
1143 char* BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1144 throw (SALOME::SALOME_Exception)
1147 MESSAGE("ENGINE : GetEnforcedVertexGroupName START ");
1149 return CORBA::string_dup( this->GetImpl()->GetEnforcedVertexGroupName(x, y, z).c_str());
1151 catch (const std::invalid_argument& ex) {
1152 SALOME::ExceptionStruct ExDescription;
1153 ExDescription.text = ex.what();
1154 ExDescription.type = SALOME::BAD_PARAM;
1155 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(entry)";
1156 ExDescription.lineNumber = 1146;
1157 throw SALOME::SALOME_Exception(ExDescription);
1159 catch (SALOME_Exception& ex) {
1160 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1162 MESSAGE("ENGINE : GetEnforcedVertexGroupName END ");
1167 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName)
1168 throw (SALOME::SALOME_Exception)
1171 MESSAGE("ENGINE : SetEnforcedVertexGroupName START ");
1173 this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName);
1175 catch (const std::invalid_argument& ex) {
1176 SALOME::ExceptionStruct ExDescription;
1177 ExDescription.text = ex.what();
1178 ExDescription.type = SALOME::BAD_PARAM;
1179 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(x,y,z)";
1180 ExDescription.lineNumber = 1170;
1181 throw SALOME::SALOME_Exception(ExDescription);
1183 catch (SALOME_Exception& ex) {
1184 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1187 SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName("
1188 << x << ", " << y << ", " << z << ", '" << groupName << "' )";
1190 MESSAGE("ENGINE : SetEnforcedVertexGroupName END ");
1193 ///////////////////////
1199 //=============================================================================
1201 * BLSURFPlugin_Hypothesis_i::GetImpl
1203 * Get implementation
1205 //=============================================================================
1206 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl()
1208 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
1209 return (::BLSURFPlugin_Hypothesis*)myBaseImpl;
1212 //================================================================================
1214 * \brief Verify whether hypothesis supports given entity type
1215 * \param type - dimension (see SMESH::Dimension enumeration)
1216 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
1218 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
1220 //================================================================================
1221 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1223 return type == SMESH::DIM_2D;