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, long nbSeg, long conv )
82 throw ( SALOME::SALOME_Exception )
84 MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
88 SMESH::double_array_var aRes = new SMESH::double_array();
89 const std::vector<double>& res = this->GetImpl()->BuildDistributionExpr( func, nbSeg, conv );
90 aRes->length( res.size() );
91 for (int i = 0; i < res.size(); i++)
95 catch( SALOME_Exception& S_ex )
97 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
101 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
102 long nbSeg, long conv )
103 throw ( SALOME::SALOME_Exception )
105 MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
106 ASSERT( myBaseImpl );
108 std::vector<double> tbl( func.length() );
109 for (int i = 0; i < func.length(); i++)
114 SMESH::double_array_var aRes = new SMESH::double_array();
115 const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
116 aRes->length( res.size() );
117 for (int i = 0; i < res.size(); i++)
121 catch( SALOME_Exception& S_ex )
123 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
127 //=============================================================================
129 * StdMeshers_NumberOfSegments_i::SetNumberOfSegments
131 * Set number of segments
133 //=============================================================================
135 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
136 throw ( SALOME::SALOME_Exception )
138 MESSAGE( "StdMeshers_NumberOfSegments_i::SetNumberOfSegments" );
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 MESSAGE( "StdMeshers_NumberOfSegments_i::GetNumberOfSegments" );
163 ASSERT( myBaseImpl );
164 return this->GetImpl()->GetNumberOfSegments();
167 //=============================================================================
170 //=============================================================================
172 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
173 throw ( SALOME::SALOME_Exception )
175 MESSAGE( "StdMeshers_NumberOfSegments_i::SetDistrType" );
176 ASSERT( myBaseImpl );
178 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
180 // Update Python script
181 SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
183 catch ( SALOME_Exception& S_ex ) {
184 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
189 //=============================================================================
192 //=============================================================================
194 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
196 MESSAGE( "StdMeshers_NumberOfSegments_i::GetDistrType" );
197 ASSERT( myBaseImpl );
198 return this->GetImpl()->GetDistrType();
201 //=============================================================================
203 * StdMeshers_NumberOfSegments_i::SetScaleFactor
207 //=============================================================================
209 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
210 throw ( SALOME::SALOME_Exception )
212 MESSAGE( "StdMeshers_NumberOfSegments_i::SetScaleFactor" );
213 ASSERT( myBaseImpl );
215 this->GetImpl()->SetScaleFactor( theScaleFactor );
216 // Update Python script
217 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << theScaleFactor << " )";
219 catch ( SALOME_Exception& S_ex ) {
220 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
225 //=============================================================================
227 * StdMeshers_NumberOfSegments_i::GetScaleFactor
231 //=============================================================================
233 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
234 throw ( SALOME::SALOME_Exception )
236 MESSAGE( "StdMeshers_NumberOfSegments_i::GetScaleFactor" );
237 ASSERT( myBaseImpl );
240 scale = this->GetImpl()->GetScaleFactor();
242 catch ( SALOME_Exception& S_ex ) {
243 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
249 //=============================================================================
252 //=============================================================================
254 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
255 throw ( SALOME::SALOME_Exception )
257 MESSAGE( "StdMeshers_NumberOfSegments_i::SetTableFunction" );
258 ASSERT( myBaseImpl );
259 std::vector<double> tbl( table.length() );
260 for (int i = 0; i < table.length(); i++)
263 this->GetImpl()->SetTableFunction( tbl );
264 // Update Python script
265 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
267 catch ( SALOME_Exception& S_ex ) {
268 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
273 //=============================================================================
276 //=============================================================================
278 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
279 throw ( SALOME::SALOME_Exception )
281 MESSAGE( "StdMeshers_NumberOfSegments_i::GetTableFunction" );
282 ASSERT( myBaseImpl );
283 const std::vector<double>* tbl;
285 tbl = &this->GetImpl()->GetTableFunction();
287 catch ( SALOME_Exception& S_ex ) {
288 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
291 SMESH::double_array_var aRes = new SMESH::double_array();
292 aRes->length(tbl->size());
293 for (int i = 0; i < tbl->size(); i++)
298 //=============================================================================
301 //=============================================================================
303 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
304 throw ( SALOME::SALOME_Exception )
306 MESSAGE( "StdMeshers_NumberOfSegments_i::SetExpressionFunction" );
307 ASSERT( myBaseImpl );
309 this->GetImpl()->SetExpressionFunction( expr );
310 // Update Python script
311 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
313 catch ( SALOME_Exception& S_ex ) {
314 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
319 //=============================================================================
322 //=============================================================================
324 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
325 throw ( SALOME::SALOME_Exception )
327 MESSAGE( "StdMeshers_NumberOfSegments_i::GetExpressionFunction" );
328 ASSERT( myBaseImpl );
331 expr = this->GetImpl()->GetExpressionFunction();
333 catch ( SALOME_Exception& S_ex ) {
334 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
337 return CORBA::string_dup(expr);
340 //=============================================================================
343 //=============================================================================
345 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
346 throw ( SALOME::SALOME_Exception )
348 MESSAGE( "StdMeshers_NumberOfSegments_i::SetConversionMode" );
349 ASSERT( myBaseImpl );
351 this->GetImpl()->SetConversionMode( conv );
352 // Update Python script
353 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
355 catch ( SALOME_Exception& S_ex ) {
356 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
361 //=============================================================================
364 //=============================================================================
366 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
367 throw ( SALOME::SALOME_Exception )
369 MESSAGE( "StdMeshers_NumberOfSegments_i::ConversionMode" );
370 ASSERT( myBaseImpl );
373 conv = this->GetImpl()->ConversionMode();
375 catch ( SALOME_Exception& S_ex ) {
376 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
382 //=============================================================================
384 * StdMeshers_NumberOfSegments_i::GetImpl
388 //=============================================================================
390 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
392 MESSAGE( "StdMeshers_NumberOfSegments_i::GetImpl" );
393 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
396 //================================================================================
398 * \brief Verify whether hypothesis supports given entity type
399 * \param type - dimension (see SMESH::Dimension enumeration)
400 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
402 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
404 //================================================================================
405 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
407 return type == SMESH::DIM_1D;