1 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
3 // Copyright (C) 2003 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
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>
42 //=============================================================================
44 * StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
48 //=============================================================================
50 StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
52 ::SMESH_Gen* theGenImpl )
53 : SALOME::GenericObj_i( thePOA ),
54 SMESH_Hypothesis_i( thePOA )
56 MESSAGE( "StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i" );
57 myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
62 //=============================================================================
64 * StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i
68 //=============================================================================
70 StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i()
72 MESSAGE( "StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i" );
75 //=============================================================================
77 * StdMeshers_NumberOfSegments_i::BuildDistribution
79 * Builds point distribution according to passed function
81 //=============================================================================
82 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionExpr( const char* func,
85 throw ( SALOME::SALOME_Exception )
87 MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
91 SMESH::double_array_var aRes = new SMESH::double_array();
92 const std::vector<double>& res = this->GetImpl()->BuildDistributionExpr( func, nbSeg, conv );
93 aRes->length( res.size() );
94 for (int i = 0; i < res.size(); i++)
98 catch( SALOME_Exception& S_ex )
100 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
104 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
107 throw ( SALOME::SALOME_Exception )
109 MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
110 ASSERT( myBaseImpl );
112 std::vector<double> tbl( func.length() );
113 for (int i = 0; i < func.length(); i++)
118 SMESH::double_array_var aRes = new SMESH::double_array();
119 const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
120 aRes->length( res.size() );
121 for (int i = 0; i < res.size(); i++)
125 catch( SALOME_Exception& S_ex )
127 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
131 //=============================================================================
133 * StdMeshers_NumberOfSegments_i::SetNumberOfSegments
135 * Set number of segments
137 //=============================================================================
139 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
140 throw ( SALOME::SALOME_Exception )
142 MESSAGE( "StdMeshers_NumberOfSegments_i::SetNumberOfSegments" );
143 ASSERT( myBaseImpl );
145 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
147 catch (SALOME_Exception& S_ex) {
148 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
152 // Update Python script
153 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << theSegmentsNumber << " )";
156 //=============================================================================
158 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
160 * Get number of segments
162 //=============================================================================
164 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
166 MESSAGE( "StdMeshers_NumberOfSegments_i::GetNumberOfSegments" );
167 ASSERT( myBaseImpl );
168 return this->GetImpl()->GetNumberOfSegments();
171 //=============================================================================
174 //=============================================================================
176 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
177 throw ( SALOME::SALOME_Exception )
179 MESSAGE( "StdMeshers_NumberOfSegments_i::SetDistrType" );
180 ASSERT( myBaseImpl );
182 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
184 // Update Python script
185 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
187 catch ( SALOME_Exception& S_ex ) {
188 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
193 //=============================================================================
196 //=============================================================================
198 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
200 MESSAGE( "StdMeshers_NumberOfSegments_i::GetDistrType" );
201 ASSERT( myBaseImpl );
202 return this->GetImpl()->GetDistrType();
205 //=============================================================================
207 * StdMeshers_NumberOfSegments_i::SetScaleFactor
211 //=============================================================================
213 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
214 throw ( SALOME::SALOME_Exception )
216 MESSAGE( "StdMeshers_NumberOfSegments_i::SetScaleFactor" );
217 ASSERT( myBaseImpl );
219 this->GetImpl()->SetScaleFactor( theScaleFactor );
220 // Update Python script
221 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << theScaleFactor << " )";
223 catch ( SALOME_Exception& S_ex ) {
224 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
229 //=============================================================================
231 * StdMeshers_NumberOfSegments_i::GetScaleFactor
235 //=============================================================================
237 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
238 throw ( SALOME::SALOME_Exception )
240 MESSAGE( "StdMeshers_NumberOfSegments_i::GetScaleFactor" );
241 ASSERT( myBaseImpl );
244 scale = this->GetImpl()->GetScaleFactor();
246 catch ( SALOME_Exception& S_ex ) {
247 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
253 //=============================================================================
256 //=============================================================================
258 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
259 throw ( SALOME::SALOME_Exception )
261 MESSAGE( "StdMeshers_NumberOfSegments_i::SetTableFunction" );
262 ASSERT( myBaseImpl );
263 std::vector<double> tbl( table.length() );
264 for (int i = 0; i < table.length(); i++)
267 this->GetImpl()->SetTableFunction( tbl );
268 // Update Python script
269 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
271 catch ( SALOME_Exception& S_ex ) {
272 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
277 //=============================================================================
280 //=============================================================================
282 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
283 throw ( SALOME::SALOME_Exception )
285 MESSAGE( "StdMeshers_NumberOfSegments_i::GetTableFunction" );
286 ASSERT( myBaseImpl );
287 const std::vector<double>* tbl;
289 tbl = &this->GetImpl()->GetTableFunction();
291 catch ( SALOME_Exception& S_ex ) {
292 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
295 SMESH::double_array_var aRes = new SMESH::double_array();
296 aRes->length(tbl->size());
297 for (int i = 0; i < tbl->size(); i++)
302 //=============================================================================
305 //=============================================================================
307 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
308 throw ( SALOME::SALOME_Exception )
310 MESSAGE( "StdMeshers_NumberOfSegments_i::SetExpressionFunction" );
311 ASSERT( myBaseImpl );
313 this->GetImpl()->SetExpressionFunction( expr );
314 // Update Python script
315 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
317 catch ( SALOME_Exception& S_ex ) {
318 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
323 //=============================================================================
326 //=============================================================================
328 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
329 throw ( SALOME::SALOME_Exception )
331 MESSAGE( "StdMeshers_NumberOfSegments_i::GetExpressionFunction" );
332 ASSERT( myBaseImpl );
335 expr = this->GetImpl()->GetExpressionFunction();
337 catch ( SALOME_Exception& S_ex ) {
338 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
341 return CORBA::string_dup(expr);
344 //=============================================================================
347 //=============================================================================
349 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
350 throw ( SALOME::SALOME_Exception )
352 MESSAGE( "StdMeshers_NumberOfSegments_i::SetConversionMode" );
353 ASSERT( myBaseImpl );
355 this->GetImpl()->SetConversionMode( conv );
356 // Update Python script
357 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
359 catch ( SALOME_Exception& S_ex ) {
360 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
365 //=============================================================================
368 //=============================================================================
370 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
371 throw ( SALOME::SALOME_Exception )
373 MESSAGE( "StdMeshers_NumberOfSegments_i::ConversionMode" );
374 ASSERT( myBaseImpl );
377 conv = this->GetImpl()->ConversionMode();
379 catch ( SALOME_Exception& S_ex ) {
380 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
386 //=============================================================================
388 * StdMeshers_NumberOfSegments_i::GetImpl
392 //=============================================================================
394 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
396 MESSAGE( "StdMeshers_NumberOfSegments_i::GetImpl" );
397 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
400 //================================================================================
402 * \brief Verify whether hypothesis supports given entity type
403 * \param type - dimension (see SMESH::Dimension enumeration)
404 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
406 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
408 //================================================================================
409 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
411 return type == SMESH::DIM_1D;