1 // Copyright (C) 2007-2024 CEA, EDF, 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>
39 //=============================================================================
41 * StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
45 //=============================================================================
47 StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
48 ::SMESH_Gen* theGenImpl )
49 : SALOME::GenericObj_i( thePOA ),
50 SMESH_Hypothesis_i( thePOA ),
51 StdMeshers_Reversible1D_i( this )
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,
83 SMESH::double_array_var aRes = new SMESH::double_array();
84 const std::vector<double>& res = this->GetImpl()->BuildDistributionExpr( func, nbSeg, conv );
85 aRes->length( res.size() );
86 for (size_t i = 0; i < res.size(); i++)
90 catch( SALOME_Exception& S_ex )
92 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
97 StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
101 ASSERT( myBaseImpl );
103 std::vector<double> tbl( func.length() );
104 for ( size_t i = 0; i < tbl.size(); i++ )
109 SMESH::double_array_var aRes = new SMESH::double_array();
110 const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
111 aRes->length( res.size() );
112 for (size_t i = 0; i < res.size(); i++)
116 catch( SALOME_Exception& S_ex )
118 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
122 //=============================================================================
124 * StdMeshers_NumberOfSegments_i::SetNumberOfSegments
126 * Set number of segments
128 //=============================================================================
130 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( SMESH::smIdType theSegmentsNumber )
132 ASSERT( myBaseImpl );
134 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
136 catch (SALOME_Exception& S_ex) {
137 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
141 // Update Python script
142 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(theSegmentsNumber) << " )";
145 //=============================================================================
147 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
149 * Get number of segments
151 //=============================================================================
153 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
155 ASSERT( myBaseImpl );
156 return this->GetImpl()->GetNumberOfSegments();
159 //=============================================================================
162 //=============================================================================
164 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
166 ASSERT( myBaseImpl );
168 CORBA::Long oldType = (CORBA::Long) this->GetImpl()->GetDistrType();
170 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
172 // Update Python script
173 if ( oldType != typ )
174 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
176 catch ( SALOME_Exception& S_ex ) {
177 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
182 //=============================================================================
185 //=============================================================================
187 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
189 ASSERT( myBaseImpl );
190 return this->GetImpl()->GetDistrType();
193 //=============================================================================
195 * StdMeshers_NumberOfSegments_i::SetScaleFactor
199 //=============================================================================
201 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
203 ASSERT( myBaseImpl );
205 this->GetImpl()->SetScaleFactor( theScaleFactor );
206 // Update Python script
207 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << SMESH::TVar(theScaleFactor) << " )";
209 catch ( SALOME_Exception& S_ex ) {
210 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
215 //=============================================================================
217 * StdMeshers_NumberOfSegments_i::GetScaleFactor
221 //=============================================================================
223 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
225 ASSERT( myBaseImpl );
228 scale = this->GetImpl()->GetScaleFactor();
230 catch ( SALOME_Exception& S_ex ) {
231 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
237 //=============================================================================
239 * StdMeshers_NumberOfSegments_i::SetBeta
241 * Set beta coefficient for Beta Law distribution
243 //=============================================================================
245 void StdMeshers_NumberOfSegments_i::SetBeta(CORBA::Double beta)
249 this->GetImpl()->SetBeta(beta);
250 // Update Python script
251 SMESH::TPythonDump() << _this() << ".SetBeta( " << SMESH::TVar(beta) << " )";
253 catch (SALOME_Exception& S_ex) {
254 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
258 //=============================================================================
260 * StdMeshers_NumberOfSegments_i::GetBeta
262 * Get beta coefficient for Beta Law distribution
264 //=============================================================================
266 CORBA::Double StdMeshers_NumberOfSegments_i::GetBeta()
272 beta = this->GetImpl()->GetBeta();
274 catch (SALOME_Exception& S_ex) {
275 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
281 //=============================================================================
284 //=============================================================================
286 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
288 ASSERT( myBaseImpl );
289 std::vector<double> tbl( table.length() );
290 for ( CORBA::ULong i = 0; i < table.length(); i++)
293 this->GetImpl()->SetTableFunction( tbl );
294 // Update Python script
295 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
297 catch ( SALOME_Exception& S_ex ) {
298 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
303 //=============================================================================
306 //=============================================================================
308 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
310 ASSERT( myBaseImpl );
311 const std::vector<double>* tbl;
313 tbl = &this->GetImpl()->GetTableFunction();
315 catch ( SALOME_Exception& S_ex ) {
316 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
318 SMESH::double_array_var aRes = new SMESH::double_array();
319 aRes->length(tbl->size());
320 for ( size_t i = 0; i < tbl->size(); i++ )
325 //=============================================================================
328 //=============================================================================
330 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
332 ASSERT( myBaseImpl );
334 this->GetImpl()->SetExpressionFunction( expr );
335 // Update Python script
336 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
338 catch ( SALOME_Exception& S_ex ) {
339 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
344 //=============================================================================
347 //=============================================================================
349 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
351 ASSERT( myBaseImpl );
354 expr = this->GetImpl()->GetExpressionFunction();
356 catch ( SALOME_Exception& S_ex ) {
357 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
360 return CORBA::string_dup(expr);
363 //=============================================================================
366 //=============================================================================
368 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
370 ASSERT( myBaseImpl );
372 this->GetImpl()->SetConversionMode( conv );
373 // Update Python script
374 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
376 catch ( SALOME_Exception& S_ex ) {
377 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
382 //=============================================================================
385 //=============================================================================
387 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
389 ASSERT( myBaseImpl );
392 conv = this->GetImpl()->ConversionMode();
394 catch ( SALOME_Exception& S_ex ) {
395 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
401 //=============================================================================
403 * StdMeshers_NumberOfSegments_i::GetImpl
407 //=============================================================================
409 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
411 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
414 //================================================================================
416 * \brief Verify whether hypothesis supports given entity type
417 * \param type - dimension (see SMESH::Dimension enumeration)
418 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
420 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
422 //================================================================================
423 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
425 return type == SMESH::DIM_1D;
428 //================================================================================
430 * \brief Return method name corresponding to index of variable parameter
432 //================================================================================
434 std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramIndex, int ) const
436 return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";
440 //================================================================================
442 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
444 //================================================================================
447 StdMeshers_NumberOfSegments_i::getObjectsDependOn( std::vector< std::string > & entryArray,
448 std::vector< int > & subIDArray ) const
450 return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
453 //================================================================================
455 * \brief Set new geometry instead of that returned by getObjectsDependOn()
457 //================================================================================
460 StdMeshers_NumberOfSegments_i::setObjectsDependOn( std::vector< std::string > & entryArray,
461 std::vector< int > & subIDArray )
463 return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );