1 // Copyright (C) 2007-2020 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, 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)
263 throw ( SALOME::SALOME_Exception )
266 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
268 this->GetImpl()->SetMaximumMemory(MB);
269 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
272 //=======================================================================
273 //function : GetMaximumMemory
274 //=======================================================================
276 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetMaximumMemory()
279 return this->GetImpl()->GetMaximumMemory();
282 //=======================================================================
283 //function : SetInitialMemory
284 //=======================================================================
286 void HYBRIDPlugin_Hypothesis_i::SetInitialMemory(CORBA::Double MB)
287 throw ( SALOME::SALOME_Exception )
290 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
292 this->GetImpl()->SetInitialMemory(MB);
293 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
296 //=======================================================================
297 //function : GetInitialMemory
298 //=======================================================================
300 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetInitialMemory()
303 return this->GetImpl()->GetInitialMemory();
306 //=======================================================================
307 //function : SetOptimizationLevel
308 //=======================================================================
310 void HYBRIDPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
311 throw ( SALOME::SALOME_Exception )
313 ::HYBRIDPlugin_Hypothesis::OptimizationLevel l =
314 (::HYBRIDPlugin_Hypothesis::OptimizationLevel) level;
315 if ( l < ::HYBRIDPlugin_Hypothesis::None ||
316 l > ::HYBRIDPlugin_Hypothesis::Strong )
317 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
320 this->GetImpl()->SetOptimizationLevel(l);
321 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
324 //=======================================================================
325 //function : GetOptimizationLevel
326 //=======================================================================
328 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetOptimizationLevel()
331 return this->GetImpl()->GetOptimizationLevel();
335 //=======================================================================
336 //function : SetCollisionMode
337 //=======================================================================
338 void HYBRIDPlugin_Hypothesis_i::SetCollisionMode(CORBA::Short level)
339 throw ( SALOME::SALOME_Exception )
341 ::HYBRIDPlugin_Hypothesis::CollisionMode l =
342 (::HYBRIDPlugin_Hypothesis::CollisionMode) level;
343 if ( l < ::HYBRIDPlugin_Hypothesis::Decrease ||
344 l > ::HYBRIDPlugin_Hypothesis::Stop )
345 THROW_SALOME_CORBA_EXCEPTION( "Invalid collision mode",SALOME::BAD_PARAM );
348 this->GetImpl()->SetCollisionMode(l);
349 SMESH::TPythonDump() << _this() << ".SetCollisionMode( " << level << " )";
352 //=======================================================================
353 //function : GetCollisionMode
354 //=======================================================================
355 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetCollisionMode()
358 return this->GetImpl()->GetCollisionMode();
361 //=======================================================================
362 //function : SetWorkingDirectory
363 //=======================================================================
364 void HYBRIDPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
367 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
369 std::string file(path);
370 const char lastChar = *file.rbegin();
372 if ( lastChar != '\\' ) file += '\\';
374 if ( lastChar != '/' ) file += '/';
376 file += "HYBRID.log";
377 SMESH_Mesh_i::PrepareForWriting (file.c_str());
380 this->GetImpl()->SetWorkingDirectory(path);
381 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
384 //=======================================================================
385 //function : GetWorkingDirectory
386 //=======================================================================
387 char* HYBRIDPlugin_Hypothesis_i::GetWorkingDirectory()
390 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
393 //=======================================================================
394 //function : SetKeepFiles
395 //=======================================================================
396 void HYBRIDPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
399 this->GetImpl()->SetKeepFiles(toKeep);
400 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
403 //=======================================================================
404 //function : GetKeepFiles
405 //=======================================================================
406 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetKeepFiles()
409 return this->GetImpl()->GetKeepFiles();
412 //=======================================================================
413 //function : SetVerboseLevel
414 //=======================================================================
415 void HYBRIDPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
416 throw ( SALOME::SALOME_Exception )
418 if (level < 0 || level > 10 )
419 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
422 this->GetImpl()->SetVerboseLevel(level);
423 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
426 //=======================================================================
427 //function : GetVerboseLevel
428 //=======================================================================
429 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetVerboseLevel()
432 return this->GetImpl()->GetVerboseLevel();
435 //=======================================================================
436 //function : SetToCreateNewNodes
437 //=======================================================================
439 void HYBRIDPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
442 this->GetImpl()->SetToCreateNewNodes(toCreate);
443 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
446 //=======================================================================
447 //function : GetToCreateNewNodes
448 //=======================================================================
450 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToCreateNewNodes()
453 return this->GetImpl()->GetToCreateNewNodes();
456 //=======================================================================
457 //function : SetToUseBoundaryRecoveryVersion
458 //=======================================================================
460 void HYBRIDPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
463 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
464 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
467 //=======================================================================
468 //function : GetToUseBoundaryRecoveryVersion
469 //=======================================================================
471 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
474 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
477 //=======================================================================
478 //function : SetFEMCorrection
479 //=======================================================================
481 void HYBRIDPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
484 this->GetImpl()->SetFEMCorrection(toUseFem);
485 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
488 //=======================================================================
489 //function : GetFEMCorrection
490 //=======================================================================
492 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetFEMCorrection()
495 return this->GetImpl()->GetFEMCorrection();
498 //=======================================================================
499 //function : SetToRemoveCentralPoint
500 //=======================================================================
502 void HYBRIDPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
505 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
506 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
509 //=======================================================================
510 //function : GetToRemoveCentralPoint
511 //=======================================================================
513 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToRemoveCentralPoint()
516 return this->GetImpl()->GetToRemoveCentralPoint();
519 //=============================================================================
521 void HYBRIDPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue)
522 throw (SALOME::SALOME_Exception)
526 std::string name( optionName );
527 while ( !name.empty() && name[0] == '-' )
528 name = name.substr(1);
530 if ( !optionValue || !optionValue[0] )
531 UnsetOption( optionName );
533 // basic options (visible in Advanced table)
535 else if ( name == "number_of_boundary_layers" )
536 SetNbOfBoundaryLayers( GetImpl()->ToInt( optionValue ));
538 else if ( name == "boundary_layer_global_initial_height" )
539 SetHeightFirstLayer( GetImpl()->ToDbl( optionValue ));
541 else if ( name == "boundary_layer_geometric_progression" )
542 SetBoundaryLayersProgression( GetImpl()->ToDbl( optionValue ));
544 else if ( name == "boundary_layer_max_element_angle" )
545 SetBoundaryLayersMaxElemAngle( GetImpl()->ToDbl( optionValue ));
547 else if ( name == "boundary_layer_height_relative_to_local_surface_size" )
548 SetHeightIsRelative( GetImpl()->ToBool( optionValue ));
550 else if ( name == "gradation" )
551 SetGradation( GetImpl()->ToDbl( optionValue ));
553 else if ( name == "element_generation" )
554 switch ( optionValue[0] ) {
555 case 't': SetElementGeneration( 0 ); break;
556 case 'h': SetElementGeneration( 1 ); break;
557 case 'c': SetElementGeneration( 2 ); break;
558 case 'e': SetElementGeneration( 3 ); break;
561 else if ( name == "collision_mode" ) // decrease|stop
562 SetCollisionMode( optionValue[0] != 'd' );
564 else if ( name == "add_multinormals" )
565 SetAddMultinormals( GetImpl()->ToBool( optionValue ));
567 else if ( name == "multinormal_angle_threshold" )
568 SetMultinormalsAngle( GetImpl()->ToDbl( optionValue ));
570 else if ( name == "verbose" )
571 SetVerboseLevel( GetImpl()->ToInt( optionValue ));
573 else if ( name == "max_memory" )
574 SetMaximumMemory( GetImpl()->ToInt( optionValue ));
576 else if ( name == "automatic_memory" )
577 SetInitialMemory( GetImpl()->ToInt( optionValue ));
579 else if ( name == "smooth_normals" )
580 SetSmoothNormals( GetImpl()->ToBool( optionValue ));
582 else if ( name == "optimisation" )
583 switch ( optionValue[0] ) {
584 case 'n': SetOptimizationLevel( 0 ); break;
585 case 'y': SetOptimizationLevel( 1 ); break;
586 case 'o': SetOptimizationLevel( 2 ); break;
590 // advanced options (for backward compatibility)
591 // else if ( name == "create_tag_on_collision" ||
592 // name == "tiny_edge_respect_geometry" )
593 // AddOption( optionName, optionValue );
596 bool valueChanged = true;
598 valueChanged = ( this->GetImpl()->GetOptionValue( name ) != optionValue );
600 catch ( std::invalid_argument ) {
604 this->GetImpl()->SetOptionValue(optionName, optionValue);
605 SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
608 } catch (const std::invalid_argument& ex) {
609 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
610 } catch (SALOME_Exception& ex) {
611 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
615 //=============================================================================
617 char* HYBRIDPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
618 throw (SALOME::SALOME_Exception)
623 return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName,&isDefault).c_str());
624 } catch (const std::invalid_argument& ex) {
625 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
626 } catch (SALOME_Exception& ex) {
627 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
632 //=============================================================================
634 void HYBRIDPlugin_Hypothesis_i::UnsetOption(const char* optionName) {
636 if ( !GetImpl()->GetOptionValue( optionName ).empty() )
638 this->GetImpl()->ClearOption(optionName);
639 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
643 //=============================================================================
645 HYBRIDPlugin::string_array* HYBRIDPlugin_Hypothesis_i::GetOptionValues()
647 HYBRIDPlugin::string_array_var result = new HYBRIDPlugin::string_array();
649 const ::HYBRIDPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
650 result->length(opts.size());
654 ::HYBRIDPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
655 for (; opIt != opts.end(); ++opIt, ++i)
657 std::string name_value_type = opIt->first;
658 //if (!opIt->second.empty())
660 name_value_type += ":";
661 name_value_type += GetImpl()->GetOptionValue( opIt->first, &isDefault );
662 name_value_type += isDefault ? ":0" : ":1";
664 result[i] = CORBA::string_dup(name_value_type.c_str());
667 return result._retn();
670 //=============================================================================
672 HYBRIDPlugin::string_array* HYBRIDPlugin_Hypothesis_i::GetAdvancedOptionValues()
674 HYBRIDPlugin::string_array_var result = new HYBRIDPlugin::string_array();
676 const ::HYBRIDPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomOptionValues();
677 result->length(custom_opts.size());
680 ::HYBRIDPlugin_Hypothesis::TOptionValues::const_iterator opIt = custom_opts.begin();
681 for (; opIt != custom_opts.end(); ++opIt, ++i) {
682 std::string name_value_type = opIt->first;
683 if (!opIt->second.empty()) {
684 name_value_type += ":";
685 name_value_type += opIt->second;
686 name_value_type += ":1"; // user defined
688 result[i] = CORBA::string_dup(name_value_type.c_str());
690 return result._retn();
693 //=============================================================================
695 void HYBRIDPlugin_Hypothesis_i::SetOptionValues(const HYBRIDPlugin::string_array& options)
696 throw (SALOME::SALOME_Exception)
698 for (CORBA::ULong i = 0; i < options.length(); ++i)
700 std::string name_value_type = options[i].in();
701 if(name_value_type.empty())
703 size_t colonPos = name_value_type.find(':');
704 std::string name, value;
705 if (colonPos == std::string::npos) // ':' not found
706 name = name_value_type;
708 name = name_value_type.substr(0, colonPos);
709 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
710 std::string value_type = name_value_type.substr(colonPos + 1);
711 colonPos = value_type.find(':');
712 value = value_type.substr(0, colonPos);
713 if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
714 if ( value_type.substr(colonPos + 1) == "0" ) // is default
718 SetOptionValue(name.c_str(), value.c_str());
722 //=============================================================================
724 void HYBRIDPlugin_Hypothesis_i::SetAdvancedOptionValues(const HYBRIDPlugin::string_array& options)
726 SMESH::TPythonDump dump;
728 std::string optionsAndValues;
729 for ( CORBA::ULong i = 0; i < options.length(); ++i) {
730 std::string name_value_type = options[i].in();
731 if(name_value_type.empty())
733 size_t colonPos = name_value_type.find(':');
734 std::string name, value;
735 if (colonPos == std::string::npos) // ':' not found
736 name = name_value_type;
738 name = name_value_type.substr(0, colonPos);
739 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
740 std::string value_type = name_value_type.substr(colonPos + 1);
741 colonPos = value_type.find(':');
742 value = value_type.substr(0, colonPos);
745 AddOption(name.c_str(), value.c_str());
747 optionsAndValues += name + " " + value + " ";
750 if ( !optionsAndValues.empty() )
751 dump << _this() << ".SetAdvancedOptions( '" << optionsAndValues.c_str() << "' )";
754 //=============================================================================
756 void HYBRIDPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues)
757 throw (SALOME::SALOME_Exception)
759 if ( !optionsAndValues ) return;
761 //SMESH::TPythonDump dump;
763 std::istringstream strm( optionsAndValues );
764 std::istream_iterator<std::string> sIt( strm ), sEnd;
765 for ( int nbPairs = 0; sIt != sEnd; ++nbPairs )
767 std::string option = *sIt;
770 std::string value = *sIt;
772 AddOption( option.c_str(), value.c_str() );
777 THROW_SALOME_CORBA_EXCEPTION( "Uneven number of options and values" ,SALOME::BAD_PARAM );
778 AddOption( option.c_str(), "" );
781 //dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )";
784 //=============================================================================
786 void HYBRIDPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue)
788 if ( strncmp( "--", optionName, 2 ) == 0 )
791 bool valueChanged = ( !this->GetImpl()->HasOptionDefined(optionName) ||
792 this->GetImpl()->GetOptionValue(optionName) != optionValue );
795 SetOptionValue(optionName, optionValue);
797 SMESH_Comment optVal("--");
798 optVal << optionName << " " << optionValue;
799 std::string cmd = ::HYBRIDPlugin_Hypothesis::CommandToRun( GetImpl() );
800 if ( cmd.find( optVal ) == std::string::npos )
802 this->GetImpl()->SetOptionValue(optionName, optionValue);
803 SMESH::TPythonDump() << _this() << ".AddOption( '" << optionName << "', '" << optionValue << "' )";
808 //=============================================================================
810 char* HYBRIDPlugin_Hypothesis_i::GetOption(const char* optionName)
813 return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName).c_str());
816 //=======================================================================
817 //function : SetTextOption
818 //=======================================================================
819 void HYBRIDPlugin_Hypothesis_i::SetTextOption(const char* option)
822 this->GetImpl()->SetAdvancedOption(option);
823 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
826 //=======================================================================
827 //function : GetTextOption
828 //=======================================================================
829 char* HYBRIDPlugin_Hypothesis_i::GetTextOption()
832 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
835 //=======================================================================
836 //function : GetAdvancedOption
837 //=======================================================================
838 char* HYBRIDPlugin_Hypothesis_i::GetAdvancedOption()
840 return CORBA::string_dup( GetImpl()->GetAdvancedOption().c_str() );
843 //=======================================================================
844 //function : SetToRemoveCentralPoint
845 //=======================================================================
847 void HYBRIDPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
850 THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM );
852 if (gradation != GetGradation()) {
853 this->GetImpl()->SetGradation(gradation);
854 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
858 //=======================================================================
859 //function : GetToRemoveCentralPoint
860 //=======================================================================
862 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetGradation()
865 return this->GetImpl()->GetGradation();
868 //=======================================================================
869 //function : SetStandardOutputLog
870 //=======================================================================
871 void HYBRIDPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
874 this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
875 SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
878 //=======================================================================
879 //function : GetStandardOutputLog
880 //=======================================================================
881 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetStandardOutputLog()
884 return this->GetImpl()->GetStandardOutputLog();
887 //=======================================================================
888 //function : SetRemoveLogOnSuccess
889 //=======================================================================
890 void HYBRIDPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
893 this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
894 SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
897 //=======================================================================
898 //function : GetRemoveLogOnSuccess
899 //=======================================================================
900 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
903 return this->GetImpl()->GetRemoveLogOnSuccess();
906 //=======================================================================
907 //function : SetBoundaryLayersGrowth
908 //=======================================================================
909 void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersGrowth(CORBA::Short level)
910 throw ( SALOME::SALOME_Exception )
912 ::HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth l =
913 (::HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth) level;
914 if ( l < ::HYBRIDPlugin_Hypothesis::Layer_Growth_Inward ||
915 l > ::HYBRIDPlugin_Hypothesis::Layer_Growth_Outward )
916 THROW_SALOME_CORBA_EXCEPTION( "Invalid BoundaryLayersGrowth mode",SALOME::BAD_PARAM );
919 this->GetImpl()->SetBoundaryLayersGrowth(l);
920 SMESH::TPythonDump() << _this() << ".SetBoundaryLayersGrowth( " << level << " )";
923 //=======================================================================
924 //function : GetBoundaryLayersGrowth
925 //=======================================================================
926 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersGrowth()
929 return this->GetImpl()->GetBoundaryLayersGrowth();
932 //=======================================================================
933 //function : SetElementGeneration
934 //=======================================================================
935 void HYBRIDPlugin_Hypothesis_i::SetElementGeneration(CORBA::Short level)
936 throw ( SALOME::SALOME_Exception )
938 ::HYBRIDPlugin_Hypothesis::ElementGeneration l =
939 (::HYBRIDPlugin_Hypothesis::ElementGeneration) level;
940 if ( l < ::HYBRIDPlugin_Hypothesis::Generation_Tetra_Dominant ||
941 l > ::HYBRIDPlugin_Hypothesis::Generation_Extrusion_Only )
942 THROW_SALOME_CORBA_EXCEPTION( "Invalid ElementGeneration mode",SALOME::BAD_PARAM );
945 this->GetImpl()->SetElementGeneration(l);
946 SMESH::TPythonDump() << _this() << ".SetElementGeneration( " << level << " )";
949 //=======================================================================
950 //function : GetElementGeneration
951 //=======================================================================
952 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetElementGeneration()
955 return this->GetImpl()->GetElementGeneration();
958 //=======================================================================
959 //function : SetAddMultinormals
960 //=======================================================================
961 void HYBRIDPlugin_Hypothesis_i::SetAddMultinormals(CORBA::Boolean toAddMultinormals)
964 this->GetImpl()->SetAddMultinormals(toAddMultinormals);
965 SMESH::TPythonDump() << _this() << ".SetAddMultinormals( " << toAddMultinormals << " )";
968 //=======================================================================
969 //function : GetAddMultinormals
970 //=======================================================================
971 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetAddMultinormals()
974 return this->GetImpl()->GetAddMultinormals();
977 //=======================================================================
978 //function : SetSmoothNormals
979 //=======================================================================
980 void HYBRIDPlugin_Hypothesis_i::SetSmoothNormals(CORBA::Boolean toSmoothNormals)
983 this->GetImpl()->SetSmoothNormals(toSmoothNormals);
984 SMESH::TPythonDump() << _this() << ".SetSmoothNormals( " << toSmoothNormals << " )";
987 //=======================================================================
988 //function : GetSmoothNormals
989 //=======================================================================
990 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetSmoothNormals()
993 return this->GetImpl()->GetSmoothNormals();
996 //=======================================================================
997 //function : SetHeightFirstLayer
998 //=======================================================================
999 void HYBRIDPlugin_Hypothesis_i::SetHeightFirstLayer(CORBA::Double toHeightFirstLayer)
1002 this->GetImpl()->SetHeightFirstLayer(toHeightFirstLayer);
1003 SMESH::TPythonDump() << _this() << ".SetHeightFirstLayer( " << toHeightFirstLayer << " )";
1006 //=======================================================================
1007 //function : GetHeightFirstLayer
1008 //=======================================================================
1009 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetHeightFirstLayer()
1012 return this->GetImpl()->GetHeightFirstLayer();
1015 //=======================================================================
1016 //function : SetBoundaryLayersProgression
1017 //=======================================================================
1018 void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersProgression(CORBA::Double toBoundaryLayersProgression)
1021 this->GetImpl()->SetBoundaryLayersProgression(toBoundaryLayersProgression);
1022 SMESH::TPythonDump() << _this() << ".SetBoundaryLayersProgression( " << toBoundaryLayersProgression << " )";
1025 //=======================================================================
1026 //function : GetBoundaryLayersProgression
1027 //=======================================================================
1028 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersProgression()
1031 return this->GetImpl()->GetBoundaryLayersProgression();
1034 //=======================================================================
1035 //function : SetCoreSize
1036 //=======================================================================
1037 void HYBRIDPlugin_Hypothesis_i::SetCoreSize(CORBA::Double toCoreSize)
1040 this->GetImpl()->SetCoreSize(toCoreSize);
1041 SMESH::TPythonDump() << _this() << ".SetCoreSize( " << toCoreSize << " )";
1044 //=======================================================================
1045 //function : GetCoreSize
1046 //=======================================================================
1047 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetCoreSize()
1050 return this->GetImpl()->GetCoreSize();
1053 //=======================================================================
1054 //function : SetMultinormalsAngle
1055 //=======================================================================
1056 void HYBRIDPlugin_Hypothesis_i::SetMultinormalsAngle(CORBA::Double toMultinormalsAngle)
1059 this->GetImpl()->SetMultinormalsAngle(toMultinormalsAngle);
1060 SMESH::TPythonDump() << _this() << ".SetMultinormalsAngle( " << toMultinormalsAngle << " )";
1063 //=======================================================================
1064 //function : GetMultinormalsAngle
1065 //=======================================================================
1066 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetMultinormalsAngle()
1069 return this->GetImpl()->GetMultinormalsAngle();
1072 //=======================================================================
1073 //function : SetNbOfBoundaryLayers
1074 //=======================================================================
1075 void HYBRIDPlugin_Hypothesis_i::SetNbOfBoundaryLayers(CORBA::Short toNbOfBoundaryLayers)
1078 this->GetImpl()->SetNbOfBoundaryLayers(toNbOfBoundaryLayers);
1079 SMESH::TPythonDump() << _this() << ".SetNbOfBoundaryLayers( " << toNbOfBoundaryLayers << " )";
1082 //=======================================================================
1083 //function : GetNbOfBoundaryLayers
1084 //=======================================================================
1085 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetNbOfBoundaryLayers()
1088 return this->GetImpl()->GetNbOfBoundaryLayers();
1091 //=======================================================================
1092 //function : SetEnforcedVertex
1093 //=======================================================================
1095 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
1096 throw (SALOME::SALOME_Exception) {
1098 return p_SetEnforcedVertex(size, x, y, z);
1101 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
1102 throw (SALOME::SALOME_Exception) {
1104 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
1107 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
1108 throw (SALOME::SALOME_Exception) {
1110 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
1113 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
1114 throw (SALOME::SALOME_Exception) {
1116 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
1119 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
1120 throw (SALOME::SALOME_Exception) {
1123 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1124 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1127 std::string theVertexEntry = theVertex->GetStudyEntry();
1128 CORBA::Double x = 0, y = 0, z = 0;
1129 CORBA::Boolean isCompound = false;
1130 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1131 if (theVertexEntry.empty()) {
1133 if (theVertex->GetShapeType() == GEOM::VERTEX) {
1136 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
1137 aName = "Compound_";
1140 aName += theVertex->GetEntry();
1141 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1142 if (!theSVertex->_is_nil())
1143 theVertexEntry = theSVertex->GetID();
1145 if (theVertexEntry.empty())
1146 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1148 if (theVertex->GetShapeType() == GEOM::VERTEX) {
1149 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
1150 if (CORBA::is_nil(measureOp))
1153 measureOp->PointCoordinates (theVertex, x, y, z);
1156 std::string theVertexName = theVertex->GetName();
1158 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
1161 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
1162 throw (SALOME::SALOME_Exception) {
1165 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1166 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1167 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1170 std::string theVertexEntry = theVertex->GetStudyEntry();
1171 CORBA::Double x = 0, y = 0, z = 0;
1172 CORBA::Boolean isCompound = false;
1173 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1174 if (theVertexEntry.empty()) {
1176 if (theVertex->GetShapeType() == GEOM::VERTEX) {
1179 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
1180 aName = "Compound_";
1183 aName += theVertex->GetEntry();
1184 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1185 if (!theSVertex->_is_nil())
1186 theVertexEntry = theSVertex->GetID();
1188 if (theVertexEntry.empty())
1189 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1191 if (theVertex->GetShapeType() == GEOM::VERTEX) {
1192 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
1193 if (CORBA::is_nil(measureOp))
1196 measureOp->PointCoordinates (theVertex, x, y, z);
1199 std::string theVertexName = theVertex->GetName();
1201 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
1204 bool HYBRIDPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
1205 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
1206 CORBA::Boolean isCompound)
1207 throw (SALOME::SALOME_Exception) {
1209 bool newValue = false;
1211 ::HYBRIDPlugin_Hypothesis::TCoordsHYBRIDEnforcedVertexMap coordsList;
1212 ::HYBRIDPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap enfVertexEntryList;
1213 if (std::string(theVertexEntry).empty()) {
1214 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
1215 std::vector<double> coords;
1216 coords.push_back(x);
1217 coords.push_back(y);
1218 coords.push_back(z);
1219 if (coordsList.find(coords) == coordsList.end()) {
1223 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
1224 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
1225 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
1233 if (std::string(theVertexName).empty()) {
1234 if (std::string(theGroupName).empty())
1235 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
1237 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
1240 if (std::string(theGroupName).empty())
1241 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
1243 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
1248 // if (isCompound || (!isCompound && !std::string(theVertexEntry).empty())) {
1249 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
1250 // ::BLSURFPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
1251 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
1255 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
1256 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
1257 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
1265 if (std::string(theGroupName).empty())
1266 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
1268 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
1273 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
1278 //=======================================================================
1279 //function : GetEnforcedVertex
1280 //=======================================================================
1282 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1283 throw (SALOME::SALOME_Exception)
1287 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
1288 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
1291 catch (const std::invalid_argument& ex) {
1292 SALOME::ExceptionStruct ExDescription;
1293 ExDescription.text = ex.what();
1294 ExDescription.type = SALOME::BAD_PARAM;
1295 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1296 ExDescription.lineNumber = 513;
1297 throw SALOME::SALOME_Exception(ExDescription);
1299 catch (SALOME_Exception& ex) {
1300 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1304 //=======================================================================
1305 //function : GetEnforcedVertex
1306 //=======================================================================
1308 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1309 throw (SALOME::SALOME_Exception)
1313 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1314 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1315 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1318 std::string theVertexEntry = theVertex->GetStudyEntry();
1319 if (theVertexEntry.empty()) {
1320 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1322 if (theVertex->GetShapeType() == GEOM::VERTEX)
1324 if (theVertex->GetShapeType() == GEOM::COMPOUND)
1325 aName = "Compound_";
1326 aName += theVertex->GetEntry();
1327 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1328 if (!theSVertex->_is_nil())
1329 theVertexEntry = theSVertex->GetID();
1331 if (theVertexEntry.empty())
1332 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1334 std::string theVertexName = theVertex->GetName();
1337 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
1338 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
1341 catch (const std::invalid_argument& ex) {
1342 SALOME::ExceptionStruct ExDescription;
1343 ExDescription.text = ex.what();
1344 ExDescription.type = SALOME::BAD_PARAM;
1345 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1346 ExDescription.lineNumber = 538;
1347 throw SALOME::SALOME_Exception(ExDescription);
1349 catch (SALOME_Exception& ex) {
1350 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1354 //=======================================================================
1355 //function : GetEnforcedVertices
1356 //=======================================================================
1358 HYBRIDPlugin::HYBRIDEnforcedVertexList* HYBRIDPlugin_Hypothesis_i::GetEnforcedVertices()
1361 HYBRIDPlugin::HYBRIDEnforcedVertexList_var result = new HYBRIDPlugin::HYBRIDEnforcedVertexList();
1363 const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
1364 result->length( enfVertexList.size() );
1366 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList::const_iterator it = enfVertexList.begin();
1368 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
1369 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* currentVertex = (*it);
1370 HYBRIDPlugin::HYBRIDEnforcedVertex_var enfVertex = new HYBRIDPlugin::HYBRIDEnforcedVertex();
1372 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
1373 // Geom Vertex Entry
1374 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
1376 HYBRIDPlugin::TCoords_var coords = new HYBRIDPlugin::TCoords();
1377 coords->length(currentVertex->coords.size());
1378 for (size_t ind = 0; ind < currentVertex->coords.size(); ind++)
1379 coords[ind] = currentVertex->coords[ind];
1380 enfVertex->coords = coords;
1382 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
1384 enfVertex->size = currentVertex->size;
1386 enfVertex->isCompound = currentVertex->isCompound;
1388 result[i]=enfVertex;
1391 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1393 return result._retn();
1396 //=======================================================================
1397 //function : RemoveEnforcedVertex
1398 //=======================================================================
1400 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1401 throw (SALOME::SALOME_Exception)
1405 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
1406 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
1409 catch (const std::invalid_argument& ex) {
1410 SALOME::ExceptionStruct ExDescription;
1411 ExDescription.text = ex.what();
1412 ExDescription.type = SALOME::BAD_PARAM;
1413 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1414 ExDescription.lineNumber = 625;
1415 throw SALOME::SALOME_Exception(ExDescription);
1417 catch (SALOME_Exception& ex) {
1418 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1422 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1423 throw (SALOME::SALOME_Exception)
1427 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1428 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1429 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1432 std::string theVertexEntry = theVertex->GetStudyEntry();
1433 if (theVertexEntry.empty()) {
1434 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1436 if (theVertex->GetShapeType() == GEOM::VERTEX)
1438 if (theVertex->GetShapeType() == GEOM::COMPOUND)
1439 aName = "Compound_";
1440 aName += theVertex->GetEntry();
1441 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1442 if (!theSVertex->_is_nil())
1443 theVertexEntry = theSVertex->GetID();
1445 if (theVertexEntry.empty())
1446 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1449 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
1450 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
1453 catch (const std::invalid_argument& ex) {
1454 SALOME::ExceptionStruct ExDescription;
1455 ExDescription.text = ex.what();
1456 ExDescription.type = SALOME::BAD_PARAM;
1457 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1458 ExDescription.lineNumber = 648;
1459 throw SALOME::SALOME_Exception(ExDescription);
1461 catch (SALOME_Exception& ex) {
1462 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1466 //=======================================================================
1467 //function : ClearEnforcedVertices
1468 //=======================================================================
1470 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedVertices()
1473 this->GetImpl()->ClearEnforcedVertices();
1474 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
1477 //=======================================================================
1478 //function : ClearEnforcedMeshes
1479 //=======================================================================
1481 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedMeshes()
1484 this->GetImpl()->ClearEnforcedMeshes();
1485 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
1488 //=======================================================================
1489 //function : GetEnforcedMeshes
1490 //=======================================================================
1492 HYBRIDPlugin::HYBRIDEnforcedMeshList* HYBRIDPlugin_Hypothesis_i::GetEnforcedMeshes()
1495 HYBRIDPlugin::HYBRIDEnforcedMeshList_var result = new HYBRIDPlugin::HYBRIDEnforcedMeshList();
1497 const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
1498 result->length( enfMeshList.size() );
1500 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList::const_iterator it = enfMeshList.begin();
1502 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
1503 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMesh* currentMesh = (*it);
1504 HYBRIDPlugin::HYBRIDEnforcedMesh_var enfMesh = new HYBRIDPlugin::HYBRIDEnforcedMesh();
1506 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
1508 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
1510 enfMesh->elementType = currentMesh->elementType;
1512 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
1517 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1519 return result._retn();
1523 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
1525 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
1526 throw (SALOME::SALOME_Exception)
1528 // #if HYBRID_VERSION >= 42
1529 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1531 // SALOME::ExceptionStruct ExDescription;
1532 // ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1533 // ExDescription.type = SALOME::BAD_PARAM;
1534 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1535 // ExDescription.lineNumber = 719;
1536 // throw SALOME::SALOME_Exception(ExDescription);
1541 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
1543 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
1544 throw (SALOME::SALOME_Exception)
1546 // #if HYBRID_VERSION >= 42
1547 return p_SetEnforcedMesh(theSource, theType);
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. The elements will be grouped in theGroupName.
1561 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
1562 throw (SALOME::SALOME_Exception)
1564 // #if HYBRID_VERSION >= 42
1565 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1567 // SALOME::ExceptionStruct ExDescription;
1568 // ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1569 // ExDescription.type = SALOME::BAD_PARAM;
1570 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1571 // ExDescription.lineNumber = 750;
1572 // throw SALOME::SALOME_Exception(ExDescription);
1577 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
1579 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
1580 throw (SALOME::SALOME_Exception)
1582 // #if HYBRID_VERSION >= 42
1583 return p_SetEnforcedMesh(theSource, theType);
1585 // SALOME::ExceptionStruct ExDescription;
1586 // ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1587 // ExDescription.type = SALOME::BAD_PARAM;
1588 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1589 // ExDescription.lineNumber = 750;
1590 // throw SALOME::SALOME_Exception(ExDescription);
1594 bool HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
1595 throw (SALOME::SALOME_Exception)
1599 if (CORBA::is_nil( theSource ))
1601 SALOME::ExceptionStruct ExDescription;
1602 ExDescription.text = "The source mesh CORBA object is NULL";
1603 ExDescription.type = SALOME::BAD_PARAM;
1604 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1605 ExDescription.lineNumber = 840;
1606 throw SALOME::SALOME_Exception(ExDescription);
1619 SMESH::array_of_ElementType_var types = theSource->GetTypes();
1620 if ( types->length() >= 1 && types[types->length()-1] < theType)
1623 // SALOME::ExceptionStruct ExDescription;
1624 // ExDescription.text = "The source mesh has bad type";
1625 // ExDescription.type = SALOME::BAD_PARAM;
1626 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1627 // ExDescription.lineNumber = 840;
1628 // throw SALOME::SALOME_Exception(ExDescription);
1632 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1633 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(theSource);
1635 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1636 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1637 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1639 std::string enfMeshName = theName;
1640 if (enfMeshName.empty())
1641 enfMeshName = SObj->GetName();
1646 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1647 if (theGroupName && theGroupName[0]) {
1648 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1649 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1652 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1653 << theSource << ".GetMesh(), " << theType << " )";
1658 catch (const std::invalid_argument& ex) {
1659 SALOME::ExceptionStruct ExDescription;
1660 ExDescription.text = ex.what();
1661 ExDescription.type = SALOME::BAD_PARAM;
1662 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1663 ExDescription.lineNumber = 840;
1664 throw SALOME::SALOME_Exception(ExDescription);
1666 catch (SALOME_Exception& ex) {
1667 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1670 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1673 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1674 if (theGroupName && theGroupName[0]) {
1675 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1676 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1679 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1680 << theSource << ", " << theType << " )";
1684 catch (const std::invalid_argument& ex) {
1685 SALOME::ExceptionStruct ExDescription;
1686 ExDescription.text = ex.what();
1687 ExDescription.type = SALOME::BAD_PARAM;
1688 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1689 ExDescription.lineNumber = 840;
1690 throw SALOME::SALOME_Exception(ExDescription);
1692 catch (SALOME_Exception& ex) {
1693 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1696 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1699 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1700 if (theGroupName && theGroupName[0]) {
1701 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1702 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1705 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1706 << theSource << ", " << theType << " )";
1710 catch (const std::invalid_argument& ex) {
1711 SALOME::ExceptionStruct ExDescription;
1712 ExDescription.text = ex.what();
1713 ExDescription.type = SALOME::BAD_PARAM;
1714 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1715 ExDescription.lineNumber = 840;
1716 throw SALOME::SALOME_Exception(ExDescription);
1718 catch (SALOME_Exception& ex) {
1719 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1724 //=============================================================================
1726 * Get implementation
1728 //=============================================================================
1730 ::HYBRIDPlugin_Hypothesis* HYBRIDPlugin_Hypothesis_i::GetImpl()
1732 return (::HYBRIDPlugin_Hypothesis*)myBaseImpl;
1735 //================================================================================
1737 * \brief Verify whether hypothesis supports given entity type
1739 //================================================================================
1741 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1743 return type == SMESH::DIM_3D;