1 // Copyright (C) 2004-2024 CEA, EDF
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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 =
267 (::GHS3DPlugin_Hypothesis::ImplementedAlgorithms) algoId;
268 if ( algo != ::GHS3DPlugin_Hypothesis::MGTetra && algo != ::GHS3DPlugin_Hypothesis::MGTetraHPC )
269 THROW_SALOME_CORBA_EXCEPTION( "Invalid algorithm type", SALOME::BAD_PARAM );
272 this->GetImpl()->SetAlgorithm(algo);
273 SMESH::TPythonDump() << _this() << ".SetAlgorithm( " << algoId << " )";
276 //=======================================================================
277 //function : GetAlgorithm
278 //=======================================================================
279 CORBA::Short GHS3DPlugin_Hypothesis_i::GetAlgorithm()
282 return this->GetImpl()->GetAlgorithm();
285 //=======================================================================
286 //function : SetUseNumOfThreads
287 //=======================================================================
288 void GHS3DPlugin_Hypothesis_i::SetUseNumOfThreads(CORBA::Boolean setThread)
291 this->GetImpl()->SetUseNumOfThreads(setThread);
292 SMESH::TPythonDump() << _this() << ".SetUseNumOfThreads( " << setThread << " )";
295 //=======================================================================
296 //function : GetUseNumOfThreads
297 //=======================================================================
298 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetUseNumOfThreads()
301 return this->GetImpl()->GetUseNumOfThreads();
304 //=======================================================================
305 //function : SetNumOfThreads
306 //=======================================================================
307 void GHS3DPlugin_Hypothesis_i::SetNumOfThreads(CORBA::Short numOfThreads)
310 this->GetImpl()->SetNumOfThreads(numOfThreads);
311 SMESH::TPythonDump() << _this() << ".SetNumOfThreads( " << numOfThreads << " )";
314 //=======================================================================
315 //function : GetNumOfThreads
316 //=======================================================================
317 CORBA::Short GHS3DPlugin_Hypothesis_i::GetNumOfThreads()
320 return this->GetImpl()->GetNumOfThreads();
323 //=======================================================================
324 //function : SetNumOfThreads
325 //=======================================================================
326 void GHS3DPlugin_Hypothesis_i::SetPthreadMode(CORBA::Short pThreadMode)
328 ::GHS3DPlugin_Hypothesis::PThreadMode mode =
329 (::GHS3DPlugin_Hypothesis::PThreadMode) pThreadMode;
331 if ( mode < ::GHS3DPlugin_Hypothesis::PThreadNone ||
332 mode > ::GHS3DPlugin_Hypothesis::Safe )
333 THROW_SALOME_CORBA_EXCEPTION( "Invalid pthreadMode type", SALOME::BAD_PARAM );
337 this->GetImpl()->SetPthreadMode(mode);
338 SMESH::TPythonDump() << _this() << ".SetPthreadMode( " << pThreadMode << " )";
341 //=======================================================================
342 //function : GetNumOfThreads
343 //=======================================================================
344 CORBA::Short GHS3DPlugin_Hypothesis_i::GetPthreadMode()
347 return this->GetImpl()->GetPthreadMode();
350 //=======================================================================
351 //function : SetNumOfThreads
352 //=======================================================================
353 void GHS3DPlugin_Hypothesis_i::SetParallelMode(CORBA::Short parallelMode)
355 ::GHS3DPlugin_Hypothesis::ParallelMode mode =
356 (::GHS3DPlugin_Hypothesis::ParallelMode) parallelMode;
358 if ( mode < ::GHS3DPlugin_Hypothesis::ParallelNone ||
359 mode > ::GHS3DPlugin_Hypothesis::ParallelAggressive )
360 THROW_SALOME_CORBA_EXCEPTION( "Invalid parallelMode type", SALOME::BAD_PARAM );
363 this->GetImpl()->SetParallelMode(mode);
364 SMESH::TPythonDump() << _this() << ".SetParallelMode( " << parallelMode << " )";
367 //=======================================================================
368 //function : GetNumOfThreads
369 //=======================================================================
370 CORBA::Short GHS3DPlugin_Hypothesis_i::GetParallelMode()
373 return this->GetImpl()->GetParallelMode();
376 //=======================================================================
377 //function : SetWorkingDirectory
378 //=======================================================================
380 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path)
383 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
386 const char lastChar = *file.rbegin();
388 if ( lastChar != '\\' ) file += '\\';
390 if ( lastChar != '/' ) file += '/';
393 SMESH_Mesh_i::PrepareForWriting (file.c_str());
396 this->GetImpl()->SetWorkingDirectory(path);
397 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
400 //=======================================================================
401 //function : GetWorkingDirectory
402 //=======================================================================
404 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
407 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
410 //=======================================================================
411 //function : SetKeepFiles
412 //=======================================================================
414 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
417 this->GetImpl()->SetKeepFiles(toKeep);
418 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
421 //=======================================================================
422 //function : GetKeepFiles
423 //=======================================================================
425 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
428 return this->GetImpl()->GetKeepFiles();
431 //=======================================================================
432 //function : SetVerboseLevel
433 //=======================================================================
435 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
437 if (level < 0 || level > 10 )
438 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
441 this->GetImpl()->SetVerboseLevel(level);
442 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
445 //=======================================================================
446 //function : GetVerboseLevel
447 //=======================================================================
449 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
452 return this->GetImpl()->GetVerboseLevel();
455 //=======================================================================
456 //function : SetToCreateNewNodes
457 //=======================================================================
459 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
462 this->GetImpl()->SetToCreateNewNodes(toCreate);
463 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
466 //=======================================================================
467 //function : GetToCreateNewNodes
468 //=======================================================================
470 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
473 return this->GetImpl()->GetToCreateNewNodes();
476 //=======================================================================
477 //function : SetToUseBoundaryRecoveryVersion
478 //=======================================================================
480 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
483 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
484 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
487 //=======================================================================
488 //function : GetToUseBoundaryRecoveryVersion
489 //=======================================================================
491 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
494 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
497 //=======================================================================
498 //function : SetFEMCorrection
499 //=======================================================================
501 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
504 this->GetImpl()->SetFEMCorrection(toUseFem);
505 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
508 //=======================================================================
509 //function : GetFEMCorrection
510 //=======================================================================
512 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
515 return this->GetImpl()->GetFEMCorrection();
518 //=======================================================================
519 //function : SetToRemoveCentralPoint
520 //=======================================================================
522 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
525 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
526 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
529 //=======================================================================
530 //function : GetToRemoveCentralPoint
531 //=======================================================================
533 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
536 return this->GetImpl()->GetToRemoveCentralPoint();
539 //=======================================================================
540 //function : SetTextOption
541 //=======================================================================
543 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
545 SetAdvancedOption(option);
548 //=======================================================================
549 //function : GetTextOption
550 //=======================================================================
552 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
554 return GetAdvancedOption();
557 //=======================================================================
558 //function : SetAdvancedOption
559 //=======================================================================
561 // void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* option)
563 // ASSERT(myBaseImpl);
564 // this->GetImpl()->SetAdvancedOption(option);
565 // SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
568 //=======================================================================
569 //function : GetAdvancedOption
570 //=======================================================================
572 char* GHS3DPlugin_Hypothesis_i::GetAdvancedOption()
575 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
578 //=============================================================================
580 void GHS3DPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue)
584 std::string name( optionName );
585 if ( !optionValue || !optionValue[0] )
586 UnsetOption( optionName );
588 // basic options (visible in Advanced table)
590 else if ( name == "verbose" )
591 SetVerboseLevel((CORBA::Short) GetImpl()->ToInt( optionValue ));
593 else if ( name == "max_memory" )
594 SetMaximumMemory((CORBA::Short) GetImpl()->ToInt( optionValue ));
596 else if ( name == "automatic_memory" )
597 SetInitialMemory((CORBA::Short) GetImpl()->ToInt( optionValue ));
599 else if ( name == "no_initial_central_point" && // optimizer
600 strcmp( GetImpl()->GetName(), ::GHS3DPlugin_Hypothesis::GetHypType() ) != 0 )
602 //if ( strcmp( optionValue, ::GHS3DPlugin_Hypothesis::NoValue() ) == 0 )
603 if ( !optionValue[0] )
604 SetToRemoveCentralPoint( true );
606 SetToRemoveCentralPoint( GetImpl()->ToBool( optionValue ));
608 else if ( name == "no_internal_points" && // optimizer
609 strcmp( GetImpl()->GetName(), ::GHS3DPlugin_Hypothesis::GetHypType() ) != 0)
611 //if ( strcmp( optionValue, ::GHS3DPlugin_Hypothesis::NoValue() ) == 0 )
612 if ( !optionValue[0] )
613 SetToRemoveCentralPoint( true );
615 SetToCreateNewNodes( GetImpl()->ToBool( optionValue ));
617 else if ( name == "min_size" )
618 SetMinSize( GetImpl()->ToDbl( optionValue ));
620 else if ( name == "max_size" )
621 SetMaxSize( GetImpl()->ToDbl( optionValue ));
623 else if ( name == "gradation" )
624 SetGradation( GetImpl()->ToDbl( optionValue ));
626 else if ( name == "volume_proximity_layers" )
627 SetNbVolumeProximityLayers((CORBA::Short) GetImpl()->ToInt( optionValue ));
629 else if ( name == "components" )
630 SetToMeshHoles( strncmp( "all", optionValue, 3 ) == 0 );
632 // advanced options (for backward compatibility)
633 // else if ( name == "create_tag_on_collision" ||
634 // name == "tiny_edge_respect_geometry" )
635 // AddOption( optionName, optionValue );
638 bool valueChanged = true;
640 valueChanged = ( this->GetImpl()->GetOptionValue( name ) != optionValue );
642 catch ( std::invalid_argument& ) {
646 this->GetImpl()->SetOptionValue(optionName, optionValue);
647 SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
650 } catch (const std::invalid_argument& ex) {
651 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
652 } catch (SALOME_Exception& ex) {
653 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
657 //=============================================================================
659 char* GHS3DPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
664 return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName,&isDefault).c_str());
665 } catch (const std::invalid_argument& ex) {
666 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
667 } catch (SALOME_Exception& ex) {
668 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
673 //=============================================================================
675 void GHS3DPlugin_Hypothesis_i::UnsetOption(const char* optionName) {
677 if ( !GetImpl()->GetOptionValue( optionName ).empty() )
679 this->GetImpl()->ClearOption(optionName);
680 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
684 //=============================================================================
686 GHS3DPlugin::string_array* GHS3DPlugin_Hypothesis_i::GetOptionValues()
688 GHS3DPlugin::string_array_var result = new GHS3DPlugin::string_array();
690 const ::GHS3DPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
691 result->length((CORBA::ULong) opts.size());
695 ::GHS3DPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
696 for (; opIt != opts.end(); ++opIt, ++i)
698 string name_value_type = opIt->first;
699 //if (!opIt->second.empty())
701 name_value_type += ":";
702 name_value_type += GetImpl()->GetOptionValue( opIt->first, &isDefault );
703 name_value_type += isDefault ? ":0" : ":1";
705 result[i] = CORBA::string_dup(name_value_type.c_str());
708 return result._retn();
711 //=============================================================================
713 GHS3DPlugin::string_array* GHS3DPlugin_Hypothesis_i::GetAdvancedOptionValues()
715 GHS3DPlugin::string_array_var result = new GHS3DPlugin::string_array();
717 const ::GHS3DPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomOptionValues();
718 result->length((CORBA::ULong) custom_opts.size());
721 ::GHS3DPlugin_Hypothesis::TOptionValues::const_iterator opIt = custom_opts.begin();
722 for (; opIt != custom_opts.end(); ++opIt, ++i) {
723 string name_value_type = opIt->first;
724 if (!opIt->second.empty()) {
725 name_value_type += ":";
726 name_value_type += opIt->second;
727 name_value_type += ":1"; // user defined
729 result[i] = CORBA::string_dup(name_value_type.c_str());
731 return result._retn();
734 //=============================================================================
736 void GHS3DPlugin_Hypothesis_i::SetOptionValues(const GHS3DPlugin::string_array& options)
738 for (CORBA::ULong i = 0; i < options.length(); ++i)
740 string name_value_type = options[i].in();
741 if(name_value_type.empty())
743 size_t colonPos = name_value_type.find(':');
745 if (colonPos == string::npos) // ':' not found
746 name = name_value_type;
748 name = name_value_type.substr(0, colonPos);
749 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
750 string value_type = name_value_type.substr(colonPos + 1);
751 colonPos = value_type.find(':');
752 value = value_type.substr(0, colonPos);
753 if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
754 if ( value_type.substr(colonPos + 1) == "0" ) // is default
758 SetOptionValue(name.c_str(), value.c_str());
762 //=============================================================================
764 void GHS3DPlugin_Hypothesis_i::SetAdvancedOptionValues(const GHS3DPlugin::string_array& options)
766 SMESH::TPythonDump dump;
768 string optionsAndValues;
769 for ( CORBA::ULong i = 0; i < options.length(); ++i) {
770 string name_value_type = options[i].in();
771 if(name_value_type.empty())
773 size_t colonPos = name_value_type.find(':');
775 if (colonPos == string::npos) // ':' not found
776 name = name_value_type;
778 name = name_value_type.substr(0, colonPos);
779 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
780 string value_type = name_value_type.substr(colonPos + 1);
781 colonPos = value_type.find(':');
782 value = value_type.substr(0, colonPos);
785 AddOption(name.c_str(), value.c_str());
787 optionsAndValues += name + " " + value + " ";
790 if ( !optionsAndValues.empty() )
791 dump << _this() << ".SetAdvancedOptions( '" << optionsAndValues.c_str() << "' )";
794 //=============================================================================
796 void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues)
798 if ( !optionsAndValues ) return;
800 SMESH::TPythonDump dump;
802 std::istringstream strm( optionsAndValues );
803 std::istream_iterator<std::string> sIt( strm ), sEnd;
804 for ( int nbPairs = 0; sIt != sEnd; ++nbPairs )
806 std::string option = *sIt;
809 std::string value = *sIt;
811 AddOption( option.c_str(), value.c_str() );
816 THROW_SALOME_CORBA_EXCEPTION( "Uneven number of options and values" ,SALOME::BAD_PARAM );
817 AddOption( option.c_str(), "" );
820 dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )";
823 //=============================================================================
825 void GHS3DPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue)
828 bool valueChanged = ( !this->GetImpl()->HasOptionDefined(optionName) ||
829 this->GetImpl()->GetOptionValue(optionName) != optionValue );
831 this->GetImpl()->SetOptionValue(optionName, optionValue);
832 SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
836 //=============================================================================
838 char* GHS3DPlugin_Hypothesis_i::GetOption(const char* optionName)
841 return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName).c_str());
844 //=======================================================================
845 //function : SetGradation
846 //=======================================================================
848 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
851 if (gradation != GetGradation()) {
852 this->GetImpl()->SetGradation(gradation);
853 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
857 //=======================================================================
858 //function : GetGradation
859 //=======================================================================
861 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
864 return this->GetImpl()->GetGradation();
867 //=======================================================================
868 //function : SetStandardOutputLog
869 //=======================================================================
871 void GHS3DPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
874 this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
875 SMESH::TPythonDump() << _this() << ".SetStandardOutputLog( " << logInStandardOutput << " )";
878 //=======================================================================
879 //function : GetStandardOutputLog
880 //=======================================================================
882 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetStandardOutputLog()
885 return this->GetImpl()->GetStandardOutputLog();
888 //=======================================================================
889 //function : SetRemoveLogOnSuccess
890 //=======================================================================
892 void GHS3DPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
895 this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
896 SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
899 //=======================================================================
900 //function : GetRemoveLogOnSuccess
901 //=======================================================================
903 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
906 return this->GetImpl()->GetRemoveLogOnSuccess();
909 //=======================================================================
910 //function : SetEnforcedVertex
911 //=======================================================================
913 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
916 return p_SetEnforcedVertex(size, x, y, z);
919 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
922 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
925 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
928 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
931 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
934 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
937 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
941 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
942 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
945 string theVertexEntry = theVertex->GetStudyEntry();
946 CORBA::Double x = 0, y = 0, z = 0;
947 CORBA::Boolean isCompound = false;
948 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
949 if (theVertexEntry.empty()) {
951 if (theVertex->GetShapeType() == GEOM::VERTEX) {
954 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
958 aName += theVertex->GetEntry();
959 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
960 if (!theSVertex->_is_nil())
961 theVertexEntry = theSVertex->GetID();
963 if (theVertexEntry.empty())
964 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
966 if (theVertex->GetShapeType() == GEOM::VERTEX) {
967 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
968 if (CORBA::is_nil(measureOp))
971 measureOp->PointCoordinates (theVertex, x, y, z);
974 string theVertexName = theVertex->GetName();
976 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
979 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
983 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
984 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
987 string theVertexEntry = theVertex->GetStudyEntry();
988 CORBA::Double x = 0, y = 0, z = 0;
989 CORBA::Boolean isCompound = false;
990 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
991 if (theVertexEntry.empty()) {
993 if (theVertex->GetShapeType() == GEOM::VERTEX) {
996 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
1000 aName += theVertex->GetEntry();
1001 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1002 if (!theSVertex->_is_nil())
1003 theVertexEntry = theSVertex->GetID();
1005 if (theVertexEntry.empty())
1006 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1008 if (theVertex->GetShapeType() == GEOM::VERTEX) {
1009 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
1010 if (CORBA::is_nil(measureOp))
1013 measureOp->PointCoordinates (theVertex, x, y, z);
1016 string theVertexName = theVertex->GetName();
1018 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
1021 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
1022 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
1023 CORBA::Boolean isCompound)
1026 bool newValue = false;
1028 ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
1029 ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
1030 if (string(theVertexEntry).empty()) {
1031 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
1032 std::vector<double> coords;
1033 coords.push_back(x);
1034 coords.push_back(y);
1035 coords.push_back(z);
1036 if (coordsList.find(coords) == coordsList.end()) {
1040 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
1041 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
1047 if (string(theVertexName).empty()) {
1048 if (string(theGroupName).empty())
1049 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
1051 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
1054 if (string(theGroupName).empty())
1055 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
1057 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
1062 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
1063 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
1067 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
1068 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
1074 if (string(theGroupName).empty())
1075 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
1077 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
1082 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
1087 //=======================================================================
1088 //function : GetEnforcedVertex
1089 //=======================================================================
1091 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1095 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
1096 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
1099 catch (const std::invalid_argument& ex) {
1100 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1102 catch (SALOME_Exception& ex) {
1103 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1107 //=======================================================================
1108 //function : GetEnforcedVertex
1109 //=======================================================================
1111 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1115 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1116 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1119 string theVertexEntry = theVertex->GetStudyEntry();
1120 if (theVertexEntry.empty()) {
1121 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1123 if (theVertex->GetShapeType() == GEOM::VERTEX)
1125 if (theVertex->GetShapeType() == GEOM::COMPOUND)
1126 aName = "Compound_";
1127 aName += theVertex->GetEntry();
1128 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1129 if (!theSVertex->_is_nil())
1130 theVertexEntry = theSVertex->GetID();
1132 if (theVertexEntry.empty())
1133 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1135 string theVertexName = theVertex->GetName();
1138 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
1139 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
1142 catch (const std::invalid_argument& ex) {
1143 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1145 catch (SALOME_Exception& ex) {
1146 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1150 //=======================================================================
1151 //function : GetEnforcedVertices
1152 //=======================================================================
1154 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
1157 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
1159 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
1160 result->length((CORBA::ULong) enfVertexList.size() );
1162 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
1164 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
1165 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
1166 GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
1168 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
1169 // Geom Vertex Entry
1170 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
1172 GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
1173 coords->length((CORBA::ULong) currentVertex->coords.size());
1174 for ( CORBA::ULong ind = 0; ind < currentVertex->coords.size(); ind++)
1175 coords[ind] = currentVertex->coords[ind];
1176 enfVertex->coords = coords;
1178 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
1180 enfVertex->size = currentVertex->size;
1182 enfVertex->isCompound = currentVertex->isCompound;
1184 result[i]=enfVertex;
1187 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1189 return result._retn();
1192 //=======================================================================
1193 //function : RemoveEnforcedVertex
1194 //=======================================================================
1196 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1200 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
1201 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
1204 catch (const std::invalid_argument& ex) {
1205 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1207 catch (SALOME_Exception& ex) {
1208 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1212 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1216 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1217 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1220 string theVertexEntry = theVertex->GetStudyEntry();
1221 if (theVertexEntry.empty()) {
1222 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1224 if (theVertex->GetShapeType() == GEOM::VERTEX)
1226 if (theVertex->GetShapeType() == GEOM::COMPOUND)
1227 aName = "Compound_";
1228 aName += theVertex->GetEntry();
1229 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1230 if (!theSVertex->_is_nil())
1231 theVertexEntry = theSVertex->GetID();
1233 if (theVertexEntry.empty())
1234 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1237 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
1238 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
1241 catch (const std::invalid_argument& ex) {
1242 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1244 catch (SALOME_Exception& ex) {
1245 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1249 //=======================================================================
1250 //function : ClearEnforcedVertices
1251 //=======================================================================
1253 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
1256 this->GetImpl()->ClearEnforcedVertices();
1257 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
1260 //=======================================================================
1261 //function : ClearEnforcedMeshes
1262 //=======================================================================
1264 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
1267 this->GetImpl()->ClearEnforcedMeshes();
1268 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
1271 //=======================================================================
1272 //function : GetEnforcedMeshes
1273 //=======================================================================
1275 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
1278 GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
1280 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
1281 result->length((CORBA::ULong) enfMeshList.size() );
1283 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
1285 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
1286 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
1287 GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
1289 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
1291 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
1293 enfMesh->elementType = currentMesh->elementType;
1295 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
1300 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1302 return result._retn();
1306 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
1308 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
1310 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1314 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
1316 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
1318 return p_SetEnforcedMesh(theSource, theType);
1322 * \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.
1324 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double /*theSize*/, const char* theGroupName)
1326 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1330 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
1332 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double /*theSize*/)
1334 return p_SetEnforcedMesh(theSource, theType);
1337 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource,
1338 SMESH::ElementType theType,
1339 const char* theName,
1340 const char* theGroupName)
1344 if (CORBA::is_nil( theSource ))
1345 THROW_SALOME_CORBA_EXCEPTION( "The source mesh CORBA object is NULL" ,SALOME::BAD_PARAM );
1350 case SMESH::FACE: break;
1354 SMESH::array_of_ElementType_var types = theSource->GetTypes();
1355 if ( types->length() >= 1 && types[types->length()-1] < theType)
1360 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1361 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(theSource);
1363 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1364 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1365 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1367 string enfMeshName = theName;
1368 if (enfMeshName.empty())
1369 enfMeshName = SObj->GetName();
1374 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1375 if (theGroupName && theGroupName[0] ) {
1376 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1377 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1380 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1381 << theSource << ".GetMesh(), " << theType << " )";
1386 catch (const std::invalid_argument& ex) {
1387 SALOME::ExceptionStruct ExDescription;
1388 ExDescription.text = ex.what();
1389 ExDescription.type = SALOME::BAD_PARAM;
1390 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1391 ExDescription.lineNumber = 840;
1392 throw SALOME::SALOME_Exception(ExDescription);
1394 catch (SALOME_Exception& ex) {
1395 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1398 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1401 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1402 if ( theGroupName && theGroupName[0] ) {
1403 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1404 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1407 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1408 << theSource << ", " << theType << " )";
1412 catch (const std::invalid_argument& ex) {
1413 SALOME::ExceptionStruct ExDescription;
1414 ExDescription.text = ex.what();
1415 ExDescription.type = SALOME::BAD_PARAM;
1416 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1417 ExDescription.lineNumber = 840;
1418 throw SALOME::SALOME_Exception(ExDescription);
1420 catch (SALOME_Exception& ex) {
1421 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1424 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1427 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1428 if ( theGroupName && theGroupName[0] ) {
1429 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1430 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1433 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1434 << theSource << ", " << theType << " )";
1438 catch (const std::invalid_argument& ex) {
1439 SALOME::ExceptionStruct ExDescription;
1440 ExDescription.text = ex.what();
1441 ExDescription.type = SALOME::BAD_PARAM;
1442 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1443 ExDescription.lineNumber = 840;
1444 throw SALOME::SALOME_Exception(ExDescription);
1446 catch (SALOME_Exception& ex) {
1447 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1452 //=============================================================================
1454 * Get implementation
1456 //=============================================================================
1458 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1460 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1463 //================================================================================
1465 * \brief Verify whether hypothesis supports given entity type
1467 //================================================================================
1469 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1471 return type == SMESH::DIM_3D;
1475 //================================================================================
1477 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
1479 //================================================================================
1482 GHS3DPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray,
1483 std::vector< int > & /*subIDArray*/ ) const
1485 typedef ::GHS3DPlugin_Hypothesis THyp;
1486 const THyp* h = static_cast< const THyp*>( myBaseImpl );
1489 const THyp::TGHS3DEnforcedVertexList& enfVertexList = h->_GetEnforcedVertices();
1490 THyp::TGHS3DEnforcedVertexList::const_iterator evIt = enfVertexList.begin();
1491 for ( ; evIt != enfVertexList.end(); ++evIt )
1493 const THyp::TGHS3DEnforcedVertex* ev = *evIt;
1494 entryArray.push_back( ev->geomEntry );
1498 const THyp::TGHS3DEnforcedVertexEntryValues&
1499 enfVertexEntrySizeList = h->_GetEnforcedVerticesEntrySize();
1500 THyp::TGHS3DEnforcedVertexEntryValues::const_iterator entry2size;
1501 for ( entry2size = enfVertexEntrySizeList.cbegin();
1502 entry2size != enfVertexEntrySizeList.cend();
1505 entryArray.push_back( entry2size->first );
1509 const THyp::TCoordsGHS3DEnforcedVertexMap&
1510 coordsEnfVertexMap = h->_GetEnforcedVerticesByCoords();
1511 THyp::TCoordsGHS3DEnforcedVertexMap::const_iterator size2ev = coordsEnfVertexMap.cbegin();
1512 for ( ; size2ev != coordsEnfVertexMap.cend(); ++size2ev )
1514 const THyp::TGHS3DEnforcedVertex* ev = size2ev->second;
1515 entryArray.push_back( ev->geomEntry );
1519 const THyp::TGeomEntryGHS3DEnforcedVertexMap&
1520 geomEntryEnfVertexMap = h->_GetEnforcedVerticesByEntry();
1521 THyp::TGeomEntryGHS3DEnforcedVertexMap::const_iterator entry2ev;
1522 for ( entry2ev = geomEntryEnfVertexMap.cbegin();
1523 entry2ev != geomEntryEnfVertexMap.cend();
1526 entryArray.push_back( entry2ev->first );
1528 const THyp::TGHS3DEnforcedVertex* ev = entry2ev->second;
1529 entryArray.push_back( ev->geomEntry );
1533 return entryArray.size() > 0;
1536 //================================================================================
1538 * \brief Set new geometry instead of that returned by getObjectsDependOn()
1540 //================================================================================
1543 GHS3DPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray,
1544 std::vector< int > & /*subIDArray*/ )
1546 typedef ::GHS3DPlugin_Hypothesis THyp;
1547 THyp* h = static_cast< THyp*>( myBaseImpl );
1551 THyp::TGHS3DEnforcedVertexList& enfVertexList =
1552 const_cast<THyp::TGHS3DEnforcedVertexList& >( h->_GetEnforcedVertices() );
1553 THyp::TGHS3DEnforcedVertexList::iterator evIt = enfVertexList.begin();
1554 for ( ; evIt != enfVertexList.end(); ++evIt )
1556 THyp::TGHS3DEnforcedVertex* ev = *evIt;
1557 ev->geomEntry = entryArray[ iEnt++ ];
1561 THyp::TGHS3DEnforcedVertexEntryValues& enfVertexEntrySizeListNew =
1562 const_cast< THyp::TGHS3DEnforcedVertexEntryValues& > ( h->_GetEnforcedVerticesEntrySize() );
1563 THyp::TGHS3DEnforcedVertexEntryValues enfVertexEntrySizeList;
1564 enfVertexEntrySizeList.swap( enfVertexEntrySizeListNew );
1565 THyp::TGHS3DEnforcedVertexEntryValues::const_iterator entry2size;
1566 for ( entry2size = enfVertexEntrySizeList.cbegin();
1567 entry2size != enfVertexEntrySizeList.cend();
1568 entry2size++, ++iEnt )
1570 if ( entry2size->first.empty() == entryArray[ iEnt ].empty() )
1571 enfVertexEntrySizeListNew[ entryArray[ iEnt ]] = entry2size->second;
1575 THyp::TCoordsGHS3DEnforcedVertexMap& coordsEnfVertexMap =
1576 const_cast< THyp::TCoordsGHS3DEnforcedVertexMap& > ( h->_GetEnforcedVerticesByCoords() );
1577 THyp::TCoordsGHS3DEnforcedVertexMap::iterator size2ev = coordsEnfVertexMap.begin();
1578 for ( ; size2ev != coordsEnfVertexMap.end(); ++size2ev )
1580 THyp::TGHS3DEnforcedVertex* ev = size2ev->second;
1581 ev->geomEntry = entryArray[ iEnt++ ];
1585 THyp::TGeomEntryGHS3DEnforcedVertexMap& geomEntryEnfVertexMapNew =
1586 const_cast< THyp::TGeomEntryGHS3DEnforcedVertexMap& > ( h->_GetEnforcedVerticesByEntry() );
1587 THyp::TGeomEntryGHS3DEnforcedVertexMap geomEntryEnfVertexMap;
1588 geomEntryEnfVertexMap.swap( geomEntryEnfVertexMapNew );
1589 THyp::TGeomEntryGHS3DEnforcedVertexMap::iterator entry2ev;
1590 for ( entry2ev = geomEntryEnfVertexMap.begin();
1591 entry2ev != geomEntryEnfVertexMap.end();
1594 const std::string& entry = entryArray[ iEnt++ ];
1595 THyp::TGHS3DEnforcedVertex* ev = entry2ev->second;
1596 ev->geomEntry = entryArray[ iEnt++ ];
1598 geomEntryEnfVertexMapNew[ entry ] = ev;
1602 return iEnt == entryArray.size();