]> SALOME platform Git repositories - plugins/netgenplugin.git/blob - src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx
Salome HOME
ba2f4b8bb0358e73a824e364a0748562d7d1448b
[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                                     ::SMESH_Gen*            theGenImpl)
49   : SALOME::GenericObj_i( thePOA ),
50     SMESH_Hypothesis_i( thePOA )
51 {
52   MESSAGE( "NETGENPlugin_SimpleHypothesis_2D_i::NETGENPlugin_SimpleHypothesis_2D_i" );
53   myBaseImpl = new ::NETGENPlugin_SimpleHypothesis_2D (theGenImpl->GetANewId(),
54                                                        theGenImpl);
55 }
56
57 //=============================================================================
58 /*!
59  *  NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i
60  *
61  *  Destructor
62  */
63 //=============================================================================
64 NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i()
65 {
66   MESSAGE( "NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i" );
67 }
68
69 //=============================================================================
70 /*!
71  *  NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments
72  */
73 //=============================================================================
74 void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Short nb)
75   throw ( SALOME::SALOME_Exception )
76 {
77   MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments");
78   ASSERT(myBaseImpl);
79   try {
80     this->GetImpl()->SetNumberOfSegments(nb);
81   }
82   catch (SALOME_Exception& S_ex) {
83     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
84   }
85   SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(nb) << " )";
86 }
87
88 //=============================================================================
89 /*!
90  *  NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments()
91  */
92 //=============================================================================
93 CORBA::Short NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments()
94 {
95   MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments");
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   MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::SetLocalLength");
109   ASSERT(myBaseImpl);
110   try {
111     this->GetImpl()->SetLocalLength(segmentLength);
112   }
113   catch (SALOME_Exception& S_ex) {
114     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
115   }
116   SMESH::TPythonDump() << _this() << ".SetLocalLength( " << SMESH::TVar(segmentLength) << " )";
117 }
118
119 //================================================================================
120 /*!
121  * GetLocalLength()
122  */
123 //================================================================================
124
125 CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetLocalLength()
126 {
127   MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetLocalLength");
128   ASSERT(myBaseImpl);
129   return this->GetImpl()->GetLocalLength();
130 }
131
132 //=============================================================================
133 /*!
134  *  NETGENPlugin_SimpleHypothesis_2D_i::LengthFromEdges()
135  */
136 //=============================================================================
137 void NETGENPlugin_SimpleHypothesis_2D_i::LengthFromEdges()
138 {
139   MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::LengthFromEdges");
140   ASSERT(myBaseImpl);
141   this->GetImpl()->LengthFromEdges();
142   SMESH::TPythonDump() << _this() << ".LengthFromEdges()";
143 }
144
145 //=============================================================================
146 /*!
147  *  NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea()
148  */
149 //=============================================================================
150 void NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea(CORBA::Double area)
151 {
152   MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea");
153   ASSERT(myBaseImpl);
154   this->GetImpl()->SetMaxElementArea(area);
155   SMESH::TPythonDump() << _this() << ".SetMaxElementArea( " << SMESH::TVar(area) << " )";
156 }
157
158
159 //=============================================================================
160 /*!
161  *  NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea()
162  */
163 //=============================================================================
164
165 CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea()
166 {
167   MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea");
168   ASSERT(myBaseImpl);
169   return this->GetImpl()->GetMaxElementArea();
170 }
171
172 //=============================================================================
173 /*!
174  * Enables/disables generation of quadrangular faces
175  */
176 //=============================================================================
177
178 void NETGENPlugin_SimpleHypothesis_2D_i::SetAllowQuadrangles(CORBA::Boolean toAllow)
179 {
180   ASSERT(myBaseImpl);
181   SMESH::TPythonDump() << _this() << ".SetAllowQuadrangles( " << toAllow << " )";
182   this->GetImpl()->SetAllowQuadrangles(toAllow);
183 }
184
185 //=============================================================================
186 /*!
187  * Returns true if generation of quadrangular faces is enabled
188  */
189 //=============================================================================
190
191 CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::GetAllowQuadrangles()
192 {
193   return this->GetImpl()->GetAllowQuadrangles();
194 }
195 //=============================================================================
196 /*!
197  *  NETGENPlugin_SimpleHypothesis_2D_i::GetImpl
198  */
199 //=============================================================================
200 ::NETGENPlugin_SimpleHypothesis_2D* NETGENPlugin_SimpleHypothesis_2D_i::GetImpl() const
201 {
202   MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetImpl");
203   return (::NETGENPlugin_SimpleHypothesis_2D*)myBaseImpl;
204 }
205
206 //================================================================================
207 /*!
208  * \brief Verify whether hypothesis supports given entity type 
209  * \param type - dimension (see SMESH::Dimension enumeration)
210  * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
211  *
212  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
213  */
214 //================================================================================  
215 CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::IsDimSupported( SMESH::Dimension type )
216 {
217   return type == SMESH::DIM_2D;
218 }
219
220 //================================================================================
221 /*!
222  * \brief method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook
223  */
224 //================================================================================
225
226 int NETGENPlugin_SimpleHypothesis_2D_i::getParamIndex(const TCollection_AsciiString& method,
227                                                       int nbVars) const
228 {
229   if ( method == "SetLocalLength"      ) return 0;
230   if ( method == "SetNumberOfSegments" ) return 0;
231   if ( method == "SetMaxElementArea"   ) return 1;
232   if ( method == "LengthFromEdges"     ) return 10; // just to go to the next state
233   if ( method == "SetMaxElementVolume" ) return 2;
234   if ( method == "LengthFromFaces"     ) return 10; // just to go to the next state
235
236   return SMESH_Hypothesis_i::getParamIndex( method, nbVars ); // return default value
237 }
238
239 //================================================================================
240 /*!
241  * \brief Method used to convert variable parameters stored in an old study
242  * into myMethod2VarParams. It should return a method name for an index of
243  * variable parameters. Index is countered from zero
244  */
245 //================================================================================
246
247 std::string NETGENPlugin_SimpleHypothesis_2D_i::getMethodOfParameter(const int paramIndex,
248                                                                      int nbVars) const
249 {
250   switch ( paramIndex ) {
251   case 0: return GetImpl()->GetNumberOfSegments() ? "SetNumberOfSegments" : "SetLocalLength";
252   case 1: return "SetMaxElementArea";
253   case 2: return "SetMaxElementVolume";
254   }
255   return "";
256 }