1 // Copyright (C) 2007-2016 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 classes
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,
49 ::SMESH_Gen* theGenImpl )
50 : SALOME::GenericObj_i( thePOA ),
51 SMESH_Hypothesis_i( thePOA )
53 myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
57 //=============================================================================
59 * StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i
63 //=============================================================================
65 StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i()
69 //=============================================================================
71 * StdMeshers_NumberOfSegments_i::BuildDistribution
73 * Builds point distribution according to passed function
75 //=============================================================================
76 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionExpr( const char* func,
79 throw ( SALOME::SALOME_Exception )
84 SMESH::double_array_var aRes = new SMESH::double_array();
85 const std::vector<double>& res = this->GetImpl()->BuildDistributionExpr( func, nbSeg, conv );
86 aRes->length( res.size() );
87 for (size_t i = 0; i < res.size(); i++)
91 catch( SALOME_Exception& S_ex )
93 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
98 StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
101 throw ( SALOME::SALOME_Exception )
103 ASSERT( myBaseImpl );
105 std::vector<double> tbl( func.length() );
106 for ( size_t i = 0; i < tbl.size(); i++ )
111 SMESH::double_array_var aRes = new SMESH::double_array();
112 const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
113 aRes->length( res.size() );
114 for (size_t i = 0; i < res.size(); i++)
118 catch( SALOME_Exception& S_ex )
120 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
124 //=============================================================================
126 * StdMeshers_NumberOfSegments_i::SetNumberOfSegments
128 * Set number of segments
130 //=============================================================================
132 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
133 throw ( SALOME::SALOME_Exception )
135 ASSERT( myBaseImpl );
137 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
139 catch (SALOME_Exception& S_ex) {
140 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
144 // Update Python script
145 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(theSegmentsNumber) << " )";
148 //=============================================================================
150 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
152 * Get number of segments
154 //=============================================================================
156 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
158 ASSERT( myBaseImpl );
159 return this->GetImpl()->GetNumberOfSegments();
162 //=============================================================================
164 * StdMeshers_NumberOfSegments_i::SetReversedEdges
166 * Set edges to reverse
168 //=============================================================================
170 void StdMeshers_NumberOfSegments_i::SetReversedEdges( const SMESH::long_array& theIds )
172 ASSERT( myBaseImpl );
174 std::vector<int> ids( theIds.length() );
175 CORBA::Long iEnd = theIds.length();
176 for ( CORBA::Long i = 0; i < iEnd; i++ )
177 ids[ i ] = theIds[ i ];
179 this->GetImpl()->SetReversedEdges( ids );
181 catch ( SALOME_Exception& S_ex ) {
182 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
186 // Update Python script
187 SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
190 //=============================================================================
192 * StdMeshers_NumberOfSegments_i::SetObjectEntry
194 * Set the Entry for the Main Object
196 //=============================================================================
198 void StdMeshers_NumberOfSegments_i::SetObjectEntry( const char* theEntry )
200 ASSERT( myBaseImpl );
201 string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
203 this->GetImpl()->SetObjectEntry( entry.c_str() );
205 catch ( SALOME_Exception& S_ex ) {
206 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
209 // Update Python script
210 SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
213 //=============================================================================
215 * StdMeshers_NumberOfSegments_i::GetObjectEntry
217 * Set the Entry for the Main Object
219 //=============================================================================
221 char* StdMeshers_NumberOfSegments_i::GetObjectEntry()
223 ASSERT( myBaseImpl );
227 entry = this->GetImpl()->GetObjectEntry();
229 catch ( SALOME_Exception& S_ex ) {
230 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
233 return CORBA::string_dup( entry );
236 //=============================================================================
238 * StdMeshers_NumberOfSegments_i::GetReversedEdges
242 //=============================================================================
244 SMESH::long_array* StdMeshers_NumberOfSegments_i::GetReversedEdges()
246 ASSERT( myBaseImpl );
247 SMESH::long_array_var anArray = new SMESH::long_array;
248 std::vector<int> ids = this->GetImpl()->GetReversedEdges();
249 anArray->length( ids.size() );
250 for ( size_t i = 0; i < ids.size(); i++)
251 anArray [ i ] = ids [ i ];
253 return anArray._retn();
256 //=============================================================================
259 //=============================================================================
261 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
262 throw ( SALOME::SALOME_Exception )
264 ASSERT( myBaseImpl );
266 CORBA::Long oldType = (CORBA::Long) this->GetImpl()->GetDistrType();
268 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
270 // Update Python script
271 if ( oldType != typ )
272 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
274 catch ( SALOME_Exception& S_ex ) {
275 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
280 //=============================================================================
283 //=============================================================================
285 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
287 ASSERT( myBaseImpl );
288 return this->GetImpl()->GetDistrType();
291 //=============================================================================
293 * StdMeshers_NumberOfSegments_i::SetScaleFactor
297 //=============================================================================
299 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
300 throw ( SALOME::SALOME_Exception )
302 ASSERT( myBaseImpl );
304 this->GetImpl()->SetScaleFactor( theScaleFactor );
305 // Update Python script
306 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << SMESH::TVar(theScaleFactor) << " )";
308 catch ( SALOME_Exception& S_ex ) {
309 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
314 //=============================================================================
316 * StdMeshers_NumberOfSegments_i::GetScaleFactor
320 //=============================================================================
322 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
323 throw ( SALOME::SALOME_Exception )
325 ASSERT( myBaseImpl );
328 scale = this->GetImpl()->GetScaleFactor();
330 catch ( SALOME_Exception& S_ex ) {
331 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
337 //=============================================================================
340 //=============================================================================
342 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
343 throw ( SALOME::SALOME_Exception )
345 ASSERT( myBaseImpl );
346 std::vector<double> tbl( table.length() );
347 for ( CORBA::ULong i = 0; i < table.length(); i++)
350 this->GetImpl()->SetTableFunction( tbl );
351 // Update Python script
352 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
354 catch ( SALOME_Exception& S_ex ) {
355 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
360 //=============================================================================
363 //=============================================================================
365 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
366 throw ( SALOME::SALOME_Exception )
368 ASSERT( myBaseImpl );
369 const std::vector<double>* tbl;
371 tbl = &this->GetImpl()->GetTableFunction();
373 catch ( SALOME_Exception& S_ex ) {
374 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
376 SMESH::double_array_var aRes = new SMESH::double_array();
377 aRes->length(tbl->size());
378 for ( size_t i = 0; i < tbl->size(); i++ )
383 //=============================================================================
386 //=============================================================================
388 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
389 throw ( SALOME::SALOME_Exception )
391 ASSERT( myBaseImpl );
393 this->GetImpl()->SetExpressionFunction( expr );
394 // Update Python script
395 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
397 catch ( SALOME_Exception& S_ex ) {
398 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
403 //=============================================================================
406 //=============================================================================
408 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
409 throw ( SALOME::SALOME_Exception )
411 ASSERT( myBaseImpl );
414 expr = this->GetImpl()->GetExpressionFunction();
416 catch ( SALOME_Exception& S_ex ) {
417 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
420 return CORBA::string_dup(expr);
423 //=============================================================================
426 //=============================================================================
428 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
429 throw ( SALOME::SALOME_Exception )
431 ASSERT( myBaseImpl );
433 this->GetImpl()->SetConversionMode( conv );
434 // Update Python script
435 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
437 catch ( SALOME_Exception& S_ex ) {
438 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
443 //=============================================================================
446 //=============================================================================
448 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
449 throw ( SALOME::SALOME_Exception )
451 ASSERT( myBaseImpl );
454 conv = this->GetImpl()->ConversionMode();
456 catch ( SALOME_Exception& S_ex ) {
457 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
463 //=============================================================================
465 * StdMeshers_NumberOfSegments_i::GetImpl
469 //=============================================================================
471 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
473 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
476 //================================================================================
478 * \brief Verify whether hypothesis supports given entity type
479 * \param type - dimension (see SMESH::Dimension enumeration)
480 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
482 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
484 //================================================================================
485 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
487 return type == SMESH::DIM_1D;
490 //================================================================================
492 * \brief Return method name corresponding to index of variable parameter
494 //================================================================================
496 std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramIndex, int ) const
498 return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";