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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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 )
86 MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
90 SMESH::double_array_var aRes = new SMESH::double_array();
91 const std::vector<double>& res = this->GetImpl()->BuildDistributionExpr( func, nbSeg, conv );
92 aRes->length( res.size() );
93 for (int i = 0; i < res.size(); i++)
97 catch( SALOME_Exception& S_ex )
99 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
103 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
106 throw ( SALOME::SALOME_Exception )
108 MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
109 ASSERT( myBaseImpl );
111 std::vector<double> tbl( func.length() );
112 for (int i = 0; i < func.length(); i++)
117 SMESH::double_array_var aRes = new SMESH::double_array();
118 const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
119 aRes->length( res.size() );
120 for (int i = 0; i < res.size(); i++)
124 catch( SALOME_Exception& S_ex )
126 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
130 //=============================================================================
132 * StdMeshers_NumberOfSegments_i::SetNumberOfSegments
134 * Set number of segments
136 //=============================================================================
138 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
139 throw ( SALOME::SALOME_Exception )
141 MESSAGE( "StdMeshers_NumberOfSegments_i::SetNumberOfSegments" );
142 ASSERT( myBaseImpl );
144 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
146 catch (SALOME_Exception& S_ex) {
147 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
151 // Update Python script
152 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << theSegmentsNumber << " )";
155 //=============================================================================
157 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
159 * Get number of segments
161 //=============================================================================
163 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
165 MESSAGE( "StdMeshers_NumberOfSegments_i::GetNumberOfSegments" );
166 ASSERT( myBaseImpl );
167 return this->GetImpl()->GetNumberOfSegments();
170 //=============================================================================
173 //=============================================================================
175 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
176 throw ( SALOME::SALOME_Exception )
178 MESSAGE( "StdMeshers_NumberOfSegments_i::SetDistrType" );
179 ASSERT( myBaseImpl );
181 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
183 // Update Python script
184 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
186 catch ( SALOME_Exception& S_ex ) {
187 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
192 //=============================================================================
195 //=============================================================================
197 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
199 MESSAGE( "StdMeshers_NumberOfSegments_i::GetDistrType" );
200 ASSERT( myBaseImpl );
201 return this->GetImpl()->GetDistrType();
204 //=============================================================================
206 * StdMeshers_NumberOfSegments_i::SetScaleFactor
210 //=============================================================================
212 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
213 throw ( SALOME::SALOME_Exception )
215 MESSAGE( "StdMeshers_NumberOfSegments_i::SetScaleFactor" );
216 ASSERT( myBaseImpl );
218 this->GetImpl()->SetScaleFactor( theScaleFactor );
219 // Update Python script
220 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << theScaleFactor << " )";
222 catch ( SALOME_Exception& S_ex ) {
223 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
228 //=============================================================================
230 * StdMeshers_NumberOfSegments_i::GetScaleFactor
234 //=============================================================================
236 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
237 throw ( SALOME::SALOME_Exception )
239 MESSAGE( "StdMeshers_NumberOfSegments_i::GetScaleFactor" );
240 ASSERT( myBaseImpl );
243 scale = this->GetImpl()->GetScaleFactor();
245 catch ( SALOME_Exception& S_ex ) {
246 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
252 //=============================================================================
255 //=============================================================================
257 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
258 throw ( SALOME::SALOME_Exception )
260 MESSAGE( "StdMeshers_NumberOfSegments_i::SetTableFunction" );
261 ASSERT( myBaseImpl );
262 std::vector<double> tbl( table.length() );
263 for (int i = 0; i < table.length(); i++)
266 this->GetImpl()->SetTableFunction( tbl );
267 // Update Python script
268 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
270 catch ( SALOME_Exception& S_ex ) {
271 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
276 //=============================================================================
279 //=============================================================================
281 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
282 throw ( SALOME::SALOME_Exception )
284 MESSAGE( "StdMeshers_NumberOfSegments_i::GetTableFunction" );
285 ASSERT( myBaseImpl );
286 const std::vector<double>* tbl;
288 tbl = &this->GetImpl()->GetTableFunction();
290 catch ( SALOME_Exception& S_ex ) {
291 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
294 SMESH::double_array_var aRes = new SMESH::double_array();
295 aRes->length(tbl->size());
296 for (int i = 0; i < tbl->size(); i++)
301 //=============================================================================
304 //=============================================================================
306 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
307 throw ( SALOME::SALOME_Exception )
309 MESSAGE( "StdMeshers_NumberOfSegments_i::SetExpressionFunction" );
310 ASSERT( myBaseImpl );
312 this->GetImpl()->SetExpressionFunction( expr );
313 // Update Python script
314 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
316 catch ( SALOME_Exception& S_ex ) {
317 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
322 //=============================================================================
325 //=============================================================================
327 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
328 throw ( SALOME::SALOME_Exception )
330 MESSAGE( "StdMeshers_NumberOfSegments_i::GetExpressionFunction" );
331 ASSERT( myBaseImpl );
334 expr = this->GetImpl()->GetExpressionFunction();
336 catch ( SALOME_Exception& S_ex ) {
337 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
340 return CORBA::string_dup(expr);
343 //=============================================================================
346 //=============================================================================
348 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
349 throw ( SALOME::SALOME_Exception )
351 MESSAGE( "StdMeshers_NumberOfSegments_i::SetConversionMode" );
352 ASSERT( myBaseImpl );
354 this->GetImpl()->SetConversionMode( conv );
355 // Update Python script
356 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
358 catch ( SALOME_Exception& S_ex ) {
359 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
364 //=============================================================================
367 //=============================================================================
369 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
370 throw ( SALOME::SALOME_Exception )
372 MESSAGE( "StdMeshers_NumberOfSegments_i::ConversionMode" );
373 ASSERT( myBaseImpl );
376 conv = this->GetImpl()->ConversionMode();
378 catch ( SALOME_Exception& S_ex ) {
379 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
385 //=============================================================================
387 * StdMeshers_NumberOfSegments_i::GetImpl
391 //=============================================================================
393 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
395 MESSAGE( "StdMeshers_NumberOfSegments_i::GetImpl" );
396 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
399 //================================================================================
401 * \brief Verify whether hypothesis supports given entity type
402 * \param type - dimension (see SMESH::Dimension enumeration)
403 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
405 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
407 //================================================================================
408 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
410 return type == SMESH::DIM_1D;