1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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 (size_t i = 0; i < res.size(); i++)
95 catch( SALOME_Exception& S_ex )
97 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
102 StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
105 throw ( SALOME::SALOME_Exception )
107 ASSERT( myBaseImpl );
109 std::vector<double> tbl( func.length() );
110 for ( size_t i = 0; i < tbl.size(); i++ )
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 (size_t i = 0; i < res.size(); i++)
122 catch( SALOME_Exception& S_ex )
124 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
128 //=============================================================================
130 * StdMeshers_NumberOfSegments_i::SetNumberOfSegments
132 * Set number of segments
134 //=============================================================================
136 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
137 throw ( SALOME::SALOME_Exception )
139 ASSERT( myBaseImpl );
141 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
143 catch (SALOME_Exception& S_ex) {
144 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
148 // Update Python script
149 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(theSegmentsNumber) << " )";
152 //=============================================================================
154 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
156 * Get number of segments
158 //=============================================================================
160 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
162 ASSERT( myBaseImpl );
163 return this->GetImpl()->GetNumberOfSegments();
166 //=============================================================================
168 * StdMeshers_NumberOfSegments_i::SetReversedEdges
170 * Set edges to reverse
172 //=============================================================================
174 void StdMeshers_NumberOfSegments_i::SetReversedEdges( const SMESH::long_array& theIds )
176 ASSERT( myBaseImpl );
178 std::vector<int> ids( theIds.length() );
179 CORBA::Long iEnd = theIds.length();
180 for ( CORBA::Long i = 0; i < iEnd; i++ )
181 ids[ i ] = theIds[ i ];
183 this->GetImpl()->SetReversedEdges( ids );
185 catch ( SALOME_Exception& S_ex ) {
186 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
190 // Update Python script
191 SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
194 //=============================================================================
196 * StdMeshers_NumberOfSegments_i::SetObjectEntry
198 * Set the Entry for the Main Object
200 //=============================================================================
202 void StdMeshers_NumberOfSegments_i::SetObjectEntry( const char* theEntry )
204 ASSERT( myBaseImpl );
205 string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
207 this->GetImpl()->SetObjectEntry( entry.c_str() );
209 catch ( SALOME_Exception& S_ex ) {
210 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
213 // Update Python script
214 SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
217 //=============================================================================
219 * StdMeshers_NumberOfSegments_i::GetObjectEntry
221 * Set the Entry for the Main Object
223 //=============================================================================
225 char* StdMeshers_NumberOfSegments_i::GetObjectEntry()
227 ASSERT( myBaseImpl );
231 entry = this->GetImpl()->GetObjectEntry();
233 catch ( SALOME_Exception& S_ex ) {
234 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
237 return CORBA::string_dup( entry );
240 //=============================================================================
242 * StdMeshers_NumberOfSegments_i::GetReversedEdges
246 //=============================================================================
248 SMESH::long_array* StdMeshers_NumberOfSegments_i::GetReversedEdges()
250 MESSAGE( "StdMeshers_NumberOfSegments_i::GetReversedEdges" );
251 ASSERT( myBaseImpl );
252 SMESH::long_array_var anArray = new SMESH::long_array;
253 std::vector<int> ids = this->GetImpl()->GetReversedEdges();
254 anArray->length( ids.size() );
255 for ( size_t i = 0; i < ids.size(); i++)
256 anArray [ i ] = ids [ i ];
258 return anArray._retn();
261 //=============================================================================
264 //=============================================================================
266 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
267 throw ( SALOME::SALOME_Exception )
269 ASSERT( myBaseImpl );
271 CORBA::Long oldType = (CORBA::Long) this->GetImpl()->GetDistrType();
273 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
275 // Update Python script
276 if ( oldType != typ )
277 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
279 catch ( SALOME_Exception& S_ex ) {
280 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
285 //=============================================================================
288 //=============================================================================
290 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
292 ASSERT( myBaseImpl );
293 return this->GetImpl()->GetDistrType();
296 //=============================================================================
298 * StdMeshers_NumberOfSegments_i::SetScaleFactor
302 //=============================================================================
304 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
305 throw ( SALOME::SALOME_Exception )
307 ASSERT( myBaseImpl );
309 this->GetImpl()->SetScaleFactor( theScaleFactor );
310 // Update Python script
311 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << SMESH::TVar(theScaleFactor) << " )";
313 catch ( SALOME_Exception& S_ex ) {
314 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
319 //=============================================================================
321 * StdMeshers_NumberOfSegments_i::GetScaleFactor
325 //=============================================================================
327 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
328 throw ( SALOME::SALOME_Exception )
330 ASSERT( myBaseImpl );
333 scale = this->GetImpl()->GetScaleFactor();
335 catch ( SALOME_Exception& S_ex ) {
336 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
342 //=============================================================================
345 //=============================================================================
347 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
348 throw ( SALOME::SALOME_Exception )
350 ASSERT( myBaseImpl );
351 std::vector<double> tbl( table.length() );
352 for ( CORBA::ULong i = 0; i < table.length(); i++)
355 this->GetImpl()->SetTableFunction( tbl );
356 // Update Python script
357 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
359 catch ( SALOME_Exception& S_ex ) {
360 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
365 //=============================================================================
368 //=============================================================================
370 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
371 throw ( SALOME::SALOME_Exception )
373 ASSERT( myBaseImpl );
374 const std::vector<double>* tbl;
376 tbl = &this->GetImpl()->GetTableFunction();
378 catch ( SALOME_Exception& S_ex ) {
379 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
381 SMESH::double_array_var aRes = new SMESH::double_array();
382 aRes->length(tbl->size());
383 for ( size_t i = 0; i < tbl->size(); i++ )
388 //=============================================================================
391 //=============================================================================
393 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
394 throw ( SALOME::SALOME_Exception )
396 ASSERT( myBaseImpl );
398 this->GetImpl()->SetExpressionFunction( expr );
399 // Update Python script
400 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
402 catch ( SALOME_Exception& S_ex ) {
403 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
408 //=============================================================================
411 //=============================================================================
413 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
414 throw ( SALOME::SALOME_Exception )
416 ASSERT( myBaseImpl );
419 expr = this->GetImpl()->GetExpressionFunction();
421 catch ( SALOME_Exception& S_ex ) {
422 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
425 return CORBA::string_dup(expr);
428 //=============================================================================
431 //=============================================================================
433 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
434 throw ( SALOME::SALOME_Exception )
436 ASSERT( myBaseImpl );
438 this->GetImpl()->SetConversionMode( conv );
439 // Update Python script
440 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
442 catch ( SALOME_Exception& S_ex ) {
443 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
448 //=============================================================================
451 //=============================================================================
453 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
454 throw ( SALOME::SALOME_Exception )
456 ASSERT( myBaseImpl );
459 conv = this->GetImpl()->ConversionMode();
461 catch ( SALOME_Exception& S_ex ) {
462 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
468 //=============================================================================
470 * StdMeshers_NumberOfSegments_i::GetImpl
474 //=============================================================================
476 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
478 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
481 //================================================================================
483 * \brief Verify whether hypothesis supports given entity type
484 * \param type - dimension (see SMESH::Dimension enumeration)
485 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
487 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
489 //================================================================================
490 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
492 return type == SMESH::DIM_1D;
495 //================================================================================
497 * \brief Return method name corresponding to index of variable parameter
499 //================================================================================
501 std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramIndex, int ) const
503 return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";