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
30 #include "StdMeshers_NumberOfSegments_i.hxx"
31 #include "SMESH_Gen_i.hxx"
32 #include "SMESH_Gen.hxx"
33 #include "SMESH_PythonDump.hxx"
35 #include "Utils_CorbaException.hxx"
36 #include "utilities.h"
38 #include <TCollection_AsciiString.hxx>
42 //=============================================================================
44 * StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
48 //=============================================================================
50 StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
52 ::SMESH_Gen* theGenImpl )
53 : SALOME::GenericObj_i( thePOA ),
54 SMESH_Hypothesis_i( thePOA )
56 MESSAGE( "StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i" );
57 myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
62 //=============================================================================
64 * StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i
68 //=============================================================================
70 StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i()
72 MESSAGE( "StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i" );
75 //=============================================================================
77 * StdMeshers_NumberOfSegments_i::BuildDistribution
79 * Builds point distribution according to passed function
81 //=============================================================================
82 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionExpr( const char* func,
85 throw ( SALOME::SALOME_Exception )
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 ASSERT( myBaseImpl );
110 std::vector<double> tbl( func.length() );
111 for (int i = 0; i < func.length(); i++)
116 SMESH::double_array_var aRes = new SMESH::double_array();
117 const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
118 aRes->length( res.size() );
119 for (int i = 0; i < res.size(); i++)
123 catch( SALOME_Exception& S_ex )
125 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
129 //=============================================================================
131 * StdMeshers_NumberOfSegments_i::SetNumberOfSegments
133 * Set number of segments
135 //=============================================================================
137 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
138 throw ( SALOME::SALOME_Exception )
140 ASSERT( myBaseImpl );
142 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
144 catch (SALOME_Exception& S_ex) {
145 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
149 // Update Python script
150 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << theSegmentsNumber << " )";
153 //=============================================================================
155 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
157 * Get number of segments
159 //=============================================================================
161 CORBA::Long 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 ASSERT( myBaseImpl );
177 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
179 // Update Python script
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( " << 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 (int 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(),
285 SMESH::double_array_var aRes = new SMESH::double_array();
286 aRes->length(tbl->size());
287 for (int i = 0; i < tbl->size(); i++)
292 //=============================================================================
295 //=============================================================================
297 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
298 throw ( SALOME::SALOME_Exception )
300 ASSERT( myBaseImpl );
302 this->GetImpl()->SetExpressionFunction( expr );
303 // Update Python script
304 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
306 catch ( SALOME_Exception& S_ex ) {
307 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
312 //=============================================================================
315 //=============================================================================
317 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
318 throw ( SALOME::SALOME_Exception )
320 ASSERT( myBaseImpl );
323 expr = this->GetImpl()->GetExpressionFunction();
325 catch ( SALOME_Exception& S_ex ) {
326 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
329 return CORBA::string_dup(expr);
332 //=============================================================================
335 //=============================================================================
337 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
338 throw ( SALOME::SALOME_Exception )
340 ASSERT( myBaseImpl );
342 this->GetImpl()->SetConversionMode( conv );
343 // Update Python script
344 SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
346 catch ( SALOME_Exception& S_ex ) {
347 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
352 //=============================================================================
355 //=============================================================================
357 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
358 throw ( SALOME::SALOME_Exception )
360 ASSERT( myBaseImpl );
363 conv = this->GetImpl()->ConversionMode();
365 catch ( SALOME_Exception& S_ex ) {
366 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
372 //=============================================================================
374 * StdMeshers_NumberOfSegments_i::GetImpl
378 //=============================================================================
380 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
382 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
385 //================================================================================
387 * \brief Verify whether hypothesis supports given entity type
388 * \param type - dimension (see SMESH::Dimension enumeration)
389 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
391 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
393 //================================================================================
394 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
396 return type == SMESH::DIM_1D;