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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : StdMeshers_NumberOfSegments_i.cxx
25 // Moved here from SMESH_NumberOfSegments_i.cxx
26 // Author : Paul RASCLE, EDF
31 #include "StdMeshers_NumberOfSegments_i.hxx"
32 #include "SMESH_Gen_i.hxx"
33 #include "SMESH_Gen.hxx"
34 #include "SMESH_PythonDump.hxx"
36 #include "Utils_CorbaException.hxx"
37 #include "utilities.h"
39 #include <TCollection_AsciiString.hxx>
41 //=============================================================================
43 * StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
47 //=============================================================================
49 StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
51 ::SMESH_Gen* theGenImpl )
52 : SALOME::GenericObj_i( thePOA ),
53 SMESH_Hypothesis_i( thePOA )
55 MESSAGE( "StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i" );
56 myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
61 //=============================================================================
63 * StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i
67 //=============================================================================
69 StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i()
71 MESSAGE( "StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i" );
74 //=============================================================================
76 * StdMeshers_NumberOfSegments_i::BuildDistribution
78 * Builds point distribution according to passed function
80 //=============================================================================
81 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionExpr( const char* func,
84 throw ( SALOME::SALOME_Exception )
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,
105 throw ( SALOME::SALOME_Exception )
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 ASSERT( myBaseImpl );
141 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
143 catch (SALOME_Exception& S_ex) {
144 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
148 // Update Python script
149 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << theSegmentsNumber << " )";
152 //=============================================================================
154 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
156 * Get number of segments
158 //=============================================================================
160 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
162 ASSERT( myBaseImpl );
163 return this->GetImpl()->GetNumberOfSegments();
166 //=============================================================================
169 //=============================================================================
171 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
172 throw ( SALOME::SALOME_Exception )
174 ASSERT( myBaseImpl );
176 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
178 // Update Python script
179 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
181 catch ( SALOME_Exception& S_ex ) {
182 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
187 //=============================================================================
190 //=============================================================================
192 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
194 ASSERT( myBaseImpl );
195 return this->GetImpl()->GetDistrType();
198 //=============================================================================
200 * StdMeshers_NumberOfSegments_i::SetScaleFactor
204 //=============================================================================
206 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
207 throw ( SALOME::SALOME_Exception )
209 ASSERT( myBaseImpl );
211 this->GetImpl()->SetScaleFactor( theScaleFactor );
212 // Update Python script
213 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << theScaleFactor << " )";
215 catch ( SALOME_Exception& S_ex ) {
216 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
221 //=============================================================================
223 * StdMeshers_NumberOfSegments_i::GetScaleFactor
227 //=============================================================================
229 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
230 throw ( SALOME::SALOME_Exception )
232 ASSERT( myBaseImpl );
235 scale = this->GetImpl()->GetScaleFactor();
237 catch ( SALOME_Exception& S_ex ) {
238 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
244 //=============================================================================
247 //=============================================================================
249 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
250 throw ( SALOME::SALOME_Exception )
252 ASSERT( myBaseImpl );
253 std::vector<double> tbl( table.length() );
254 for (int i = 0; i < table.length(); i++)
257 this->GetImpl()->SetTableFunction( tbl );
258 // Update Python script
259 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
261 catch ( SALOME_Exception& S_ex ) {
262 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
267 //=============================================================================
270 //=============================================================================
272 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
273 throw ( SALOME::SALOME_Exception )
275 ASSERT( myBaseImpl );
276 const std::vector<double>* tbl;
278 tbl = &this->GetImpl()->GetTableFunction();
280 catch ( SALOME_Exception& S_ex ) {
281 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
284 SMESH::double_array_var aRes = new SMESH::double_array();
285 aRes->length(tbl->size());
286 for (int 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;