1 // Copyright (C) 2007-2011 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
30 #include "StdMeshers_NumberOfSegments_i.hxx"
31 #include "SMESH_Gen_i.hxx"
32 #include "SMESH_Gen.hxx"
33 #include "SMESH_PythonDump.hxx"
35 #include "Utils_CorbaException.hxx"
36 #include "utilities.h"
38 #include <TCollection_AsciiString.hxx>
41 //=============================================================================
43 * StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
47 //=============================================================================
49 StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
51 ::SMESH_Gen* theGenImpl )
52 : SALOME::GenericObj_i( thePOA ),
53 SMESH_Hypothesis_i( thePOA )
55 MESSAGE( "StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i" );
56 myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
61 //=============================================================================
63 * StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i
67 //=============================================================================
69 StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i()
71 MESSAGE( "StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i" );
74 //=============================================================================
76 * StdMeshers_NumberOfSegments_i::BuildDistribution
78 * Builds point distribution according to passed function
80 //=============================================================================
81 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionExpr( const char* func,
84 throw ( SALOME::SALOME_Exception )
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++)
96 catch( SALOME_Exception& S_ex )
98 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
102 SMESH::double_array* 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 (int i = 0; i < func.length(); 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 (int 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( " << 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 ( CORBA::Long 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 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
273 // Update Python script
274 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
276 catch ( SALOME_Exception& S_ex ) {
277 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
282 //=============================================================================
285 //=============================================================================
287 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
289 ASSERT( myBaseImpl );
290 return this->GetImpl()->GetDistrType();
293 //=============================================================================
295 * StdMeshers_NumberOfSegments_i::SetScaleFactor
299 //=============================================================================
301 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
302 throw ( SALOME::SALOME_Exception )
304 ASSERT( myBaseImpl );
306 this->GetImpl()->SetScaleFactor( theScaleFactor );
307 // Update Python script
308 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << theScaleFactor << " )";
310 catch ( SALOME_Exception& S_ex ) {
311 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
316 //=============================================================================
318 * StdMeshers_NumberOfSegments_i::GetScaleFactor
322 //=============================================================================
324 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
325 throw ( SALOME::SALOME_Exception )
327 ASSERT( myBaseImpl );
330 scale = this->GetImpl()->GetScaleFactor();
332 catch ( SALOME_Exception& S_ex ) {
333 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
339 //=============================================================================
342 //=============================================================================
344 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
345 throw ( SALOME::SALOME_Exception )
347 ASSERT( myBaseImpl );
348 std::vector<double> tbl( table.length() );
349 for (int i = 0; i < table.length(); i++)
352 this->GetImpl()->SetTableFunction( tbl );
353 // Update Python script
354 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
356 catch ( SALOME_Exception& S_ex ) {
357 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
362 //=============================================================================
365 //=============================================================================
367 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
368 throw ( SALOME::SALOME_Exception )
370 ASSERT( myBaseImpl );
371 const std::vector<double>* tbl;
373 tbl = &this->GetImpl()->GetTableFunction();
375 catch ( SALOME_Exception& S_ex ) {
376 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
379 SMESH::double_array_var aRes = new SMESH::double_array();
380 aRes->length(tbl->size());
381 for (int i = 0; i < tbl->size(); i++)
386 //=============================================================================
389 //=============================================================================
391 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
392 throw ( SALOME::SALOME_Exception )
394 ASSERT( myBaseImpl );
396 this->GetImpl()->SetExpressionFunction( expr );
397 // Update Python script
398 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
400 catch ( SALOME_Exception& S_ex ) {
401 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
406 //=============================================================================
409 //=============================================================================
411 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
412 throw ( SALOME::SALOME_Exception )
414 ASSERT( myBaseImpl );
417 expr = this->GetImpl()->GetExpressionFunction();
419 catch ( SALOME_Exception& S_ex ) {
420 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
423 return CORBA::string_dup(expr);
426 //=============================================================================
429 //=============================================================================
431 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
432 throw ( SALOME::SALOME_Exception )
434 ASSERT( myBaseImpl );
436 this->GetImpl()->SetConversionMode( conv );
437 // Update Python script
438 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
440 catch ( SALOME_Exception& S_ex ) {
441 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
446 //=============================================================================
449 //=============================================================================
451 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
452 throw ( SALOME::SALOME_Exception )
454 ASSERT( myBaseImpl );
457 conv = this->GetImpl()->ConversionMode();
459 catch ( SALOME_Exception& S_ex ) {
460 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
466 //=============================================================================
468 * StdMeshers_NumberOfSegments_i::GetImpl
472 //=============================================================================
474 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
476 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
479 //================================================================================
481 * \brief Verify whether hypothesis supports given entity type
482 * \param type - dimension (see SMESH::Dimension enumeration)
483 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
485 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
487 //================================================================================
488 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
490 return type == SMESH::DIM_1D;