]> SALOME platform Git repositories - plugins/netgenplugin.git/blob - src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx
Salome HOME
Remove useless MESSAGEs
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_SimpleHypothesis_2D_i.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  NETGENPlugin : C++ implementation
21 // File      : NETGENPlugin_SimpleHypothesis_2D_i.cxx
22 // Author    : Edward AGAPOV
23 // Project   : SALOME
24 //=============================================================================
25 //
26 #include "NETGENPlugin_SimpleHypothesis_2D_i.hxx"
27 #include "NETGENPlugin_SimpleHypothesis_2D.hxx"
28
29 #include <SMESH_Gen.hxx>
30 #include <SMESH_PythonDump.hxx>
31
32 #include <Utils_CorbaException.hxx>
33 #include <utilities.h>
34
35 #include <TCollection_AsciiString.hxx>
36
37 using namespace std;
38
39 //=============================================================================
40 /*!
41  *  NETGENPlugin_SimpleHypothesis_2D_i::NETGENPlugin_SimpleHypothesis_2D_i
42  *
43  *  Constructor
44  */
45 //=============================================================================
46 NETGENPlugin_SimpleHypothesis_2D_i::
47 NETGENPlugin_SimpleHypothesis_2D_i (PortableServer::POA_ptr thePOA,
48                                     int                     theStudyId,
49                                     ::SMESH_Gen*            theGenImpl)
50   : SALOME::GenericObj_i( thePOA ),
51     SMESH_Hypothesis_i( thePOA )
52 {
53   //MESSAGE( "NETGENPlugin_SimpleHypothesis_2D_i::NETGENPlugin_SimpleHypothesis_2D_i" );
54   myBaseImpl = new ::NETGENPlugin_SimpleHypothesis_2D (theGenImpl->GetANewId(),
55                                                        theStudyId,
56                                                        theGenImpl);
57 }
58
59 //=============================================================================
60 /*!
61  *  NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i
62  *
63  *  Destructor
64  */
65 //=============================================================================
66 NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i()
67 {
68   //MESSAGE( "NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i" );
69 }
70
71 //=============================================================================
72 /*!
73  *  NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments
74  */
75 //=============================================================================
76 void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Short nb)
77   throw ( SALOME::SALOME_Exception )
78 {
79   ASSERT(myBaseImpl);
80   try {
81     this->GetImpl()->SetNumberOfSegments(nb);
82   }
83   catch (SALOME_Exception& S_ex) {
84     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
85   }
86   SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(nb) << " )";
87 }
88
89 //=============================================================================
90 /*!
91  *  NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments()
92  */
93 //=============================================================================
94 CORBA::Short NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments()
95 {
96   ASSERT(myBaseImpl);
97   return this->GetImpl()->GetNumberOfSegments();
98 }
99
100 //================================================================================
101 /*!
102  * LocalLength()
103  */
104 //================================================================================
105
106 void NETGENPlugin_SimpleHypothesis_2D_i::SetLocalLength(CORBA::Double segmentLength)
107 {
108   ASSERT(myBaseImpl);
109   try {
110     this->GetImpl()->SetLocalLength(segmentLength);
111   }
112   catch (SALOME_Exception& S_ex) {
113     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
114   }
115   SMESH::TPythonDump() << _this() << ".SetLocalLength( " << SMESH::TVar(segmentLength) << " )";
116 }
117
118 //================================================================================
119 /*!
120  * GetLocalLength()
121  */
122 //================================================================================
123
124 CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetLocalLength()
125 {
126   ASSERT(myBaseImpl);
127   return this->GetImpl()->GetLocalLength();
128 }
129
130 //=============================================================================
131 /*!
132  *  NETGENPlugin_SimpleHypothesis_2D_i::LengthFromEdges()
133  */
134 //=============================================================================
135 void NETGENPlugin_SimpleHypothesis_2D_i::LengthFromEdges()
136 {
137   ASSERT(myBaseImpl);
138   this->GetImpl()->LengthFromEdges();
139   SMESH::TPythonDump() << _this() << ".LengthFromEdges()";
140 }
141
142 //=============================================================================
143 /*!
144  *  NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea()
145  */
146 //=============================================================================
147 void NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea(CORBA::Double area)
148 {
149   ASSERT(myBaseImpl);
150   this->GetImpl()->SetMaxElementArea(area);
151   SMESH::TPythonDump() << _this() << ".SetMaxElementArea( " << SMESH::TVar(area) << " )";
152 }
153
154
155 //=============================================================================
156 /*!
157  *  NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea()
158  */
159 //=============================================================================
160
161 CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea()
162 {
163   ASSERT(myBaseImpl);
164   return this->GetImpl()->GetMaxElementArea();
165 }
166
167 //=============================================================================
168 /*!
169  * Enables/disables generation of quadrangular faces
170  */
171 //=============================================================================
172
173 void NETGENPlugin_SimpleHypothesis_2D_i::SetAllowQuadrangles(CORBA::Boolean toAllow)
174 {
175   ASSERT(myBaseImpl);
176   SMESH::TPythonDump() << _this() << ".SetAllowQuadrangles( " << toAllow << " )";
177   this->GetImpl()->SetAllowQuadrangles(toAllow);
178 }
179
180 //=============================================================================
181 /*!
182  * Returns true if generation of quadrangular faces is enabled
183  */
184 //=============================================================================
185
186 CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::GetAllowQuadrangles()
187 {
188   return this->GetImpl()->GetAllowQuadrangles();
189 }
190 //=============================================================================
191 /*!
192  *  NETGENPlugin_SimpleHypothesis_2D_i::GetImpl
193  */
194 //=============================================================================
195 ::NETGENPlugin_SimpleHypothesis_2D* NETGENPlugin_SimpleHypothesis_2D_i::GetImpl() const
196 {
197   return (::NETGENPlugin_SimpleHypothesis_2D*)myBaseImpl;
198 }
199
200 //================================================================================
201 /*!
202  * \brief Verify whether hypothesis supports given entity type 
203  * \param type - dimension (see SMESH::Dimension enumeration)
204  * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
205  *
206  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
207  */
208 //================================================================================  
209 CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::IsDimSupported( SMESH::Dimension type )
210 {
211   return type == SMESH::DIM_2D;
212 }
213
214 //================================================================================
215 /*!
216  * \brief method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook
217  */
218 //================================================================================
219
220 int NETGENPlugin_SimpleHypothesis_2D_i::getParamIndex(const TCollection_AsciiString& method,
221                                                       int nbVars) const
222 {
223   if ( method == "SetLocalLength"      ) return 0;
224   if ( method == "SetNumberOfSegments" ) return 0;
225   if ( method == "SetMaxElementArea"   ) return 1;
226   if ( method == "LengthFromEdges"     ) return 10; // just to go to the next state
227   if ( method == "SetMaxElementVolume" ) return 2;
228   if ( method == "LengthFromFaces"     ) return 10; // just to go to the next state
229
230   return SMESH_Hypothesis_i::getParamIndex( method, nbVars ); // return default value
231 }
232
233 //================================================================================
234 /*!
235  * \brief Method used to convert variable parameters stored in an old study
236  * into myMethod2VarParams. It should return a method name for an index of
237  * variable parameters. Index is countered from zero
238  */
239 //================================================================================
240
241 std::string NETGENPlugin_SimpleHypothesis_2D_i::getMethodOfParameter(const int paramIndex,
242                                                                      int nbVars) const
243 {
244   switch ( paramIndex ) {
245   case 0: return GetImpl()->GetNumberOfSegments() ? "SetNumberOfSegments" : "SetLocalLength";
246   case 1: return "SetMaxElementArea";
247   case 2: return "SetMaxElementVolume";
248   }
249   return "";
250 }