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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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, long nbSeg, long conv )
83 throw ( SALOME::SALOME_Exception )
85 MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
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,
103 long nbSeg, long conv )
104 throw ( SALOME::SALOME_Exception )
106 MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
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 MESSAGE( "StdMeshers_NumberOfSegments_i::SetNumberOfSegments" );
140 ASSERT( myBaseImpl );
142 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
144 catch (SALOME_Exception& S_ex) {
145 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
149 // Update Python script
150 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << theSegmentsNumber << " )";
153 //=============================================================================
155 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
157 * Get number of segments
159 //=============================================================================
161 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
163 MESSAGE( "StdMeshers_NumberOfSegments_i::GetNumberOfSegments" );
164 ASSERT( myBaseImpl );
165 return this->GetImpl()->GetNumberOfSegments();
168 //=============================================================================
171 //=============================================================================
173 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
174 throw ( SALOME::SALOME_Exception )
176 MESSAGE( "StdMeshers_NumberOfSegments_i::SetDistrType" );
177 ASSERT( myBaseImpl );
179 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
181 // Update Python script
182 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
184 catch ( SALOME_Exception& S_ex ) {
185 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
190 //=============================================================================
193 //=============================================================================
195 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
197 MESSAGE( "StdMeshers_NumberOfSegments_i::GetDistrType" );
198 ASSERT( myBaseImpl );
199 return this->GetImpl()->GetDistrType();
202 //=============================================================================
204 * StdMeshers_NumberOfSegments_i::SetScaleFactor
208 //=============================================================================
210 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
211 throw ( SALOME::SALOME_Exception )
213 MESSAGE( "StdMeshers_NumberOfSegments_i::SetScaleFactor" );
214 ASSERT( myBaseImpl );
216 this->GetImpl()->SetScaleFactor( theScaleFactor );
217 // Update Python script
218 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << theScaleFactor << " )";
220 catch ( SALOME_Exception& S_ex ) {
221 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
226 //=============================================================================
228 * StdMeshers_NumberOfSegments_i::GetScaleFactor
232 //=============================================================================
234 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
235 throw ( SALOME::SALOME_Exception )
237 MESSAGE( "StdMeshers_NumberOfSegments_i::GetScaleFactor" );
238 ASSERT( myBaseImpl );
241 scale = this->GetImpl()->GetScaleFactor();
243 catch ( SALOME_Exception& S_ex ) {
244 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
250 //=============================================================================
253 //=============================================================================
255 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
256 throw ( SALOME::SALOME_Exception )
258 MESSAGE( "StdMeshers_NumberOfSegments_i::SetTableFunction" );
259 ASSERT( myBaseImpl );
260 std::vector<double> tbl( table.length() );
261 for (int i = 0; i < table.length(); i++)
264 this->GetImpl()->SetTableFunction( tbl );
265 // Update Python script
266 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
268 catch ( SALOME_Exception& S_ex ) {
269 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
274 //=============================================================================
277 //=============================================================================
279 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
280 throw ( SALOME::SALOME_Exception )
282 MESSAGE( "StdMeshers_NumberOfSegments_i::GetTableFunction" );
283 ASSERT( myBaseImpl );
284 const std::vector<double>* tbl;
286 tbl = &this->GetImpl()->GetTableFunction();
288 catch ( SALOME_Exception& S_ex ) {
289 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
292 SMESH::double_array_var aRes = new SMESH::double_array();
293 aRes->length(tbl->size());
294 for (int i = 0; i < tbl->size(); i++)
299 //=============================================================================
302 //=============================================================================
304 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
305 throw ( SALOME::SALOME_Exception )
307 MESSAGE( "StdMeshers_NumberOfSegments_i::SetExpressionFunction" );
308 ASSERT( myBaseImpl );
310 this->GetImpl()->SetExpressionFunction( expr );
311 // Update Python script
312 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( " << expr << " )";
314 catch ( SALOME_Exception& S_ex ) {
315 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
320 //=============================================================================
323 //=============================================================================
325 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
326 throw ( SALOME::SALOME_Exception )
328 MESSAGE( "StdMeshers_NumberOfSegments_i::GetExpressionFunction" );
329 ASSERT( myBaseImpl );
332 expr = this->GetImpl()->GetExpressionFunction();
334 catch ( SALOME_Exception& S_ex ) {
335 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
338 return CORBA::string_dup(expr);
341 //=============================================================================
344 //=============================================================================
346 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
347 throw ( SALOME::SALOME_Exception )
349 MESSAGE( "StdMeshers_NumberOfSegments_i::SetConversionMode" );
350 ASSERT( myBaseImpl );
352 this->GetImpl()->SetConversionMode( conv );
353 // Update Python script
354 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
356 catch ( SALOME_Exception& S_ex ) {
357 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
362 //=============================================================================
365 //=============================================================================
367 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
368 throw ( SALOME::SALOME_Exception )
370 MESSAGE( "StdMeshers_NumberOfSegments_i::ConversionMode" );
371 ASSERT( myBaseImpl );
374 conv = this->GetImpl()->ConversionMode();
376 catch ( SALOME_Exception& S_ex ) {
377 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
383 //=============================================================================
385 * StdMeshers_NumberOfSegments_i::GetImpl
389 //=============================================================================
391 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
393 MESSAGE( "StdMeshers_NumberOfSegments_i::GetImpl" );
394 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
397 //================================================================================
399 * \brief Verify whether hypothesis supports given entity type
400 * \param type - dimension (see SMESH::Dimension enumeration)
401 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
403 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
405 //================================================================================
406 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
408 return type == SMESH::DIM_1D;