X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGHS3DPlugin%2FGHS3DPlugin_Hypothesis_i.cxx;h=b7c78bf64be0f3b984cf8b96fa3ad089704bcb8e;hb=204cc2f125ee558768f785d0f9d7ec26937f8aac;hp=dd3239f6c4f2d6ebb419d53f7e48aa3f60901e4e;hpb=0f34318ba078d93758776d6c9d115d5b3ff58930;p=plugins%2Fghs3dplugin.git diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx index dd3239f..b7c78bf 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2004-2016 CEA/DEN, EDF R&D +// Copyright (C) 2004-2021 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -23,26 +23,16 @@ // #include "GHS3DPlugin_Hypothesis_i.hxx" -#include "SMESH_Gen.hxx" -#include "SMESH_PythonDump.hxx" -//#include "SMESH_Mesh.hxx" -//#include "SMESH_ProxyMesh.hxx" -//#include - -#include "Utils_CorbaException.hxx" -#include "utilities.h" -#include "SMESH_Mesh_i.hxx" -#include "SMESH_Group_i.hxx" -#include "SMESH_Gen_i.hxx" -#include "SMESH_TypeDefs.hxx" -#include "SMESHDS_GroupBase.hxx" - -// SALOME KERNEL includes -#include "SALOMEDSClient.hxx" -#include -// // IDL headers -// #include -// #include CORBA_SERVER_HEADER(SALOMEDS) +#include +#include + +#include +#include +#include +#include +#include +#include + using namespace std; @@ -51,15 +41,12 @@ using namespace std; //======================================================================= GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, - int theStudyId, ::SMESH_Gen* theGenImpl) : SALOME::GenericObj_i( thePOA ), SMESH_Hypothesis_i( thePOA ) { - MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" ); myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(), - theStudyId, - theGenImpl); + theGenImpl); } //======================================================================= @@ -68,7 +55,6 @@ GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr theP GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i() { - MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" ); } //======================================================================= @@ -92,6 +78,92 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles() return this->GetImpl()->GetToMeshHoles(); } +//============================================================================= +void GHS3DPlugin_Hypothesis_i::SetMinSize(CORBA::Double theMinSize) +{ + if ( GetMinSize() != theMinSize ) { + this->GetImpl()->SetMinSize( theMinSize ); + SMESH::TPythonDump() << _this() << ".SetMinSize( " << theMinSize << " )"; + } +} + +//============================================================================= +CORBA::Double GHS3DPlugin_Hypothesis_i::GetMinSize() +{ + return this->GetImpl()->GetMinSize(); +} + +//============================================================================= +CORBA::Double GHS3DPlugin_Hypothesis_i::GetMinSizeDefault() +{ + return this->GetImpl()->GetMinSizeDefault(); +} + +//============================================================================= +void GHS3DPlugin_Hypothesis_i::SetMaxSize(CORBA::Double theMaxSize) +{ + if ( GetMaxSize() != theMaxSize ) { + this->GetImpl()->SetMaxSize( theMaxSize ); + SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theMaxSize << " )"; + } +} + +//============================================================================= +CORBA::Double GHS3DPlugin_Hypothesis_i::GetMaxSize() +{ + return this->GetImpl()->GetMaxSize(); +} + +//============================================================================= +CORBA::Double GHS3DPlugin_Hypothesis_i::GetMaxSizeDefault() +{ + return this->GetImpl()->GetMaxSizeDefault(); +} + +//============================================================================= +void GHS3DPlugin_Hypothesis_i::SetMinMaxSizeDefault( CORBA::Double theMinSize, + CORBA::Double theMaxSize ) +{ + this->GetImpl()->SetMinMaxSizeDefault( theMinSize, theMaxSize ); +} + +//============================================================================= +/*! + * Activate/deactivate volume proximity computation + */ +void GHS3DPlugin_Hypothesis_i::SetVolumeProximity( CORBA::Boolean toUse ) +{ + if ( GetVolumeProximity() != toUse ) + { + this->GetImpl()->SetUseVolumeProximity( toUse ); + SMESH::TPythonDump() << _this() << ".SetVolumeProximity( " << toUse << " )"; + } +} + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetVolumeProximity() +{ + return this->GetImpl()->GetUseVolumeProximity(); +} + + +//============================================================================= +/*! + * Set number of surface element layers to be generated due to volume proximity + */ +void GHS3DPlugin_Hypothesis_i::SetNbVolumeProximityLayers( CORBA::Short nbLayers ) +{ + if ( GetNbVolumeProximityLayers() != nbLayers ) + { + this->GetImpl()->SetNbVolumeProximityLayers( nbLayers ); + SMESH::TPythonDump() << _this() << ".SetNbVolumeProximityLayers( " << nbLayers << " )"; + } +} + +CORBA::Short GHS3DPlugin_Hypothesis_i::GetNbVolumeProximityLayers() +{ + return (CORBA::Short) this->GetImpl()->GetNbVolumeProximityLayers(); +} + //======================================================================= //function : SetToMakeGroupsOfDomains //======================================================================= @@ -117,8 +189,7 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMakeGroupsOfDomains() //function : SetMaximumMemory //======================================================================= -void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB) - throw ( SALOME::SALOME_Exception ) +void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Float MB) { if ( MB == 0 ) THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM ); @@ -131,7 +202,7 @@ void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB) //function : GetMaximumMemory //======================================================================= -CORBA::Long GHS3DPlugin_Hypothesis_i::GetMaximumMemory() +CORBA::Float GHS3DPlugin_Hypothesis_i::GetMaximumMemory() { ASSERT(myBaseImpl); return this->GetImpl()->GetMaximumMemory(); @@ -141,8 +212,7 @@ CORBA::Long GHS3DPlugin_Hypothesis_i::GetMaximumMemory() //function : SetInitialMemory //======================================================================= -void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Long MB) - throw ( SALOME::SALOME_Exception ) +void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Float MB) { if ( MB == 0 ) THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM ); @@ -155,7 +225,7 @@ void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Long MB) //function : GetInitialMemory //======================================================================= -CORBA::Long GHS3DPlugin_Hypothesis_i::GetInitialMemory() +CORBA::Float GHS3DPlugin_Hypothesis_i::GetInitialMemory() { ASSERT(myBaseImpl); return this->GetImpl()->GetInitialMemory(); @@ -166,10 +236,9 @@ CORBA::Long GHS3DPlugin_Hypothesis_i::GetInitialMemory() //======================================================================= void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level) - throw ( SALOME::SALOME_Exception ) { ::GHS3DPlugin_Hypothesis::OptimizationLevel l = - (::GHS3DPlugin_Hypothesis::OptimizationLevel) level; + (::GHS3DPlugin_Hypothesis::OptimizationLevel) level; if ( l < ::GHS3DPlugin_Hypothesis::None || l > ::GHS3DPlugin_Hypothesis::Strong ) THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM ); @@ -193,7 +262,7 @@ CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel() //function : SetWorkingDirectory //======================================================================= -void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception ) +void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) { if (!path ) THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM ); @@ -249,7 +318,6 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles() //======================================================================= void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level) - throw ( SALOME::SALOME_Exception ) { if (level < 0 || level > 10 ) THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]", @@ -359,9 +427,7 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint() void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option) { - ASSERT(myBaseImpl); - this->GetImpl()->SetAdvancedOption(option); - SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )"; + SetAdvancedOption(option); } //======================================================================= @@ -370,20 +436,19 @@ void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option) char* GHS3DPlugin_Hypothesis_i::GetTextOption() { - ASSERT(myBaseImpl); - return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() ); + return GetAdvancedOption(); } //======================================================================= //function : SetAdvancedOption //======================================================================= -void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* option) -{ - ASSERT(myBaseImpl); - this->GetImpl()->SetAdvancedOption(option); - SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )"; -} +// void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* option) +// { +// ASSERT(myBaseImpl); +// this->GetImpl()->SetAdvancedOption(option); +// SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )"; +// } //======================================================================= //function : GetAdvancedOption @@ -395,8 +460,274 @@ char* GHS3DPlugin_Hypothesis_i::GetAdvancedOption() return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() ); } +//============================================================================= + +void GHS3DPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue) +{ + ASSERT(myBaseImpl); + try { + std::string name( optionName ); + if ( !optionValue || !optionValue[0] ) + UnsetOption( optionName ); + + // basic options (visible in Advanced table) + + else if ( name == "verbose" ) + SetVerboseLevel((CORBA::Short) GetImpl()->ToInt( optionValue )); + + else if ( name == "max_memory" ) + SetMaximumMemory((CORBA::Short) GetImpl()->ToInt( optionValue )); + + else if ( name == "automatic_memory" ) + SetInitialMemory((CORBA::Short) GetImpl()->ToInt( optionValue )); + + else if ( name == "no_initial_central_point" && // optimizer + strcmp( GetImpl()->GetName(), ::GHS3DPlugin_Hypothesis::GetHypType() ) != 0 ) + { + //if ( strcmp( optionValue, ::GHS3DPlugin_Hypothesis::NoValue() ) == 0 ) + if ( !optionValue[0] ) + SetToRemoveCentralPoint( true ); + else + SetToRemoveCentralPoint( GetImpl()->ToBool( optionValue )); + } + else if ( name == "no_internal_points" && // optimizer + strcmp( GetImpl()->GetName(), ::GHS3DPlugin_Hypothesis::GetHypType() ) != 0) + { + //if ( strcmp( optionValue, ::GHS3DPlugin_Hypothesis::NoValue() ) == 0 ) + if ( !optionValue[0] ) + SetToRemoveCentralPoint( true ); + else + SetToCreateNewNodes( GetImpl()->ToBool( optionValue )); + } + else if ( name == "min_size" ) + SetMinSize( GetImpl()->ToDbl( optionValue )); + + else if ( name == "max_size" ) + SetMaxSize( GetImpl()->ToDbl( optionValue )); + + else if ( name == "gradation" ) + SetGradation( GetImpl()->ToDbl( optionValue )); + + else if ( name == "volume_proximity_layers" ) + SetNbVolumeProximityLayers((CORBA::Short) GetImpl()->ToInt( optionValue )); + + else if ( name == "components" ) + SetToMeshHoles( strncmp( "all", optionValue, 3 ) == 0 ); + + // advanced options (for backward compatibility) + // else if ( name == "create_tag_on_collision" || + // name == "tiny_edge_respect_geometry" ) + // AddOption( optionName, optionValue ); + + else { + bool valueChanged = true; + try { + valueChanged = ( this->GetImpl()->GetOptionValue( name ) != optionValue ); + } + catch ( std::invalid_argument& ) { + } + if ( valueChanged ) + { + this->GetImpl()->SetOptionValue(optionName, optionValue); + SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )"; + } + } + } catch (const std::invalid_argument& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +//============================================================================= + +char* GHS3DPlugin_Hypothesis_i::GetOptionValue(const char* optionName) +{ + ASSERT(myBaseImpl); + try { + bool isDefault; + return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName,&isDefault).c_str()); + } catch (const std::invalid_argument& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + return 0; +} + +//============================================================================= + +void GHS3DPlugin_Hypothesis_i::UnsetOption(const char* optionName) { + ASSERT(myBaseImpl); + if ( !GetImpl()->GetOptionValue( optionName ).empty() ) + { + this->GetImpl()->ClearOption(optionName); + SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )"; + } +} + +//============================================================================= + +GHS3DPlugin::string_array* GHS3DPlugin_Hypothesis_i::GetOptionValues() +{ + GHS3DPlugin::string_array_var result = new GHS3DPlugin::string_array(); + + const ::GHS3DPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues(); + result->length((CORBA::ULong) opts.size()); + int i=0; + + bool isDefault; + ::GHS3DPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin(); + for (; opIt != opts.end(); ++opIt, ++i) + { + string name_value_type = opIt->first; + //if (!opIt->second.empty()) + { + name_value_type += ":"; + name_value_type += GetImpl()->GetOptionValue( opIt->first, &isDefault ); + name_value_type += isDefault ? ":0" : ":1"; + } + result[i] = CORBA::string_dup(name_value_type.c_str()); + } + + return result._retn(); +} + +//============================================================================= + +GHS3DPlugin::string_array* GHS3DPlugin_Hypothesis_i::GetAdvancedOptionValues() +{ + GHS3DPlugin::string_array_var result = new GHS3DPlugin::string_array(); + + const ::GHS3DPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomOptionValues(); + result->length((CORBA::ULong) custom_opts.size()); + int i=0; + + ::GHS3DPlugin_Hypothesis::TOptionValues::const_iterator opIt = custom_opts.begin(); + for (; opIt != custom_opts.end(); ++opIt, ++i) { + string name_value_type = opIt->first; + if (!opIt->second.empty()) { + name_value_type += ":"; + name_value_type += opIt->second; + name_value_type += ":1"; // user defined + } + result[i] = CORBA::string_dup(name_value_type.c_str()); + } + return result._retn(); +} + +//============================================================================= + +void GHS3DPlugin_Hypothesis_i::SetOptionValues(const GHS3DPlugin::string_array& options) +{ + for (CORBA::ULong i = 0; i < options.length(); ++i) + { + string name_value_type = options[i].in(); + if(name_value_type.empty()) + continue; + size_t colonPos = name_value_type.find(':'); + string name, value; + if (colonPos == string::npos) // ':' not found + name = name_value_type; + else { + name = name_value_type.substr(0, colonPos); + if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') { + string value_type = name_value_type.substr(colonPos + 1); + colonPos = value_type.find(':'); + value = value_type.substr(0, colonPos); + if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ') + if ( value_type.substr(colonPos + 1) == "0" ) // is default + value.clear(); + } + } + SetOptionValue(name.c_str(), value.c_str()); + } +} + +//============================================================================= + +void GHS3DPlugin_Hypothesis_i::SetAdvancedOptionValues(const GHS3DPlugin::string_array& options) +{ + SMESH::TPythonDump dump; + + string optionsAndValues; + for ( CORBA::ULong i = 0; i < options.length(); ++i) { + string name_value_type = options[i].in(); + if(name_value_type.empty()) + continue; + size_t colonPos = name_value_type.find(':'); + string name, value; + if (colonPos == string::npos) // ':' not found + name = name_value_type; + else { + name = name_value_type.substr(0, colonPos); + if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') { + string value_type = name_value_type.substr(colonPos + 1); + colonPos = value_type.find(':'); + value = value_type.substr(0, colonPos); + } + } + AddOption(name.c_str(), value.c_str()); + + optionsAndValues += name + " " + value + " "; + } + + if ( !optionsAndValues.empty() ) + dump << _this() << ".SetAdvancedOptions( '" << optionsAndValues.c_str() << "' )"; +} + +//============================================================================= + +void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues) +{ + if ( !optionsAndValues ) return; + + SMESH::TPythonDump dump; + + std::istringstream strm( optionsAndValues ); + std::istream_iterator sIt( strm ), sEnd; + for ( int nbPairs = 0; sIt != sEnd; ++nbPairs ) + { + std::string option = *sIt; + if ( ++sIt != sEnd ) + { + std::string value = *sIt; + ++sIt; + AddOption( option.c_str(), value.c_str() ); + } + else + { + if ( nbPairs > 0 ) + THROW_SALOME_CORBA_EXCEPTION( "Uneven number of options and values" ,SALOME::BAD_PARAM ); + AddOption( option.c_str(), "" ); + } + } + dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )"; +} + +//============================================================================= + +void GHS3DPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue) +{ + ASSERT(myBaseImpl); + bool valueChanged = ( !this->GetImpl()->HasOptionDefined(optionName) || + this->GetImpl()->GetOptionValue(optionName) != optionValue ); + if (valueChanged) { + this->GetImpl()->SetOptionValue(optionName, optionValue); + SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )"; + } +} + +//============================================================================= + +char* GHS3DPlugin_Hypothesis_i::GetOption(const char* optionName) +{ + ASSERT(myBaseImpl); + return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName).c_str()); +} + //======================================================================= -//function : SetToRemoveCentralPoint +//function : SetGradation //======================================================================= void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation) @@ -409,7 +740,7 @@ void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation) } //======================================================================= -//function : GetToRemoveCentralPoint +//function : GetGradation //======================================================================= CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation() @@ -426,7 +757,7 @@ void GHS3DPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandard { ASSERT(myBaseImpl); this->GetImpl()->SetStandardOutputLog(logInStandardOutput); - SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )"; + SMESH::TPythonDump() << _this() << ".SetStandardOutputLog( " << logInStandardOutput << " )"; } //======================================================================= @@ -465,47 +796,41 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess() //======================================================================= bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size) - throw (SALOME::SALOME_Exception) { +{ ASSERT(myBaseImpl); - MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")"); return p_SetEnforcedVertex(size, x, y, z); } bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName) - throw (SALOME::SALOME_Exception) { +{ ASSERT(myBaseImpl); - MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")"); return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", ""); } bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName) - throw (SALOME::SALOME_Exception) { +{ ASSERT(myBaseImpl); - MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")"); return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName); } bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName) - throw (SALOME::SALOME_Exception) { +{ ASSERT(myBaseImpl); - MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")"); return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName); } bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size) - throw (SALOME::SALOME_Exception) { +{ ASSERT(myBaseImpl); if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { - MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } string theVertexEntry = theVertex->GetStudyEntry(); CORBA::Double x = 0, y = 0, z = 0; CORBA::Boolean isCompound = false; - GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); - SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex ); if (theVertexEntry.empty()) { string aName; if (theVertex->GetShapeType() == GEOM::VERTEX) { @@ -516,7 +841,7 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVe isCompound = true; } aName += theVertex->GetEntry(); - SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str()); if (!theSVertex->_is_nil()) theVertexEntry = theSVertex->GetID(); } @@ -524,34 +849,30 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVe THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); if (theVertex->GetShapeType() == GEOM::VERTEX) { - GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() ); + GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations(); if (CORBA::is_nil(measureOp)) return false; measureOp->PointCoordinates (theVertex, x, y, z); - MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z); } string theVertexName = theVertex->GetName(); - MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")"); return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound); } bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName) - throw (SALOME::SALOME_Exception) { +{ ASSERT(myBaseImpl); if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { - MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } string theVertexEntry = theVertex->GetStudyEntry(); CORBA::Double x = 0, y = 0, z = 0; CORBA::Boolean isCompound = false; - GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); - SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex ); if (theVertexEntry.empty()) { string aName; if (theVertex->GetShapeType() == GEOM::VERTEX) { @@ -562,7 +883,7 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ isCompound = true; } aName += theVertex->GetEntry(); - SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str()); if (!theSVertex->_is_nil()) theVertexEntry = theSVertex->GetID(); } @@ -570,26 +891,23 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); if (theVertex->GetShapeType() == GEOM::VERTEX) { - GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() ); + GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations(); if (CORBA::is_nil(measureOp)) return false; measureOp->PointCoordinates (theVertex, x, y, z); - MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z); } string theVertexName = theVertex->GetName(); - MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")"); return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound); } bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z, - const char* theVertexName, const char* theVertexEntry, const char* theGroupName, - CORBA::Boolean isCompound) - throw (SALOME::SALOME_Exception) { + const char* theVertexName, const char* theVertexEntry, const char* theGroupName, + CORBA::Boolean isCompound) +{ ASSERT(myBaseImpl); - MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")"); bool newValue = false; ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList; @@ -601,20 +919,13 @@ bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::D coords.push_back(y); coords.push_back(z); if (coordsList.find(coords) == coordsList.end()) { - MESSAGE("Coords not found: add it in coordsList"); newValue = true; } else { - MESSAGE("Coords already found, compare names"); ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z); if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) { - MESSAGE("The names or size are different: update"); -// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); newValue = true; } - else { - MESSAGE("The names and size are identical"); - } } if (newValue) { @@ -633,24 +944,15 @@ bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::D } } else { -// if (isCompound || (!isCompound && !string(theVertexEntry).empty())) { enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry(); -// ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry); if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) { - MESSAGE("Geom entry not found: add it in enfVertexEntryList"); newValue = true; } else { - MESSAGE("Geom entry already found, compare names"); ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry); if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) { - MESSAGE("The names or size are different: update"); -// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); newValue = true; } - else { - MESSAGE("The names and size are identical"); - } } if (newValue) { @@ -664,7 +966,6 @@ bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::D if (newValue) this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound); - MESSAGE("IDL : SetEnforcedVertexEntry END"); return newValue; } @@ -673,7 +974,6 @@ bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::D //======================================================================= CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); try { @@ -682,12 +982,7 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA return isDone; } catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; - ExDescription.lineNumber = 513; - throw SALOME::SALOME_Exception(ExDescription); + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); @@ -699,26 +994,23 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA //======================================================================= CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex) - throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { - MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } string theVertexEntry = theVertex->GetStudyEntry(); if (theVertexEntry.empty()) { - GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); - SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex ); string aName; if (theVertex->GetShapeType() == GEOM::VERTEX) aName = "Vertex_"; if (theVertex->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theVertex->GetEntry(); - SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str()); if (!theSVertex->_is_nil()) theVertexEntry = theSVertex->GetID(); } @@ -733,12 +1025,7 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ return isDone; } catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; - ExDescription.lineNumber = 538; - throw SALOME::SALOME_Exception(ExDescription); + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); @@ -755,7 +1042,7 @@ GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVerti GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList(); const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices(); - result->length( enfVertexList.size() ); + result->length((CORBA::ULong) enfVertexList.size() ); ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin(); @@ -768,8 +1055,8 @@ GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVerti enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str()); // Coords GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords(); - coords->length(currentVertex->coords.size()); - for ( size_t ind = 0; ind < currentVertex->coords.size(); ind++) + coords->length((CORBA::ULong) currentVertex->coords.size()); + for ( CORBA::ULong ind = 0; ind < currentVertex->coords.size(); ind++) coords[ind] = currentVertex->coords[ind]; enfVertex->coords = coords; // Group Name @@ -780,9 +1067,9 @@ GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVerti enfVertex->isCompound = currentVertex->isCompound; result[i]=enfVertex; - } + } -// SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()"; + // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()"; return result._retn(); } @@ -792,7 +1079,6 @@ GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVerti //======================================================================= bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); try { @@ -801,12 +1087,7 @@ bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Doub return res; } catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; - ExDescription.lineNumber = 625; - throw SALOME::SALOME_Exception(ExDescription); + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); @@ -814,26 +1095,23 @@ bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Doub } bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex) - throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { - MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } string theVertexEntry = theVertex->GetStudyEntry(); if (theVertexEntry.empty()) { - GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); - SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex ); string aName; if (theVertex->GetShapeType() == GEOM::VERTEX) aName = "Vertex_"; if (theVertex->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theVertex->GetEntry(); - SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str()); if (!theSVertex->_is_nil()) theVertexEntry = theSVertex->GetID(); } @@ -846,12 +1124,7 @@ bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr th return res; } catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; - ExDescription.lineNumber = 648; - throw SALOME::SALOME_Exception(ExDescription); + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); @@ -890,7 +1163,7 @@ GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes( GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList(); const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes(); - result->length( enfMeshList.size() ); + result->length((CORBA::ULong) enfMeshList.size() ); ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin(); @@ -907,9 +1180,9 @@ GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes( enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str()); result[i]=enfMesh; - } + } -// SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()"; + // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()"; return result._retn(); } @@ -918,124 +1191,59 @@ GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes( * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName. */ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName) - throw (SALOME::SALOME_Exception) { -// #if GHS3D_VERSION >= 42 return p_SetEnforcedMesh(theSource, theType, "", theGroupName); -// #else -// SALOME::ExceptionStruct ExDescription; -// ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; -// ExDescription.type = SALOME::BAD_PARAM; -// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; -// ExDescription.lineNumber = 719; -// throw SALOME::SALOME_Exception(ExDescription); -// #endif } /*! * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. */ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType) - throw (SALOME::SALOME_Exception) { -// MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh"); -// #if GHS3D_VERSION >= 42 return p_SetEnforcedMesh(theSource, theType); -// #else -// SALOME::ExceptionStruct ExDescription; -// ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; -// ExDescription.type = SALOME::BAD_PARAM; -// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; -// ExDescription.lineNumber = 750; -// throw SALOME::SALOME_Exception(ExDescription); -// #endif } /*! * \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. */ -bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName) - throw (SALOME::SALOME_Exception) +bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double /*theSize*/, const char* theGroupName) { -// #if GHS3D_VERSION >= 42 return p_SetEnforcedMesh(theSource, theType, "", theGroupName); -// #else -// SALOME::ExceptionStruct ExDescription; -// ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; -// ExDescription.type = SALOME::BAD_PARAM; -// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; -// ExDescription.lineNumber = 750; -// throw SALOME::SALOME_Exception(ExDescription); -// #endif } /*! * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size. */ -bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize) - throw (SALOME::SALOME_Exception) +bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double /*theSize*/) { -// #if GHS3D_VERSION >= 42 return p_SetEnforcedMesh(theSource, theType); -// #else -// SALOME::ExceptionStruct ExDescription; -// ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; -// ExDescription.type = SALOME::BAD_PARAM; -// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; -// ExDescription.lineNumber = 750; -// throw SALOME::SALOME_Exception(ExDescription); -// #endif } -bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName) - throw (SALOME::SALOME_Exception) +bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, + SMESH::ElementType theType, + const char* theName, + const char* theGroupName) { - MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh"); ASSERT(myBaseImpl); - + if (CORBA::is_nil( theSource )) - { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = "The source mesh CORBA object is NULL"; - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; - ExDescription.lineNumber = 840; - throw SALOME::SALOME_Exception(ExDescription); - } - + THROW_SALOME_CORBA_EXCEPTION( "The source mesh CORBA object is NULL" ,SALOME::BAD_PARAM ); + switch (theType) { - case SMESH::NODE: - MESSAGE("Required type is NODE"); - break; - case SMESH::EDGE: - MESSAGE("Required type is EDGE"); - break; - case SMESH::FACE: - MESSAGE("Required type is FACE"); - break; - default: - MESSAGE("Incompatible required type: " << theType); - return false; + case SMESH::NODE: + case SMESH::EDGE: + case SMESH::FACE: break; + default: + return false; } -// MESSAGE("Required type is "<GetTypes(); - MESSAGE("Available types:"); - for ( CORBA::ULong i=0;ilength();i++){MESSAGE(types[i]);} if ( types->length() >= 1 && types[types->length()-1] < theType) { - MESSAGE("Required type not available"); return false; -// SALOME::ExceptionStruct ExDescription; -// ExDescription.text = "The source mesh has bad type"; -// ExDescription.type = SALOME::BAD_PARAM; -// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; -// ExDescription.lineNumber = 840; -// throw SALOME::SALOME_Exception(ExDescription); } - SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); - SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource); + SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(theSource); SMESH_Mesh_i* theMesh_i = SMESH::DownCast( theSource); SMESH_Group_i* theGroup_i = SMESH::DownCast( theSource); @@ -1074,21 +1282,20 @@ bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSo } else if (theGroup_i)// && types->length() == 1 && types[0] == theType) { - MESSAGE("The source is a group") - try { - bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName); - if ( theGroupName && theGroupName[0] ) { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " - << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; - } - else { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " - << theSource << ", " << theType << " )"; - } - return res; + try { + bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName); + if ( theGroupName && theGroupName[0] ) { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " + << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; + } + else { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " + << theSource << ", " << theType << " )"; } - catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; + return res; + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; @@ -1101,17 +1308,16 @@ bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSo } else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType) { - MESSAGE("The source is a group on geom") try { - bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName); - if ( theGroupName && theGroupName[0] ) { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " - << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; - } - else { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " - << theSource << ", " << theType << " )"; - } + bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName); + if ( theGroupName && theGroupName[0] ) { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " + << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; + } + else { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " + << theSource << ", " << theType << " )"; + } return res; } catch (const std::invalid_argument& ex) { @@ -1150,3 +1356,133 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type ) return type == SMESH::DIM_3D; } + +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +GHS3DPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & /*subIDArray*/ ) const +{ + typedef ::GHS3DPlugin_Hypothesis THyp; + const THyp* h = static_cast< const THyp*>( myBaseImpl ); + + { + const THyp::TGHS3DEnforcedVertexList& enfVertexList = h->_GetEnforcedVertices(); + THyp::TGHS3DEnforcedVertexList::const_iterator evIt = enfVertexList.begin(); + for ( ; evIt != enfVertexList.end(); ++evIt ) + { + const THyp::TGHS3DEnforcedVertex* ev = *evIt; + entryArray.push_back( ev->geomEntry ); + } + } + { + const THyp::TGHS3DEnforcedVertexEntryValues& + enfVertexEntrySizeList = h->_GetEnforcedVerticesEntrySize(); + THyp::TGHS3DEnforcedVertexEntryValues::const_iterator entry2size; + for ( entry2size = enfVertexEntrySizeList.cbegin(); + entry2size != enfVertexEntrySizeList.cend(); + entry2size++ ) + { + entryArray.push_back( entry2size->first ); + } + } + { + const THyp::TCoordsGHS3DEnforcedVertexMap& + coordsEnfVertexMap = h->_GetEnforcedVerticesByCoords(); + THyp::TCoordsGHS3DEnforcedVertexMap::const_iterator size2ev = coordsEnfVertexMap.cbegin(); + for ( ; size2ev != coordsEnfVertexMap.cend(); ++size2ev ) + { + const THyp::TGHS3DEnforcedVertex* ev = size2ev->second; + entryArray.push_back( ev->geomEntry ); + } + } + { + const THyp::TGeomEntryGHS3DEnforcedVertexMap& + geomEntryEnfVertexMap = h->_GetEnforcedVerticesByEntry(); + THyp::TGeomEntryGHS3DEnforcedVertexMap::const_iterator entry2ev; + for ( entry2ev = geomEntryEnfVertexMap.cbegin(); + entry2ev != geomEntryEnfVertexMap.cend(); + entry2ev++ ) + { + entryArray.push_back( entry2ev->first ); + + const THyp::TGHS3DEnforcedVertex* ev = entry2ev->second; + entryArray.push_back( ev->geomEntry ); + } + } + + return entryArray.size() > 0; +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +GHS3DPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & /*subIDArray*/ ) +{ + typedef ::GHS3DPlugin_Hypothesis THyp; + THyp* h = static_cast< THyp*>( myBaseImpl ); + + size_t iEnt = 0; + { + THyp::TGHS3DEnforcedVertexList& enfVertexList = + const_cast( h->_GetEnforcedVertices() ); + THyp::TGHS3DEnforcedVertexList::iterator evIt = enfVertexList.begin(); + for ( ; evIt != enfVertexList.end(); ++evIt ) + { + THyp::TGHS3DEnforcedVertex* ev = *evIt; + ev->geomEntry = entryArray[ iEnt++ ]; + } + } + { + THyp::TGHS3DEnforcedVertexEntryValues& enfVertexEntrySizeListNew = + const_cast< THyp::TGHS3DEnforcedVertexEntryValues& > ( h->_GetEnforcedVerticesEntrySize() ); + THyp::TGHS3DEnforcedVertexEntryValues enfVertexEntrySizeList; + enfVertexEntrySizeList.swap( enfVertexEntrySizeListNew ); + THyp::TGHS3DEnforcedVertexEntryValues::const_iterator entry2size; + for ( entry2size = enfVertexEntrySizeList.cbegin(); + entry2size != enfVertexEntrySizeList.cend(); + entry2size++, ++iEnt ) + { + if ( entry2size->first.empty() == entryArray[ iEnt ].empty() ) + enfVertexEntrySizeListNew[ entryArray[ iEnt ]] = entry2size->second; + } + } + { + THyp::TCoordsGHS3DEnforcedVertexMap& coordsEnfVertexMap = + const_cast< THyp::TCoordsGHS3DEnforcedVertexMap& > ( h->_GetEnforcedVerticesByCoords() ); + THyp::TCoordsGHS3DEnforcedVertexMap::iterator size2ev = coordsEnfVertexMap.begin(); + for ( ; size2ev != coordsEnfVertexMap.end(); ++size2ev ) + { + THyp::TGHS3DEnforcedVertex* ev = size2ev->second; + ev->geomEntry = entryArray[ iEnt++ ]; + } + } + { + THyp::TGeomEntryGHS3DEnforcedVertexMap& geomEntryEnfVertexMapNew = + const_cast< THyp::TGeomEntryGHS3DEnforcedVertexMap& > ( h->_GetEnforcedVerticesByEntry() ); + THyp::TGeomEntryGHS3DEnforcedVertexMap geomEntryEnfVertexMap; + geomEntryEnfVertexMap.swap( geomEntryEnfVertexMapNew ); + THyp::TGeomEntryGHS3DEnforcedVertexMap::iterator entry2ev; + for ( entry2ev = geomEntryEnfVertexMap.begin(); + entry2ev != geomEntryEnfVertexMap.end(); + entry2ev++ ) + { + const std::string& entry = entryArray[ iEnt++ ]; + THyp::TGHS3DEnforcedVertex* ev = entry2ev->second; + ev->geomEntry = entryArray[ iEnt++ ]; + + geomEntryEnfVertexMapNew[ entry ] = ev; + } + } + + return iEnt == entryArray.size(); +}