1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
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 // NETGENPlugin : C++ implementation
21 // File : NETGENPlugin_SimpleHypothesis_2D_i.cxx
22 // Author : Edward AGAPOV
24 //=============================================================================
26 #include "NETGENPlugin_SimpleHypothesis_2D_i.hxx"
27 #include "NETGENPlugin_SimpleHypothesis_2D.hxx"
29 #include <SMESH_Gen.hxx>
30 #include <SMESH_PythonDump.hxx>
32 #include <Utils_CorbaException.hxx>
33 #include <utilities.h>
35 #include <TCollection_AsciiString.hxx>
39 //=============================================================================
41 * NETGENPlugin_SimpleHypothesis_2D_i::NETGENPlugin_SimpleHypothesis_2D_i
45 //=============================================================================
46 NETGENPlugin_SimpleHypothesis_2D_i::
47 NETGENPlugin_SimpleHypothesis_2D_i (PortableServer::POA_ptr thePOA,
48 ::SMESH_Gen* theGenImpl)
49 : SALOME::GenericObj_i( thePOA ),
50 SMESH_Hypothesis_i( thePOA )
52 //MESSAGE( "NETGENPlugin_SimpleHypothesis_2D_i::NETGENPlugin_SimpleHypothesis_2D_i" );
53 myBaseImpl = new ::NETGENPlugin_SimpleHypothesis_2D (theGenImpl->GetANewId(),
57 //=============================================================================
59 * NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i
63 //=============================================================================
64 NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i()
66 //MESSAGE( "NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i" );
69 //=============================================================================
71 * NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments
73 //=============================================================================
74 void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Short nb)
75 throw ( SALOME::SALOME_Exception )
79 this->GetImpl()->SetNumberOfSegments(nb);
81 catch (SALOME_Exception& S_ex) {
82 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
84 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(nb) << " )";
87 //=============================================================================
89 * NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments()
91 //=============================================================================
92 CORBA::Short NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments()
95 return this->GetImpl()->GetNumberOfSegments();
98 //================================================================================
102 //================================================================================
104 void NETGENPlugin_SimpleHypothesis_2D_i::SetLocalLength(CORBA::Double segmentLength)
108 this->GetImpl()->SetLocalLength(segmentLength);
110 catch (SALOME_Exception& S_ex) {
111 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
113 SMESH::TPythonDump() << _this() << ".SetLocalLength( " << SMESH::TVar(segmentLength) << " )";
116 //================================================================================
120 //================================================================================
122 CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetLocalLength()
125 return this->GetImpl()->GetLocalLength();
128 //=============================================================================
130 * NETGENPlugin_SimpleHypothesis_2D_i::LengthFromEdges()
132 //=============================================================================
133 void NETGENPlugin_SimpleHypothesis_2D_i::LengthFromEdges()
136 this->GetImpl()->LengthFromEdges();
137 SMESH::TPythonDump() << _this() << ".LengthFromEdges()";
140 //=============================================================================
142 * NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea()
144 //=============================================================================
145 void NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea(CORBA::Double area)
148 this->GetImpl()->SetMaxElementArea(area);
149 SMESH::TPythonDump() << _this() << ".SetMaxElementArea( " << SMESH::TVar(area) << " )";
153 //=============================================================================
155 * NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea()
157 //=============================================================================
159 CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea()
162 return this->GetImpl()->GetMaxElementArea();
165 //=============================================================================
167 * Enables/disables generation of quadrangular faces
169 //=============================================================================
171 void NETGENPlugin_SimpleHypothesis_2D_i::SetAllowQuadrangles(CORBA::Boolean toAllow)
174 SMESH::TPythonDump() << _this() << ".SetAllowQuadrangles( " << toAllow << " )";
175 this->GetImpl()->SetAllowQuadrangles(toAllow);
178 //=============================================================================
180 * Returns true if generation of quadrangular faces is enabled
182 //=============================================================================
184 CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::GetAllowQuadrangles()
186 return this->GetImpl()->GetAllowQuadrangles();
188 //=============================================================================
190 * NETGENPlugin_SimpleHypothesis_2D_i::GetImpl
192 //=============================================================================
193 ::NETGENPlugin_SimpleHypothesis_2D* NETGENPlugin_SimpleHypothesis_2D_i::GetImpl() const
195 return (::NETGENPlugin_SimpleHypothesis_2D*)myBaseImpl;
198 //================================================================================
200 * \brief Verify whether hypothesis supports given entity type
201 * \param type - dimension (see SMESH::Dimension enumeration)
202 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
204 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
206 //================================================================================
207 CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::IsDimSupported( SMESH::Dimension type )
209 return type == SMESH::DIM_2D;
212 //================================================================================
214 * \brief method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook
216 //================================================================================
218 int NETGENPlugin_SimpleHypothesis_2D_i::getParamIndex(const TCollection_AsciiString& method,
221 if ( method == "SetLocalLength" ) return 0;
222 if ( method == "SetNumberOfSegments" ) return 0;
223 if ( method == "SetMaxElementArea" ) return 1;
224 if ( method == "LengthFromEdges" ) return 10; // just to go to the next state
225 if ( method == "SetMaxElementVolume" ) return 2;
226 if ( method == "LengthFromFaces" ) return 10; // just to go to the next state
228 return SMESH_Hypothesis_i::getParamIndex( method, nbVars ); // return default value
231 //================================================================================
233 * \brief Method used to convert variable parameters stored in an old study
234 * into myMethod2VarParams. It should return a method name for an index of
235 * variable parameters. Index is countered from zero
237 //================================================================================
239 std::string NETGENPlugin_SimpleHypothesis_2D_i::getMethodOfParameter(const int paramIndex,
242 switch ( paramIndex ) {
243 case 0: return GetImpl()->GetNumberOfSegments() ? "SetNumberOfSegments" : "SetLocalLength";
244 case 1: return "SetMaxElementArea";
245 case 2: return "SetMaxElementVolume";