Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_MaxLength_i.cxx
1 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : StdMeshers_MaxLength_i.cxx
23 //  Module : SMESH
24
25 #include "StdMeshers_MaxLength_i.hxx"
26 #include "SMESH_Gen_i.hxx"
27 #include "SMESH_Gen.hxx"
28 #include "SMESH_PythonDump.hxx"
29
30 #include "Utils_CorbaException.hxx"
31 #include "utilities.h"
32
33 #include <TCollection_AsciiString.hxx>
34
35 using namespace std;
36
37 //=============================================================================
38 /*!
39  *  StdMeshers_MaxLength_i::StdMeshers_MaxLength_i
40  *
41  *  Constructor
42  */
43 //=============================================================================
44
45 StdMeshers_MaxLength_i::StdMeshers_MaxLength_i( PortableServer::POA_ptr thePOA,
46                                                 int                     theStudyId,
47                                                 ::SMESH_Gen*            theGenImpl )
48   : SALOME::GenericObj_i( thePOA ),
49     SMESH_Hypothesis_i( thePOA )
50 {
51   myBaseImpl = new ::StdMeshers_MaxLength( theGenImpl->GetANewId(),
52                                            theStudyId,
53                                            theGenImpl );
54 }
55
56 //=============================================================================
57 /*!
58  *  StdMeshers_MaxLength_i::~StdMeshers_MaxLength_i
59  *
60  *  Destructor
61  */
62 //=============================================================================
63
64 StdMeshers_MaxLength_i::~StdMeshers_MaxLength_i()
65 {
66 }
67
68 //=============================================================================
69 /*!
70  *  StdMeshers_MaxLength_i::SetLength
71  *
72  *  Set length
73  */
74 //=============================================================================
75 void StdMeshers_MaxLength_i::SetLength( CORBA::Double theLength )
76      throw ( SALOME::SALOME_Exception )
77 {
78   ASSERT( myBaseImpl );
79   try {
80     this->GetImpl()->SetLength( theLength );
81   }
82   catch ( SALOME_Exception& S_ex ) {
83     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
84                                   SALOME::BAD_PARAM );
85   }
86
87   // Update Python script
88   SMESH::TPythonDump() << _this() << ".SetLength( " << theLength << " )";
89 }
90
91 //=============================================================================
92 /*!
93  *  Sets preestimation flag
94  */
95 //=============================================================================
96 void StdMeshers_MaxLength_i::SetUsePreestimatedLength( CORBA::Boolean toUse )
97   throw ( SALOME::SALOME_Exception )
98 {
99   ASSERT( myBaseImpl );
100   try {
101     this->GetImpl()->SetUsePreestimatedLength( toUse );
102   }
103   catch ( SALOME_Exception& S_ex ) {
104     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
105                                   SALOME::BAD_PARAM );
106   }
107
108   // this is an internal kitchen call - no Python dump
109   // Update Python script
110   //SMESH::TPythonDump() << _this() << ".SetUsePreestimatedLength( " << toUse << " )";
111 }
112
113 //=============================================================================
114 /*!
115  *  Sets preestimation length
116  */
117 //=============================================================================
118 void StdMeshers_MaxLength_i::SetPreestimatedLength( CORBA::Double theLength )
119 {
120   ASSERT( myBaseImpl );
121   try {
122     this->GetImpl()->SetPreestimatedLength( theLength );
123   }
124   catch ( SALOME_Exception& S_ex ) {
125     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
126                                   SALOME::BAD_PARAM );
127   }
128   // this is an internal kitchen call - no Python dump
129   // Update Python script
130   //SMESH::TPythonDump() << _this() << ".SetPreestimatedLength( " << toUse << " )";
131 }
132
133 //=============================================================================
134 /*!
135  *  StdMeshers_MaxLength_i::GetLength
136  *
137  *  Get length
138  */
139 //=============================================================================
140 CORBA::Double StdMeshers_MaxLength_i::GetLength()
141 {
142   ASSERT( myBaseImpl );
143   return this->GetImpl()->GetLength();
144 }
145
146 //=============================================================================
147 /*!
148  *  StdMeshers_MaxLength_i::GetPreestimatedLength
149  */
150 //=============================================================================
151 CORBA::Double StdMeshers_MaxLength_i::GetPreestimatedLength()
152 {
153   ASSERT( myBaseImpl );
154   return this->GetImpl()->GetPreestimatedLength();
155 }
156
157 //=============================================================================
158 /*!
159  *  Returns preestimation flag
160  */
161 //=============================================================================
162 CORBA::Boolean StdMeshers_MaxLength_i::GetUsePreestimatedLength()
163 {
164   ASSERT( myBaseImpl );
165   return this->GetImpl()->GetUsePreestimatedLength();
166 }
167
168 //================================================================================
169 /*!
170  * \brief Returns true if preestemated length is defined
171  */
172 //================================================================================
173
174 CORBA::Boolean StdMeshers_MaxLength_i::HavePreestimatedLength()
175 {
176   ASSERT( myBaseImpl );
177   return this->GetImpl()->HavePreestimatedLength();
178 }
179
180 //=============================================================================
181 /*!
182  *  StdMeshers_MaxLength_i::GetImpl
183  *
184  *  Get implementation
185  */
186 //=============================================================================
187 ::StdMeshers_MaxLength* StdMeshers_MaxLength_i::GetImpl()
188 {
189   return ( ::StdMeshers_MaxLength* )myBaseImpl;
190 }
191
192 //================================================================================
193 /*!
194  * \brief Verify whether hypothesis supports given entity type 
195   * \param type - dimension (see SMESH::Dimension enumeration)
196   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
197  * 
198  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
199  */
200 //================================================================================  
201 CORBA::Boolean StdMeshers_MaxLength_i::IsDimSupported( SMESH::Dimension type )
202 {
203   return type == SMESH::DIM_1D;
204 }