1 // Copyright (C) 2007-2019 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,
79 throw ( SALOME::SALOME_Exception )
84 SMESH::double_array_var aRes = new SMESH::double_array();
85 const std::vector<double>& res = this->GetImpl()->BuildDistributionExpr( func, nbSeg, conv );
86 aRes->length( res.size() );
87 for (size_t i = 0; i < res.size(); i++)
91 catch( SALOME_Exception& S_ex )
93 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
98 StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
101 throw ( SALOME::SALOME_Exception )
103 ASSERT( myBaseImpl );
105 std::vector<double> tbl( func.length() );
106 for ( size_t i = 0; i < tbl.size(); i++ )
111 SMESH::double_array_var aRes = new SMESH::double_array();
112 const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
113 aRes->length( res.size() );
114 for (size_t i = 0; i < res.size(); i++)
118 catch( SALOME_Exception& S_ex )
120 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
124 //=============================================================================
126 * StdMeshers_NumberOfSegments_i::SetNumberOfSegments
128 * Set number of segments
130 //=============================================================================
132 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
133 throw ( SALOME::SALOME_Exception )
135 ASSERT( myBaseImpl );
137 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
139 catch (SALOME_Exception& S_ex) {
140 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
144 // Update Python script
145 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(theSegmentsNumber) << " )";
148 //=============================================================================
150 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
152 * Get number of segments
154 //=============================================================================
156 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
158 ASSERT( myBaseImpl );
159 return this->GetImpl()->GetNumberOfSegments();
162 //=============================================================================
165 //=============================================================================
167 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
168 throw ( SALOME::SALOME_Exception )
170 ASSERT( myBaseImpl );
172 CORBA::Long oldType = (CORBA::Long) this->GetImpl()->GetDistrType();
174 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
176 // Update Python script
177 if ( oldType != typ )
178 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
180 catch ( SALOME_Exception& S_ex ) {
181 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
186 //=============================================================================
189 //=============================================================================
191 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
193 ASSERT( myBaseImpl );
194 return this->GetImpl()->GetDistrType();
197 //=============================================================================
199 * StdMeshers_NumberOfSegments_i::SetScaleFactor
203 //=============================================================================
205 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
206 throw ( SALOME::SALOME_Exception )
208 ASSERT( myBaseImpl );
210 this->GetImpl()->SetScaleFactor( theScaleFactor );
211 // Update Python script
212 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << SMESH::TVar(theScaleFactor) << " )";
214 catch ( SALOME_Exception& S_ex ) {
215 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
220 //=============================================================================
222 * StdMeshers_NumberOfSegments_i::GetScaleFactor
226 //=============================================================================
228 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
229 throw ( SALOME::SALOME_Exception )
231 ASSERT( myBaseImpl );
234 scale = this->GetImpl()->GetScaleFactor();
236 catch ( SALOME_Exception& S_ex ) {
237 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
243 //=============================================================================
246 //=============================================================================
248 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
249 throw ( SALOME::SALOME_Exception )
251 ASSERT( myBaseImpl );
252 std::vector<double> tbl( table.length() );
253 for ( CORBA::ULong i = 0; i < table.length(); i++)
256 this->GetImpl()->SetTableFunction( tbl );
257 // Update Python script
258 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
260 catch ( SALOME_Exception& S_ex ) {
261 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
266 //=============================================================================
269 //=============================================================================
271 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
272 throw ( SALOME::SALOME_Exception )
274 ASSERT( myBaseImpl );
275 const std::vector<double>* tbl;
277 tbl = &this->GetImpl()->GetTableFunction();
279 catch ( SALOME_Exception& S_ex ) {
280 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
282 SMESH::double_array_var aRes = new SMESH::double_array();
283 aRes->length(tbl->size());
284 for ( size_t i = 0; i < tbl->size(); i++ )
289 //=============================================================================
292 //=============================================================================
294 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
295 throw ( SALOME::SALOME_Exception )
297 ASSERT( myBaseImpl );
299 this->GetImpl()->SetExpressionFunction( expr );
300 // Update Python script
301 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
303 catch ( SALOME_Exception& S_ex ) {
304 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
309 //=============================================================================
312 //=============================================================================
314 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
315 throw ( SALOME::SALOME_Exception )
317 ASSERT( myBaseImpl );
320 expr = this->GetImpl()->GetExpressionFunction();
322 catch ( SALOME_Exception& S_ex ) {
323 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
326 return CORBA::string_dup(expr);
329 //=============================================================================
332 //=============================================================================
334 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
335 throw ( SALOME::SALOME_Exception )
337 ASSERT( myBaseImpl );
339 this->GetImpl()->SetConversionMode( conv );
340 // Update Python script
341 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
343 catch ( SALOME_Exception& S_ex ) {
344 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
349 //=============================================================================
352 //=============================================================================
354 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
355 throw ( SALOME::SALOME_Exception )
357 ASSERT( myBaseImpl );
360 conv = this->GetImpl()->ConversionMode();
362 catch ( SALOME_Exception& S_ex ) {
363 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
369 //=============================================================================
371 * StdMeshers_NumberOfSegments_i::GetImpl
375 //=============================================================================
377 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
379 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
382 //================================================================================
384 * \brief Verify whether hypothesis supports given entity type
385 * \param type - dimension (see SMESH::Dimension enumeration)
386 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
388 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
390 //================================================================================
391 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
393 return type == SMESH::DIM_1D;
396 //================================================================================
398 * \brief Return method name corresponding to index of variable parameter
400 //================================================================================
402 std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramIndex, int ) const
404 return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";
408 //================================================================================
410 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
412 //================================================================================
415 StdMeshers_NumberOfSegments_i::getObjectsDependOn( std::vector< std::string > & entryArray,
416 std::vector< int > & subIDArray ) const
418 return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
421 //================================================================================
423 * \brief Set new geometry instead of that returned by getObjectsDependOn()
425 //================================================================================
428 StdMeshers_NumberOfSegments_i::setObjectsDependOn( std::vector< std::string > & entryArray,
429 std::vector< int > & subIDArray )
431 return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );