1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
24 // File : StdMeshers_NumberOfSegments_i.cxx
25 // Moved here from SMESH_NumberOfSegments_i.cxx
26 // Author : Paul RASCLE, EDF
29 #include "StdMeshers_NumberOfSegments_i.hxx"
30 #include "SMESH_Gen_i.hxx"
31 #include "SMESH_Gen.hxx"
32 #include "SMESH_PythonDump.hxx"
34 #include "Utils_CorbaException.hxx"
35 #include "utilities.h"
37 #include <TCollection_AsciiString.hxx>
40 //=============================================================================
42 * StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
46 //=============================================================================
48 StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
50 ::SMESH_Gen* theGenImpl )
51 : SALOME::GenericObj_i( thePOA ),
52 SMESH_Hypothesis_i( thePOA )
54 MESSAGE( "StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i" );
55 myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
60 //=============================================================================
62 * StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i
66 //=============================================================================
68 StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i()
70 MESSAGE( "StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i" );
73 //=============================================================================
75 * StdMeshers_NumberOfSegments_i::BuildDistribution
77 * Builds point distribution according to passed function
79 //=============================================================================
80 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionExpr( const char* func,
83 throw ( SALOME::SALOME_Exception )
88 SMESH::double_array_var aRes = new SMESH::double_array();
89 const std::vector<double>& res = this->GetImpl()->BuildDistributionExpr( func, nbSeg, conv );
90 aRes->length( res.size() );
91 for (int i = 0; i < res.size(); i++)
95 catch( SALOME_Exception& S_ex )
97 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
101 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
104 throw ( SALOME::SALOME_Exception )
106 ASSERT( myBaseImpl );
108 std::vector<double> tbl( func.length() );
109 for (int i = 0; i < func.length(); i++)
114 SMESH::double_array_var aRes = new SMESH::double_array();
115 const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
116 aRes->length( res.size() );
117 for (int i = 0; i < res.size(); i++)
121 catch( SALOME_Exception& S_ex )
123 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
127 //=============================================================================
129 * StdMeshers_NumberOfSegments_i::SetNumberOfSegments
131 * Set number of segments
133 //=============================================================================
135 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
136 throw ( SALOME::SALOME_Exception )
138 ASSERT( myBaseImpl );
140 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
142 catch (SALOME_Exception& S_ex) {
143 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
147 // Update Python script
148 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(theSegmentsNumber) << " )";
151 //=============================================================================
153 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
155 * Get number of segments
157 //=============================================================================
159 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
161 ASSERT( myBaseImpl );
162 return this->GetImpl()->GetNumberOfSegments();
165 //=============================================================================
167 * StdMeshers_NumberOfSegments_i::SetReversedEdges
169 * Set edges to reverse
171 //=============================================================================
173 void StdMeshers_NumberOfSegments_i::SetReversedEdges( const SMESH::long_array& theIds )
175 ASSERT( myBaseImpl );
177 std::vector<int> ids( theIds.length() );
178 CORBA::Long iEnd = theIds.length();
179 for ( CORBA::Long i = 0; i < iEnd; i++ )
180 ids[ i ] = theIds[ i ];
182 this->GetImpl()->SetReversedEdges( ids );
184 catch ( SALOME_Exception& S_ex ) {
185 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
189 // Update Python script
190 SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
193 //=============================================================================
195 * StdMeshers_NumberOfSegments_i::SetObjectEntry
197 * Set the Entry for the Main Object
199 //=============================================================================
201 void StdMeshers_NumberOfSegments_i::SetObjectEntry( const char* theEntry )
203 ASSERT( myBaseImpl );
204 string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
206 this->GetImpl()->SetObjectEntry( entry.c_str() );
208 catch ( SALOME_Exception& S_ex ) {
209 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
212 // Update Python script
213 SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
216 //=============================================================================
218 * StdMeshers_NumberOfSegments_i::GetObjectEntry
220 * Set the Entry for the Main Object
222 //=============================================================================
224 char* StdMeshers_NumberOfSegments_i::GetObjectEntry()
226 ASSERT( myBaseImpl );
230 entry = this->GetImpl()->GetObjectEntry();
232 catch ( SALOME_Exception& S_ex ) {
233 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
236 return CORBA::string_dup( entry );
239 //=============================================================================
241 * StdMeshers_NumberOfSegments_i::GetReversedEdges
245 //=============================================================================
247 SMESH::long_array* StdMeshers_NumberOfSegments_i::GetReversedEdges()
249 MESSAGE( "StdMeshers_NumberOfSegments_i::GetReversedEdges" );
250 ASSERT( myBaseImpl );
251 SMESH::long_array_var anArray = new SMESH::long_array;
252 std::vector<int> ids = this->GetImpl()->GetReversedEdges();
253 anArray->length( ids.size() );
254 for ( CORBA::Long i = 0; i < ids.size(); i++)
255 anArray [ i ] = ids [ i ];
257 return anArray._retn();
260 //=============================================================================
263 //=============================================================================
265 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
266 throw ( SALOME::SALOME_Exception )
268 ASSERT( myBaseImpl );
270 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
272 // Update Python script
273 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
275 catch ( SALOME_Exception& S_ex ) {
276 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
281 //=============================================================================
284 //=============================================================================
286 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
288 ASSERT( myBaseImpl );
289 return this->GetImpl()->GetDistrType();
292 //=============================================================================
294 * StdMeshers_NumberOfSegments_i::SetScaleFactor
298 //=============================================================================
300 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
301 throw ( SALOME::SALOME_Exception )
303 ASSERT( myBaseImpl );
305 this->GetImpl()->SetScaleFactor( theScaleFactor );
306 // Update Python script
307 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << SMESH::TVar(theScaleFactor) << " )";
309 catch ( SALOME_Exception& S_ex ) {
310 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
315 //=============================================================================
317 * StdMeshers_NumberOfSegments_i::GetScaleFactor
321 //=============================================================================
323 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
324 throw ( SALOME::SALOME_Exception )
326 ASSERT( myBaseImpl );
329 scale = this->GetImpl()->GetScaleFactor();
331 catch ( SALOME_Exception& S_ex ) {
332 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
338 //=============================================================================
341 //=============================================================================
343 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
344 throw ( SALOME::SALOME_Exception )
346 ASSERT( myBaseImpl );
347 std::vector<double> tbl( table.length() );
348 for (int i = 0; i < table.length(); i++)
351 this->GetImpl()->SetTableFunction( tbl );
352 // Update Python script
353 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
355 catch ( SALOME_Exception& S_ex ) {
356 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
361 //=============================================================================
364 //=============================================================================
366 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
367 throw ( SALOME::SALOME_Exception )
369 ASSERT( myBaseImpl );
370 const std::vector<double>* tbl;
372 tbl = &this->GetImpl()->GetTableFunction();
374 catch ( SALOME_Exception& S_ex ) {
375 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
378 SMESH::double_array_var aRes = new SMESH::double_array();
379 aRes->length(tbl->size());
380 for (int i = 0; i < tbl->size(); i++)
385 //=============================================================================
388 //=============================================================================
390 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
391 throw ( SALOME::SALOME_Exception )
393 ASSERT( myBaseImpl );
395 this->GetImpl()->SetExpressionFunction( expr );
396 // Update Python script
397 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
399 catch ( SALOME_Exception& S_ex ) {
400 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
405 //=============================================================================
408 //=============================================================================
410 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
411 throw ( SALOME::SALOME_Exception )
413 ASSERT( myBaseImpl );
416 expr = this->GetImpl()->GetExpressionFunction();
418 catch ( SALOME_Exception& S_ex ) {
419 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
422 return CORBA::string_dup(expr);
425 //=============================================================================
428 //=============================================================================
430 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
431 throw ( SALOME::SALOME_Exception )
433 ASSERT( myBaseImpl );
435 this->GetImpl()->SetConversionMode( conv );
436 // Update Python script
437 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
439 catch ( SALOME_Exception& S_ex ) {
440 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
445 //=============================================================================
448 //=============================================================================
450 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
451 throw ( SALOME::SALOME_Exception )
453 ASSERT( myBaseImpl );
456 conv = this->GetImpl()->ConversionMode();
458 catch ( SALOME_Exception& S_ex ) {
459 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
465 //=============================================================================
467 * StdMeshers_NumberOfSegments_i::GetImpl
471 //=============================================================================
473 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
475 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
478 //================================================================================
480 * \brief Verify whether hypothesis supports given entity type
481 * \param type - dimension (see SMESH::Dimension enumeration)
482 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
484 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
486 //================================================================================
487 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
489 return type == SMESH::DIM_1D;
492 //================================================================================
494 * \brief Return method name corresponding to index of variable parameter
496 //================================================================================
498 std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramIndex, int ) const
500 return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";