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"
35 #include "Utils_CorbaException.hxx"
36 #include "utilities.h"
38 #include <TCollection_AsciiString.hxx>
40 //=============================================================================
42 * StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
46 //=============================================================================
48 StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
50 ::SMESH_Gen* theGenImpl )
51 : SALOME::GenericObj_i( thePOA ),
52 SMESH_Hypothesis_i( thePOA )
54 MESSAGE( "StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i" );
55 myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
60 //=============================================================================
62 * StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i
66 //=============================================================================
68 StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i()
70 MESSAGE( "StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i" );
73 //=============================================================================
75 * StdMeshers_NumberOfSegments_i::SetNumberOfSegments
77 * Set number of segments
79 //=============================================================================
81 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
82 throw ( SALOME::SALOME_Exception )
84 MESSAGE( "StdMeshers_NumberOfSegments_i::SetNumberOfSegments" );
87 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
89 catch (SALOME_Exception& S_ex) {
90 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
94 // Update Python script
95 TCollection_AsciiString aStr, aStrNb ((int)theSegmentsNumber);
96 SMESH_Gen_i::AddObject(aStr, _this()) += ".SetNumberOfSegments(";
99 SMESH_Gen_i::AddToCurrentPyScript(aStr);
102 //=============================================================================
104 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
106 * Get number of segments
108 //=============================================================================
110 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
112 MESSAGE( "StdMeshers_NumberOfSegments_i::GetNumberOfSegments" );
113 ASSERT( myBaseImpl );
114 return this->GetImpl()->GetNumberOfSegments();
117 //=============================================================================
120 //=============================================================================
122 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
123 throw ( SALOME::SALOME_Exception )
125 MESSAGE( "StdMeshers_NumberOfSegments_i::SetDistrType" );
126 ASSERT( myBaseImpl );
128 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
130 catch ( SALOME_Exception& S_ex ) {
131 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
136 //=============================================================================
139 //=============================================================================
141 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
143 MESSAGE( "StdMeshers_NumberOfSegments_i::GetDistrType" );
144 ASSERT( myBaseImpl );
145 return this->GetImpl()->GetDistrType();
148 //=============================================================================
150 * StdMeshers_NumberOfSegments_i::SetScaleFactor
154 //=============================================================================
156 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
157 throw ( SALOME::SALOME_Exception )
159 MESSAGE( "StdMeshers_NumberOfSegments_i::SetScaleFactor" );
160 ASSERT( myBaseImpl );
162 this->GetImpl()->SetScaleFactor( theScaleFactor );
164 catch ( SALOME_Exception& S_ex ) {
165 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
170 //=============================================================================
172 * StdMeshers_NumberOfSegments_i::GetScaleFactor
176 //=============================================================================
178 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
179 throw ( SALOME::SALOME_Exception )
181 MESSAGE( "StdMeshers_NumberOfSegments_i::GetScaleFactor" );
182 ASSERT( myBaseImpl );
185 scale = this->GetImpl()->GetScaleFactor();
187 catch ( SALOME_Exception& S_ex ) {
188 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
194 //=============================================================================
197 //=============================================================================
199 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
200 throw ( SALOME::SALOME_Exception )
202 MESSAGE( "StdMeshers_NumberOfSegments_i::SetTableFunction" );
203 ASSERT( myBaseImpl );
204 std::vector<double> tbl( table.length() );
205 for (int i = 0; i < table.length(); i++)
208 this->GetImpl()->SetTableFunction( tbl );
210 catch ( SALOME_Exception& S_ex ) {
211 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
216 //=============================================================================
219 //=============================================================================
221 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
222 throw ( SALOME::SALOME_Exception )
224 MESSAGE( "StdMeshers_NumberOfSegments_i::GetTableFunction" );
225 ASSERT( myBaseImpl );
226 const std::vector<double>* tbl;
228 tbl = &this->GetImpl()->GetTableFunction();
230 catch ( SALOME_Exception& S_ex ) {
231 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
234 SMESH::double_array_var aRes = new SMESH::double_array();
235 aRes->length(tbl->size());
236 for (int i = 0; i < tbl->size(); i++)
241 //=============================================================================
244 //=============================================================================
246 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
247 throw ( SALOME::SALOME_Exception )
249 MESSAGE( "StdMeshers_NumberOfSegments_i::SetExpressionFunction" );
250 ASSERT( myBaseImpl );
252 this->GetImpl()->SetExpressionFunction( expr );
254 catch ( SALOME_Exception& S_ex ) {
255 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
260 //=============================================================================
263 //=============================================================================
265 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
266 throw ( SALOME::SALOME_Exception )
268 MESSAGE( "StdMeshers_NumberOfSegments_i::GetExpressionFunction" );
269 ASSERT( myBaseImpl );
272 expr = this->GetImpl()->GetExpressionFunction();
274 catch ( SALOME_Exception& S_ex ) {
275 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
278 return CORBA::string_dup(expr);
281 //=============================================================================
284 //=============================================================================
286 void StdMeshers_NumberOfSegments_i::SetExponentMode(CORBA::Boolean isExp)
287 throw ( SALOME::SALOME_Exception )
289 MESSAGE( "StdMeshers_NumberOfSegments_i::SetExponentMode" );
290 ASSERT( myBaseImpl );
292 this->GetImpl()->SetExponentMode( isExp );
294 catch ( SALOME_Exception& S_ex ) {
295 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
300 //=============================================================================
303 //=============================================================================
305 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsExponentMode()
306 throw ( SALOME::SALOME_Exception )
308 MESSAGE( "StdMeshers_NumberOfSegments_i::IsExponentMode" );
309 ASSERT( myBaseImpl );
312 isExp = this->GetImpl()->IsExponentMode();
314 catch ( SALOME_Exception& S_ex ) {
315 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
321 //=============================================================================
323 * StdMeshers_NumberOfSegments_i::GetImpl
327 //=============================================================================
329 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
331 MESSAGE( "StdMeshers_NumberOfSegments_i::GetImpl" );
332 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
335 //================================================================================
337 * \brief Verify whether hypothesis supports given entity type
338 * \param type - dimension (see SMESH::Dimension enumeration)
339 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
341 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
343 //================================================================================
344 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
346 return type == SMESH::DIM_1D;