1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : BLSURFPlugin_Hypothesis.cxx
21 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
22 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
25 #include "BLSURFPlugin_Hypothesis_i.hxx"
26 #include "SMESH_Gen.hxx"
27 #include "SMESH_PythonDump.hxx"
28 #include "GEOM_Object.hxx"
30 #include "Utils_CorbaException.hxx"
31 #include "utilities.h"
34 #include "boost/regex.hpp"
36 //=============================================================================
38 * BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i
42 //=============================================================================
43 BLSURFPlugin_Hypothesis_i::
44 BLSURFPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
46 ::SMESH_Gen* theGenImpl)
47 : SALOME::GenericObj_i( thePOA ),
48 SMESH_Hypothesis_i( thePOA )
50 MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" );
51 myBaseImpl = new ::BLSURFPlugin_Hypothesis (theGenImpl->GetANewId(),
56 //=============================================================================
58 * BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i
62 //=============================================================================
63 BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i()
65 MESSAGE( "BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i" );
69 * BLSURFPlugin_Hypothesis_i::SetTopology
74 //=============================================================================
75 void BLSURFPlugin_Hypothesis_i::SetTopology (CORBA::Long theValue)
77 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTopology");
79 this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology)theValue);
80 SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
83 //=============================================================================
85 * BLSURFPlugin_Hypothesis_i::GetTopology
89 //=============================================================================
90 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology()
92 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTopology");
94 return this->GetImpl()->GetTopology();
97 //=============================================================================
99 //=============================================================================
101 * BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
106 //=============================================================================
107 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh (CORBA::Long theValue)
109 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhysicalMesh");
111 this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh)theValue);
112 SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
115 //=============================================================================
117 * BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
121 //=============================================================================
122 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh()
124 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhysicalMesh");
126 return this->GetImpl()->GetPhysicalMesh();
129 //=============================================================================
131 * BLSURFPlugin_Hypothesis_i::SetPhySize
135 //=============================================================================
136 void BLSURFPlugin_Hypothesis_i::SetPhySize (CORBA::Double theValue)
138 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize");
140 this->GetImpl()->SetPhySize(theValue);
141 SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
144 //=============================================================================
146 * BLSURFPlugin_Hypothesis_i::GetPhySize
150 //=============================================================================
151 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize()
153 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize");
155 return this->GetImpl()->GetPhySize();
158 //=============================================================================
159 void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize)
162 if ( GetPhyMin() != theMinSize ) {
163 this->GetImpl()->SetPhyMin(theMinSize);
164 SMESH::TPythonDump() << _this() << ".SetPhyMin( " << theMinSize << " )";
168 //=============================================================================
169 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin()
172 return this->GetImpl()->GetPhyMin();
176 //=============================================================================
177 void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize)
180 if ( GetPhyMax() != theMaxSize ) {
181 this->GetImpl()->SetPhyMax(theMaxSize);
182 SMESH::TPythonDump() << _this() << ".SetPhyMax( " << theMaxSize << " )";
186 //=============================================================================
187 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax()
190 return this->GetImpl()->GetPhyMax();
194 //=============================================================================
196 * BLSURFPlugin_Hypothesis_i::SetGeometricMesh
201 //=============================================================================
202 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh (CORBA::Long theValue)
204 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGeometricMesh");
206 this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh)theValue);
207 SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
210 //=============================================================================
212 * BLSURFPlugin_Hypothesis_i::GetGeometricMesh
216 //=============================================================================
217 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh()
219 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGeometricMesh");
221 return this->GetImpl()->GetGeometricMesh();
224 //=============================================================================
226 * BLSURFPlugin_Hypothesis_i::SetAngleMeshS
230 //=============================================================================
231 void BLSURFPlugin_Hypothesis_i::SetAngleMeshS (CORBA::Double theValue)
233 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAngleMeshS");
235 this->GetImpl()->SetAngleMeshS(theValue);
236 SMESH::TPythonDump() << _this() << ".SetAngleMeshS( " << theValue << " )";
239 //=============================================================================
241 * BLSURFPlugin_Hypothesis_i::GetAngleMeshS
245 //=============================================================================
246 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS()
248 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAngleMeshS");
250 return this->GetImpl()->GetAngleMeshS();
253 //=============================================================================
254 void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle)
257 this->GetImpl()->SetAngleMeshC(angle);
258 SMESH::TPythonDump() << _this() << ".SetAngleMeshC( " << angle << " )";
261 //=============================================================================
262 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC()
265 return this->GetImpl()->GetAngleMeshC();
268 //=============================================================================
269 void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize)
272 if ( GetGeoMin() != theMinSize ) {
273 this->GetImpl()->SetGeoMin(theMinSize);
274 SMESH::TPythonDump() << _this() << ".SetGeoMin( " << theMinSize << " )";
278 //=============================================================================
279 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin()
282 return this->GetImpl()->GetGeoMin();
285 //=============================================================================
286 void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize)
289 if ( GetGeoMax() != theMaxSize ) {
290 this->GetImpl()->SetGeoMax(theMaxSize);
291 SMESH::TPythonDump() << _this() << ".SetGeoMax( " << theMaxSize << " )";
295 //=============================================================================
296 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax()
299 return this->GetImpl()->GetGeoMax();
302 //=============================================================================
304 * BLSURFPlugin_Hypothesis_i::SetGradation
308 //=============================================================================
309 void BLSURFPlugin_Hypothesis_i::SetGradation (CORBA::Double theValue)
311 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGradation");
313 this->GetImpl()->SetGradation(theValue);
314 SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
317 //=============================================================================
319 * BLSURFPlugin_Hypothesis_i::GetGradation
323 //=============================================================================
324 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation()
326 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGradation");
328 return this->GetImpl()->GetGradation();
331 //=============================================================================
333 * BLSURFPlugin_Hypothesis_i::SetQuadAllowed
337 //=============================================================================
338 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue)
340 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadAllowed");
342 this->GetImpl()->SetQuadAllowed(theValue);
343 SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
346 //=============================================================================
348 * BLSURFPlugin_Hypothesis_i::GetQuadAllowed
352 //=============================================================================
353 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed()
355 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadAllowed");
357 return this->GetImpl()->GetQuadAllowed();
360 //=============================================================================
362 * BLSURFPlugin_Hypothesis_i::SetDecimesh
366 //=============================================================================
367 void BLSURFPlugin_Hypothesis_i::SetDecimesh (CORBA::Boolean theValue)
369 // MESSAGE("BLSURFPlugin_Hypothesis_i::SetDecimesh");
371 this->GetImpl()->SetDecimesh(theValue);
372 SMESH::TPythonDump() << _this() << ".SetDecimesh( " << theValue << " )";
375 //=============================================================================
377 * BLSURFPlugin_Hypothesis_i::GetDecimesh
381 //=============================================================================
382 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh()
384 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetDecimesh");
386 return this->GetImpl()->GetDecimesh();
389 //=============================================================================
390 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal)
391 throw (SALOME::SALOME_Exception)
394 if ( theVal < 0 || theVal > 100 )
395 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM );
396 this->GetImpl()->SetVerbosity(theVal);
397 SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )";
400 //=============================================================================
402 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity()
405 return (CORBA::Short) this->GetImpl()->GetVerbosity();
408 //=============================================================================
410 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName,
411 const char* optionValue)
412 throw (SALOME::SALOME_Exception)
415 bool valueChanged = false;
417 valueChanged = ( this->GetImpl()->GetOptionValue(optionName) != optionValue );
419 this->GetImpl()->SetOptionValue(optionName, optionValue);
421 catch (const std::invalid_argument& ex) {
422 SALOME::ExceptionStruct ExDescription;
423 ExDescription.text = ex.what();
424 ExDescription.type = SALOME::BAD_PARAM;
425 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetOptionValue(name,value)";
426 ExDescription.lineNumber = 0;
427 throw SALOME::SALOME_Exception(ExDescription);
429 catch (SALOME_Exception& ex) {
430 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
433 SMESH::TPythonDump() << _this() << ".SetOptionValue( '"
434 << optionName << "', '" << optionValue << "' )";
437 //=============================================================================
439 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
440 throw (SALOME::SALOME_Exception)
444 return CORBA::string_dup( this->GetImpl()->GetOptionValue(optionName).c_str() );
446 catch (const std::invalid_argument& ex) {
447 SALOME::ExceptionStruct ExDescription;
448 ExDescription.text = ex.what();
449 ExDescription.type = SALOME::BAD_PARAM;
450 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetOptionValue(name)";
451 ExDescription.lineNumber = 0;
452 throw SALOME::SALOME_Exception(ExDescription);
454 catch (SALOME_Exception& ex) {
455 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
460 //=============================================================================
462 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName)
465 this->GetImpl()->ClearOption(optionName);
466 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
469 //=============================================================================
471 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues()
474 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
476 const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
477 result->length( opts.size() );
479 ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
480 for ( int i = 0 ; opIt != opts.end(); ++opIt, ++i ) {
481 string name_value = opIt->first;
482 if ( !opIt->second.empty() ) {
484 name_value += opIt->second;
486 result[i] = CORBA::string_dup(name_value.c_str());
488 return result._retn();
491 //=============================================================================
493 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
494 throw (SALOME::SALOME_Exception)
497 for (int i = 0; i < options.length(); ++i)
499 string name_value = options[i].in();
500 int colonPos = name_value.find( ':' );
502 if ( colonPos == string::npos ) // ':' not found
505 name = name_value.substr( 0, colonPos);
506 if ( colonPos < name_value.size()-1 && name_value[colonPos] != ' ')
507 value = name_value.substr( colonPos+1 );
509 SetOptionValue( name.c_str(), value.c_str() );
513 //=============================================================================
515 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry,const char* sizeMap)
516 throw (SALOME::SALOME_Exception)
519 MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry);
520 bool valueChanged = false;
522 valueChanged = ( this->GetImpl()->GetSizeMapEntry(entry) != sizeMap );
524 this->GetImpl()->SetSizeMapEntry(entry, sizeMap);
526 catch (const std::invalid_argument& ex) {
527 SALOME::ExceptionStruct ExDescription;
528 ExDescription.text = ex.what();
529 ExDescription.type = SALOME::BAD_PARAM;
530 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
531 ExDescription.lineNumber = 0;
532 throw SALOME::SALOME_Exception(ExDescription);
534 catch (SALOME_Exception& ex) {
535 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
537 MESSAGE("ENGINE : SETSIZEMAP END ENTRY : " << entry);
539 SMESH::TPythonDump() << _this() << ".SetSizeMap("
540 << entry << ", '" << sizeMap << "' )";
543 //=============================================================================
545 void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* attractor )
546 throw (SALOME::SALOME_Exception)
549 MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry);
550 bool valueChanged = false;
552 valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor );
553 if ( valueChanged ) {
554 boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$");
555 if (!boost::regex_match(string(attractor), re))
556 throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False)");
557 this->GetImpl()->SetAttractorEntry(entry, attractor);
560 catch (const std::invalid_argument& ex) {
561 SALOME::ExceptionStruct ExDescription;
562 ExDescription.text = ex.what();
563 ExDescription.type = SALOME::BAD_PARAM;
564 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)";
565 ExDescription.lineNumber = 0;
566 throw SALOME::SALOME_Exception(ExDescription);
568 catch (SALOME_Exception& ex) {
569 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
571 MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry);
573 SMESH::TPythonDump() << _this() << ".SetAttractor("
574 << entry << ", '" << attractor << "' )";
578 //=============================================================================
580 char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry)
581 throw (SALOME::SALOME_Exception)
585 return CORBA::string_dup( this->GetImpl()->GetSizeMapEntry(entry).c_str());
587 catch (const std::invalid_argument& ex) {
588 SALOME::ExceptionStruct ExDescription;
589 ExDescription.text = ex.what();
590 ExDescription.type = SALOME::BAD_PARAM;
591 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)";
592 ExDescription.lineNumber = 0;
593 throw SALOME::SALOME_Exception(ExDescription);
595 catch (SALOME_Exception& ex) {
596 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
601 //=============================================================================
603 char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry)
604 throw (SALOME::SALOME_Exception)
608 return CORBA::string_dup( this->GetImpl()->GetAttractorEntry(entry).c_str());
610 catch (const std::invalid_argument& ex) {
611 SALOME::ExceptionStruct ExDescription;
612 ExDescription.text = ex.what();
613 ExDescription.type = SALOME::BAD_PARAM;
614 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetAttractorEntry(name)";
615 ExDescription.lineNumber = 0;
616 throw SALOME::SALOME_Exception(ExDescription);
618 catch (SALOME_Exception& ex) {
619 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
624 //=============================================================================
626 void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry)
629 this->GetImpl()->ClearEntry(entry);
630 // SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";
633 //=============================================================================
635 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries()
638 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
640 const ::BLSURFPlugin_Hypothesis::TSizeMap sizeMaps= this->GetImpl()->_GetSizeMapEntries();
641 result->length( sizeMaps.size() );
643 ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin();
644 for ( int i = 0 ; smIt != sizeMaps.end(); ++smIt, ++i ) {
645 string entry_sizemap = smIt->first;
646 if ( !smIt->second.empty() ) {
647 entry_sizemap += "|";
648 entry_sizemap += smIt->second;
650 result[i] = CORBA::string_dup(entry_sizemap.c_str());
652 return result._retn();
655 //=============================================================================
657 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries()
660 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
662 const ::BLSURFPlugin_Hypothesis::TSizeMap attractors= this->GetImpl()->_GetAttractorEntries();
663 result->length( attractors.size() );
665 ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin();
666 for ( int i = 0 ; atIt != attractors.end(); ++atIt, ++i ) {
667 string entry_attractor = atIt->first;
668 if ( !atIt->second.empty() ) {
669 entry_attractor += "|";
670 entry_attractor += atIt->second;
672 result[i] = CORBA::string_dup(entry_attractor.c_str());
674 return result._retn();
677 //=============================================================================
679 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)
680 throw (SALOME::SALOME_Exception)
683 for (int i = 0; i < sizeMaps.length(); ++i)
685 string entry_sizemap = sizeMaps[i].in();
686 int colonPos = entry_sizemap.find( '|' );
687 string entry, sizemap;
688 if ( colonPos == string::npos ) // '|' separator not found
689 entry = entry_sizemap;
691 entry = entry_sizemap.substr( 0, colonPos);
692 if ( colonPos < entry_sizemap.size()-1 && entry_sizemap[colonPos] != ' ')
693 sizemap = entry_sizemap.substr( colonPos+1 );
695 this->GetImpl()->SetSizeMapEntry( entry.c_str(), sizemap.c_str() );
699 //=============================================================================
701 void BLSURFPlugin_Hypothesis_i::ClearSizeMaps()
704 this->GetImpl()->ClearSizeMaps();
708 //=============================================================================
710 void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj,const char* sizeMap)
714 entry=GeomObj->GetStudyEntry();
715 MESSAGE("IDL : GetName : " << GeomObj->GetName());
716 MESSAGE("IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")");
717 SetSizeMapEntry( entry.c_str(),sizeMap);
720 //=============================================================================
721 void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj)
725 entry=GeomObj->GetStudyEntry();
726 MESSAGE("IDL : GetName : " << GeomObj->GetName());
727 MESSAGE("IDL : UNSETSIZEMAP ( "<< entry << ")");
728 UnsetEntry( entry.c_str());
729 SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )";
733 void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor)
737 entry=GeomObj->GetStudyEntry();
738 MESSAGE("IDL : GetName : " << GeomObj->GetName());
739 MESSAGE("IDL : SETATTRACTOR ( "<< entry << " , " << attractor << ")");
740 SetAttractorEntry( entry.c_str(),attractor);
743 void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj)
747 entry=GeomObj->GetStudyEntry();
748 MESSAGE("IDL : GetName : " << GeomObj->GetName());
749 MESSAGE("IDL : UNSETATTRACTOR ( "<< entry << ")");
750 UnsetEntry( entry.c_str());
751 SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
758 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
761 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj)
764 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap ) throw (SALOME::SALOME_Exception)
767 char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception)
770 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry)
773 this->GetImpl()->UnsetCustomSizeMap(entry);
774 SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )";
778 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries()
784 ///////////////////////
785 // ENFORCED VERTEXES //
786 ///////////////////////
788 BLSURFPlugin::TEnforcedVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices()
790 MESSAGE("IDL: GetAllEnforcedVertices()");
792 BLSURFPlugin::TEnforcedVertexMap_var resultMap = new BLSURFPlugin::TEnforcedVertexMap();
793 const ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap enforcedVertexMap = this->GetImpl()->_GetAllEnforcedVertices();
794 resultMap->length(enforcedVertexMap.size());
795 MESSAGE("Enforced Vertex map size is " << enforcedVertexMap.size());
797 ::BLSURFPlugin_Hypothesis::TEnforcedVertexList enforcedVertexList;
798 ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap::const_iterator evmIt = enforcedVertexMap.begin();
799 for ( int i = 0 ; evmIt != enforcedVertexMap.end(); ++evmIt, ++i ) {
800 string entry = evmIt->first;
801 MESSAGE("Entry: " << entry);
802 enforcedVertexList = evmIt->second;
804 BLSURFPlugin::TEnforcedVertexMapElement_var mapElement = new BLSURFPlugin::TEnforcedVertexMapElement();
806 BLSURFPlugin::TEnforcedVertexList_var vertexList = new BLSURFPlugin::TEnforcedVertexList();
807 vertexList->length(enforcedVertexList.size());
808 MESSAGE("Number of enforced vertices: " << enforcedVertexList.size());
810 ::BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = enforcedVertexList.begin();
811 for ( int j = 0 ; evlIt != enforcedVertexList.end(); ++evlIt, ++j ) {
812 MESSAGE("Enforced Vertex #" << j);
813 BLSURFPlugin::TEnforcedVertex_var enforcedVertex = new BLSURFPlugin::TEnforcedVertex();
814 enforcedVertex->length(3);
815 enforcedVertex[0] = (*evlIt)[0];
816 enforcedVertex[1] = (*evlIt)[1];
817 enforcedVertex[2] = (*evlIt)[2];
818 vertexList[j] = enforcedVertex;
819 MESSAGE("Enforced vertex: " << enforcedVertex[0] << ", " << enforcedVertex[1] << ", " << enforcedVertex[2]);
822 mapElement->entry = CORBA::string_dup(entry.c_str());
823 mapElement->vertexList = vertexList;
825 resultMap[i] = mapElement;
828 return resultMap._retn();
831 void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices()
834 this->GetImpl()->ClearAllEnforcedVertices();
835 SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVertices()";
839 * Set/get/unset an enforced vertex on geom object
841 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
842 throw (SALOME::SALOME_Exception)
845 // TODO check that GeomObj is a face => in engine ?
846 string entry = GeomObj->GetStudyEntry();
847 MESSAGE("IDL : GetName : " << GeomObj->GetName());
848 MESSAGE("IDL : SetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
850 SetEnforcedVertexEntry(entry.c_str(), x, y, z);
852 catch (SALOME_Exception& ex) {
853 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
858 BLSURFPlugin::TEnforcedVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj)
859 throw (SALOME::SALOME_Exception)
862 string entry = GeomObj->GetStudyEntry();
863 MESSAGE("IDL : GetName : " << GeomObj->GetName());
864 MESSAGE("IDL : GetEnforcedVertexList ( "<< entry << ")");
866 return GetEnforcedVerticesEntry(entry.c_str());
868 catch (SALOME_Exception& ex) {
869 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
874 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
875 throw (SALOME::SALOME_Exception)
878 string entry = GeomObj->GetStudyEntry();
879 MESSAGE("IDL : GetName : " << GeomObj->GetName());
880 MESSAGE("IDL : UnsetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
883 UnsetEnforcedVertexEntry(entry.c_str(), x, y, z);
885 catch (SALOME_Exception& ex) {
886 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
891 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj)
892 throw (SALOME::SALOME_Exception)
895 string entry = GeomObj->GetStudyEntry();
896 MESSAGE("IDL : GetName : " << GeomObj->GetName());
897 MESSAGE("IDL : UnsetEnforcedVertices ( "<< entry << ")");
900 UnsetEnforcedVerticesEntry(entry.c_str());
902 catch (SALOME_Exception& ex) {
903 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
909 * Set/get/unset an enforced vertex on geom object given by entry
911 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* entry, double x, double y, double z)
912 throw (SALOME::SALOME_Exception)
915 MESSAGE("IDL : SETENFORCEDVERTEX START - ENTRY: " << entry << " VERTEX: " << x << " " << y << " " << z);
916 bool newValue = false;
919 ::BLSURFPlugin_Hypothesis::TEnforcedVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry);
920 ::BLSURFPlugin_Hypothesis::TEnforcedVertex vertex;
924 if (vertexList.find(vertex) == vertexList.end()) {
925 MESSAGE("Vertex not found: add it in vertexList")
929 MESSAGE("Vertex already found")
931 catch (const std::invalid_argument& ex) {
932 // no enforced vertex for entry
933 MESSAGE("Entry not found : add it to the list")
936 catch (SALOME_Exception& ex) {
937 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
941 this->GetImpl()->SetEnforcedVertex(entry, x, y, z);
942 SMESH::TPythonDump() << _this() << ".SetEnforcedVertex("
948 MESSAGE("IDL : SETENFORCEDVERTEX END - ENTRY: " << entry);
951 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList)
952 throw (SALOME::SALOME_Exception)
958 BLSURFPlugin::TEnforcedVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry)
959 throw (SALOME::SALOME_Exception)
962 MESSAGE("ENGINE : GETENFORCEDVERTICES START ENTRY : " << entry);
965 BLSURFPlugin::TEnforcedVertexList_var vertexList = new BLSURFPlugin::TEnforcedVertexList();
966 ::BLSURFPlugin_Hypothesis::TEnforcedVertexList _vList = this->GetImpl()->GetEnforcedVertices(entry);
967 vertexList->length(_vList.size());
968 MESSAGE("Number of enforced vertices: " << _vList.size());
969 ::BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = _vList.begin();
970 for ( int i = 0; evlIt != _vList.end() ; ++evlIt, ++i ) {
971 BLSURFPlugin::TEnforcedVertex_var enforcedVertex = new BLSURFPlugin::TEnforcedVertex();
972 enforcedVertex->length(3);
973 MESSAGE("Enforced vertex #" << i << ": "<< (*evlIt)[0] << ", " << (*evlIt)[1] << ", " << (*evlIt)[2]);
974 enforcedVertex[0] = (*evlIt)[0];
975 enforcedVertex[1] = (*evlIt)[1];
976 enforcedVertex[2] = (*evlIt)[2];
977 vertexList[i] = enforcedVertex;
979 return vertexList._retn();
981 catch (const std::invalid_argument& ex) {
982 SALOME::ExceptionStruct ExDescription;
983 ExDescription.text = ex.what();
984 ExDescription.type = SALOME::BAD_PARAM;
985 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)";
986 ExDescription.lineNumber = 945;
987 throw SALOME::SALOME_Exception(ExDescription);
989 catch(const std::exception& ex) {
990 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
993 MESSAGE("ENGINE : GETENFORCEDVERTICES END ENTRY : " << entry);
997 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z)
998 throw (SALOME::SALOME_Exception)
1001 MESSAGE("ENGINE : UNSETENFORCEDVERTEX START ENTRY : " << entry);
1004 this->GetImpl()->ClearEnforcedVertex(entry, x, y, z);
1005 SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex("
1011 catch (const std::invalid_argument& ex) {
1012 SALOME::ExceptionStruct ExDescription;
1013 ExDescription.text = ex.what();
1014 ExDescription.type = SALOME::BAD_PARAM;
1015 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(entry,x,y,z)";
1016 ExDescription.lineNumber = 1003;
1017 throw SALOME::SALOME_Exception(ExDescription);
1019 catch(const std::exception& ex) {
1020 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1023 MESSAGE("ENGINE : UNSETENFORCEDVERTEX END ENTRY : " << entry);
1026 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList)
1027 throw (SALOME::SALOME_Exception)
1032 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* entry)
1033 throw (SALOME::SALOME_Exception)
1036 MESSAGE("ENGINE : UNSETENFORCEDVERTICES START ENTRY : " << entry);
1039 this->GetImpl()->ClearEnforcedVertices(entry);
1040 SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << entry << ")";
1042 catch (const std::invalid_argument& ex) {
1043 SALOME::ExceptionStruct ExDescription;
1044 ExDescription.text = ex.what();
1045 ExDescription.type = SALOME::BAD_PARAM;
1046 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(entry)";
1047 ExDescription.lineNumber = 1051;
1048 throw SALOME::SALOME_Exception(ExDescription);
1050 catch(const std::exception& ex) {
1051 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1054 MESSAGE("ENGINE : UNSETENFORCEDVERTICES END ENTRY : " << entry);
1058 ///////////////////////
1064 //=============================================================================
1066 * BLSURFPlugin_Hypothesis_i::GetImpl
1068 * Get implementation
1070 //=============================================================================
1071 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl()
1073 // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
1074 return (::BLSURFPlugin_Hypothesis*)myBaseImpl;
1077 //================================================================================
1079 * \brief Verify whether hypothesis supports given entity type
1080 * \param type - dimension (see SMESH::Dimension enumeration)
1081 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
1083 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
1085 //================================================================================
1086 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1088 return type == SMESH::DIM_2D;