X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FNETGENPlugin%2FNETGENPlugin_SimpleHypothesis_2D_i.cxx;h=7f90be1616a81b735087c9f3c2dff0984852fb12;hb=2d646f5c7d5ad52f0a47ea87c18d9ce74273599b;hp=fac763ef12f1e52f63d209727ca0a5460632f6d4;hpb=5e1cfe70db0966728aff50c2d2796bf13bb3614f;p=plugins%2Fnetgenplugin.git diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx index fac763e..7f90be1 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2023 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_SimpleHypothesis_2D_i.cxx // Author : Edward AGAPOV @@ -34,6 +32,8 @@ #include #include +#include + using namespace std; //============================================================================= @@ -45,14 +45,12 @@ using namespace std; //============================================================================= NETGENPlugin_SimpleHypothesis_2D_i:: NETGENPlugin_SimpleHypothesis_2D_i (PortableServer::POA_ptr thePOA, - int theStudyId, ::SMESH_Gen* theGenImpl) : SALOME::GenericObj_i( thePOA ), SMESH_Hypothesis_i( thePOA ) { - MESSAGE( "NETGENPlugin_SimpleHypothesis_2D_i::NETGENPlugin_SimpleHypothesis_2D_i" ); + //MESSAGE( "NETGENPlugin_SimpleHypothesis_2D_i::NETGENPlugin_SimpleHypothesis_2D_i" ); myBaseImpl = new ::NETGENPlugin_SimpleHypothesis_2D (theGenImpl->GetANewId(), - theStudyId, theGenImpl); } @@ -65,7 +63,7 @@ NETGENPlugin_SimpleHypothesis_2D_i (PortableServer::POA_ptr thePOA, //============================================================================= NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i() { - MESSAGE( "NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i" ); + //MESSAGE( "NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i" ); } //============================================================================= @@ -73,10 +71,8 @@ NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i() * NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments */ //============================================================================= -void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Short nb) - throw ( SALOME::SALOME_Exception ) +void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Long nb) { - MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments"); ASSERT(myBaseImpl); try { this->GetImpl()->SetNumberOfSegments(nb); @@ -84,7 +80,7 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Short nb) catch (SALOME_Exception& S_ex) { THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); } - SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << nb << " )"; + SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(nb) << " )"; } //============================================================================= @@ -92,11 +88,10 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Short nb) * NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments() */ //============================================================================= -CORBA::Short NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments() +CORBA::Long NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments() { - MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments"); ASSERT(myBaseImpl); - return this->GetImpl()->GetNumberOfSegments(); + return (CORBA::Long) this->GetImpl()->GetNumberOfSegments(); } //================================================================================ @@ -107,7 +102,6 @@ CORBA::Short NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments() void NETGENPlugin_SimpleHypothesis_2D_i::SetLocalLength(CORBA::Double segmentLength) { - MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::SetLocalLength"); ASSERT(myBaseImpl); try { this->GetImpl()->SetLocalLength(segmentLength); @@ -115,7 +109,7 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetLocalLength(CORBA::Double segmentLen catch (SALOME_Exception& S_ex) { THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); } - SMESH::TPythonDump() << _this() << ".SetLocalLength( " << segmentLength << " )"; + SMESH::TPythonDump() << _this() << ".SetLocalLength( " << SMESH::TVar(segmentLength) << " )"; } //================================================================================ @@ -126,7 +120,6 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetLocalLength(CORBA::Double segmentLen CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetLocalLength() { - MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetLocalLength"); ASSERT(myBaseImpl); return this->GetImpl()->GetLocalLength(); } @@ -138,7 +131,6 @@ CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetLocalLength() //============================================================================= void NETGENPlugin_SimpleHypothesis_2D_i::LengthFromEdges() { - MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::LengthFromEdges"); ASSERT(myBaseImpl); this->GetImpl()->LengthFromEdges(); SMESH::TPythonDump() << _this() << ".LengthFromEdges()"; @@ -151,10 +143,9 @@ void NETGENPlugin_SimpleHypothesis_2D_i::LengthFromEdges() //============================================================================= void NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea(CORBA::Double area) { - MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea"); ASSERT(myBaseImpl); this->GetImpl()->SetMaxElementArea(area); - SMESH::TPythonDump() << _this() << ".SetMaxElementArea( " << area << " )"; + SMESH::TPythonDump() << _this() << ".SetMaxElementArea( " << SMESH::TVar(area) << " )"; } @@ -163,29 +154,52 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea(CORBA::Double area) * NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea() */ //============================================================================= + CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea() { - MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea"); ASSERT(myBaseImpl); return this->GetImpl()->GetMaxElementArea(); } + +//============================================================================= +/*! + * Enables/disables generation of quadrangular faces + */ +//============================================================================= + +void NETGENPlugin_SimpleHypothesis_2D_i::SetAllowQuadrangles(CORBA::Boolean toAllow) +{ + ASSERT(myBaseImpl); + SMESH::TPythonDump() << _this() << ".SetAllowQuadrangles( " << toAllow << " )"; + this->GetImpl()->SetAllowQuadrangles(toAllow); +} + +//============================================================================= +/*! + * Returns true if generation of quadrangular faces is enabled + */ +//============================================================================= + +CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::GetAllowQuadrangles() +{ + return this->GetImpl()->GetAllowQuadrangles(); +} //============================================================================= /*! * NETGENPlugin_SimpleHypothesis_2D_i::GetImpl */ //============================================================================= -::NETGENPlugin_SimpleHypothesis_2D* NETGENPlugin_SimpleHypothesis_2D_i::GetImpl() +::NETGENPlugin_SimpleHypothesis_2D* NETGENPlugin_SimpleHypothesis_2D_i::GetImpl() const { - MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetImpl"); return (::NETGENPlugin_SimpleHypothesis_2D*)myBaseImpl; } //================================================================================ /*! * \brief Verify whether hypothesis supports given entity type - * \param type - dimension (see SMESH::Dimension enumeration) - * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise - * + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) */ //================================================================================ @@ -193,3 +207,41 @@ CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::IsDimSupported( SMESH::Dimens { return type == SMESH::DIM_2D; } + +//================================================================================ +/*! + * \brief method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook + */ +//================================================================================ + +int NETGENPlugin_SimpleHypothesis_2D_i::getParamIndex(const TCollection_AsciiString& method, + int nbVars) const +{ + if ( method == "SetLocalLength" ) return 0; + if ( method == "SetNumberOfSegments" ) return 0; + if ( method == "SetMaxElementArea" ) return 1; + if ( method == "LengthFromEdges" ) return 10; // just to go to the next state + if ( method == "SetMaxElementVolume" ) return 2; + if ( method == "LengthFromFaces" ) return 10; // just to go to the next state + + return SMESH_Hypothesis_i::getParamIndex( method, nbVars ); // return default value +} + +//================================================================================ +/*! + * \brief Method used to convert variable parameters stored in an old study + * into myMethod2VarParams. It should return a method name for an index of + * variable parameters. Index is countered from zero + */ +//================================================================================ + +std::string NETGENPlugin_SimpleHypothesis_2D_i::getMethodOfParameter(const int paramIndex, + int /*nbVars*/) const +{ + switch ( paramIndex ) { + case 0: return GetImpl()->GetNumberOfSegments() ? "SetNumberOfSegments" : "SetLocalLength"; + case 1: return "SetMaxElementArea"; + case 2: return "SetMaxElementVolume"; + } + return ""; +}