1 // Copyright (C) 2007-2023 CEA, EDF
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, or (at your option) any later version.
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 : HYBRIDPlugin_Hypothesis_i.cxx
22 // Author : Christian VAN WAMBEKE (CEA)
25 #include "HYBRIDPlugin_Hypothesis_i.hxx"
27 #include "SMESH_Gen.hxx"
28 #include "SMESH_PythonDump.hxx"
29 //#include "SMESH_Mesh.hxx"
30 //#include "SMESH_ProxyMesh.hxx"
31 //#include <StdMeshers_QuadToTriaAdaptor.hxx>
33 #include "Utils_CorbaException.hxx"
34 #include "utilities.h"
35 #include "SMESH_Mesh_i.hxx"
36 #include "SMESH_Group_i.hxx"
37 #include "SMESH_Gen_i.hxx"
38 #include "SMESH_TypeDefs.hxx"
39 #include "SMESHDS_GroupBase.hxx"
41 // SALOME KERNEL includes
42 #include "SALOMEDSClient.hxx"
43 #include <SALOMEDSClient_definitions.hxx>
45 // #include <SALOMEconfig.h>
46 // #include CORBA_SERVER_HEADER(SALOMEDS)
48 //=======================================================================
49 //function : HYBRIDPlugin_Hypothesis_i
50 //=======================================================================
51 HYBRIDPlugin_Hypothesis_i::HYBRIDPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
52 ::SMESH_Gen* theGenImpl)
53 : SALOME::GenericObj_i( thePOA ),
54 SMESH_Hypothesis_i( thePOA )
56 myBaseImpl = new ::HYBRIDPlugin_Hypothesis (theGenImpl->GetANewId(),
60 //=======================================================================
61 //function : ~HYBRIDPlugin_Hypothesis_i
62 //=======================================================================
63 HYBRIDPlugin_Hypothesis_i::~HYBRIDPlugin_Hypothesis_i()
67 //=======================================================================
69 * Sizes of boundary layers are relative to the surface size. Default no
71 //=======================================================================
73 void HYBRIDPlugin_Hypothesis_i::SetHeightIsRelative( CORBA::Boolean isRelative )
76 if ( GetImpl()->GetHeightIsRelative() != isRelative )
78 this->GetImpl()->SetHeightIsRelative( isRelative );
79 SMESH::TPythonDump() << _this() << ".SetHeightIsRelative( " << isRelative << " )";
83 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetHeightIsRelative()
85 return this->GetImpl()->GetHeightIsRelative();
88 //=======================================================================
90 * Maximum internal angles of boundary elements (in degree)
92 //=======================================================================
94 void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersMaxElemAngle( CORBA::Double angle )
96 if ( GetImpl()->GetBoundaryLayersMaxElemAngle() != angle )
98 this->GetImpl()->SetBoundaryLayersMaxElemAngle( angle );
99 SMESH::TPythonDump() << _this() << ".SetBoundaryLayersMaxElemAngle( " << angle << " )";
103 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersMaxElemAngle()
105 return this->GetImpl()->GetBoundaryLayersMaxElemAngle();
108 //=======================================================================
109 //function : SetLayersOnAllWrap
110 //=======================================================================
112 void HYBRIDPlugin_Hypothesis_i::SetLayersOnAllWrap(CORBA::Boolean toMesh)
115 this->GetImpl()->SetLayersOnAllWrap(toMesh);
116 SMESH::TPythonDump() << _this() << ".SetLayersOnAllWrap( " << toMesh << " )";
119 //=======================================================================
120 //function : GetLayersOnAllWrap
121 //=======================================================================
123 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetLayersOnAllWrap()
126 return this->GetImpl()->GetLayersOnAllWrap();
129 //=======================================================================
130 //function : SetFacesWithLayers
131 //=======================================================================
133 void HYBRIDPlugin_Hypothesis_i::SetFacesWithLayers(const ::SMESH::long_array& theVal)
135 std::vector<int> ids( theVal.length() );
136 for ( size_t i = 0; i < ids.size(); ++i )
139 bool valueChanged = this->GetImpl()->SetFacesWithLayers(ids);
141 SMESH::TPythonDump() << _this() << ".SetFacesWithLayers( "<< theVal << " )";
144 //=======================================================================
145 //function : GetFacesWithLayers
146 //=======================================================================
148 SMESH::long_array* HYBRIDPlugin_Hypothesis_i::GetFacesWithLayers()
150 const std::vector<int>& idsVec = this->GetImpl()->GetFacesWithLayers();
151 SMESH::long_array_var ids = new SMESH::long_array;
152 ids->length( idsVec.size() );
153 for ( size_t i = 0; i < idsVec.size(); ++i )
158 //=======================================================================
159 //function : SetFacesWithImprinting
160 //=======================================================================
162 void HYBRIDPlugin_Hypothesis_i::SetFacesWithImprinting(const ::SMESH::long_array& theVal)
164 std::vector<int> ids( theVal.length() );
165 for ( size_t i = 0; i < ids.size(); ++i )
168 bool valueChanged = this->GetImpl()->SetFacesWithImprinting(ids);
170 SMESH::TPythonDump() << _this() << ".SetFacesWithImprinting( "<< theVal << " )";
173 //=======================================================================
174 //function : GetFacesWithImprinting
175 //=======================================================================
177 SMESH::long_array* HYBRIDPlugin_Hypothesis_i::GetFacesWithImprinting()
179 const std::vector<int>& idsVec = this->GetImpl()->GetFacesWithImprinting();
180 SMESH::long_array_var ids = new SMESH::long_array;
181 ids->length( idsVec.size() );
182 for ( size_t i = 0; i < idsVec.size(); ++i )
187 //=======================================================================
188 //function : SetFacesWithSnapping
189 //=======================================================================
191 void HYBRIDPlugin_Hypothesis_i::SetFacesWithSnapping(const ::SMESH::long_array& theVal)
193 std::vector<int> ids( theVal.length() );
194 for ( size_t i = 0; i < ids.size(); ++i )
197 bool valueChanged = this->GetImpl()->SetFacesWithSnapping(ids);
199 SMESH::TPythonDump() << _this() << ".SetFacesWithSnapping( "<< theVal << " )";
202 //=======================================================================
203 //function : GetFacesWithSnapping
204 //=======================================================================
206 SMESH::long_array* HYBRIDPlugin_Hypothesis_i::GetFacesWithSnapping()
208 const std::vector<int>& idsVec = this->GetImpl()->GetFacesWithSnapping();
209 SMESH::long_array_var ids = new SMESH::long_array;
210 ids->length( idsVec.size() );
211 for ( size_t i = 0; i < idsVec.size(); ++i )
216 //=======================================================================
217 //function : SetToMeshHoles
218 //=======================================================================
220 void HYBRIDPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
223 this->GetImpl()->SetToMeshHoles(toMesh);
224 SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
227 //=======================================================================
228 //function : GetToMeshHoles
229 //=======================================================================
231 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToMeshHoles()
234 return this->GetImpl()->GetToMeshHoles();
237 //=======================================================================
238 //function : SetToMakeGroupsOfDomains
239 //=======================================================================
241 void HYBRIDPlugin_Hypothesis_i::SetToMakeGroupsOfDomains(CORBA::Boolean toMakeGroups)
244 this->GetImpl()->SetToMakeGroupsOfDomains(toMakeGroups);
245 SMESH::TPythonDump() << _this() << ".SetToMakeGroupsOfDomains( " << toMakeGroups << " )";
248 //=======================================================================
249 //function : GetToMakeGroupsOfDomains
250 //=======================================================================
252 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
255 return this->GetImpl()->GetToMakeGroupsOfDomains();
258 //=======================================================================
259 //function : SetMaximumMemory
260 //=======================================================================
262 void HYBRIDPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Double MB)
265 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
267 this->GetImpl()->SetMaximumMemory(MB);
268 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
271 //=======================================================================
272 //function : GetMaximumMemory
273 //=======================================================================
275 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetMaximumMemory()
278 return this->GetImpl()->GetMaximumMemory();
281 //=======================================================================
282 //function : SetInitialMemory
283 //=======================================================================
285 void HYBRIDPlugin_Hypothesis_i::SetInitialMemory(CORBA::Double MB)
288 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
290 this->GetImpl()->SetInitialMemory(MB);
291 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
294 //=======================================================================
295 //function : GetInitialMemory
296 //=======================================================================
298 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetInitialMemory()
301 return this->GetImpl()->GetInitialMemory();
304 //=======================================================================
305 //function : SetOptimizationLevel
306 //=======================================================================
308 void HYBRIDPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
310 ::HYBRIDPlugin_Hypothesis::OptimizationLevel l =
311 (::HYBRIDPlugin_Hypothesis::OptimizationLevel) level;
312 if ( l < ::HYBRIDPlugin_Hypothesis::None ||
313 l > ::HYBRIDPlugin_Hypothesis::Strong )
314 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
317 this->GetImpl()->SetOptimizationLevel(l);
318 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
321 //=======================================================================
322 //function : GetOptimizationLevel
323 //=======================================================================
325 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetOptimizationLevel()
328 return this->GetImpl()->GetOptimizationLevel();
332 //=======================================================================
333 //function : SetCollisionMode
334 //=======================================================================
335 void HYBRIDPlugin_Hypothesis_i::SetCollisionMode(CORBA::Short level)
337 ::HYBRIDPlugin_Hypothesis::CollisionMode l =
338 (::HYBRIDPlugin_Hypothesis::CollisionMode) level;
339 if ( l < ::HYBRIDPlugin_Hypothesis::Decrease ||
340 l > ::HYBRIDPlugin_Hypothesis::Stop )
341 THROW_SALOME_CORBA_EXCEPTION( "Invalid collision mode",SALOME::BAD_PARAM );
344 this->GetImpl()->SetCollisionMode(l);
345 SMESH::TPythonDump() << _this() << ".SetCollisionMode( " << level << " )";
348 //=======================================================================
349 //function : GetCollisionMode
350 //=======================================================================
351 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetCollisionMode()
354 return this->GetImpl()->GetCollisionMode();
357 //=======================================================================
358 //function : SetWorkingDirectory
359 //=======================================================================
360 void HYBRIDPlugin_Hypothesis_i::SetWorkingDirectory(const char* path)
363 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
365 std::string file(path);
366 const char lastChar = *file.rbegin();
368 if ( lastChar != '\\' ) file += '\\';
370 if ( lastChar != '/' ) file += '/';
372 file += "HYBRID.log";
373 SMESH_Mesh_i::PrepareForWriting (file.c_str());
376 this->GetImpl()->SetWorkingDirectory(path);
377 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
380 //=======================================================================
381 //function : GetWorkingDirectory
382 //=======================================================================
383 char* HYBRIDPlugin_Hypothesis_i::GetWorkingDirectory()
386 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
389 //=======================================================================
390 //function : SetKeepFiles
391 //=======================================================================
392 void HYBRIDPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
395 this->GetImpl()->SetKeepFiles(toKeep);
396 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
399 //=======================================================================
400 //function : GetKeepFiles
401 //=======================================================================
402 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetKeepFiles()
405 return this->GetImpl()->GetKeepFiles();
408 //=======================================================================
409 //function : SetVerboseLevel
410 //=======================================================================
411 void HYBRIDPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
413 if (level < 0 || level > 10 )
414 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
417 this->GetImpl()->SetVerboseLevel(level);
418 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
421 //=======================================================================
422 //function : GetVerboseLevel
423 //=======================================================================
424 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetVerboseLevel()
427 return this->GetImpl()->GetVerboseLevel();
430 //=======================================================================
431 //function : SetToCreateNewNodes
432 //=======================================================================
434 void HYBRIDPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
437 this->GetImpl()->SetToCreateNewNodes(toCreate);
438 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
441 //=======================================================================
442 //function : GetToCreateNewNodes
443 //=======================================================================
445 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToCreateNewNodes()
448 return this->GetImpl()->GetToCreateNewNodes();
451 //=======================================================================
452 //function : SetToUseBoundaryRecoveryVersion
453 //=======================================================================
455 void HYBRIDPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
458 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
459 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
462 //=======================================================================
463 //function : GetToUseBoundaryRecoveryVersion
464 //=======================================================================
466 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
469 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
472 //=======================================================================
473 //function : SetFEMCorrection
474 //=======================================================================
476 void HYBRIDPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
479 this->GetImpl()->SetFEMCorrection(toUseFem);
480 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
483 //=======================================================================
484 //function : GetFEMCorrection
485 //=======================================================================
487 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetFEMCorrection()
490 return this->GetImpl()->GetFEMCorrection();
493 //=======================================================================
494 //function : SetToRemoveCentralPoint
495 //=======================================================================
497 void HYBRIDPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
500 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
501 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
504 //=======================================================================
505 //function : GetToRemoveCentralPoint
506 //=======================================================================
508 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToRemoveCentralPoint()
511 return this->GetImpl()->GetToRemoveCentralPoint();
514 //=============================================================================
516 void HYBRIDPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue)
520 std::string name( optionName );
521 while ( !name.empty() && name[0] == '-' )
522 name = name.substr(1);
524 if ( !optionValue || !optionValue[0] )
525 UnsetOption( optionName );
527 // basic options (visible in Advanced table)
529 else if ( name == "number_of_boundary_layers" )
530 SetNbOfBoundaryLayers( GetImpl()->ToInt( optionValue ));
532 else if ( name == "boundary_layer_global_initial_height" )
533 SetHeightFirstLayer( GetImpl()->ToDbl( optionValue ));
535 else if ( name == "boundary_layer_geometric_progression" )
536 SetBoundaryLayersProgression( GetImpl()->ToDbl( optionValue ));
538 else if ( name == "boundary_layer_max_element_angle" )
539 SetBoundaryLayersMaxElemAngle( GetImpl()->ToDbl( optionValue ));
541 else if ( name == "boundary_layer_height_relative_to_local_surface_size" )
542 SetHeightIsRelative( GetImpl()->ToBool( optionValue ));
544 else if ( name == "gradation" )
545 SetGradation( GetImpl()->ToDbl( optionValue ));
547 else if ( name == "element_generation" )
548 switch ( optionValue[0] ) {
549 case 't': SetElementGeneration( 0 ); break;
550 case 'h': SetElementGeneration( 1 ); break;
551 case 'c': SetElementGeneration( 2 ); break;
552 case 'e': SetElementGeneration( 3 ); break;
555 else if ( name == "collision_mode" ) // decrease|stop
556 SetCollisionMode( optionValue[0] != 'd' );
558 else if ( name == "add_multinormals" )
559 SetAddMultinormals( GetImpl()->ToBool( optionValue ));
561 else if ( name == "multinormal_angle_threshold" )
562 SetMultinormalsAngle( GetImpl()->ToDbl( optionValue ));
564 else if ( name == "verbose" )
565 SetVerboseLevel( GetImpl()->ToInt( optionValue ));
567 else if ( name == "max_memory" )
568 SetMaximumMemory( GetImpl()->ToInt( optionValue ));
570 else if ( name == "automatic_memory" )
571 SetInitialMemory( GetImpl()->ToInt( optionValue ));
573 else if ( name == "smooth_normals" )
574 SetSmoothNormals( GetImpl()->ToBool( optionValue ));
576 else if ( name == "optimisation" )
577 switch ( optionValue[0] ) {
578 case 'n': SetOptimizationLevel( 0 ); break;
579 case 'y': SetOptimizationLevel( 1 ); break;
580 case 'o': SetOptimizationLevel( 2 ); break;
584 // advanced options (for backward compatibility)
585 // else if ( name == "create_tag_on_collision" ||
586 // name == "tiny_edge_respect_geometry" )
587 // AddOption( optionName, optionValue );
590 bool valueChanged = true;
592 valueChanged = ( this->GetImpl()->GetOptionValue( name ) != optionValue );
594 catch ( std::invalid_argument& ) {
598 this->GetImpl()->SetOptionValue(optionName, optionValue);
599 SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
602 } catch (const std::invalid_argument& ex) {
603 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
604 } catch (SALOME_Exception& ex) {
605 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
609 //=============================================================================
611 char* HYBRIDPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
616 return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName,&isDefault).c_str());
617 } catch (const std::invalid_argument& ex) {
618 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
619 } catch (SALOME_Exception& ex) {
620 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
625 //=============================================================================
627 void HYBRIDPlugin_Hypothesis_i::UnsetOption(const char* optionName) {
629 if ( !GetImpl()->GetOptionValue( optionName ).empty() )
631 this->GetImpl()->ClearOption(optionName);
632 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
636 //=============================================================================
638 HYBRIDPlugin::string_array* HYBRIDPlugin_Hypothesis_i::GetOptionValues()
640 HYBRIDPlugin::string_array_var result = new HYBRIDPlugin::string_array();
642 const ::HYBRIDPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
643 result->length(opts.size());
647 ::HYBRIDPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
648 for (; opIt != opts.end(); ++opIt, ++i)
650 std::string name_value_type = opIt->first;
651 //if (!opIt->second.empty())
653 name_value_type += ":";
654 name_value_type += GetImpl()->GetOptionValue( opIt->first, &isDefault );
655 name_value_type += isDefault ? ":0" : ":1";
657 result[i] = CORBA::string_dup(name_value_type.c_str());
660 return result._retn();
663 //=============================================================================
665 HYBRIDPlugin::string_array* HYBRIDPlugin_Hypothesis_i::GetAdvancedOptionValues()
667 HYBRIDPlugin::string_array_var result = new HYBRIDPlugin::string_array();
669 const ::HYBRIDPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomOptionValues();
670 result->length(custom_opts.size());
673 ::HYBRIDPlugin_Hypothesis::TOptionValues::const_iterator opIt = custom_opts.begin();
674 for (; opIt != custom_opts.end(); ++opIt, ++i) {
675 std::string name_value_type = opIt->first;
676 if (!opIt->second.empty()) {
677 name_value_type += ":";
678 name_value_type += opIt->second;
679 name_value_type += ":1"; // user defined
681 result[i] = CORBA::string_dup(name_value_type.c_str());
683 return result._retn();
686 //=============================================================================
688 void HYBRIDPlugin_Hypothesis_i::SetOptionValues(const HYBRIDPlugin::string_array& options)
690 for (CORBA::ULong i = 0; i < options.length(); ++i)
692 std::string name_value_type = options[i].in();
693 if(name_value_type.empty())
695 size_t colonPos = name_value_type.find(':');
696 std::string name, value;
697 if (colonPos == std::string::npos) // ':' not found
698 name = name_value_type;
700 name = name_value_type.substr(0, colonPos);
701 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
702 std::string value_type = name_value_type.substr(colonPos + 1);
703 colonPos = value_type.find(':');
704 value = value_type.substr(0, colonPos);
705 if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
706 if ( value_type.substr(colonPos + 1) == "0" ) // is default
710 SetOptionValue(name.c_str(), value.c_str());
714 //=============================================================================
716 void HYBRIDPlugin_Hypothesis_i::SetAdvancedOptionValues(const HYBRIDPlugin::string_array& options)
718 SMESH::TPythonDump dump;
720 std::string optionsAndValues;
721 for ( CORBA::ULong i = 0; i < options.length(); ++i) {
722 std::string name_value_type = options[i].in();
723 if(name_value_type.empty())
725 size_t colonPos = name_value_type.find(':');
726 std::string name, value;
727 if (colonPos == std::string::npos) // ':' not found
728 name = name_value_type;
730 name = name_value_type.substr(0, colonPos);
731 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
732 std::string value_type = name_value_type.substr(colonPos + 1);
733 colonPos = value_type.find(':');
734 value = value_type.substr(0, colonPos);
737 AddOption(name.c_str(), value.c_str());
739 optionsAndValues += name + " " + value + " ";
742 if ( !optionsAndValues.empty() )
743 dump << _this() << ".SetAdvancedOptions( '" << optionsAndValues.c_str() << "' )";
746 //=============================================================================
748 void HYBRIDPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues)
750 if ( !optionsAndValues ) return;
752 //SMESH::TPythonDump dump;
754 std::istringstream strm( optionsAndValues );
755 std::istream_iterator<std::string> sIt( strm ), sEnd;
756 for ( int nbPairs = 0; sIt != sEnd; ++nbPairs )
758 std::string option = *sIt;
761 std::string value = *sIt;
763 AddOption( option.c_str(), value.c_str() );
768 THROW_SALOME_CORBA_EXCEPTION( "Uneven number of options and values" ,SALOME::BAD_PARAM );
769 AddOption( option.c_str(), "" );
772 //dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )";
775 //=============================================================================
777 void HYBRIDPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue)
779 if ( strncmp( "--", optionName, 2 ) == 0 )
782 bool valueChanged = ( !this->GetImpl()->HasOptionDefined(optionName) ||
783 this->GetImpl()->GetOptionValue(optionName) != optionValue );
786 SetOptionValue(optionName, optionValue);
788 SMESH_Comment optVal("--");
789 optVal << optionName << " " << optionValue;
790 std::string cmd = ::HYBRIDPlugin_Hypothesis::CommandToRun( GetImpl() );
791 if ( cmd.find( optVal ) == std::string::npos )
793 this->GetImpl()->SetOptionValue(optionName, optionValue);
794 SMESH::TPythonDump() << _this() << ".AddOption( '" << optionName << "', '" << optionValue << "' )";
799 //=============================================================================
801 char* HYBRIDPlugin_Hypothesis_i::GetOption(const char* optionName)
804 return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName).c_str());
807 //=======================================================================
808 //function : SetTextOption
809 //=======================================================================
810 void HYBRIDPlugin_Hypothesis_i::SetTextOption(const char* option)
813 this->GetImpl()->SetAdvancedOption(option);
814 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
817 //=======================================================================
818 //function : GetTextOption
819 //=======================================================================
820 char* HYBRIDPlugin_Hypothesis_i::GetTextOption()
823 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
826 //=======================================================================
827 //function : GetAdvancedOption
828 //=======================================================================
829 char* HYBRIDPlugin_Hypothesis_i::GetAdvancedOption()
831 return CORBA::string_dup( GetImpl()->GetAdvancedOption().c_str() );
834 //=======================================================================
835 //function : SetToRemoveCentralPoint
836 //=======================================================================
838 void HYBRIDPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
841 THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM );
843 if (gradation != GetGradation()) {
844 this->GetImpl()->SetGradation(gradation);
845 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
849 //=======================================================================
850 //function : GetToRemoveCentralPoint
851 //=======================================================================
853 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetGradation()
856 return this->GetImpl()->GetGradation();
859 //=======================================================================
860 //function : SetStandardOutputLog
861 //=======================================================================
862 void HYBRIDPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
865 this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
866 SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
869 //=======================================================================
870 //function : GetStandardOutputLog
871 //=======================================================================
872 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetStandardOutputLog()
875 return this->GetImpl()->GetStandardOutputLog();
878 //=======================================================================
879 //function : SetRemoveLogOnSuccess
880 //=======================================================================
881 void HYBRIDPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
884 this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
885 SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
888 //=======================================================================
889 //function : GetRemoveLogOnSuccess
890 //=======================================================================
891 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
894 return this->GetImpl()->GetRemoveLogOnSuccess();
897 //=======================================================================
898 //function : SetBoundaryLayersGrowth
899 //=======================================================================
900 void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersGrowth(CORBA::Short level)
902 ::HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth l =
903 (::HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth) level;
904 if ( l < ::HYBRIDPlugin_Hypothesis::Layer_Growth_Inward ||
905 l > ::HYBRIDPlugin_Hypothesis::Layer_Growth_Outward )
906 THROW_SALOME_CORBA_EXCEPTION( "Invalid BoundaryLayersGrowth mode",SALOME::BAD_PARAM );
909 this->GetImpl()->SetBoundaryLayersGrowth(l);
910 SMESH::TPythonDump() << _this() << ".SetBoundaryLayersGrowth( " << level << " )";
913 //=======================================================================
914 //function : GetBoundaryLayersGrowth
915 //=======================================================================
916 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersGrowth()
919 return this->GetImpl()->GetBoundaryLayersGrowth();
922 //=======================================================================
923 //function : SetElementGeneration
924 //=======================================================================
925 void HYBRIDPlugin_Hypothesis_i::SetElementGeneration(CORBA::Short level)
927 ::HYBRIDPlugin_Hypothesis::ElementGeneration l =
928 (::HYBRIDPlugin_Hypothesis::ElementGeneration) level;
929 if ( l < ::HYBRIDPlugin_Hypothesis::Generation_Tetra_Dominant ||
930 l > ::HYBRIDPlugin_Hypothesis::Generation_Extrusion_Only )
931 THROW_SALOME_CORBA_EXCEPTION( "Invalid ElementGeneration mode",SALOME::BAD_PARAM );
934 this->GetImpl()->SetElementGeneration(l);
935 SMESH::TPythonDump() << _this() << ".SetElementGeneration( " << level << " )";
938 //=======================================================================
939 //function : GetElementGeneration
940 //=======================================================================
941 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetElementGeneration()
944 return this->GetImpl()->GetElementGeneration();
947 //=======================================================================
948 //function : SetAddMultinormals
949 //=======================================================================
950 void HYBRIDPlugin_Hypothesis_i::SetAddMultinormals(CORBA::Boolean toAddMultinormals)
953 this->GetImpl()->SetAddMultinormals(toAddMultinormals);
954 SMESH::TPythonDump() << _this() << ".SetAddMultinormals( " << toAddMultinormals << " )";
957 //=======================================================================
958 //function : GetAddMultinormals
959 //=======================================================================
960 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetAddMultinormals()
963 return this->GetImpl()->GetAddMultinormals();
966 //=======================================================================
967 //function : SetSmoothNormals
968 //=======================================================================
969 void HYBRIDPlugin_Hypothesis_i::SetSmoothNormals(CORBA::Boolean toSmoothNormals)
972 this->GetImpl()->SetSmoothNormals(toSmoothNormals);
973 SMESH::TPythonDump() << _this() << ".SetSmoothNormals( " << toSmoothNormals << " )";
976 //=======================================================================
977 //function : GetSmoothNormals
978 //=======================================================================
979 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetSmoothNormals()
982 return this->GetImpl()->GetSmoothNormals();
985 //=======================================================================
986 //function : SetHeightFirstLayer
987 //=======================================================================
988 void HYBRIDPlugin_Hypothesis_i::SetHeightFirstLayer(CORBA::Double toHeightFirstLayer)
991 this->GetImpl()->SetHeightFirstLayer(toHeightFirstLayer);
992 SMESH::TPythonDump() << _this() << ".SetHeightFirstLayer( " << toHeightFirstLayer << " )";
995 //=======================================================================
996 //function : GetHeightFirstLayer
997 //=======================================================================
998 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetHeightFirstLayer()
1001 return this->GetImpl()->GetHeightFirstLayer();
1004 //=======================================================================
1005 //function : SetBoundaryLayersProgression
1006 //=======================================================================
1007 void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersProgression(CORBA::Double toBoundaryLayersProgression)
1010 this->GetImpl()->SetBoundaryLayersProgression(toBoundaryLayersProgression);
1011 SMESH::TPythonDump() << _this() << ".SetBoundaryLayersProgression( " << toBoundaryLayersProgression << " )";
1014 //=======================================================================
1015 //function : GetBoundaryLayersProgression
1016 //=======================================================================
1017 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersProgression()
1020 return this->GetImpl()->GetBoundaryLayersProgression();
1023 //=======================================================================
1024 //function : SetCoreSize
1025 //=======================================================================
1026 void HYBRIDPlugin_Hypothesis_i::SetCoreSize(CORBA::Double toCoreSize)
1029 this->GetImpl()->SetCoreSize(toCoreSize);
1030 SMESH::TPythonDump() << _this() << ".SetCoreSize( " << toCoreSize << " )";
1033 //=======================================================================
1034 //function : GetCoreSize
1035 //=======================================================================
1036 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetCoreSize()
1039 return this->GetImpl()->GetCoreSize();
1042 //=======================================================================
1043 //function : SetMultinormalsAngle
1044 //=======================================================================
1045 void HYBRIDPlugin_Hypothesis_i::SetMultinormalsAngle(CORBA::Double toMultinormalsAngle)
1048 this->GetImpl()->SetMultinormalsAngle(toMultinormalsAngle);
1049 SMESH::TPythonDump() << _this() << ".SetMultinormalsAngle( " << toMultinormalsAngle << " )";
1052 //=======================================================================
1053 //function : GetMultinormalsAngle
1054 //=======================================================================
1055 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetMultinormalsAngle()
1058 return this->GetImpl()->GetMultinormalsAngle();
1061 //=======================================================================
1062 //function : SetNbOfBoundaryLayers
1063 //=======================================================================
1064 void HYBRIDPlugin_Hypothesis_i::SetNbOfBoundaryLayers(CORBA::Short toNbOfBoundaryLayers)
1067 this->GetImpl()->SetNbOfBoundaryLayers(toNbOfBoundaryLayers);
1068 SMESH::TPythonDump() << _this() << ".SetNbOfBoundaryLayers( " << toNbOfBoundaryLayers << " )";
1071 //=======================================================================
1072 //function : GetNbOfBoundaryLayers
1073 //=======================================================================
1074 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetNbOfBoundaryLayers()
1077 return this->GetImpl()->GetNbOfBoundaryLayers();
1080 //=======================================================================
1081 //function : SetEnforcedVertex
1082 //=======================================================================
1084 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
1087 return p_SetEnforcedVertex(size, x, y, z);
1090 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
1093 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
1096 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
1099 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
1102 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
1105 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
1108 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
1112 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1113 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1116 std::string theVertexEntry = theVertex->GetStudyEntry();
1117 CORBA::Double x = 0, y = 0, z = 0;
1118 CORBA::Boolean isCompound = false;
1119 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1120 if (theVertexEntry.empty()) {
1122 if (theVertex->GetShapeType() == GEOM::VERTEX) {
1125 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
1126 aName = "Compound_";
1129 aName += theVertex->GetEntry();
1130 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1131 if (!theSVertex->_is_nil())
1132 theVertexEntry = theSVertex->GetID();
1134 if (theVertexEntry.empty())
1135 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1137 if (theVertex->GetShapeType() == GEOM::VERTEX) {
1138 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
1139 if (CORBA::is_nil(measureOp))
1142 measureOp->PointCoordinates (theVertex, x, y, z);
1145 std::string theVertexName = theVertex->GetName();
1147 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
1150 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
1154 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1155 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1156 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1159 std::string theVertexEntry = theVertex->GetStudyEntry();
1160 CORBA::Double x = 0, y = 0, z = 0;
1161 CORBA::Boolean isCompound = false;
1162 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1163 if (theVertexEntry.empty()) {
1165 if (theVertex->GetShapeType() == GEOM::VERTEX) {
1168 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
1169 aName = "Compound_";
1172 aName += theVertex->GetEntry();
1173 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1174 if (!theSVertex->_is_nil())
1175 theVertexEntry = theSVertex->GetID();
1177 if (theVertexEntry.empty())
1178 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1180 if (theVertex->GetShapeType() == GEOM::VERTEX) {
1181 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
1182 if (CORBA::is_nil(measureOp))
1185 measureOp->PointCoordinates (theVertex, x, y, z);
1188 std::string theVertexName = theVertex->GetName();
1190 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
1193 bool HYBRIDPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
1194 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
1195 CORBA::Boolean isCompound)
1198 bool newValue = false;
1200 ::HYBRIDPlugin_Hypothesis::TCoordsHYBRIDEnforcedVertexMap coordsList;
1201 ::HYBRIDPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap enfVertexEntryList;
1202 if (std::string(theVertexEntry).empty()) {
1203 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
1204 std::vector<double> coords;
1205 coords.push_back(x);
1206 coords.push_back(y);
1207 coords.push_back(z);
1208 if (coordsList.find(coords) == coordsList.end()) {
1212 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
1213 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
1214 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
1222 if (std::string(theVertexName).empty()) {
1223 if (std::string(theGroupName).empty())
1224 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
1226 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
1229 if (std::string(theGroupName).empty())
1230 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
1232 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
1237 // if (isCompound || (!isCompound && !std::string(theVertexEntry).empty())) {
1238 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
1239 // ::BLSURFPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
1240 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
1244 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
1245 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
1246 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
1254 if (std::string(theGroupName).empty())
1255 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
1257 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
1262 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
1267 //=======================================================================
1268 //function : GetEnforcedVertex
1269 //=======================================================================
1271 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1275 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
1276 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
1279 catch (const std::invalid_argument& ex) {
1280 SALOME::ExceptionStruct ExDescription;
1281 ExDescription.text = ex.what();
1282 ExDescription.type = SALOME::BAD_PARAM;
1283 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1284 ExDescription.lineNumber = 513;
1285 throw SALOME::SALOME_Exception(ExDescription);
1287 catch (SALOME_Exception& ex) {
1288 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1292 //=======================================================================
1293 //function : GetEnforcedVertex
1294 //=======================================================================
1296 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1300 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1301 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1302 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1305 std::string theVertexEntry = theVertex->GetStudyEntry();
1306 if (theVertexEntry.empty()) {
1307 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1309 if (theVertex->GetShapeType() == GEOM::VERTEX)
1311 if (theVertex->GetShapeType() == GEOM::COMPOUND)
1312 aName = "Compound_";
1313 aName += theVertex->GetEntry();
1314 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1315 if (!theSVertex->_is_nil())
1316 theVertexEntry = theSVertex->GetID();
1318 if (theVertexEntry.empty())
1319 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1321 std::string theVertexName = theVertex->GetName();
1324 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
1325 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
1328 catch (const std::invalid_argument& ex) {
1329 SALOME::ExceptionStruct ExDescription;
1330 ExDescription.text = ex.what();
1331 ExDescription.type = SALOME::BAD_PARAM;
1332 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1333 ExDescription.lineNumber = 538;
1334 throw SALOME::SALOME_Exception(ExDescription);
1336 catch (SALOME_Exception& ex) {
1337 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1341 //=======================================================================
1342 //function : GetEnforcedVertices
1343 //=======================================================================
1345 HYBRIDPlugin::HYBRIDEnforcedVertexList* HYBRIDPlugin_Hypothesis_i::GetEnforcedVertices()
1348 HYBRIDPlugin::HYBRIDEnforcedVertexList_var result = new HYBRIDPlugin::HYBRIDEnforcedVertexList();
1350 const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
1351 result->length( enfVertexList.size() );
1353 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList::const_iterator it = enfVertexList.begin();
1355 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
1356 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* currentVertex = (*it);
1357 HYBRIDPlugin::HYBRIDEnforcedVertex_var enfVertex = new HYBRIDPlugin::HYBRIDEnforcedVertex();
1359 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
1360 // Geom Vertex Entry
1361 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
1363 HYBRIDPlugin::TCoords_var coords = new HYBRIDPlugin::TCoords();
1364 coords->length(currentVertex->coords.size());
1365 for (size_t ind = 0; ind < currentVertex->coords.size(); ind++)
1366 coords[ind] = currentVertex->coords[ind];
1367 enfVertex->coords = coords;
1369 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
1371 enfVertex->size = currentVertex->size;
1373 enfVertex->isCompound = currentVertex->isCompound;
1375 result[i]=enfVertex;
1378 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1380 return result._retn();
1383 //=======================================================================
1384 //function : RemoveEnforcedVertex
1385 //=======================================================================
1387 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1391 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
1392 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
1395 catch (const std::invalid_argument& ex) {
1396 SALOME::ExceptionStruct ExDescription;
1397 ExDescription.text = ex.what();
1398 ExDescription.type = SALOME::BAD_PARAM;
1399 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1400 ExDescription.lineNumber = 625;
1401 throw SALOME::SALOME_Exception(ExDescription);
1403 catch (SALOME_Exception& ex) {
1404 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1408 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1412 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1413 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1414 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1417 std::string theVertexEntry = theVertex->GetStudyEntry();
1418 if (theVertexEntry.empty()) {
1419 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1421 if (theVertex->GetShapeType() == GEOM::VERTEX)
1423 if (theVertex->GetShapeType() == GEOM::COMPOUND)
1424 aName = "Compound_";
1425 aName += theVertex->GetEntry();
1426 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1427 if (!theSVertex->_is_nil())
1428 theVertexEntry = theSVertex->GetID();
1430 if (theVertexEntry.empty())
1431 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1434 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
1435 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
1438 catch (const std::invalid_argument& ex) {
1439 SALOME::ExceptionStruct ExDescription;
1440 ExDescription.text = ex.what();
1441 ExDescription.type = SALOME::BAD_PARAM;
1442 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1443 ExDescription.lineNumber = 648;
1444 throw SALOME::SALOME_Exception(ExDescription);
1446 catch (SALOME_Exception& ex) {
1447 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1451 //=======================================================================
1452 //function : ClearEnforcedVertices
1453 //=======================================================================
1455 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedVertices()
1458 this->GetImpl()->ClearEnforcedVertices();
1459 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
1462 //=======================================================================
1463 //function : ClearEnforcedMeshes
1464 //=======================================================================
1466 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedMeshes()
1469 this->GetImpl()->ClearEnforcedMeshes();
1470 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
1473 //=======================================================================
1474 //function : GetEnforcedMeshes
1475 //=======================================================================
1477 HYBRIDPlugin::HYBRIDEnforcedMeshList* HYBRIDPlugin_Hypothesis_i::GetEnforcedMeshes()
1480 HYBRIDPlugin::HYBRIDEnforcedMeshList_var result = new HYBRIDPlugin::HYBRIDEnforcedMeshList();
1482 const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
1483 result->length( enfMeshList.size() );
1485 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList::const_iterator it = enfMeshList.begin();
1487 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
1488 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMesh* currentMesh = (*it);
1489 HYBRIDPlugin::HYBRIDEnforcedMesh_var enfMesh = new HYBRIDPlugin::HYBRIDEnforcedMesh();
1491 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
1493 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
1495 enfMesh->elementType = currentMesh->elementType;
1497 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
1502 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1504 return result._retn();
1508 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
1510 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
1512 // #if HYBRID_VERSION >= 42
1513 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1515 // SALOME::ExceptionStruct ExDescription;
1516 // ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1517 // ExDescription.type = SALOME::BAD_PARAM;
1518 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1519 // ExDescription.lineNumber = 719;
1520 // throw SALOME::SALOME_Exception(ExDescription);
1525 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
1527 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
1529 // #if HYBRID_VERSION >= 42
1530 return p_SetEnforcedMesh(theSource, theType);
1532 // SALOME::ExceptionStruct ExDescription;
1533 // ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1534 // ExDescription.type = SALOME::BAD_PARAM;
1535 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1536 // ExDescription.lineNumber = 750;
1537 // throw SALOME::SALOME_Exception(ExDescription);
1542 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size. The elements will be grouped in theGroupName.
1544 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double /*theSize*/, const char* theGroupName)
1546 // #if HYBRID_VERSION >= 42
1547 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1549 // SALOME::ExceptionStruct ExDescription;
1550 // ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1551 // ExDescription.type = SALOME::BAD_PARAM;
1552 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1553 // ExDescription.lineNumber = 750;
1554 // throw SALOME::SALOME_Exception(ExDescription);
1559 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
1561 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double /*theSize*/)
1563 // #if HYBRID_VERSION >= 42
1564 return p_SetEnforcedMesh(theSource, theType);
1566 // SALOME::ExceptionStruct ExDescription;
1567 // ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1568 // ExDescription.type = SALOME::BAD_PARAM;
1569 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1570 // ExDescription.lineNumber = 750;
1571 // throw SALOME::SALOME_Exception(ExDescription);
1575 bool HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
1579 if (CORBA::is_nil( theSource ))
1581 SALOME::ExceptionStruct ExDescription;
1582 ExDescription.text = "The source mesh CORBA object is NULL";
1583 ExDescription.type = SALOME::BAD_PARAM;
1584 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1585 ExDescription.lineNumber = 840;
1586 throw SALOME::SALOME_Exception(ExDescription);
1599 SMESH::array_of_ElementType_var types = theSource->GetTypes();
1600 if ( types->length() >= 1 && types[types->length()-1] < theType)
1603 // SALOME::ExceptionStruct ExDescription;
1604 // ExDescription.text = "The source mesh has bad type";
1605 // ExDescription.type = SALOME::BAD_PARAM;
1606 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1607 // ExDescription.lineNumber = 840;
1608 // throw SALOME::SALOME_Exception(ExDescription);
1612 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1613 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(theSource);
1615 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1616 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1617 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1619 std::string enfMeshName = theName;
1620 if (enfMeshName.empty())
1621 enfMeshName = SObj->GetName();
1626 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1627 if (theGroupName && theGroupName[0]) {
1628 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1629 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1632 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1633 << theSource << ".GetMesh(), " << theType << " )";
1638 catch (const std::invalid_argument& ex) {
1639 SALOME::ExceptionStruct ExDescription;
1640 ExDescription.text = ex.what();
1641 ExDescription.type = SALOME::BAD_PARAM;
1642 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1643 ExDescription.lineNumber = 840;
1644 throw SALOME::SALOME_Exception(ExDescription);
1646 catch (SALOME_Exception& ex) {
1647 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1650 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1653 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1654 if (theGroupName && theGroupName[0]) {
1655 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1656 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1659 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1660 << theSource << ", " << theType << " )";
1664 catch (const std::invalid_argument& ex) {
1665 SALOME::ExceptionStruct ExDescription;
1666 ExDescription.text = ex.what();
1667 ExDescription.type = SALOME::BAD_PARAM;
1668 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1669 ExDescription.lineNumber = 840;
1670 throw SALOME::SALOME_Exception(ExDescription);
1672 catch (SALOME_Exception& ex) {
1673 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1676 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1679 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1680 if (theGroupName && theGroupName[0]) {
1681 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1682 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1685 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1686 << theSource << ", " << theType << " )";
1690 catch (const std::invalid_argument& ex) {
1691 SALOME::ExceptionStruct ExDescription;
1692 ExDescription.text = ex.what();
1693 ExDescription.type = SALOME::BAD_PARAM;
1694 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1695 ExDescription.lineNumber = 840;
1696 throw SALOME::SALOME_Exception(ExDescription);
1698 catch (SALOME_Exception& ex) {
1699 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1704 //=============================================================================
1706 * Get implementation
1708 //=============================================================================
1710 ::HYBRIDPlugin_Hypothesis* HYBRIDPlugin_Hypothesis_i::GetImpl()
1712 return (::HYBRIDPlugin_Hypothesis*)myBaseImpl;
1715 //================================================================================
1717 * \brief Verify whether hypothesis supports given entity type
1719 //================================================================================
1721 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1723 return type == SMESH::DIM_3D;