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::SetNumberOfSegments
78 * Set number of segments
80 //=============================================================================
82 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
83 throw ( SALOME::SALOME_Exception )
85 MESSAGE( "StdMeshers_NumberOfSegments_i::SetNumberOfSegments" );
88 this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
90 catch (SALOME_Exception& S_ex) {
91 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
95 // Update Python script
96 SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << theSegmentsNumber << " )";
99 //=============================================================================
101 * StdMeshers_NumberOfSegments_i::GetNumberOfSegments
103 * Get number of segments
105 //=============================================================================
107 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
109 MESSAGE( "StdMeshers_NumberOfSegments_i::GetNumberOfSegments" );
110 ASSERT( myBaseImpl );
111 return this->GetImpl()->GetNumberOfSegments();
114 //=============================================================================
117 //=============================================================================
119 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
120 throw ( SALOME::SALOME_Exception )
122 MESSAGE( "StdMeshers_NumberOfSegments_i::SetDistrType" );
123 ASSERT( myBaseImpl );
125 this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
127 // Update Python script
128 SMESH::TPythonDump() << _this() << ".SetDistrType( " << 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 );
163 // Update Python script
164 SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << theScaleFactor << " )";
166 catch ( SALOME_Exception& S_ex ) {
167 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
172 //=============================================================================
174 * StdMeshers_NumberOfSegments_i::GetScaleFactor
178 //=============================================================================
180 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
181 throw ( SALOME::SALOME_Exception )
183 MESSAGE( "StdMeshers_NumberOfSegments_i::GetScaleFactor" );
184 ASSERT( myBaseImpl );
187 scale = this->GetImpl()->GetScaleFactor();
189 catch ( SALOME_Exception& S_ex ) {
190 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
196 //=============================================================================
199 //=============================================================================
201 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
202 throw ( SALOME::SALOME_Exception )
204 MESSAGE( "StdMeshers_NumberOfSegments_i::SetTableFunction" );
205 ASSERT( myBaseImpl );
206 std::vector<double> tbl( table.length() );
207 for (int i = 0; i < table.length(); i++)
210 this->GetImpl()->SetTableFunction( tbl );
211 // Update Python script
212 SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
214 catch ( SALOME_Exception& S_ex ) {
215 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
220 //=============================================================================
223 //=============================================================================
225 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
226 throw ( SALOME::SALOME_Exception )
228 MESSAGE( "StdMeshers_NumberOfSegments_i::GetTableFunction" );
229 ASSERT( myBaseImpl );
230 const std::vector<double>* tbl;
232 tbl = &this->GetImpl()->GetTableFunction();
234 catch ( SALOME_Exception& S_ex ) {
235 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
238 SMESH::double_array_var aRes = new SMESH::double_array();
239 aRes->length(tbl->size());
240 for (int i = 0; i < tbl->size(); i++)
245 //=============================================================================
248 //=============================================================================
250 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
251 throw ( SALOME::SALOME_Exception )
253 MESSAGE( "StdMeshers_NumberOfSegments_i::SetExpressionFunction" );
254 ASSERT( myBaseImpl );
256 this->GetImpl()->SetExpressionFunction( expr );
257 // Update Python script
258 SMESH::TPythonDump() << _this() << ".SetExpressionFunction( " << expr << " )";
260 catch ( SALOME_Exception& S_ex ) {
261 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
266 //=============================================================================
269 //=============================================================================
271 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
272 throw ( SALOME::SALOME_Exception )
274 MESSAGE( "StdMeshers_NumberOfSegments_i::GetExpressionFunction" );
275 ASSERT( myBaseImpl );
278 expr = this->GetImpl()->GetExpressionFunction();
280 catch ( SALOME_Exception& S_ex ) {
281 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
284 return CORBA::string_dup(expr);
287 //=============================================================================
290 //=============================================================================
292 void StdMeshers_NumberOfSegments_i::SetExponentMode(CORBA::Boolean isExp)
293 throw ( SALOME::SALOME_Exception )
295 MESSAGE( "StdMeshers_NumberOfSegments_i::SetExponentMode" );
296 ASSERT( myBaseImpl );
298 this->GetImpl()->SetExponentMode( isExp );
299 // Update Python script
300 SMESH::TPythonDump() << _this() << ".SetExponentMode( " << isExp << " )";
302 catch ( SALOME_Exception& S_ex ) {
303 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
308 //=============================================================================
311 //=============================================================================
313 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsExponentMode()
314 throw ( SALOME::SALOME_Exception )
316 MESSAGE( "StdMeshers_NumberOfSegments_i::IsExponentMode" );
317 ASSERT( myBaseImpl );
320 isExp = this->GetImpl()->IsExponentMode();
322 catch ( SALOME_Exception& S_ex ) {
323 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
329 //=============================================================================
331 * StdMeshers_NumberOfSegments_i::GetImpl
335 //=============================================================================
337 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
339 MESSAGE( "StdMeshers_NumberOfSegments_i::GetImpl" );
340 return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
343 //================================================================================
345 * \brief Verify whether hypothesis supports given entity type
346 * \param type - dimension (see SMESH::Dimension enumeration)
347 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
349 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
351 //================================================================================
352 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
354 return type == SMESH::DIM_1D;