1 // Copyright (C) 2004-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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 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)
193 throw ( SALOME::SALOME_Exception )
196 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
198 this->GetImpl()->SetMaximumMemory(MB);
199 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
202 //=======================================================================
203 //function : GetMaximumMemory
204 //=======================================================================
206 CORBA::Float GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
209 return this->GetImpl()->GetMaximumMemory();
212 //=======================================================================
213 //function : SetInitialMemory
214 //=======================================================================
216 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Float MB)
217 throw ( SALOME::SALOME_Exception )
220 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
222 this->GetImpl()->SetInitialMemory(MB);
223 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
226 //=======================================================================
227 //function : GetInitialMemory
228 //=======================================================================
230 CORBA::Float GHS3DPlugin_Hypothesis_i::GetInitialMemory()
233 return this->GetImpl()->GetInitialMemory();
236 //=======================================================================
237 //function : SetOptimizationLevel
238 //=======================================================================
240 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
241 throw ( SALOME::SALOME_Exception )
243 ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
244 (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
245 if ( l < ::GHS3DPlugin_Hypothesis::None ||
246 l > ::GHS3DPlugin_Hypothesis::Strong )
247 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
250 this->GetImpl()->SetOptimizationLevel(l);
251 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
254 //=======================================================================
255 //function : GetOptimizationLevel
256 //=======================================================================
258 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
261 return this->GetImpl()->GetOptimizationLevel();
264 //=======================================================================
265 //function : SetWorkingDirectory
266 //=======================================================================
268 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
271 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
274 const char lastChar = *file.rbegin();
276 if ( lastChar != '\\' ) file += '\\';
278 if ( lastChar != '/' ) file += '/';
281 SMESH_Mesh_i::PrepareForWriting (file.c_str());
284 this->GetImpl()->SetWorkingDirectory(path);
285 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
288 //=======================================================================
289 //function : GetWorkingDirectory
290 //=======================================================================
292 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
295 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
298 //=======================================================================
299 //function : SetKeepFiles
300 //=======================================================================
302 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
305 this->GetImpl()->SetKeepFiles(toKeep);
306 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
309 //=======================================================================
310 //function : GetKeepFiles
311 //=======================================================================
313 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
316 return this->GetImpl()->GetKeepFiles();
319 //=======================================================================
320 //function : SetVerboseLevel
321 //=======================================================================
323 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
324 throw ( SALOME::SALOME_Exception )
326 if (level < 0 || level > 10 )
327 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
330 this->GetImpl()->SetVerboseLevel(level);
331 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
334 //=======================================================================
335 //function : GetVerboseLevel
336 //=======================================================================
338 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
341 return this->GetImpl()->GetVerboseLevel();
344 //=======================================================================
345 //function : SetToCreateNewNodes
346 //=======================================================================
348 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
351 this->GetImpl()->SetToCreateNewNodes(toCreate);
352 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
355 //=======================================================================
356 //function : GetToCreateNewNodes
357 //=======================================================================
359 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
362 return this->GetImpl()->GetToCreateNewNodes();
365 //=======================================================================
366 //function : SetToUseBoundaryRecoveryVersion
367 //=======================================================================
369 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
372 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
373 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
376 //=======================================================================
377 //function : GetToUseBoundaryRecoveryVersion
378 //=======================================================================
380 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
383 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
386 //=======================================================================
387 //function : SetFEMCorrection
388 //=======================================================================
390 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
393 this->GetImpl()->SetFEMCorrection(toUseFem);
394 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
397 //=======================================================================
398 //function : GetFEMCorrection
399 //=======================================================================
401 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
404 return this->GetImpl()->GetFEMCorrection();
407 //=======================================================================
408 //function : SetToRemoveCentralPoint
409 //=======================================================================
411 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
414 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
415 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
418 //=======================================================================
419 //function : GetToRemoveCentralPoint
420 //=======================================================================
422 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
425 return this->GetImpl()->GetToRemoveCentralPoint();
428 //=======================================================================
429 //function : SetTextOption
430 //=======================================================================
432 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
434 SetAdvancedOption(option);
437 //=======================================================================
438 //function : GetTextOption
439 //=======================================================================
441 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
443 return GetAdvancedOption();
446 //=======================================================================
447 //function : SetAdvancedOption
448 //=======================================================================
450 // void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* option)
452 // ASSERT(myBaseImpl);
453 // this->GetImpl()->SetAdvancedOption(option);
454 // SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
457 //=======================================================================
458 //function : GetAdvancedOption
459 //=======================================================================
461 char* GHS3DPlugin_Hypothesis_i::GetAdvancedOption()
464 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
467 //=============================================================================
469 void GHS3DPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue)
470 throw (SALOME::SALOME_Exception)
474 std::string name( optionName );
475 if ( !optionValue || !optionValue[0] )
476 UnsetOption( optionName );
478 // basic options (visible in Advanced table)
480 else if ( name == "verbose" )
481 SetVerboseLevel( GetImpl()->ToInt( optionValue ));
483 else if ( name == "max_memory" )
484 SetMaximumMemory( GetImpl()->ToInt( optionValue ));
486 else if ( name == "automatic_memory" )
487 SetInitialMemory( GetImpl()->ToInt( optionValue ));
489 else if ( name == "no_initial_central_point" && // optimizer
490 strcmp( GetImpl()->GetName(), ::GHS3DPlugin_Hypothesis::GetHypType() ) != 0 )
492 //if ( strcmp( optionValue, ::GHS3DPlugin_Hypothesis::NoValue() ) == 0 )
493 if ( !optionValue[0] )
494 SetToRemoveCentralPoint( true );
496 SetToRemoveCentralPoint( GetImpl()->ToBool( optionValue ));
498 else if ( name == "no_internal_points" && // optimizer
499 strcmp( GetImpl()->GetName(), ::GHS3DPlugin_Hypothesis::GetHypType() ) != 0)
501 //if ( strcmp( optionValue, ::GHS3DPlugin_Hypothesis::NoValue() ) == 0 )
502 if ( !optionValue[0] )
503 SetToRemoveCentralPoint( true );
505 SetToCreateNewNodes( GetImpl()->ToBool( optionValue ));
507 else if ( name == "min_size" )
508 SetMinSize( GetImpl()->ToDbl( optionValue ));
510 else if ( name == "max_size" )
511 SetMaxSize( GetImpl()->ToDbl( optionValue ));
513 else if ( name == "gradation" )
514 SetGradation( GetImpl()->ToDbl( optionValue ));
516 else if ( name == "volume_proximity_layers" )
517 SetNbVolumeProximityLayers( GetImpl()->ToInt( optionValue ));
519 else if ( name == "components" )
520 SetToMeshHoles( strncmp( "all", optionValue, 3 ) == 0 );
522 // advanced options (for backward compatibility)
523 // else if ( name == "create_tag_on_collision" ||
524 // name == "tiny_edge_respect_geometry" )
525 // AddOption( optionName, optionValue );
528 bool valueChanged = true;
530 valueChanged = ( this->GetImpl()->GetOptionValue( name ) != optionValue );
532 catch ( std::invalid_argument ) {
536 this->GetImpl()->SetOptionValue(optionName, optionValue);
537 SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
540 } catch (const std::invalid_argument& ex) {
541 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
542 } catch (SALOME_Exception& ex) {
543 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
547 //=============================================================================
549 char* GHS3DPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
550 throw (SALOME::SALOME_Exception)
555 return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName,&isDefault).c_str());
556 } catch (const std::invalid_argument& ex) {
557 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
558 } catch (SALOME_Exception& ex) {
559 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
564 //=============================================================================
566 void GHS3DPlugin_Hypothesis_i::UnsetOption(const char* optionName) {
568 if ( !GetImpl()->GetOptionValue( optionName ).empty() )
570 this->GetImpl()->ClearOption(optionName);
571 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
575 //=============================================================================
577 GHS3DPlugin::string_array* GHS3DPlugin_Hypothesis_i::GetOptionValues()
579 GHS3DPlugin::string_array_var result = new GHS3DPlugin::string_array();
581 const ::GHS3DPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
582 result->length(opts.size());
586 ::GHS3DPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
587 for (; opIt != opts.end(); ++opIt, ++i)
589 string name_value_type = opIt->first;
590 //if (!opIt->second.empty())
592 name_value_type += ":";
593 name_value_type += GetImpl()->GetOptionValue( opIt->first, &isDefault );
594 name_value_type += isDefault ? ":0" : ":1";
596 result[i] = CORBA::string_dup(name_value_type.c_str());
599 return result._retn();
602 //=============================================================================
604 GHS3DPlugin::string_array* GHS3DPlugin_Hypothesis_i::GetAdvancedOptionValues()
606 GHS3DPlugin::string_array_var result = new GHS3DPlugin::string_array();
608 const ::GHS3DPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomOptionValues();
609 result->length(custom_opts.size());
612 ::GHS3DPlugin_Hypothesis::TOptionValues::const_iterator opIt = custom_opts.begin();
613 for (; opIt != custom_opts.end(); ++opIt, ++i) {
614 string name_value_type = opIt->first;
615 if (!opIt->second.empty()) {
616 name_value_type += ":";
617 name_value_type += opIt->second;
618 name_value_type += ":1"; // user defined
620 result[i] = CORBA::string_dup(name_value_type.c_str());
622 return result._retn();
625 //=============================================================================
627 void GHS3DPlugin_Hypothesis_i::SetOptionValues(const GHS3DPlugin::string_array& options)
628 throw (SALOME::SALOME_Exception)
630 for (CORBA::ULong i = 0; i < options.length(); ++i)
632 string name_value_type = options[i].in();
633 if(name_value_type.empty())
635 size_t colonPos = name_value_type.find(':');
637 if (colonPos == string::npos) // ':' not found
638 name = name_value_type;
640 name = name_value_type.substr(0, colonPos);
641 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
642 string value_type = name_value_type.substr(colonPos + 1);
643 colonPos = value_type.find(':');
644 value = value_type.substr(0, colonPos);
645 if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
646 if ( value_type.substr(colonPos + 1) == "0" ) // is default
650 SetOptionValue(name.c_str(), value.c_str());
654 //=============================================================================
656 void GHS3DPlugin_Hypothesis_i::SetAdvancedOptionValues(const GHS3DPlugin::string_array& options)
658 SMESH::TPythonDump dump;
660 string optionsAndValues;
661 for ( CORBA::ULong i = 0; i < options.length(); ++i) {
662 string name_value_type = options[i].in();
663 if(name_value_type.empty())
665 size_t colonPos = name_value_type.find(':');
667 if (colonPos == string::npos) // ':' not found
668 name = name_value_type;
670 name = name_value_type.substr(0, colonPos);
671 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
672 string value_type = name_value_type.substr(colonPos + 1);
673 colonPos = value_type.find(':');
674 value = value_type.substr(0, colonPos);
677 AddOption(name.c_str(), value.c_str());
679 optionsAndValues += name + " " + value + " ";
682 if ( !optionsAndValues.empty() )
683 dump << _this() << ".SetAdvancedOptions( '" << optionsAndValues.c_str() << "' )";
686 //=============================================================================
688 void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues)
689 throw (SALOME::SALOME_Exception)
691 if ( !optionsAndValues ) return;
693 SMESH::TPythonDump dump;
695 std::istringstream strm( optionsAndValues );
696 std::istream_iterator<std::string> sIt( strm ), sEnd;
697 for ( int nbPairs = 0; sIt != sEnd; ++nbPairs )
699 std::string option = *sIt;
702 std::string value = *sIt;
704 AddOption( option.c_str(), value.c_str() );
709 THROW_SALOME_CORBA_EXCEPTION( "Uneven number of options and values" ,SALOME::BAD_PARAM );
710 AddOption( option.c_str(), "" );
713 dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )";
716 //=============================================================================
718 void GHS3DPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue)
721 bool valueChanged = ( !this->GetImpl()->HasOptionDefined(optionName) ||
722 this->GetImpl()->GetOptionValue(optionName) != optionValue );
724 this->GetImpl()->SetOptionValue(optionName, optionValue);
725 SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
729 //=============================================================================
731 char* GHS3DPlugin_Hypothesis_i::GetOption(const char* optionName)
734 return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName).c_str());
737 //=======================================================================
738 //function : SetGradation
739 //=======================================================================
741 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
744 if (gradation != GetGradation()) {
745 this->GetImpl()->SetGradation(gradation);
746 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
750 //=======================================================================
751 //function : GetGradation
752 //=======================================================================
754 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
757 return this->GetImpl()->GetGradation();
760 //=======================================================================
761 //function : SetStandardOutputLog
762 //=======================================================================
764 void GHS3DPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
767 this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
768 SMESH::TPythonDump() << _this() << ".SetStandardOutputLog( " << !logInStandardOutput << " )";
771 //=======================================================================
772 //function : GetStandardOutputLog
773 //=======================================================================
775 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetStandardOutputLog()
778 return this->GetImpl()->GetStandardOutputLog();
781 //=======================================================================
782 //function : SetRemoveLogOnSuccess
783 //=======================================================================
785 void GHS3DPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
788 this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
789 SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
792 //=======================================================================
793 //function : GetRemoveLogOnSuccess
794 //=======================================================================
796 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
799 return this->GetImpl()->GetRemoveLogOnSuccess();
802 //=======================================================================
803 //function : SetEnforcedVertex
804 //=======================================================================
806 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
807 throw (SALOME::SALOME_Exception) {
809 return p_SetEnforcedVertex(size, x, y, z);
812 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
813 throw (SALOME::SALOME_Exception) {
815 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
818 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
819 throw (SALOME::SALOME_Exception) {
821 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
824 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
825 throw (SALOME::SALOME_Exception) {
827 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
830 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
831 throw (SALOME::SALOME_Exception) {
834 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
835 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
838 string theVertexEntry = theVertex->GetStudyEntry();
839 CORBA::Double x = 0, y = 0, z = 0;
840 CORBA::Boolean isCompound = false;
841 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
842 if (theVertexEntry.empty()) {
844 if (theVertex->GetShapeType() == GEOM::VERTEX) {
847 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
851 aName += theVertex->GetEntry();
852 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
853 if (!theSVertex->_is_nil())
854 theVertexEntry = theSVertex->GetID();
856 if (theVertexEntry.empty())
857 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
859 if (theVertex->GetShapeType() == GEOM::VERTEX) {
860 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
861 if (CORBA::is_nil(measureOp))
864 measureOp->PointCoordinates (theVertex, x, y, z);
867 string theVertexName = theVertex->GetName();
869 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
872 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
873 throw (SALOME::SALOME_Exception) {
876 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
877 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
880 string theVertexEntry = theVertex->GetStudyEntry();
881 CORBA::Double x = 0, y = 0, z = 0;
882 CORBA::Boolean isCompound = false;
883 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
884 if (theVertexEntry.empty()) {
886 if (theVertex->GetShapeType() == GEOM::VERTEX) {
889 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
893 aName += theVertex->GetEntry();
894 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
895 if (!theSVertex->_is_nil())
896 theVertexEntry = theSVertex->GetID();
898 if (theVertexEntry.empty())
899 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
901 if (theVertex->GetShapeType() == GEOM::VERTEX) {
902 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
903 if (CORBA::is_nil(measureOp))
906 measureOp->PointCoordinates (theVertex, x, y, z);
909 string theVertexName = theVertex->GetName();
911 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
914 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
915 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
916 CORBA::Boolean isCompound)
917 throw (SALOME::SALOME_Exception) {
919 bool newValue = false;
921 ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
922 ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
923 if (string(theVertexEntry).empty()) {
924 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
925 std::vector<double> coords;
929 if (coordsList.find(coords) == coordsList.end()) {
933 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
934 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
940 if (string(theVertexName).empty()) {
941 if (string(theGroupName).empty())
942 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
944 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
947 if (string(theGroupName).empty())
948 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
950 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
955 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
956 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
960 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
961 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
967 if (string(theGroupName).empty())
968 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
970 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
975 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
980 //=======================================================================
981 //function : GetEnforcedVertex
982 //=======================================================================
984 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
985 throw (SALOME::SALOME_Exception)
989 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
990 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
993 catch (const std::invalid_argument& ex) {
994 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
996 catch (SALOME_Exception& ex) {
997 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1001 //=======================================================================
1002 //function : GetEnforcedVertex
1003 //=======================================================================
1005 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1006 throw (SALOME::SALOME_Exception)
1010 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1011 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1014 string theVertexEntry = theVertex->GetStudyEntry();
1015 if (theVertexEntry.empty()) {
1016 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1018 if (theVertex->GetShapeType() == GEOM::VERTEX)
1020 if (theVertex->GetShapeType() == GEOM::COMPOUND)
1021 aName = "Compound_";
1022 aName += theVertex->GetEntry();
1023 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1024 if (!theSVertex->_is_nil())
1025 theVertexEntry = theSVertex->GetID();
1027 if (theVertexEntry.empty())
1028 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1030 string theVertexName = theVertex->GetName();
1033 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
1034 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
1037 catch (const std::invalid_argument& ex) {
1038 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1040 catch (SALOME_Exception& ex) {
1041 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1045 //=======================================================================
1046 //function : GetEnforcedVertices
1047 //=======================================================================
1049 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
1052 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
1054 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
1055 result->length( enfVertexList.size() );
1057 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
1059 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
1060 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
1061 GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
1063 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
1064 // Geom Vertex Entry
1065 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
1067 GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
1068 coords->length(currentVertex->coords.size());
1069 for ( size_t ind = 0; ind < currentVertex->coords.size(); ind++)
1070 coords[ind] = currentVertex->coords[ind];
1071 enfVertex->coords = coords;
1073 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
1075 enfVertex->size = currentVertex->size;
1077 enfVertex->isCompound = currentVertex->isCompound;
1079 result[i]=enfVertex;
1082 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1084 return result._retn();
1087 //=======================================================================
1088 //function : RemoveEnforcedVertex
1089 //=======================================================================
1091 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1092 throw (SALOME::SALOME_Exception)
1096 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
1097 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
1100 catch (const std::invalid_argument& ex) {
1101 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1103 catch (SALOME_Exception& ex) {
1104 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1108 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1109 throw (SALOME::SALOME_Exception)
1113 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1114 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1117 string theVertexEntry = theVertex->GetStudyEntry();
1118 if (theVertexEntry.empty()) {
1119 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1121 if (theVertex->GetShapeType() == GEOM::VERTEX)
1123 if (theVertex->GetShapeType() == GEOM::COMPOUND)
1124 aName = "Compound_";
1125 aName += theVertex->GetEntry();
1126 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1127 if (!theSVertex->_is_nil())
1128 theVertexEntry = theSVertex->GetID();
1130 if (theVertexEntry.empty())
1131 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1134 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
1135 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
1138 catch (const std::invalid_argument& ex) {
1139 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1141 catch (SALOME_Exception& ex) {
1142 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1146 //=======================================================================
1147 //function : ClearEnforcedVertices
1148 //=======================================================================
1150 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
1153 this->GetImpl()->ClearEnforcedVertices();
1154 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
1157 //=======================================================================
1158 //function : ClearEnforcedMeshes
1159 //=======================================================================
1161 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
1164 this->GetImpl()->ClearEnforcedMeshes();
1165 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
1168 //=======================================================================
1169 //function : GetEnforcedMeshes
1170 //=======================================================================
1172 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
1175 GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
1177 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
1178 result->length( enfMeshList.size() );
1180 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
1182 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
1183 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
1184 GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
1186 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
1188 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
1190 enfMesh->elementType = currentMesh->elementType;
1192 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
1197 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1199 return result._retn();
1203 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
1205 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
1206 throw (SALOME::SALOME_Exception)
1208 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1212 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
1214 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
1215 throw (SALOME::SALOME_Exception)
1217 return p_SetEnforcedMesh(theSource, theType);
1221 * \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.
1223 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
1224 throw (SALOME::SALOME_Exception)
1226 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1230 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
1232 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
1233 throw (SALOME::SALOME_Exception)
1235 return p_SetEnforcedMesh(theSource, theType);
1238 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource,
1239 SMESH::ElementType theType,
1240 const char* theName,
1241 const char* theGroupName)
1242 throw (SALOME::SALOME_Exception)
1246 if (CORBA::is_nil( theSource ))
1247 THROW_SALOME_CORBA_EXCEPTION( "The source mesh CORBA object is NULL" ,SALOME::BAD_PARAM );
1252 case SMESH::FACE: break;
1256 SMESH::array_of_ElementType_var types = theSource->GetTypes();
1257 if ( types->length() >= 1 && types[types->length()-1] < theType)
1262 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1263 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(theSource);
1265 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1266 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1267 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1269 string enfMeshName = theName;
1270 if (enfMeshName.empty())
1271 enfMeshName = SObj->GetName();
1276 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1277 if (theGroupName && theGroupName[0] ) {
1278 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1279 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1282 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1283 << theSource << ".GetMesh(), " << theType << " )";
1288 catch (const std::invalid_argument& ex) {
1289 SALOME::ExceptionStruct ExDescription;
1290 ExDescription.text = ex.what();
1291 ExDescription.type = SALOME::BAD_PARAM;
1292 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1293 ExDescription.lineNumber = 840;
1294 throw SALOME::SALOME_Exception(ExDescription);
1296 catch (SALOME_Exception& ex) {
1297 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1300 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1303 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1304 if ( theGroupName && theGroupName[0] ) {
1305 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1306 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1309 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1310 << theSource << ", " << theType << " )";
1314 catch (const std::invalid_argument& ex) {
1315 SALOME::ExceptionStruct ExDescription;
1316 ExDescription.text = ex.what();
1317 ExDescription.type = SALOME::BAD_PARAM;
1318 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1319 ExDescription.lineNumber = 840;
1320 throw SALOME::SALOME_Exception(ExDescription);
1322 catch (SALOME_Exception& ex) {
1323 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1326 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1329 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1330 if ( theGroupName && theGroupName[0] ) {
1331 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1332 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1335 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1336 << theSource << ", " << theType << " )";
1340 catch (const std::invalid_argument& ex) {
1341 SALOME::ExceptionStruct ExDescription;
1342 ExDescription.text = ex.what();
1343 ExDescription.type = SALOME::BAD_PARAM;
1344 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1345 ExDescription.lineNumber = 840;
1346 throw SALOME::SALOME_Exception(ExDescription);
1348 catch (SALOME_Exception& ex) {
1349 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1354 //=============================================================================
1356 * Get implementation
1358 //=============================================================================
1360 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1362 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1365 //================================================================================
1367 * \brief Verify whether hypothesis supports given entity type
1369 //================================================================================
1371 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1373 return type == SMESH::DIM_3D;
1377 //================================================================================
1379 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
1381 //================================================================================
1384 GHS3DPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray,
1385 std::vector< int > & subIDArray ) const
1387 typedef ::GHS3DPlugin_Hypothesis THyp;
1388 const THyp* h = static_cast< const THyp*>( myBaseImpl );
1391 const THyp::TGHS3DEnforcedVertexList& enfVertexList = h->_GetEnforcedVertices();
1392 THyp::TGHS3DEnforcedVertexList::const_iterator evIt = enfVertexList.begin();
1393 for ( ; evIt != enfVertexList.end(); ++evIt )
1395 const THyp::TGHS3DEnforcedVertex* ev = *evIt;
1396 entryArray.push_back( ev->geomEntry );
1400 const THyp::TGHS3DEnforcedVertexEntryValues&
1401 enfVertexEntrySizeList = h->_GetEnforcedVerticesEntrySize();
1402 THyp::TGHS3DEnforcedVertexEntryValues::const_iterator entry2size;
1403 for ( entry2size = enfVertexEntrySizeList.cbegin();
1404 entry2size != enfVertexEntrySizeList.cend();
1407 entryArray.push_back( entry2size->first );
1411 const THyp::TCoordsGHS3DEnforcedVertexMap&
1412 coordsEnfVertexMap = h->_GetEnforcedVerticesByCoords();
1413 THyp::TCoordsGHS3DEnforcedVertexMap::const_iterator size2ev = coordsEnfVertexMap.cbegin();
1414 for ( ; size2ev != coordsEnfVertexMap.cend(); ++size2ev )
1416 const THyp::TGHS3DEnforcedVertex* ev = size2ev->second;
1417 entryArray.push_back( ev->geomEntry );
1421 const THyp::TGeomEntryGHS3DEnforcedVertexMap&
1422 geomEntryEnfVertexMap = h->_GetEnforcedVerticesByEntry();
1423 THyp::TGeomEntryGHS3DEnforcedVertexMap::const_iterator entry2ev;
1424 for ( entry2ev = geomEntryEnfVertexMap.cbegin();
1425 entry2ev != geomEntryEnfVertexMap.cend();
1428 entryArray.push_back( entry2ev->first );
1430 const THyp::TGHS3DEnforcedVertex* ev = entry2ev->second;
1431 entryArray.push_back( ev->geomEntry );
1435 return entryArray.size() > 0;
1438 //================================================================================
1440 * \brief Set new geometry instead of that returned by getObjectsDependOn()
1442 //================================================================================
1445 GHS3DPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray,
1446 std::vector< int > & subIDArray )
1448 typedef ::GHS3DPlugin_Hypothesis THyp;
1449 THyp* h = static_cast< THyp*>( myBaseImpl );
1453 THyp::TGHS3DEnforcedVertexList& enfVertexList =
1454 const_cast<THyp::TGHS3DEnforcedVertexList& >( h->_GetEnforcedVertices() );
1455 THyp::TGHS3DEnforcedVertexList::iterator evIt = enfVertexList.begin();
1456 for ( ; evIt != enfVertexList.end(); ++evIt )
1458 THyp::TGHS3DEnforcedVertex* ev = *evIt;
1459 ev->geomEntry = entryArray[ iEnt++ ];
1463 THyp::TGHS3DEnforcedVertexEntryValues& enfVertexEntrySizeListNew =
1464 const_cast< THyp::TGHS3DEnforcedVertexEntryValues& > ( h->_GetEnforcedVerticesEntrySize() );
1465 THyp::TGHS3DEnforcedVertexEntryValues enfVertexEntrySizeList;
1466 enfVertexEntrySizeList.swap( enfVertexEntrySizeListNew );
1467 THyp::TGHS3DEnforcedVertexEntryValues::const_iterator entry2size;
1468 for ( entry2size = enfVertexEntrySizeList.cbegin();
1469 entry2size != enfVertexEntrySizeList.cend();
1470 entry2size++, ++iEnt )
1472 if ( entry2size->first.empty() == entryArray[ iEnt ].empty() )
1473 enfVertexEntrySizeListNew[ entryArray[ iEnt ]] = entry2size->second;
1477 THyp::TCoordsGHS3DEnforcedVertexMap& coordsEnfVertexMap =
1478 const_cast< THyp::TCoordsGHS3DEnforcedVertexMap& > ( h->_GetEnforcedVerticesByCoords() );
1479 THyp::TCoordsGHS3DEnforcedVertexMap::iterator size2ev = coordsEnfVertexMap.begin();
1480 for ( ; size2ev != coordsEnfVertexMap.end(); ++size2ev )
1482 THyp::TGHS3DEnforcedVertex* ev = size2ev->second;
1483 ev->geomEntry = entryArray[ iEnt++ ];
1487 THyp::TGeomEntryGHS3DEnforcedVertexMap& geomEntryEnfVertexMapNew =
1488 const_cast< THyp::TGeomEntryGHS3DEnforcedVertexMap& > ( h->_GetEnforcedVerticesByEntry() );
1489 THyp::TGeomEntryGHS3DEnforcedVertexMap geomEntryEnfVertexMap;
1490 geomEntryEnfVertexMap.swap( geomEntryEnfVertexMapNew );
1491 THyp::TGeomEntryGHS3DEnforcedVertexMap::iterator entry2ev;
1492 for ( entry2ev = geomEntryEnfVertexMap.begin();
1493 entry2ev != geomEntryEnfVertexMap.end();
1496 const std::string& entry = entryArray[ iEnt++ ];
1497 THyp::TGHS3DEnforcedVertex* ev = entry2ev->second;
1498 ev->geomEntry = entryArray[ iEnt++ ];
1500 geomEntryEnfVertexMapNew[ entry ] = ev;
1504 return iEnt == entryArray.size();