1 // Copyright (C) 2007-2016 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 calsses
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,
49 ::SMESH_Gen* theGenImpl )
50 : SALOME::GenericObj_i( thePOA ),
51 SMESH_Hypothesis_i( thePOA ),
52 StdMeshers_Reversible1D_i( this )
54 myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
59 //=============================================================================
61 * StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i
65 //=============================================================================
67 StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i()
71 //=============================================================================
73 * StdMeshers_NumberOfSegments_i::BuildDistribution
75 * Builds point distribution according to passed function
77 //=============================================================================
78 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionExpr( const char* func,
81 throw ( SALOME::SALOME_Exception )
86 SMESH::double_array_var aRes = new SMESH::double_array();
87 const std::vector<double>& res = this->GetImpl()->BuildDistributionExpr( func, nbSeg, conv );
88 aRes->length( res.size() );
89 for (size_t i = 0; i < res.size(); i++)
93 catch( SALOME_Exception& S_ex )
95 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
100 StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
103 throw ( SALOME::SALOME_Exception )
105 ASSERT( myBaseImpl );
107 std::vector<double> tbl( func.length() );
108 for ( size_t i = 0; i < tbl.size(); i++ )
113 SMESH::double_array_var aRes = new SMESH::double_array();
114 const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
115 aRes->length( res.size() );
116 for (size_t i = 0; i < res.size(); i++)
120 catch( SALOME_Exception& S_ex )
122 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
126 //=============================================================================
128 * StdMeshers_NumberOfSegments_i::SetNumberOfSegments
130 * Set number of segments
132 //=============================================================================
134 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
135 throw ( SALOME::SALOME_Exception )
137 ASSERT( myBaseImpl );
139 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
141 catch (SALOME_Exception& S_ex) {
142 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
146 // Update Python script
147 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(theSegmentsNumber) << " )";
150 //=============================================================================
152 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
154 * Get number of segments
156 //=============================================================================
158 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
160 ASSERT( myBaseImpl );
161 return this->GetImpl()->GetNumberOfSegments();
164 //=============================================================================
167 //=============================================================================
169 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
170 throw ( SALOME::SALOME_Exception )
172 ASSERT( myBaseImpl );
174 CORBA::Long oldType = (CORBA::Long) this->GetImpl()->GetDistrType();
176 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
178 // Update Python script
179 if ( oldType != typ )
180 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
182 catch ( SALOME_Exception& S_ex ) {
183 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
188 //=============================================================================
191 //=============================================================================
193 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
195 ASSERT( myBaseImpl );
196 return this->GetImpl()->GetDistrType();
199 //=============================================================================
201 * StdMeshers_NumberOfSegments_i::SetScaleFactor
205 //=============================================================================
207 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
208 throw ( SALOME::SALOME_Exception )
210 ASSERT( myBaseImpl );
212 this->GetImpl()->SetScaleFactor( theScaleFactor );
213 // Update Python script
214 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << SMESH::TVar(theScaleFactor) << " )";
216 catch ( SALOME_Exception& S_ex ) {
217 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
222 //=============================================================================
224 * StdMeshers_NumberOfSegments_i::GetScaleFactor
228 //=============================================================================
230 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
231 throw ( SALOME::SALOME_Exception )
233 ASSERT( myBaseImpl );
236 scale = this->GetImpl()->GetScaleFactor();
238 catch ( SALOME_Exception& S_ex ) {
239 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
245 //=============================================================================
248 //=============================================================================
250 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
251 throw ( SALOME::SALOME_Exception )
253 ASSERT( myBaseImpl );
254 std::vector<double> tbl( table.length() );
255 for ( CORBA::ULong i = 0; i < table.length(); i++)
258 this->GetImpl()->SetTableFunction( tbl );
259 // Update Python script
260 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
262 catch ( SALOME_Exception& S_ex ) {
263 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
268 //=============================================================================
271 //=============================================================================
273 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
274 throw ( SALOME::SALOME_Exception )
276 ASSERT( myBaseImpl );
277 const std::vector<double>* tbl;
279 tbl = &this->GetImpl()->GetTableFunction();
281 catch ( SALOME_Exception& S_ex ) {
282 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
284 SMESH::double_array_var aRes = new SMESH::double_array();
285 aRes->length(tbl->size());
286 for ( size_t i = 0; i < tbl->size(); i++ )
291 //=============================================================================
294 //=============================================================================
296 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
297 throw ( SALOME::SALOME_Exception )
299 ASSERT( myBaseImpl );
301 this->GetImpl()->SetExpressionFunction( expr );
302 // Update Python script
303 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
305 catch ( SALOME_Exception& S_ex ) {
306 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
311 //=============================================================================
314 //=============================================================================
316 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
317 throw ( SALOME::SALOME_Exception )
319 ASSERT( myBaseImpl );
322 expr = this->GetImpl()->GetExpressionFunction();
324 catch ( SALOME_Exception& S_ex ) {
325 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
328 return CORBA::string_dup(expr);
331 //=============================================================================
334 //=============================================================================
336 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
337 throw ( SALOME::SALOME_Exception )
339 ASSERT( myBaseImpl );
341 this->GetImpl()->SetConversionMode( conv );
342 // Update Python script
343 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
345 catch ( SALOME_Exception& S_ex ) {
346 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
351 //=============================================================================
354 //=============================================================================
356 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
357 throw ( SALOME::SALOME_Exception )
359 ASSERT( myBaseImpl );
362 conv = this->GetImpl()->ConversionMode();
364 catch ( SALOME_Exception& S_ex ) {
365 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
371 //=============================================================================
373 * StdMeshers_NumberOfSegments_i::GetImpl
377 //=============================================================================
379 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
381 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
384 //================================================================================
386 * \brief Verify whether hypothesis supports given entity type
387 * \param type - dimension (see SMESH::Dimension enumeration)
388 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
390 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
392 //================================================================================
393 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
395 return type == SMESH::DIM_1D;
398 //================================================================================
400 * \brief Return method name corresponding to index of variable parameter
402 //================================================================================
404 std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramIndex, int ) const
406 return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";
410 //================================================================================
412 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
414 //================================================================================
417 StdMeshers_NumberOfSegments_i::getObjectsDependOn( std::vector< std::string > & entryArray,
418 std::vector< int > & subIDArray ) const
420 return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
423 //================================================================================
425 * \brief Set new geometry instead of that returned by getObjectsDependOn()
427 //================================================================================
430 StdMeshers_NumberOfSegments_i::setObjectsDependOn( std::vector< std::string > & entryArray,
431 std::vector< int > & subIDArray )
433 return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );