1 // Copyright (C) 2007-2021 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, 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 //=============================================================================
240 //=============================================================================
242 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
244 ASSERT( myBaseImpl );
245 std::vector<double> tbl( table.length() );
246 for ( CORBA::ULong i = 0; i < table.length(); i++)
249 this->GetImpl()->SetTableFunction( tbl );
250 // Update Python script
251 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
253 catch ( SALOME_Exception& S_ex ) {
254 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
259 //=============================================================================
262 //=============================================================================
264 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
266 ASSERT( myBaseImpl );
267 const std::vector<double>* tbl;
269 tbl = &this->GetImpl()->GetTableFunction();
271 catch ( SALOME_Exception& S_ex ) {
272 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
274 SMESH::double_array_var aRes = new SMESH::double_array();
275 aRes->length(tbl->size());
276 for ( size_t i = 0; i < tbl->size(); i++ )
281 //=============================================================================
284 //=============================================================================
286 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
288 ASSERT( myBaseImpl );
290 this->GetImpl()->SetExpressionFunction( expr );
291 // Update Python script
292 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
294 catch ( SALOME_Exception& S_ex ) {
295 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
300 //=============================================================================
303 //=============================================================================
305 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
307 ASSERT( myBaseImpl );
310 expr = this->GetImpl()->GetExpressionFunction();
312 catch ( SALOME_Exception& S_ex ) {
313 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
316 return CORBA::string_dup(expr);
319 //=============================================================================
322 //=============================================================================
324 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
326 ASSERT( myBaseImpl );
328 this->GetImpl()->SetConversionMode( conv );
329 // Update Python script
330 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
332 catch ( SALOME_Exception& S_ex ) {
333 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
338 //=============================================================================
341 //=============================================================================
343 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
345 ASSERT( myBaseImpl );
348 conv = this->GetImpl()->ConversionMode();
350 catch ( SALOME_Exception& S_ex ) {
351 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
357 //=============================================================================
359 * StdMeshers_NumberOfSegments_i::GetImpl
363 //=============================================================================
365 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
367 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
370 //================================================================================
372 * \brief Verify whether hypothesis supports given entity type
373 * \param type - dimension (see SMESH::Dimension enumeration)
374 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
376 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
378 //================================================================================
379 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
381 return type == SMESH::DIM_1D;
384 //================================================================================
386 * \brief Return method name corresponding to index of variable parameter
388 //================================================================================
390 std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramIndex, int ) const
392 return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";
396 //================================================================================
398 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
400 //================================================================================
403 StdMeshers_NumberOfSegments_i::getObjectsDependOn( std::vector< std::string > & entryArray,
404 std::vector< int > & subIDArray ) const
406 return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
409 //================================================================================
411 * \brief Set new geometry instead of that returned by getObjectsDependOn()
413 //================================================================================
416 StdMeshers_NumberOfSegments_i::setObjectsDependOn( std::vector< std::string > & entryArray,
417 std::vector< int > & subIDArray )
419 return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );