]> SALOME platform Git repositories - modules/smesh.git/blob - src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx
Salome HOME
Correct uninitialized variables
[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 #include "StdMeshers_NumberOfSegments_i.hxx"
31 #include "SMESH_Gen_i.hxx"
32 #include "SMESH_Gen.hxx"
33 #include "SMESH_PythonDump.hxx"
34
35 #include "Utils_CorbaException.hxx"
36 #include "utilities.h"
37
38 #include <TCollection_AsciiString.hxx>
39
40 using namespace std;
41
42 //=============================================================================
43 /*!
44  *  StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
45  *
46  *  Constructor
47  */
48 //=============================================================================
49
50 StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
51                                                     int                     theStudyId,
52                                                     ::SMESH_Gen*            theGenImpl )
53      : SALOME::GenericObj_i( thePOA ), 
54        SMESH_Hypothesis_i( thePOA )
55 {
56   MESSAGE( "StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i" );
57   myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
58                                              theStudyId,
59                                              theGenImpl );
60 }
61
62 //=============================================================================
63 /*!
64  *  StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i
65  *
66  *  Destructor
67  */
68 //=============================================================================
69
70 StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i()
71 {
72   MESSAGE( "StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i" );
73 }
74
75 //=============================================================================
76 /*!
77  *  StdMeshers_NumberOfSegments_i::BuildDistribution
78  *
79  *  Builds point distribution according to passed function
80  */
81 //=============================================================================
82 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionExpr( const char* func, long nbSeg, long conv )
83 throw ( SALOME::SALOME_Exception )
84 {
85   MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
86   ASSERT( myBaseImpl );
87   try
88   {
89     SMESH::double_array_var aRes = new SMESH::double_array();
90     const std::vector<double>& res = this->GetImpl()->BuildDistributionExpr( func, nbSeg, conv );
91     aRes->length( res.size() );
92     for (int i = 0; i < res.size(); i++)
93       aRes[i] = res[i];
94     return aRes._retn();
95   }
96   catch( SALOME_Exception& S_ex )
97   {
98     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
99   }
100 }
101
102 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
103                                                                           long nbSeg, long conv )
104 throw ( SALOME::SALOME_Exception )
105 {
106   MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
107   ASSERT( myBaseImpl );
108
109   std::vector<double> tbl( func.length() );
110   for (int i = 0; i < func.length(); i++)
111     tbl[i] = func[i];
112
113   try
114   {
115     SMESH::double_array_var aRes = new SMESH::double_array();
116     const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
117     aRes->length( res.size() );
118     for (int i = 0; i < res.size(); i++)
119       aRes[i] = res[i];
120     return aRes._retn();
121   }
122   catch( SALOME_Exception& S_ex )
123   {
124     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
125   }
126 }
127
128 //=============================================================================
129 /*!
130  *  StdMeshers_NumberOfSegments_i::SetNumberOfSegments
131  *
132  *  Set number of segments
133  */
134 //=============================================================================
135
136 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
137      throw ( SALOME::SALOME_Exception )
138 {
139   MESSAGE( "StdMeshers_NumberOfSegments_i::SetNumberOfSegments" );
140   ASSERT( myBaseImpl );
141   try {
142     this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
143   }
144   catch (SALOME_Exception& S_ex) {
145     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
146                                   SALOME::BAD_PARAM );
147   }
148
149   // Update Python script
150   SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << theSegmentsNumber << " )";
151 }
152
153 //=============================================================================
154 /*!
155  *  StdMeshers_NumberOfSegments_i::GetNumberOfSegments
156  *
157  *  Get number of segments
158  */
159 //=============================================================================
160
161 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
162 {
163   MESSAGE( "StdMeshers_NumberOfSegments_i::GetNumberOfSegments" );
164   ASSERT( myBaseImpl );
165   return this->GetImpl()->GetNumberOfSegments();
166 }
167
168 //=============================================================================
169 /*!
170  */
171 //=============================================================================
172
173 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
174   throw ( SALOME::SALOME_Exception )
175 {
176   MESSAGE( "StdMeshers_NumberOfSegments_i::SetDistrType" );
177   ASSERT( myBaseImpl );
178   try {
179     this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
180
181     // Update Python script
182     SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
183   }
184   catch ( SALOME_Exception& S_ex ) {
185     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
186                                   SALOME::BAD_PARAM );
187   }
188 }
189
190 //=============================================================================
191 /*!
192  */
193 //=============================================================================
194
195 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
196 {
197   MESSAGE( "StdMeshers_NumberOfSegments_i::GetDistrType" );
198   ASSERT( myBaseImpl );
199   return this->GetImpl()->GetDistrType();
200 }
201
202 //=============================================================================
203 /*!
204  *  StdMeshers_NumberOfSegments_i::SetScaleFactor
205  *
206  *  Set scalar factor
207  */
208 //=============================================================================
209
210 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
211      throw ( SALOME::SALOME_Exception )
212 {
213   MESSAGE( "StdMeshers_NumberOfSegments_i::SetScaleFactor" );
214   ASSERT( myBaseImpl );
215   try {
216     this->GetImpl()->SetScaleFactor( theScaleFactor );
217     // Update Python script
218     SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << theScaleFactor << " )";
219   }
220   catch ( SALOME_Exception& S_ex ) {
221     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
222                                   SALOME::BAD_PARAM );
223   }
224 }
225
226 //=============================================================================
227 /*!
228  *  StdMeshers_NumberOfSegments_i::GetScaleFactor
229  *
230  *  Get scalar factor
231  */
232 //=============================================================================
233
234 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
235   throw ( SALOME::SALOME_Exception )
236 {
237   MESSAGE( "StdMeshers_NumberOfSegments_i::GetScaleFactor" );
238   ASSERT( myBaseImpl );
239   double scale;
240   try {
241     scale = this->GetImpl()->GetScaleFactor();
242   }
243   catch ( SALOME_Exception& S_ex ) {
244     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
245                                   SALOME::BAD_PARAM );
246   }
247   return scale;
248 }
249
250 //=============================================================================
251 /*!
252  */
253 //=============================================================================
254
255 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
256   throw ( SALOME::SALOME_Exception )
257 {
258   MESSAGE( "StdMeshers_NumberOfSegments_i::SetTableFunction" );
259   ASSERT( myBaseImpl );
260   std::vector<double> tbl( table.length() );
261   for (int i = 0; i < table.length(); i++)
262     tbl[i] = table[i];
263   try {
264     this->GetImpl()->SetTableFunction( tbl );
265     // Update Python script
266     SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
267   }
268   catch ( SALOME_Exception& S_ex ) {
269     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
270                                   SALOME::BAD_PARAM );
271   }
272 }
273
274 //=============================================================================
275 /*!
276  */
277 //=============================================================================
278
279 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
280   throw ( SALOME::SALOME_Exception )
281 {
282   MESSAGE( "StdMeshers_NumberOfSegments_i::GetTableFunction" );
283   ASSERT( myBaseImpl );
284   const std::vector<double>* tbl;
285   try {
286     tbl = &this->GetImpl()->GetTableFunction();
287   }
288   catch ( SALOME_Exception& S_ex ) {
289     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
290                                   SALOME::BAD_PARAM );
291   }
292   SMESH::double_array_var aRes = new SMESH::double_array();
293   aRes->length(tbl->size());
294   for (int i = 0; i < tbl->size(); i++)
295     aRes[i] = (*tbl)[i];
296   return aRes._retn();
297 }
298
299 //=============================================================================
300 /*!
301  */
302 //=============================================================================
303
304 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
305   throw ( SALOME::SALOME_Exception )
306 {
307   MESSAGE( "StdMeshers_NumberOfSegments_i::SetExpressionFunction" );
308   ASSERT( myBaseImpl );
309   try {
310     this->GetImpl()->SetExpressionFunction( expr );
311     // Update Python script
312     SMESH::TPythonDump() << _this() << ".SetExpressionFunction( " << expr << " )";
313   }
314   catch ( SALOME_Exception& S_ex ) {
315     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
316                                   SALOME::BAD_PARAM );
317   }
318 }
319
320 //=============================================================================
321 /*!
322  */
323 //=============================================================================
324
325 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
326   throw ( SALOME::SALOME_Exception )
327 {
328   MESSAGE( "StdMeshers_NumberOfSegments_i::GetExpressionFunction" );
329   ASSERT( myBaseImpl );
330   const char* expr;
331   try {
332     expr = this->GetImpl()->GetExpressionFunction();
333   }
334   catch ( SALOME_Exception& S_ex ) {
335     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
336                                   SALOME::BAD_PARAM );
337   }
338   return CORBA::string_dup(expr);
339 }
340
341 //=============================================================================
342 /*!
343  */
344 //=============================================================================
345
346 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
347   throw ( SALOME::SALOME_Exception )
348 {
349   MESSAGE( "StdMeshers_NumberOfSegments_i::SetConversionMode" );
350   ASSERT( myBaseImpl );
351   try {
352     this->GetImpl()->SetConversionMode( conv );
353     // Update Python script
354     SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
355   }
356   catch ( SALOME_Exception& S_ex ) {
357     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
358                                   SALOME::BAD_PARAM );
359   }
360 }
361
362 //=============================================================================
363 /*!
364  */
365 //=============================================================================
366
367 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
368   throw ( SALOME::SALOME_Exception )
369 {
370   MESSAGE( "StdMeshers_NumberOfSegments_i::ConversionMode" );
371   ASSERT( myBaseImpl );
372   int conv;
373   try {
374     conv = this->GetImpl()->ConversionMode();
375   }
376   catch ( SALOME_Exception& S_ex ) {
377     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
378                                   SALOME::BAD_PARAM );
379   }
380   return conv;
381 }
382
383 //=============================================================================
384 /*!
385  *  StdMeshers_NumberOfSegments_i::GetImpl
386  *
387  *  Get implementation
388  */
389 //=============================================================================
390
391 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
392 {
393   MESSAGE( "StdMeshers_NumberOfSegments_i::GetImpl" );
394   return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
395 }
396
397 //================================================================================
398 /*!
399  * \brief Verify whether hypothesis supports given entity type 
400   * \param type - dimension (see SMESH::Dimension enumeration)
401   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
402  * 
403  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
404  */
405 //================================================================================  
406 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
407 {
408   return type == SMESH::DIM_1D;
409 }
410