1 // Copyright (C) 2007-2008 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
22 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
23 // File : StdMeshers_NumberOfSegments_i.cxx
24 // Moved here from SMESH_NumberOfSegments_i.cxx
25 // 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( " << 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 MESSAGE( "StdMeshers_NumberOfSegments_i::SetReversedEdges" );
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() << ".SetEdgesToReverse( "
192 << theList << " )";*/
195 //=============================================================================
197 * StdMeshers_NumberOfSegments_i::SetObjectEntry
199 * Set the Entry for the Main Object
201 //=============================================================================
203 void StdMeshers_NumberOfSegments_i::SetObjectEntry( const char* entry )
205 MESSAGE( "StdMeshers_NumberOfSegments_i::SetObjectEntry" );
206 ASSERT( myBaseImpl );
209 this->GetImpl()->SetObjectEntry( entry );
210 // Update Python script
211 // SMESH::TPythonDump() << _this() << ".SetObjectEntry( '" << entry << "' )";
213 catch ( SALOME_Exception& S_ex ) {
214 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
219 //=============================================================================
221 * StdMeshers_NumberOfSegments_i::GetObjectEntry
223 * Set the Entry for the Main Object
225 //=============================================================================
227 char* StdMeshers_NumberOfSegments_i::GetObjectEntry()
229 MESSAGE( "StdMeshers_NumberOfSegments_i::SetObjectEntry" );
230 ASSERT( myBaseImpl );
234 entry = this->GetImpl()->GetObjectEntry();
236 catch ( SALOME_Exception& S_ex ) {
237 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
240 return CORBA::string_dup( entry );
243 //=============================================================================
245 * StdMeshers_NumberOfSegments_i::GetReversedEdges
249 //=============================================================================
251 SMESH::long_array* StdMeshers_NumberOfSegments_i::GetReversedEdges()
253 MESSAGE( "StdMeshers_NumberOfSegments_i::GetReversedEdges" );
254 ASSERT( myBaseImpl );
255 SMESH::long_array_var anArray = new SMESH::long_array;
256 std::vector<int> ids = this->GetImpl()->GetReversedEdges();
257 anArray->length( ids.size() );
258 for ( CORBA::Long i = 0; i < ids.size(); i++)
259 anArray [ i ] = ids [ i ];
261 return anArray._retn();
264 //=============================================================================
267 //=============================================================================
269 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
270 throw ( SALOME::SALOME_Exception )
272 ASSERT( myBaseImpl );
274 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
276 // Update Python script
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( " << 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 (int 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(),
382 SMESH::double_array_var aRes = new SMESH::double_array();
383 aRes->length(tbl->size());
384 for (int i = 0; i < tbl->size(); i++)
389 //=============================================================================
392 //=============================================================================
394 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
395 throw ( SALOME::SALOME_Exception )
397 ASSERT( myBaseImpl );
399 this->GetImpl()->SetExpressionFunction( expr );
400 // Update Python script
401 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
403 catch ( SALOME_Exception& S_ex ) {
404 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
409 //=============================================================================
412 //=============================================================================
414 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
415 throw ( SALOME::SALOME_Exception )
417 ASSERT( myBaseImpl );
420 expr = this->GetImpl()->GetExpressionFunction();
422 catch ( SALOME_Exception& S_ex ) {
423 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
426 return CORBA::string_dup(expr);
429 //=============================================================================
432 //=============================================================================
434 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
435 throw ( SALOME::SALOME_Exception )
437 ASSERT( myBaseImpl );
439 this->GetImpl()->SetConversionMode( conv );
440 // Update Python script
441 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
443 catch ( SALOME_Exception& S_ex ) {
444 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
449 //=============================================================================
452 //=============================================================================
454 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
455 throw ( SALOME::SALOME_Exception )
457 ASSERT( myBaseImpl );
460 conv = this->GetImpl()->ConversionMode();
462 catch ( SALOME_Exception& S_ex ) {
463 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
469 //=============================================================================
471 * StdMeshers_NumberOfSegments_i::GetImpl
475 //=============================================================================
477 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
479 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
482 //================================================================================
484 * \brief Verify whether hypothesis supports given entity type
485 * \param type - dimension (see SMESH::Dimension enumeration)
486 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
488 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
490 //================================================================================
491 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
493 return type == SMESH::DIM_1D;