1 // Copyright (C) 2004-2022 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
20 // File : GHS3DPlugin_Hypothesis_i.cxx
21 // Created : Wed Apr 2 13:53:01 2008
22 // Author : Edward AGAPOV (eap)
24 #include "GHS3DPlugin_Hypothesis_i.hxx"
26 #include <SMESH_Gen.hxx>
27 #include <SMESH_PythonDump.hxx>
29 #include <Utils_CorbaException.hxx>
30 #include <utilities.h>
31 #include <SMESH_Mesh_i.hxx>
32 #include <SMESH_Group_i.hxx>
33 #include <SMESH_Gen_i.hxx>
34 #include <SMESHDS_GroupBase.hxx>
39 //=======================================================================
40 //function : GHS3DPlugin_Hypothesis_i
41 //=======================================================================
43 GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
44 ::SMESH_Gen* theGenImpl)
45 : SALOME::GenericObj_i( thePOA ),
46 SMESH_Hypothesis_i( thePOA )
48 myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
52 //=======================================================================
53 //function : ~GHS3DPlugin_Hypothesis_i
54 //=======================================================================
56 GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
60 //=======================================================================
61 //function : SetToMeshHoles
62 //=======================================================================
64 void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
67 this->GetImpl()->SetToMeshHoles(toMesh);
68 SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
71 //=======================================================================
72 //function : GetToMeshHoles
73 //=======================================================================
75 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles()
78 return this->GetImpl()->GetToMeshHoles();
81 //=============================================================================
82 void GHS3DPlugin_Hypothesis_i::SetMinSize(CORBA::Double theMinSize)
84 if ( GetMinSize() != theMinSize ) {
85 this->GetImpl()->SetMinSize( theMinSize );
86 SMESH::TPythonDump() << _this() << ".SetMinSize( " << theMinSize << " )";
90 //=============================================================================
91 CORBA::Double GHS3DPlugin_Hypothesis_i::GetMinSize()
93 return this->GetImpl()->GetMinSize();
96 //=============================================================================
97 CORBA::Double GHS3DPlugin_Hypothesis_i::GetMinSizeDefault()
99 return this->GetImpl()->GetMinSizeDefault();
102 //=============================================================================
103 void GHS3DPlugin_Hypothesis_i::SetMaxSize(CORBA::Double theMaxSize)
105 if ( GetMaxSize() != theMaxSize ) {
106 this->GetImpl()->SetMaxSize( theMaxSize );
107 SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theMaxSize << " )";
111 //=============================================================================
112 CORBA::Double GHS3DPlugin_Hypothesis_i::GetMaxSize()
114 return this->GetImpl()->GetMaxSize();
117 //=============================================================================
118 CORBA::Double GHS3DPlugin_Hypothesis_i::GetMaxSizeDefault()
120 return this->GetImpl()->GetMaxSizeDefault();
123 //=============================================================================
124 void GHS3DPlugin_Hypothesis_i::SetMinMaxSizeDefault( CORBA::Double theMinSize,
125 CORBA::Double theMaxSize )
127 this->GetImpl()->SetMinMaxSizeDefault( theMinSize, theMaxSize );
130 //=============================================================================
132 * Activate/deactivate volume proximity computation
134 void GHS3DPlugin_Hypothesis_i::SetVolumeProximity( CORBA::Boolean toUse )
136 if ( GetVolumeProximity() != toUse )
138 this->GetImpl()->SetUseVolumeProximity( toUse );
139 SMESH::TPythonDump() << _this() << ".SetVolumeProximity( " << toUse << " )";
143 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetVolumeProximity()
145 return this->GetImpl()->GetUseVolumeProximity();
149 //=============================================================================
151 * Set number of surface element layers to be generated due to volume proximity
153 void GHS3DPlugin_Hypothesis_i::SetNbVolumeProximityLayers( CORBA::Short nbLayers )
155 if ( GetNbVolumeProximityLayers() != nbLayers )
157 this->GetImpl()->SetNbVolumeProximityLayers( nbLayers );
158 SMESH::TPythonDump() << _this() << ".SetNbVolumeProximityLayers( " << nbLayers << " )";
162 CORBA::Short GHS3DPlugin_Hypothesis_i::GetNbVolumeProximityLayers()
164 return (CORBA::Short) this->GetImpl()->GetNbVolumeProximityLayers();
167 //=======================================================================
168 //function : SetToMakeGroupsOfDomains
169 //=======================================================================
171 void GHS3DPlugin_Hypothesis_i::SetToMakeGroupsOfDomains(CORBA::Boolean toMakeGroups)
174 this->GetImpl()->SetToMakeGroupsOfDomains(toMakeGroups);
175 SMESH::TPythonDump() << _this() << ".SetToMakeGroupsOfDomains( " << toMakeGroups << " )";
178 //=======================================================================
179 //function : GetToMakeGroupsOfDomains
180 //=======================================================================
182 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
185 return this->GetImpl()->GetToMakeGroupsOfDomains();
188 //=======================================================================
189 //function : SetMaximumMemory
190 //=======================================================================
192 void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Float MB)
195 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
197 this->GetImpl()->SetMaximumMemory(MB);
198 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
201 //=======================================================================
202 //function : GetMaximumMemory
203 //=======================================================================
205 CORBA::Float GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
208 return this->GetImpl()->GetMaximumMemory();
211 //=======================================================================
212 //function : SetInitialMemory
213 //=======================================================================
215 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Float MB)
218 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
220 this->GetImpl()->SetInitialMemory(MB);
221 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
224 //=======================================================================
225 //function : GetInitialMemory
226 //=======================================================================
228 CORBA::Float GHS3DPlugin_Hypothesis_i::GetInitialMemory()
231 return this->GetImpl()->GetInitialMemory();
234 //=======================================================================
235 //function : SetOptimizationLevel
236 //=======================================================================
238 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
240 ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
241 (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
242 if ( l < ::GHS3DPlugin_Hypothesis::None ||
243 l > ::GHS3DPlugin_Hypothesis::Strong )
244 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
247 this->GetImpl()->SetOptimizationLevel(l);
248 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
251 //=======================================================================
252 //function : GetOptimizationLevel
253 //=======================================================================
255 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
258 return this->GetImpl()->GetOptimizationLevel();
261 //=======================================================================
262 //function : SetAlgorithm
263 //=======================================================================
264 void GHS3DPlugin_Hypothesis_i::SetAlgorithm(CORBA::Short algoId)
266 ::GHS3DPlugin_Hypothesis::ImplementedAlgorithms algo = (::GHS3DPlugin_Hypothesis::ImplementedAlgorithms) algoId;
268 this->GetImpl()->SetAlgorithm(algo);
269 SMESH::TPythonDump() << _this() << ".SetAlgorithm( " << algoId << " )";
272 //=======================================================================
273 //function : GetAlgorithm
274 //=======================================================================
275 CORBA::Short GHS3DPlugin_Hypothesis_i::GetAlgorithm()
278 return this->GetImpl()->GetAlgorithm();
281 //=======================================================================
282 //function : SetUseNumOfThreads
283 //=======================================================================
284 void GHS3DPlugin_Hypothesis_i::SetUseNumOfThreads(CORBA::Boolean setThread)
287 this->GetImpl()->SetUseNumOfThreads(setThread);
288 SMESH::TPythonDump() << _this() << ".SetUseNumOfThreads( " << setThread << " )";
291 //=======================================================================
292 //function : GetUseNumOfThreads
293 //=======================================================================
294 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetUseNumOfThreads()
297 return this->GetImpl()->GetUseNumOfThreads();
300 //=======================================================================
301 //function : SetNumOfThreads
302 //=======================================================================
303 void GHS3DPlugin_Hypothesis_i::SetNumOfThreads(CORBA::Short numOfThreads)
306 this->GetImpl()->SetNumOfThreads(numOfThreads);
307 SMESH::TPythonDump() << _this() << ".SetNumOfThreads( " << numOfThreads << " )";
310 //=======================================================================
311 //function : GetNumOfThreads
312 //=======================================================================
313 CORBA::Short GHS3DPlugin_Hypothesis_i::GetNumOfThreads()
316 return this->GetImpl()->GetNumOfThreads();
319 //=======================================================================
320 //function : SetNumOfThreads
321 //=======================================================================
322 void GHS3DPlugin_Hypothesis_i::SetPthreadMode(CORBA::Short pThreadMode)
324 ::GHS3DPlugin_Hypothesis::PThreadMode mode = (::GHS3DPlugin_Hypothesis::PThreadMode) pThreadMode;
326 this->GetImpl()->SetPthreadMode(mode);
327 SMESH::TPythonDump() << _this() << ".SetPthreadMode( " << pThreadMode << " )";
330 //=======================================================================
331 //function : GetNumOfThreads
332 //=======================================================================
333 CORBA::Short GHS3DPlugin_Hypothesis_i::GetPthreadMode()
336 return this->GetImpl()->GetPthreadMode();
339 //=======================================================================
340 //function : SetNumOfThreads
341 //=======================================================================
342 void GHS3DPlugin_Hypothesis_i::SetParallelMode(CORBA::Short parallelMode)
344 ::GHS3DPlugin_Hypothesis::ParallelMode mode = (::GHS3DPlugin_Hypothesis::ParallelMode) parallelMode;
346 this->GetImpl()->SetParallelMode(mode);
347 SMESH::TPythonDump() << _this() << ".SetParallelMode( " << parallelMode << " )";
350 //=======================================================================
351 //function : GetNumOfThreads
352 //=======================================================================
353 CORBA::Short GHS3DPlugin_Hypothesis_i::GetParallelMode()
356 return this->GetImpl()->GetParallelMode();
359 //=======================================================================
360 //function : SetWorkingDirectory
361 //=======================================================================
363 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path)
366 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
369 const char lastChar = *file.rbegin();
371 if ( lastChar != '\\' ) file += '\\';
373 if ( lastChar != '/' ) file += '/';
376 SMESH_Mesh_i::PrepareForWriting (file.c_str());
379 this->GetImpl()->SetWorkingDirectory(path);
380 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
383 //=======================================================================
384 //function : GetWorkingDirectory
385 //=======================================================================
387 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
390 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
393 //=======================================================================
394 //function : SetKeepFiles
395 //=======================================================================
397 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
400 this->GetImpl()->SetKeepFiles(toKeep);
401 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
404 //=======================================================================
405 //function : GetKeepFiles
406 //=======================================================================
408 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
411 return this->GetImpl()->GetKeepFiles();
414 //=======================================================================
415 //function : SetVerboseLevel
416 //=======================================================================
418 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
420 if (level < 0 || level > 10 )
421 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
424 this->GetImpl()->SetVerboseLevel(level);
425 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
428 //=======================================================================
429 //function : GetVerboseLevel
430 //=======================================================================
432 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
435 return this->GetImpl()->GetVerboseLevel();
438 //=======================================================================
439 //function : SetToCreateNewNodes
440 //=======================================================================
442 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
445 this->GetImpl()->SetToCreateNewNodes(toCreate);
446 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
449 //=======================================================================
450 //function : GetToCreateNewNodes
451 //=======================================================================
453 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
456 return this->GetImpl()->GetToCreateNewNodes();
459 //=======================================================================
460 //function : SetToUseBoundaryRecoveryVersion
461 //=======================================================================
463 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
466 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
467 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
470 //=======================================================================
471 //function : GetToUseBoundaryRecoveryVersion
472 //=======================================================================
474 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
477 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
480 //=======================================================================
481 //function : SetFEMCorrection
482 //=======================================================================
484 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
487 this->GetImpl()->SetFEMCorrection(toUseFem);
488 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
491 //=======================================================================
492 //function : GetFEMCorrection
493 //=======================================================================
495 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
498 return this->GetImpl()->GetFEMCorrection();
501 //=======================================================================
502 //function : SetToRemoveCentralPoint
503 //=======================================================================
505 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
508 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
509 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
512 //=======================================================================
513 //function : GetToRemoveCentralPoint
514 //=======================================================================
516 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
519 return this->GetImpl()->GetToRemoveCentralPoint();
522 //=======================================================================
523 //function : SetTextOption
524 //=======================================================================
526 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
528 SetAdvancedOption(option);
531 //=======================================================================
532 //function : GetTextOption
533 //=======================================================================
535 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
537 return GetAdvancedOption();
540 //=======================================================================
541 //function : SetAdvancedOption
542 //=======================================================================
544 // void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* option)
546 // ASSERT(myBaseImpl);
547 // this->GetImpl()->SetAdvancedOption(option);
548 // SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
551 //=======================================================================
552 //function : GetAdvancedOption
553 //=======================================================================
555 char* GHS3DPlugin_Hypothesis_i::GetAdvancedOption()
558 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
561 //=============================================================================
563 void GHS3DPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue)
567 std::string name( optionName );
568 if ( !optionValue || !optionValue[0] )
569 UnsetOption( optionName );
571 // basic options (visible in Advanced table)
573 else if ( name == "verbose" )
574 SetVerboseLevel((CORBA::Short) GetImpl()->ToInt( optionValue ));
576 else if ( name == "max_memory" )
577 SetMaximumMemory((CORBA::Short) GetImpl()->ToInt( optionValue ));
579 else if ( name == "automatic_memory" )
580 SetInitialMemory((CORBA::Short) GetImpl()->ToInt( optionValue ));
582 else if ( name == "no_initial_central_point" && // optimizer
583 strcmp( GetImpl()->GetName(), ::GHS3DPlugin_Hypothesis::GetHypType() ) != 0 )
585 //if ( strcmp( optionValue, ::GHS3DPlugin_Hypothesis::NoValue() ) == 0 )
586 if ( !optionValue[0] )
587 SetToRemoveCentralPoint( true );
589 SetToRemoveCentralPoint( GetImpl()->ToBool( optionValue ));
591 else if ( name == "no_internal_points" && // optimizer
592 strcmp( GetImpl()->GetName(), ::GHS3DPlugin_Hypothesis::GetHypType() ) != 0)
594 //if ( strcmp( optionValue, ::GHS3DPlugin_Hypothesis::NoValue() ) == 0 )
595 if ( !optionValue[0] )
596 SetToRemoveCentralPoint( true );
598 SetToCreateNewNodes( GetImpl()->ToBool( optionValue ));
600 else if ( name == "min_size" )
601 SetMinSize( GetImpl()->ToDbl( optionValue ));
603 else if ( name == "max_size" )
604 SetMaxSize( GetImpl()->ToDbl( optionValue ));
606 else if ( name == "gradation" )
607 SetGradation( GetImpl()->ToDbl( optionValue ));
609 else if ( name == "volume_proximity_layers" )
610 SetNbVolumeProximityLayers((CORBA::Short) GetImpl()->ToInt( optionValue ));
612 else if ( name == "components" )
613 SetToMeshHoles( strncmp( "all", optionValue, 3 ) == 0 );
615 // advanced options (for backward compatibility)
616 // else if ( name == "create_tag_on_collision" ||
617 // name == "tiny_edge_respect_geometry" )
618 // AddOption( optionName, optionValue );
621 bool valueChanged = true;
623 valueChanged = ( this->GetImpl()->GetOptionValue( name ) != optionValue );
625 catch ( std::invalid_argument& ) {
629 this->GetImpl()->SetOptionValue(optionName, optionValue);
630 SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
633 } catch (const std::invalid_argument& ex) {
634 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
635 } catch (SALOME_Exception& ex) {
636 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
640 //=============================================================================
642 char* GHS3DPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
647 return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName,&isDefault).c_str());
648 } catch (const std::invalid_argument& ex) {
649 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
650 } catch (SALOME_Exception& ex) {
651 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
656 //=============================================================================
658 void GHS3DPlugin_Hypothesis_i::UnsetOption(const char* optionName) {
660 if ( !GetImpl()->GetOptionValue( optionName ).empty() )
662 this->GetImpl()->ClearOption(optionName);
663 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
667 //=============================================================================
669 GHS3DPlugin::string_array* GHS3DPlugin_Hypothesis_i::GetOptionValues()
671 GHS3DPlugin::string_array_var result = new GHS3DPlugin::string_array();
673 const ::GHS3DPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
674 result->length((CORBA::ULong) opts.size());
678 ::GHS3DPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
679 for (; opIt != opts.end(); ++opIt, ++i)
681 string name_value_type = opIt->first;
682 //if (!opIt->second.empty())
684 name_value_type += ":";
685 name_value_type += GetImpl()->GetOptionValue( opIt->first, &isDefault );
686 name_value_type += isDefault ? ":0" : ":1";
688 result[i] = CORBA::string_dup(name_value_type.c_str());
691 return result._retn();
694 //=============================================================================
696 GHS3DPlugin::string_array* GHS3DPlugin_Hypothesis_i::GetAdvancedOptionValues()
698 GHS3DPlugin::string_array_var result = new GHS3DPlugin::string_array();
700 const ::GHS3DPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomOptionValues();
701 result->length((CORBA::ULong) custom_opts.size());
704 ::GHS3DPlugin_Hypothesis::TOptionValues::const_iterator opIt = custom_opts.begin();
705 for (; opIt != custom_opts.end(); ++opIt, ++i) {
706 string name_value_type = opIt->first;
707 if (!opIt->second.empty()) {
708 name_value_type += ":";
709 name_value_type += opIt->second;
710 name_value_type += ":1"; // user defined
712 result[i] = CORBA::string_dup(name_value_type.c_str());
714 return result._retn();
717 //=============================================================================
719 void GHS3DPlugin_Hypothesis_i::SetOptionValues(const GHS3DPlugin::string_array& options)
721 for (CORBA::ULong i = 0; i < options.length(); ++i)
723 string name_value_type = options[i].in();
724 if(name_value_type.empty())
726 size_t colonPos = name_value_type.find(':');
728 if (colonPos == string::npos) // ':' not found
729 name = name_value_type;
731 name = name_value_type.substr(0, colonPos);
732 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
733 string value_type = name_value_type.substr(colonPos + 1);
734 colonPos = value_type.find(':');
735 value = value_type.substr(0, colonPos);
736 if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
737 if ( value_type.substr(colonPos + 1) == "0" ) // is default
741 SetOptionValue(name.c_str(), value.c_str());
745 //=============================================================================
747 void GHS3DPlugin_Hypothesis_i::SetAdvancedOptionValues(const GHS3DPlugin::string_array& options)
749 SMESH::TPythonDump dump;
751 string optionsAndValues;
752 for ( CORBA::ULong i = 0; i < options.length(); ++i) {
753 string name_value_type = options[i].in();
754 if(name_value_type.empty())
756 size_t colonPos = name_value_type.find(':');
758 if (colonPos == string::npos) // ':' not found
759 name = name_value_type;
761 name = name_value_type.substr(0, colonPos);
762 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
763 string value_type = name_value_type.substr(colonPos + 1);
764 colonPos = value_type.find(':');
765 value = value_type.substr(0, colonPos);
768 AddOption(name.c_str(), value.c_str());
770 optionsAndValues += name + " " + value + " ";
773 if ( !optionsAndValues.empty() )
774 dump << _this() << ".SetAdvancedOptions( '" << optionsAndValues.c_str() << "' )";
777 //=============================================================================
779 void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues)
781 if ( !optionsAndValues ) return;
783 SMESH::TPythonDump dump;
785 std::istringstream strm( optionsAndValues );
786 std::istream_iterator<std::string> sIt( strm ), sEnd;
787 for ( int nbPairs = 0; sIt != sEnd; ++nbPairs )
789 std::string option = *sIt;
792 std::string value = *sIt;
794 AddOption( option.c_str(), value.c_str() );
799 THROW_SALOME_CORBA_EXCEPTION( "Uneven number of options and values" ,SALOME::BAD_PARAM );
800 AddOption( option.c_str(), "" );
803 dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )";
806 //=============================================================================
808 void GHS3DPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue)
811 bool valueChanged = ( !this->GetImpl()->HasOptionDefined(optionName) ||
812 this->GetImpl()->GetOptionValue(optionName) != optionValue );
814 this->GetImpl()->SetOptionValue(optionName, optionValue);
815 SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
819 //=============================================================================
821 char* GHS3DPlugin_Hypothesis_i::GetOption(const char* optionName)
824 return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName).c_str());
827 //=======================================================================
828 //function : SetGradation
829 //=======================================================================
831 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
834 if (gradation != GetGradation()) {
835 this->GetImpl()->SetGradation(gradation);
836 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
840 //=======================================================================
841 //function : GetGradation
842 //=======================================================================
844 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
847 return this->GetImpl()->GetGradation();
850 //=======================================================================
851 //function : SetStandardOutputLog
852 //=======================================================================
854 void GHS3DPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
857 this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
858 SMESH::TPythonDump() << _this() << ".SetStandardOutputLog( " << logInStandardOutput << " )";
861 //=======================================================================
862 //function : GetStandardOutputLog
863 //=======================================================================
865 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetStandardOutputLog()
868 return this->GetImpl()->GetStandardOutputLog();
871 //=======================================================================
872 //function : SetRemoveLogOnSuccess
873 //=======================================================================
875 void GHS3DPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
878 this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
879 SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
882 //=======================================================================
883 //function : GetRemoveLogOnSuccess
884 //=======================================================================
886 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
889 return this->GetImpl()->GetRemoveLogOnSuccess();
892 //=======================================================================
893 //function : SetEnforcedVertex
894 //=======================================================================
896 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
899 return p_SetEnforcedVertex(size, x, y, z);
902 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
905 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
908 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
911 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
914 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
917 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
920 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
924 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
925 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
928 string theVertexEntry = theVertex->GetStudyEntry();
929 CORBA::Double x = 0, y = 0, z = 0;
930 CORBA::Boolean isCompound = false;
931 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
932 if (theVertexEntry.empty()) {
934 if (theVertex->GetShapeType() == GEOM::VERTEX) {
937 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
941 aName += theVertex->GetEntry();
942 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
943 if (!theSVertex->_is_nil())
944 theVertexEntry = theSVertex->GetID();
946 if (theVertexEntry.empty())
947 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
949 if (theVertex->GetShapeType() == GEOM::VERTEX) {
950 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
951 if (CORBA::is_nil(measureOp))
954 measureOp->PointCoordinates (theVertex, x, y, z);
957 string theVertexName = theVertex->GetName();
959 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
962 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
966 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
967 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
970 string theVertexEntry = theVertex->GetStudyEntry();
971 CORBA::Double x = 0, y = 0, z = 0;
972 CORBA::Boolean isCompound = false;
973 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
974 if (theVertexEntry.empty()) {
976 if (theVertex->GetShapeType() == GEOM::VERTEX) {
979 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
983 aName += theVertex->GetEntry();
984 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
985 if (!theSVertex->_is_nil())
986 theVertexEntry = theSVertex->GetID();
988 if (theVertexEntry.empty())
989 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
991 if (theVertex->GetShapeType() == GEOM::VERTEX) {
992 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
993 if (CORBA::is_nil(measureOp))
996 measureOp->PointCoordinates (theVertex, x, y, z);
999 string theVertexName = theVertex->GetName();
1001 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
1004 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
1005 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
1006 CORBA::Boolean isCompound)
1009 bool newValue = false;
1011 ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
1012 ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
1013 if (string(theVertexEntry).empty()) {
1014 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
1015 std::vector<double> coords;
1016 coords.push_back(x);
1017 coords.push_back(y);
1018 coords.push_back(z);
1019 if (coordsList.find(coords) == coordsList.end()) {
1023 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
1024 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
1030 if (string(theVertexName).empty()) {
1031 if (string(theGroupName).empty())
1032 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
1034 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
1037 if (string(theGroupName).empty())
1038 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
1040 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
1045 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
1046 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
1050 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
1051 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
1057 if (string(theGroupName).empty())
1058 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
1060 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
1065 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
1070 //=======================================================================
1071 //function : GetEnforcedVertex
1072 //=======================================================================
1074 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1078 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
1079 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
1082 catch (const std::invalid_argument& ex) {
1083 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1085 catch (SALOME_Exception& ex) {
1086 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1090 //=======================================================================
1091 //function : GetEnforcedVertex
1092 //=======================================================================
1094 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1098 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1099 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1102 string theVertexEntry = theVertex->GetStudyEntry();
1103 if (theVertexEntry.empty()) {
1104 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1106 if (theVertex->GetShapeType() == GEOM::VERTEX)
1108 if (theVertex->GetShapeType() == GEOM::COMPOUND)
1109 aName = "Compound_";
1110 aName += theVertex->GetEntry();
1111 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1112 if (!theSVertex->_is_nil())
1113 theVertexEntry = theSVertex->GetID();
1115 if (theVertexEntry.empty())
1116 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1118 string theVertexName = theVertex->GetName();
1121 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
1122 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
1125 catch (const std::invalid_argument& ex) {
1126 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1128 catch (SALOME_Exception& ex) {
1129 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1133 //=======================================================================
1134 //function : GetEnforcedVertices
1135 //=======================================================================
1137 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
1140 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
1142 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
1143 result->length((CORBA::ULong) enfVertexList.size() );
1145 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
1147 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
1148 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
1149 GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
1151 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
1152 // Geom Vertex Entry
1153 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
1155 GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
1156 coords->length((CORBA::ULong) currentVertex->coords.size());
1157 for ( CORBA::ULong ind = 0; ind < currentVertex->coords.size(); ind++)
1158 coords[ind] = currentVertex->coords[ind];
1159 enfVertex->coords = coords;
1161 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
1163 enfVertex->size = currentVertex->size;
1165 enfVertex->isCompound = currentVertex->isCompound;
1167 result[i]=enfVertex;
1170 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1172 return result._retn();
1175 //=======================================================================
1176 //function : RemoveEnforcedVertex
1177 //=======================================================================
1179 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1183 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
1184 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
1187 catch (const std::invalid_argument& ex) {
1188 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1190 catch (SALOME_Exception& ex) {
1191 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1195 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1199 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1200 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1203 string theVertexEntry = theVertex->GetStudyEntry();
1204 if (theVertexEntry.empty()) {
1205 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1207 if (theVertex->GetShapeType() == GEOM::VERTEX)
1209 if (theVertex->GetShapeType() == GEOM::COMPOUND)
1210 aName = "Compound_";
1211 aName += theVertex->GetEntry();
1212 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1213 if (!theSVertex->_is_nil())
1214 theVertexEntry = theSVertex->GetID();
1216 if (theVertexEntry.empty())
1217 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1220 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
1221 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
1224 catch (const std::invalid_argument& ex) {
1225 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1227 catch (SALOME_Exception& ex) {
1228 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1232 //=======================================================================
1233 //function : ClearEnforcedVertices
1234 //=======================================================================
1236 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
1239 this->GetImpl()->ClearEnforcedVertices();
1240 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
1243 //=======================================================================
1244 //function : ClearEnforcedMeshes
1245 //=======================================================================
1247 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
1250 this->GetImpl()->ClearEnforcedMeshes();
1251 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
1254 //=======================================================================
1255 //function : GetEnforcedMeshes
1256 //=======================================================================
1258 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
1261 GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
1263 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
1264 result->length((CORBA::ULong) enfMeshList.size() );
1266 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
1268 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
1269 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
1270 GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
1272 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
1274 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
1276 enfMesh->elementType = currentMesh->elementType;
1278 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
1283 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1285 return result._retn();
1289 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
1291 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
1293 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1297 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
1299 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
1301 return p_SetEnforcedMesh(theSource, theType);
1305 * \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.
1307 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double /*theSize*/, const char* theGroupName)
1309 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1313 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
1315 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double /*theSize*/)
1317 return p_SetEnforcedMesh(theSource, theType);
1320 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource,
1321 SMESH::ElementType theType,
1322 const char* theName,
1323 const char* theGroupName)
1327 if (CORBA::is_nil( theSource ))
1328 THROW_SALOME_CORBA_EXCEPTION( "The source mesh CORBA object is NULL" ,SALOME::BAD_PARAM );
1333 case SMESH::FACE: break;
1337 SMESH::array_of_ElementType_var types = theSource->GetTypes();
1338 if ( types->length() >= 1 && types[types->length()-1] < theType)
1343 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1344 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(theSource);
1346 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1347 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1348 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1350 string enfMeshName = theName;
1351 if (enfMeshName.empty())
1352 enfMeshName = SObj->GetName();
1357 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1358 if (theGroupName && theGroupName[0] ) {
1359 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1360 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1363 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1364 << theSource << ".GetMesh(), " << theType << " )";
1369 catch (const std::invalid_argument& ex) {
1370 SALOME::ExceptionStruct ExDescription;
1371 ExDescription.text = ex.what();
1372 ExDescription.type = SALOME::BAD_PARAM;
1373 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1374 ExDescription.lineNumber = 840;
1375 throw SALOME::SALOME_Exception(ExDescription);
1377 catch (SALOME_Exception& ex) {
1378 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1381 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1384 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1385 if ( theGroupName && theGroupName[0] ) {
1386 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1387 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1390 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1391 << theSource << ", " << theType << " )";
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 = "GHS3DPlugin_Hypothesis_i.cxx";
1400 ExDescription.lineNumber = 840;
1401 throw SALOME::SALOME_Exception(ExDescription);
1403 catch (SALOME_Exception& ex) {
1404 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1407 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1410 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1411 if ( theGroupName && theGroupName[0] ) {
1412 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1413 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1416 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1417 << theSource << ", " << theType << " )";
1421 catch (const std::invalid_argument& ex) {
1422 SALOME::ExceptionStruct ExDescription;
1423 ExDescription.text = ex.what();
1424 ExDescription.type = SALOME::BAD_PARAM;
1425 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1426 ExDescription.lineNumber = 840;
1427 throw SALOME::SALOME_Exception(ExDescription);
1429 catch (SALOME_Exception& ex) {
1430 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1435 //=============================================================================
1437 * Get implementation
1439 //=============================================================================
1441 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1443 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1446 //================================================================================
1448 * \brief Verify whether hypothesis supports given entity type
1450 //================================================================================
1452 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1454 return type == SMESH::DIM_3D;
1458 //================================================================================
1460 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
1462 //================================================================================
1465 GHS3DPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray,
1466 std::vector< int > & /*subIDArray*/ ) const
1468 typedef ::GHS3DPlugin_Hypothesis THyp;
1469 const THyp* h = static_cast< const THyp*>( myBaseImpl );
1472 const THyp::TGHS3DEnforcedVertexList& enfVertexList = h->_GetEnforcedVertices();
1473 THyp::TGHS3DEnforcedVertexList::const_iterator evIt = enfVertexList.begin();
1474 for ( ; evIt != enfVertexList.end(); ++evIt )
1476 const THyp::TGHS3DEnforcedVertex* ev = *evIt;
1477 entryArray.push_back( ev->geomEntry );
1481 const THyp::TGHS3DEnforcedVertexEntryValues&
1482 enfVertexEntrySizeList = h->_GetEnforcedVerticesEntrySize();
1483 THyp::TGHS3DEnforcedVertexEntryValues::const_iterator entry2size;
1484 for ( entry2size = enfVertexEntrySizeList.cbegin();
1485 entry2size != enfVertexEntrySizeList.cend();
1488 entryArray.push_back( entry2size->first );
1492 const THyp::TCoordsGHS3DEnforcedVertexMap&
1493 coordsEnfVertexMap = h->_GetEnforcedVerticesByCoords();
1494 THyp::TCoordsGHS3DEnforcedVertexMap::const_iterator size2ev = coordsEnfVertexMap.cbegin();
1495 for ( ; size2ev != coordsEnfVertexMap.cend(); ++size2ev )
1497 const THyp::TGHS3DEnforcedVertex* ev = size2ev->second;
1498 entryArray.push_back( ev->geomEntry );
1502 const THyp::TGeomEntryGHS3DEnforcedVertexMap&
1503 geomEntryEnfVertexMap = h->_GetEnforcedVerticesByEntry();
1504 THyp::TGeomEntryGHS3DEnforcedVertexMap::const_iterator entry2ev;
1505 for ( entry2ev = geomEntryEnfVertexMap.cbegin();
1506 entry2ev != geomEntryEnfVertexMap.cend();
1509 entryArray.push_back( entry2ev->first );
1511 const THyp::TGHS3DEnforcedVertex* ev = entry2ev->second;
1512 entryArray.push_back( ev->geomEntry );
1516 return entryArray.size() > 0;
1519 //================================================================================
1521 * \brief Set new geometry instead of that returned by getObjectsDependOn()
1523 //================================================================================
1526 GHS3DPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray,
1527 std::vector< int > & /*subIDArray*/ )
1529 typedef ::GHS3DPlugin_Hypothesis THyp;
1530 THyp* h = static_cast< THyp*>( myBaseImpl );
1534 THyp::TGHS3DEnforcedVertexList& enfVertexList =
1535 const_cast<THyp::TGHS3DEnforcedVertexList& >( h->_GetEnforcedVertices() );
1536 THyp::TGHS3DEnforcedVertexList::iterator evIt = enfVertexList.begin();
1537 for ( ; evIt != enfVertexList.end(); ++evIt )
1539 THyp::TGHS3DEnforcedVertex* ev = *evIt;
1540 ev->geomEntry = entryArray[ iEnt++ ];
1544 THyp::TGHS3DEnforcedVertexEntryValues& enfVertexEntrySizeListNew =
1545 const_cast< THyp::TGHS3DEnforcedVertexEntryValues& > ( h->_GetEnforcedVerticesEntrySize() );
1546 THyp::TGHS3DEnforcedVertexEntryValues enfVertexEntrySizeList;
1547 enfVertexEntrySizeList.swap( enfVertexEntrySizeListNew );
1548 THyp::TGHS3DEnforcedVertexEntryValues::const_iterator entry2size;
1549 for ( entry2size = enfVertexEntrySizeList.cbegin();
1550 entry2size != enfVertexEntrySizeList.cend();
1551 entry2size++, ++iEnt )
1553 if ( entry2size->first.empty() == entryArray[ iEnt ].empty() )
1554 enfVertexEntrySizeListNew[ entryArray[ iEnt ]] = entry2size->second;
1558 THyp::TCoordsGHS3DEnforcedVertexMap& coordsEnfVertexMap =
1559 const_cast< THyp::TCoordsGHS3DEnforcedVertexMap& > ( h->_GetEnforcedVerticesByCoords() );
1560 THyp::TCoordsGHS3DEnforcedVertexMap::iterator size2ev = coordsEnfVertexMap.begin();
1561 for ( ; size2ev != coordsEnfVertexMap.end(); ++size2ev )
1563 THyp::TGHS3DEnforcedVertex* ev = size2ev->second;
1564 ev->geomEntry = entryArray[ iEnt++ ];
1568 THyp::TGeomEntryGHS3DEnforcedVertexMap& geomEntryEnfVertexMapNew =
1569 const_cast< THyp::TGeomEntryGHS3DEnforcedVertexMap& > ( h->_GetEnforcedVerticesByEntry() );
1570 THyp::TGeomEntryGHS3DEnforcedVertexMap geomEntryEnfVertexMap;
1571 geomEntryEnfVertexMap.swap( geomEntryEnfVertexMapNew );
1572 THyp::TGeomEntryGHS3DEnforcedVertexMap::iterator entry2ev;
1573 for ( entry2ev = geomEntryEnfVertexMap.begin();
1574 entry2ev != geomEntryEnfVertexMap.end();
1577 const std::string& entry = entryArray[ iEnt++ ];
1578 THyp::TGHS3DEnforcedVertex* ev = entry2ev->second;
1579 ev->geomEntry = entryArray[ iEnt++ ];
1581 geomEntryEnfVertexMapNew[ entry ] = ev;
1585 return iEnt == entryArray.size();