Salome HOME
Merge from V6_5_BR 05/06/2012
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_MaxLength_i.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
21 //  File   : StdMeshers_MaxLength_i.cxx
22 //  Module : SMESH
23 //
24 #include "StdMeshers_MaxLength_i.hxx"
25 #include "SMESH_Gen_i.hxx"
26 #include "SMESH_Gen.hxx"
27 #include "SMESH_PythonDump.hxx"
28
29 #include "Utils_CorbaException.hxx"
30 #include "utilities.h"
31
32 #include <TCollection_AsciiString.hxx>
33
34 using namespace std;
35
36 //=============================================================================
37 /*!
38  *  StdMeshers_MaxLength_i::StdMeshers_MaxLength_i
39  *
40  *  Constructor
41  */
42 //=============================================================================
43
44 StdMeshers_MaxLength_i::StdMeshers_MaxLength_i( PortableServer::POA_ptr thePOA,
45                                                 int                     theStudyId,
46                                                 ::SMESH_Gen*            theGenImpl )
47   : SALOME::GenericObj_i( thePOA ),
48     SMESH_Hypothesis_i( thePOA )
49 {
50   myBaseImpl = new ::StdMeshers_MaxLength( theGenImpl->GetANewId(),
51                                            theStudyId,
52                                            theGenImpl );
53 }
54
55 //=============================================================================
56 /*!
57  *  StdMeshers_MaxLength_i::~StdMeshers_MaxLength_i
58  *
59  *  Destructor
60  */
61 //=============================================================================
62
63 StdMeshers_MaxLength_i::~StdMeshers_MaxLength_i()
64 {
65 }
66
67 //=============================================================================
68 /*!
69  *  StdMeshers_MaxLength_i::SetLength
70  *
71  *  Set length
72  */
73 //=============================================================================
74 void StdMeshers_MaxLength_i::SetLength( CORBA::Double theLength )
75      throw ( SALOME::SALOME_Exception )
76 {
77   ASSERT( myBaseImpl );
78   try {
79     this->GetImpl()->SetLength( theLength );
80   }
81   catch ( SALOME_Exception& S_ex ) {
82     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
83                                   SALOME::BAD_PARAM );
84   }
85
86   // Update Python script
87   SMESH::TPythonDump() << _this() << ".SetLength( " << SMESH::TVar(theLength) << " )";
88 }
89
90 //=============================================================================
91 /*!
92  *  Sets preestimation flag
93  */
94 //=============================================================================
95 void StdMeshers_MaxLength_i::SetUsePreestimatedLength( CORBA::Boolean toUse )
96   throw ( SALOME::SALOME_Exception )
97 {
98   ASSERT( myBaseImpl );
99   try {
100     this->GetImpl()->SetUsePreestimatedLength( toUse );
101   }
102   catch ( SALOME_Exception& S_ex ) {
103     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
104                                   SALOME::BAD_PARAM );
105   }
106
107   // this is an internal kitchen call - no Python dump
108   // Update Python script
109   //SMESH::TPythonDump() << _this() << ".SetUsePreestimatedLength( " << toUse << " )";
110 }
111
112 //=============================================================================
113 /*!
114  *  Sets preestimation length
115  */
116 //=============================================================================
117 void StdMeshers_MaxLength_i::SetPreestimatedLength( CORBA::Double theLength )
118 {
119   ASSERT( myBaseImpl );
120   try {
121     this->GetImpl()->SetPreestimatedLength( theLength );
122   }
123   catch ( SALOME_Exception& S_ex ) {
124     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
125                                   SALOME::BAD_PARAM );
126   }
127   // this is an internal kitchen call - no Python dump
128   // Update Python script
129   //SMESH::TPythonDump() << _this() << ".SetPreestimatedLength( " << toUse << " )";
130 }
131
132 //=============================================================================
133 /*!
134  *  StdMeshers_MaxLength_i::GetLength
135  *
136  *  Get length
137  */
138 //=============================================================================
139 CORBA::Double StdMeshers_MaxLength_i::GetLength()
140 {
141   ASSERT( myBaseImpl );
142   return this->GetImpl()->GetLength();
143 }
144
145 //=============================================================================
146 /*!
147  *  StdMeshers_MaxLength_i::GetPreestimatedLength
148  */
149 //=============================================================================
150 CORBA::Double StdMeshers_MaxLength_i::GetPreestimatedLength()
151 {
152   ASSERT( myBaseImpl );
153   return this->GetImpl()->GetPreestimatedLength();
154 }
155
156 //=============================================================================
157 /*!
158  *  Returns preestimation flag
159  */
160 //=============================================================================
161 CORBA::Boolean StdMeshers_MaxLength_i::GetUsePreestimatedLength()
162 {
163   ASSERT( myBaseImpl );
164   return this->GetImpl()->GetUsePreestimatedLength();
165 }
166
167 //================================================================================
168 /*!
169  * \brief Returns true if preestemated length is defined
170  */
171 //================================================================================
172
173 CORBA::Boolean StdMeshers_MaxLength_i::HavePreestimatedLength()
174 {
175   ASSERT( myBaseImpl );
176   return this->GetImpl()->HavePreestimatedLength();
177 }
178
179 //=============================================================================
180 /*!
181  *  StdMeshers_MaxLength_i::GetImpl
182  *
183  *  Get implementation
184  */
185 //=============================================================================
186 ::StdMeshers_MaxLength* StdMeshers_MaxLength_i::GetImpl()
187 {
188   return ( ::StdMeshers_MaxLength* )myBaseImpl;
189 }
190
191 //================================================================================
192 /*!
193  * \brief Verify whether hypothesis supports given entity type 
194   * \param type - dimension (see SMESH::Dimension enumeration)
195   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
196  * 
197  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
198  */
199 //================================================================================  
200 CORBA::Boolean StdMeshers_MaxLength_i::IsDimSupported( SMESH::Dimension type )
201 {
202   return type == SMESH::DIM_1D;
203 }
204
205 //================================================================================
206 /*!
207  * \brief Return method name corresponding to index of variable parameter
208  */
209 //================================================================================
210
211 std::string StdMeshers_MaxLength_i::getMethodOfParameter(const int, int) const
212 {
213   return "SetLength";
214 }