Salome HOME
IsDimSupported method added
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_NumberOfSegments_i.cxx
1 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : StdMeshers_NumberOfSegments_i.cxx
25 //           Moved here from SMESH_NumberOfSegments_i.cxx
26 //  Author : Paul RASCLE, EDF
27 //  Module : SMESH
28 //  $Header$
29
30 using namespace std;
31 #include "StdMeshers_NumberOfSegments_i.hxx"
32 #include "SMESH_Gen_i.hxx"
33 #include "SMESH_Gen.hxx"
34
35 #include "Utils_CorbaException.hxx"
36 #include "utilities.h"
37
38 #include <TCollection_AsciiString.hxx>
39
40 //=============================================================================
41 /*!
42  *  StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
43  *
44  *  Constructor
45  */
46 //=============================================================================
47
48 StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
49                                                     int                     theStudyId,
50                                                     ::SMESH_Gen*            theGenImpl )
51      : SALOME::GenericObj_i( thePOA ), 
52        SMESH_Hypothesis_i( thePOA )
53 {
54   MESSAGE( "StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i" );
55   myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
56                                              theStudyId,
57                                              theGenImpl );
58 }
59
60 //=============================================================================
61 /*!
62  *  StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i
63  *
64  *  Destructor
65  */
66 //=============================================================================
67
68 StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i()
69 {
70   MESSAGE( "StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i" );
71 }
72
73 //=============================================================================
74 /*!
75  *  StdMeshers_NumberOfSegments_i::SetNumberOfSegments
76  *
77  *  Set number of segments
78  */
79 //=============================================================================
80
81 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
82      throw ( SALOME::SALOME_Exception )
83 {
84   MESSAGE( "StdMeshers_NumberOfSegments_i::SetNumberOfSegments" );
85   ASSERT( myBaseImpl );
86   try {
87     this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
88   }
89   catch (SALOME_Exception& S_ex) {
90     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
91                                   SALOME::BAD_PARAM );
92   }
93
94   // Update Python script
95   TCollection_AsciiString aStr, aStrNb ((int)theSegmentsNumber);
96   SMESH_Gen_i::AddObject(aStr, _this()) += ".SetNumberOfSegments(";
97   aStr += aStrNb + ")";
98
99   SMESH_Gen_i::AddToCurrentPyScript(aStr);
100 }
101
102 //=============================================================================
103 /*!
104  *  StdMeshers_NumberOfSegments_i::GetNumberOfSegments
105  *
106  *  Get number of segments
107  */
108 //=============================================================================
109
110 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
111 {
112   MESSAGE( "StdMeshers_NumberOfSegments_i::GetNumberOfSegments" );
113   ASSERT( myBaseImpl );
114   return this->GetImpl()->GetNumberOfSegments();
115 }
116
117 //=============================================================================
118 /*!
119  */
120 //=============================================================================
121
122 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
123   throw ( SALOME::SALOME_Exception )
124 {
125   MESSAGE( "StdMeshers_NumberOfSegments_i::SetDistrType" );
126   ASSERT( myBaseImpl );
127   try {
128     this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
129   }
130   catch ( SALOME_Exception& S_ex ) {
131     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
132                                   SALOME::BAD_PARAM );
133   }
134 }
135
136 //=============================================================================
137 /*!
138  */
139 //=============================================================================
140
141 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
142 {
143   MESSAGE( "StdMeshers_NumberOfSegments_i::GetDistrType" );
144   ASSERT( myBaseImpl );
145   return this->GetImpl()->GetDistrType();
146 }
147
148 //=============================================================================
149 /*!
150  *  StdMeshers_NumberOfSegments_i::SetScaleFactor
151  *
152  *  Set scalar factor
153  */
154 //=============================================================================
155
156 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
157      throw ( SALOME::SALOME_Exception )
158 {
159   MESSAGE( "StdMeshers_NumberOfSegments_i::SetScaleFactor" );
160   ASSERT( myBaseImpl );
161   try {
162     this->GetImpl()->SetScaleFactor( theScaleFactor );
163   }
164   catch ( SALOME_Exception& S_ex ) {
165     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
166                                   SALOME::BAD_PARAM );
167   }
168 }
169
170 //=============================================================================
171 /*!
172  *  StdMeshers_NumberOfSegments_i::GetScaleFactor
173  *
174  *  Get scalar factor
175  */
176 //=============================================================================
177
178 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
179   throw ( SALOME::SALOME_Exception )
180 {
181   MESSAGE( "StdMeshers_NumberOfSegments_i::GetScaleFactor" );
182   ASSERT( myBaseImpl );
183   double scale;
184   try {
185     scale = this->GetImpl()->GetScaleFactor();
186   }
187   catch ( SALOME_Exception& S_ex ) {
188     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
189                                   SALOME::BAD_PARAM );
190   }
191   return scale;
192 }
193
194 //=============================================================================
195 /*!
196  */
197 //=============================================================================
198
199 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
200   throw ( SALOME::SALOME_Exception )
201 {
202   MESSAGE( "StdMeshers_NumberOfSegments_i::SetTableFunction" );
203   ASSERT( myBaseImpl );
204   std::vector<double> tbl( table.length() );
205   for (int i = 0; i < table.length(); i++)
206     tbl[i] = table[i];
207   try {
208     this->GetImpl()->SetTableFunction( tbl );
209   }
210   catch ( SALOME_Exception& S_ex ) {
211     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
212                                   SALOME::BAD_PARAM );
213   }
214 }
215
216 //=============================================================================
217 /*!
218  */
219 //=============================================================================
220
221 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
222   throw ( SALOME::SALOME_Exception )
223 {
224   MESSAGE( "StdMeshers_NumberOfSegments_i::GetTableFunction" );
225   ASSERT( myBaseImpl );
226   const std::vector<double>* tbl;
227   try {
228     tbl = &this->GetImpl()->GetTableFunction();
229   }
230   catch ( SALOME_Exception& S_ex ) {
231     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
232                                   SALOME::BAD_PARAM );
233   }
234   SMESH::double_array_var aRes = new SMESH::double_array();
235   aRes->length(tbl->size());
236   for (int i = 0; i < tbl->size(); i++)
237     aRes[i] = (*tbl)[i];
238   return aRes._retn();
239 }
240
241 //=============================================================================
242 /*!
243  */
244 //=============================================================================
245
246 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
247   throw ( SALOME::SALOME_Exception )
248 {
249   MESSAGE( "StdMeshers_NumberOfSegments_i::SetExpressionFunction" );
250   ASSERT( myBaseImpl );
251   try {
252     this->GetImpl()->SetExpressionFunction( expr );
253   }
254   catch ( SALOME_Exception& S_ex ) {
255     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
256                                   SALOME::BAD_PARAM );
257   }
258 }
259
260 //=============================================================================
261 /*!
262  */
263 //=============================================================================
264
265 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
266   throw ( SALOME::SALOME_Exception )
267 {
268   MESSAGE( "StdMeshers_NumberOfSegments_i::GetExpressionFunction" );
269   ASSERT( myBaseImpl );
270   const char* expr;
271   try {
272     expr = this->GetImpl()->GetExpressionFunction();
273   }
274   catch ( SALOME_Exception& S_ex ) {
275     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
276                                   SALOME::BAD_PARAM );
277   }
278   return CORBA::string_dup(expr);
279 }
280
281 //=============================================================================
282 /*!
283  */
284 //=============================================================================
285
286 void StdMeshers_NumberOfSegments_i::SetExponentMode(CORBA::Boolean isExp)
287   throw ( SALOME::SALOME_Exception )
288 {
289   MESSAGE( "StdMeshers_NumberOfSegments_i::SetExponentMode" );
290   ASSERT( myBaseImpl );
291   try {
292     this->GetImpl()->SetExponentMode( isExp );
293   }
294   catch ( SALOME_Exception& S_ex ) {
295     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
296                                   SALOME::BAD_PARAM );
297   }
298 }
299
300 //=============================================================================
301 /*!
302  */
303 //=============================================================================
304
305 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsExponentMode()
306   throw ( SALOME::SALOME_Exception )
307 {
308   MESSAGE( "StdMeshers_NumberOfSegments_i::IsExponentMode" );
309   ASSERT( myBaseImpl );
310   bool isExp;
311   try {
312     isExp = this->GetImpl()->IsExponentMode();
313   }
314   catch ( SALOME_Exception& S_ex ) {
315     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
316                                   SALOME::BAD_PARAM );
317   }
318   return isExp;
319 }
320
321 //=============================================================================
322 /*!
323  *  StdMeshers_NumberOfSegments_i::GetImpl
324  *
325  *  Get implementation
326  */
327 //=============================================================================
328
329 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
330 {
331   MESSAGE( "StdMeshers_NumberOfSegments_i::GetImpl" );
332   return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
333 }
334
335 //================================================================================
336 /*!
337  * \brief Verify whether hypothesis supports given entity type 
338   * \param type - dimension (see SMESH::Dimension enumeration)
339   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
340  * 
341  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
342  */
343 //================================================================================  
344 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
345 {
346   return type == SMESH::DIM_1D;
347 }
348