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 boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)(?:;(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+))?\\)$");
558 if (!boost::regex_match(string(attractor), re))
559 throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False;d(opt.))");
560 this->GetImpl()->SetAttractorEntry(entry, attractor);
563 catch (const std::invalid_argument& ex) {
564 SALOME::ExceptionStruct ExDescription;
565 ExDescription.text = ex.what();
566 ExDescription.type = SALOME::BAD_PARAM;
567 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)";
568 ExDescription.lineNumber = 0;
569 throw SALOME::SALOME_Exception(ExDescription);
571 catch (SALOME_Exception& ex) {
572 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
574 MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry);
576 SMESH::TPythonDump() << _this() << ".SetAttractor("
577 << entry << ", '" << attractor << "' )";
581 //=============================================================================
583 char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry)
584 throw (SALOME::SALOME_Exception)
588 return CORBA::string_dup( this->GetImpl()->GetSizeMapEntry(entry).c_str());
590 catch (const std::invalid_argument& ex) {
591 SALOME::ExceptionStruct ExDescription;
592 ExDescription.text = ex.what();
593 ExDescription.type = SALOME::BAD_PARAM;
594 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)";
595 ExDescription.lineNumber = 0;
596 throw SALOME::SALOME_Exception(ExDescription);
598 catch (SALOME_Exception& ex) {
599 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
604 //=============================================================================
606 char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry)
607 throw (SALOME::SALOME_Exception)
611 return CORBA::string_dup( this->GetImpl()->GetAttractorEntry(entry).c_str());
613 catch (const std::invalid_argument& ex) {
614 SALOME::ExceptionStruct ExDescription;
615 ExDescription.text = ex.what();
616 ExDescription.type = SALOME::BAD_PARAM;
617 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetAttractorEntry(name)";
618 ExDescription.lineNumber = 0;
619 throw SALOME::SALOME_Exception(ExDescription);
621 catch (SALOME_Exception& ex) {
622 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
627 //=============================================================================
629 void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry)
632 this->GetImpl()->ClearEntry(entry);
633 // SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";
636 //=============================================================================
638 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries()
641 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
643 const ::BLSURFPlugin_Hypothesis::TSizeMap sizeMaps= this->GetImpl()->_GetSizeMapEntries();
644 result->length( sizeMaps.size() );
646 ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin();
647 for ( int i = 0 ; smIt != sizeMaps.end(); ++smIt, ++i ) {
648 string entry_sizemap = smIt->first;
649 if ( !smIt->second.empty() ) {
650 entry_sizemap += "|";
651 entry_sizemap += smIt->second;
653 result[i] = CORBA::string_dup(entry_sizemap.c_str());
655 return result._retn();
658 //=============================================================================
660 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries()
663 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
665 const ::BLSURFPlugin_Hypothesis::TSizeMap attractors= this->GetImpl()->_GetAttractorEntries();
666 result->length( attractors.size() );
668 ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin();
669 for ( int i = 0 ; atIt != attractors.end(); ++atIt, ++i ) {
670 string entry_attractor = atIt->first;
671 if ( !atIt->second.empty() ) {
672 entry_attractor += "|";
673 entry_attractor += atIt->second;
675 result[i] = CORBA::string_dup(entry_attractor.c_str());
677 return result._retn();
680 //=============================================================================
682 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)
683 throw (SALOME::SALOME_Exception)
686 for (int i = 0; i < sizeMaps.length(); ++i)
688 string entry_sizemap = sizeMaps[i].in();
689 int colonPos = entry_sizemap.find( '|' );
690 string entry, sizemap;
691 if ( colonPos == string::npos ) // '|' separator not found
692 entry = entry_sizemap;
694 entry = entry_sizemap.substr( 0, colonPos);
695 if ( colonPos < entry_sizemap.size()-1 && entry_sizemap[colonPos] != ' ')
696 sizemap = entry_sizemap.substr( colonPos+1 );
698 this->GetImpl()->SetSizeMapEntry( entry.c_str(), sizemap.c_str() );
702 //=============================================================================
704 void BLSURFPlugin_Hypothesis_i::ClearSizeMaps()
707 this->GetImpl()->ClearSizeMaps();
711 //=============================================================================
713 void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj,const char* sizeMap)
717 entry=GeomObj->GetStudyEntry();
718 MESSAGE("IDL : GetName : " << GeomObj->GetName());
719 MESSAGE("IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")");
720 SetSizeMapEntry( entry.c_str(),sizeMap);
723 //=============================================================================
724 void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj)
728 entry=GeomObj->GetStudyEntry();
729 MESSAGE("IDL : GetName : " << GeomObj->GetName());
730 MESSAGE("IDL : UNSETSIZEMAP ( "<< entry << ")");
731 UnsetEntry( entry.c_str());
732 SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )";
736 void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor)
740 entry=GeomObj->GetStudyEntry();
741 MESSAGE("IDL : GetName : " << GeomObj->GetName());
742 MESSAGE("IDL : SETATTRACTOR ( "<< entry << " , " << attractor << ")");
743 SetAttractorEntry( entry.c_str(),attractor);
746 void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj)
750 entry=GeomObj->GetStudyEntry();
751 MESSAGE("IDL : GetName : " << GeomObj->GetName());
752 MESSAGE("IDL : UNSETATTRACTOR ( "<< entry << ")");
753 UnsetEntry( entry.c_str());
754 SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
761 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
764 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj)
767 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap ) throw (SALOME::SALOME_Exception)
770 char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception)
773 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry)
776 this->GetImpl()->UnsetCustomSizeMap(entry);
777 SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )";
781 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries()
787 ///////////////////////
788 // ENFORCED VERTEXES //
789 ///////////////////////
791 BLSURFPlugin::TEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices()
793 MESSAGE("IDL: GetAllEnforcedVertices()");
795 BLSURFPlugin::TEntryEnfVertexListMap_var resultMap = new BLSURFPlugin::TEntryEnfVertexListMap();
796 const ::BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap entryEnfVertexListMap = this->GetImpl()->_GetAllEnforcedVertices();
797 resultMap->length(entryEnfVertexListMap.size());
798 MESSAGE("Enforced Vertex map size is " << entryEnfVertexListMap.size());
800 ::BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList;
801 ::BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap::const_iterator evmIt = entryEnfVertexListMap.begin();
802 for ( int i = 0 ; evmIt != entryEnfVertexListMap.end(); ++evmIt, ++i ) {
803 std::string entry = evmIt->first;
804 MESSAGE("Entry: " << entry);
805 enfVertexList = evmIt->second;
807 BLSURFPlugin::TEntryEnfVertexListMapElement_var mapElement = new BLSURFPlugin::TEntryEnfVertexListMapElement();
809 BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList();
810 vertexList->length(enfVertexList.size());
811 MESSAGE("Number of enforced vertices: " << enfVertexList.size());
813 ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin();
814 for ( int j = 0 ; evlIt != enfVertexList.end(); ++evlIt, ++j ) {
815 MESSAGE("Enforced Vertex #" << j);
816 BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
817 enfVertex->length(3);
818 enfVertex[0] = (*evlIt)[0];
819 enfVertex[1] = (*evlIt)[1];
820 enfVertex[2] = (*evlIt)[2];
821 vertexList[j] = enfVertex;
822 MESSAGE("Enforced vertex: " << enfVertex[0] << ", " << enfVertex[1] << ", " << enfVertex[2]);
825 mapElement->entry = CORBA::string_dup(entry.c_str());
826 mapElement->vertexList = vertexList;
828 resultMap[i] = mapElement;
831 return resultMap._retn();
834 void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices()
837 this->GetImpl()->ClearAllEnforcedVertices();
838 SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVertices()";
842 * Set/get/unset an enforced vertex on geom object
844 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
845 throw (SALOME::SALOME_Exception)
848 // TODO check that GeomObj is a face => in engine ?
849 // TODO Affecter un nom de groupe vide
850 string entry = GeomObj->GetStudyEntry();
851 MESSAGE("IDL : GetName : " << GeomObj->GetName());
852 MESSAGE("IDL : SetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
854 SetEnforcedVertexEntry(entry.c_str(), x, y, z);
856 catch (SALOME_Exception& ex) {
857 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
862 * Set/get/unset an enforced vertex on geom object with group name
865 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr GeomObj,
866 CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName)
867 throw (SALOME::SALOME_Exception)
870 // TODO check that GeomObj is a face => in engine ?
871 string entry = GeomObj->GetStudyEntry();
872 MESSAGE("IDL : GetName : " << GeomObj->GetName());
873 MESSAGE("IDL : SetEnforcedVertexWithGroup ( "<< entry << ", " << x << ", " << y << ", " << z << ", " << groupName <<")");
875 SetEnforcedVertexEntryWithGroup(entry.c_str(), x, y, z, groupName);
877 catch (SALOME_Exception& ex) {
878 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
882 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj)
883 throw (SALOME::SALOME_Exception)
886 string entry = GeomObj->GetStudyEntry();
887 MESSAGE("IDL : GetName : " << GeomObj->GetName());
888 MESSAGE("IDL : GetEnforcedVertexList ( "<< entry << ")");
890 return GetEnforcedVerticesEntry(entry.c_str());
892 catch (SALOME_Exception& ex) {
893 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
898 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
899 throw (SALOME::SALOME_Exception)
902 string entry = GeomObj->GetStudyEntry();
903 MESSAGE("IDL : GetName : " << GeomObj->GetName());
904 MESSAGE("IDL : UnsetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
907 UnsetEnforcedVertexEntry(entry.c_str(), x, y, z);
909 catch (SALOME_Exception& ex) {
910 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
915 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj)
916 throw (SALOME::SALOME_Exception)
919 string entry = GeomObj->GetStudyEntry();
920 MESSAGE("IDL : GetName : " << GeomObj->GetName());
921 MESSAGE("IDL : UnsetEnforcedVertices ( "<< entry << ")");
924 UnsetEnforcedVerticesEntry(entry.c_str());
926 catch (SALOME_Exception& ex) {
927 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
933 * Set/get/unset an enforced vertex on geom object given by entry
935 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* entry, double x, double y, double z)
936 throw (SALOME::SALOME_Exception)
939 MESSAGE("IDL : SETENFORCEDVERTEX START - ENTRY: " << entry << " VERTEX: " << x << " " << y << " " << z);
940 bool newValue = false;
943 ::BLSURFPlugin_Hypothesis::TEnfVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry);
944 ::BLSURFPlugin_Hypothesis::TEnfVertex vertex;
948 if (vertexList.find(vertex) == vertexList.end()) {
949 MESSAGE("Vertex not found: add it in vertexList")
953 MESSAGE("Vertex already found")
955 catch (const std::invalid_argument& ex) {
956 // no enforced vertex for entry
957 MESSAGE("Entry not found : add it to the list")
960 catch (SALOME_Exception& ex) {
961 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
965 this->GetImpl()->SetEnforcedVertex(entry, x, y, z);
966 SMESH::TPythonDump() << _this() << ".SetEnforcedVertex("
972 MESSAGE("IDL : SETENFORCEDVERTEX END - ENTRY: " << entry);
976 * Set/get/unset an enforced vertex on geom object given by entry
979 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntryWithGroup(const char* entry,
980 double x, double y, double z, const char* groupName)
981 throw (SALOME::SALOME_Exception)
984 MESSAGE("IDL : SETENFORCEDVERTEXWITHGROUP START - ENTRY: " << entry << " VERTEX: "
985 << x << " " << y << " " << z << " group name: " << groupName);
986 bool newValue = false;
987 bool newGroupName = false;
989 ::BLSURFPlugin_Hypothesis::TEnfVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry);
990 ::BLSURFPlugin_Hypothesis::TEnfVertex vertex;
994 if (vertexList.find(vertex) == vertexList.end()) {
995 MESSAGE("Vertex not found: add it in vertexList");
999 MESSAGE("Vertex already found");
1000 std::string oldGroupName = this->GetImpl()->GetEnforcedVertexGroupName(x,y,z);
1001 if (strcmp(oldGroupName.c_str(),groupName)!=0)
1002 newGroupName = true;
1005 catch (const std::invalid_argument& ex) {
1006 // no enforced vertex for entry
1007 MESSAGE("Entry not found : add it to the list");
1010 catch (SALOME_Exception& ex) {
1011 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1015 this->GetImpl()->SetEnforcedVertex(entry, x, y, z, groupName);
1016 SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup("
1021 << groupName << "')";
1025 this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName);
1026 SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName("
1030 << groupName << "')";
1033 MESSAGE("IDL : SETENFORCEDVERTEXWITHGROUP END - ENTRY: " << entry);
1037 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList)
1038 throw (SALOME::SALOME_Exception)
1044 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry)
1045 throw (SALOME::SALOME_Exception)
1048 MESSAGE("ENGINE : GETENFORCEDVERTICES START ENTRY : " << entry);
1051 BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList();
1052 ::BLSURFPlugin_Hypothesis::TEnfVertexList _vList = this->GetImpl()->GetEnforcedVertices(entry);
1053 vertexList->length(_vList.size());
1054 MESSAGE("Number of enforced vertices: " << _vList.size());
1055 ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin();
1056 for ( int i = 0; evlIt != _vList.end() ; ++evlIt, ++i ) {
1057 BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
1058 enfVertex->length(3);
1059 MESSAGE("Enforced vertex #" << i << ": "<< (*evlIt)[0] << ", " << (*evlIt)[1] << ", " << (*evlIt)[2]);
1060 enfVertex[0] = (*evlIt)[0];
1061 enfVertex[1] = (*evlIt)[1];
1062 enfVertex[2] = (*evlIt)[2];
1063 vertexList[i] = enfVertex;
1065 return vertexList._retn();
1067 catch (const std::invalid_argument& ex) {
1068 SALOME::ExceptionStruct ExDescription;
1069 ExDescription.text = ex.what();
1070 ExDescription.type = SALOME::BAD_PARAM;
1071 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)";
1072 ExDescription.lineNumber = 1048;
1073 throw SALOME::SALOME_Exception(ExDescription);
1075 catch(const std::exception& ex) {
1076 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1079 MESSAGE("ENGINE : GETENFORCEDVERTICES END ENTRY : " << entry);
1083 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z)
1084 throw (SALOME::SALOME_Exception)
1087 MESSAGE("ENGINE : UNSETENFORCEDVERTEX START ENTRY : " << entry);
1090 this->GetImpl()->ClearEnforcedVertex(entry, x, y, z);
1091 SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex("
1097 catch (const std::invalid_argument& ex) {
1098 SALOME::ExceptionStruct ExDescription;
1099 ExDescription.text = ex.what();
1100 ExDescription.type = SALOME::BAD_PARAM;
1101 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(entry,x,y,z)";
1102 ExDescription.lineNumber = 1086;
1103 throw SALOME::SALOME_Exception(ExDescription);
1105 catch(const std::exception& ex) {
1106 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1109 MESSAGE("ENGINE : UNSETENFORCEDVERTEX END ENTRY : " << entry);
1112 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList)
1113 throw (SALOME::SALOME_Exception)
1118 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* entry)
1119 throw (SALOME::SALOME_Exception)
1122 MESSAGE("ENGINE : UNSETENFORCEDVERTICES START ENTRY : " << entry);
1125 this->GetImpl()->ClearEnforcedVertices(entry);
1126 SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << entry << ")";
1128 catch (const std::invalid_argument& ex) {
1129 SALOME::ExceptionStruct ExDescription;
1130 ExDescription.text = ex.what();
1131 ExDescription.type = SALOME::BAD_PARAM;
1132 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(entry)";
1133 ExDescription.lineNumber = 1121;
1134 throw SALOME::SALOME_Exception(ExDescription);
1136 catch(const std::exception& ex) {
1137 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1140 MESSAGE("ENGINE : UNSETENFORCEDVERTICES END ENTRY : " << entry);
1144 char* BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1145 throw (SALOME::SALOME_Exception)
1148 MESSAGE("ENGINE : GetEnforcedVertexGroupName START ");
1150 return CORBA::string_dup( this->GetImpl()->GetEnforcedVertexGroupName(x, y, z).c_str());
1152 catch (const std::invalid_argument& ex) {
1153 SALOME::ExceptionStruct ExDescription;
1154 ExDescription.text = ex.what();
1155 ExDescription.type = SALOME::BAD_PARAM;
1156 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(entry)";
1157 ExDescription.lineNumber = 1146;
1158 throw SALOME::SALOME_Exception(ExDescription);
1160 catch (SALOME_Exception& ex) {
1161 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1163 MESSAGE("ENGINE : GetEnforcedVertexGroupName END ");
1168 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName)
1169 throw (SALOME::SALOME_Exception)
1172 MESSAGE("ENGINE : SetEnforcedVertexGroupName START ");
1174 this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName);
1176 catch (const std::invalid_argument& ex) {
1177 SALOME::ExceptionStruct ExDescription;
1178 ExDescription.text = ex.what();
1179 ExDescription.type = SALOME::BAD_PARAM;
1180 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(x,y,z)";
1181 ExDescription.lineNumber = 1170;
1182 throw SALOME::SALOME_Exception(ExDescription);
1184 catch (SALOME_Exception& ex) {
1185 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1188 SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName("
1189 << x << ", " << y << ", " << z << ", '" << groupName << "' )";
1191 MESSAGE("ENGINE : SetEnforcedVertexGroupName END ");
1194 ///////////////////////
1200 //=============================================================================
1202 * BLSURFPlugin_Hypothesis_i::GetImpl
1204 * Get implementation
1206 //=============================================================================
1207 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl()
1209 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
1210 return (::BLSURFPlugin_Hypothesis*)myBaseImpl;
1213 //================================================================================
1215 * \brief Verify whether hypothesis supports given entity type
1216 * \param type - dimension (see SMESH::Dimension enumeration)
1217 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
1219 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
1221 //================================================================================
1222 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1224 return type == SMESH::DIM_2D;