Salome HOME
Merge remote branch 'origin/V8_5_asterstudy'
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_MaxLength_i.cxx
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
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 classes
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                                                 ::SMESH_Gen*            theGenImpl )
46   : SALOME::GenericObj_i( thePOA ),
47     SMESH_Hypothesis_i( thePOA )
48 {
49   myBaseImpl = new ::StdMeshers_MaxLength( theGenImpl->GetANewId(),
50                                            theGenImpl );
51 }
52
53 //=============================================================================
54 /*!
55  *  StdMeshers_MaxLength_i::~StdMeshers_MaxLength_i
56  *
57  *  Destructor
58  */
59 //=============================================================================
60
61 StdMeshers_MaxLength_i::~StdMeshers_MaxLength_i()
62 {
63 }
64
65 //=============================================================================
66 /*!
67  *  StdMeshers_MaxLength_i::SetLength
68  *
69  *  Set length
70  */
71 //=============================================================================
72 void StdMeshers_MaxLength_i::SetLength( CORBA::Double theLength )
73      throw ( SALOME::SALOME_Exception )
74 {
75   ASSERT( myBaseImpl );
76   try {
77     this->GetImpl()->SetLength( theLength );
78   }
79   catch ( SALOME_Exception& S_ex ) {
80     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
81                                   SALOME::BAD_PARAM );
82   }
83
84   // Update Python script
85   SMESH::TPythonDump() << _this() << ".SetLength( " << SMESH::TVar(theLength) << " )";
86 }
87
88 //=============================================================================
89 /*!
90  *  Sets preestimation flag
91  */
92 //=============================================================================
93 void StdMeshers_MaxLength_i::SetUsePreestimatedLength( CORBA::Boolean toUse )
94   throw ( SALOME::SALOME_Exception )
95 {
96   ASSERT( myBaseImpl );
97   try {
98     this->GetImpl()->SetUsePreestimatedLength( toUse );
99   }
100   catch ( SALOME_Exception& S_ex ) {
101     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
102                                   SALOME::BAD_PARAM );
103   }
104
105   // this is an internal kitchen call - no Python dump
106   // Update Python script
107   //SMESH::TPythonDump() << _this() << ".SetUsePreestimatedLength( " << toUse << " )";
108 }
109
110 //=============================================================================
111 /*!
112  *  Sets preestimation length
113  */
114 //=============================================================================
115 void StdMeshers_MaxLength_i::SetPreestimatedLength( CORBA::Double theLength )
116 {
117   ASSERT( myBaseImpl );
118   try {
119     this->GetImpl()->SetPreestimatedLength( theLength );
120   }
121   catch ( SALOME_Exception& S_ex ) {
122     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
123                                   SALOME::BAD_PARAM );
124   }
125   // this is an internal kitchen call - no Python dump
126   // Update Python script
127   //SMESH::TPythonDump() << _this() << ".SetPreestimatedLength( " << toUse << " )";
128 }
129
130 //=============================================================================
131 /*!
132  *  StdMeshers_MaxLength_i::GetLength
133  *
134  *  Get length
135  */
136 //=============================================================================
137 CORBA::Double StdMeshers_MaxLength_i::GetLength()
138 {
139   ASSERT( myBaseImpl );
140   return this->GetImpl()->GetLength();
141 }
142
143 //=============================================================================
144 /*!
145  *  StdMeshers_MaxLength_i::GetPreestimatedLength
146  */
147 //=============================================================================
148 CORBA::Double StdMeshers_MaxLength_i::GetPreestimatedLength()
149 {
150   ASSERT( myBaseImpl );
151   return this->GetImpl()->GetPreestimatedLength();
152 }
153
154 //=============================================================================
155 /*!
156  *  Returns preestimation flag
157  */
158 //=============================================================================
159 CORBA::Boolean StdMeshers_MaxLength_i::GetUsePreestimatedLength()
160 {
161   ASSERT( myBaseImpl );
162   return this->GetImpl()->GetUsePreestimatedLength();
163 }
164
165 //================================================================================
166 /*!
167  * \brief Returns true if preestemated length is defined
168  */
169 //================================================================================
170
171 CORBA::Boolean StdMeshers_MaxLength_i::HavePreestimatedLength()
172 {
173   ASSERT( myBaseImpl );
174   return this->GetImpl()->HavePreestimatedLength();
175 }
176
177 //=============================================================================
178 /*!
179  *  StdMeshers_MaxLength_i::GetImpl
180  *
181  *  Get implementation
182  */
183 //=============================================================================
184 ::StdMeshers_MaxLength* StdMeshers_MaxLength_i::GetImpl()
185 {
186   return ( ::StdMeshers_MaxLength* )myBaseImpl;
187 }
188
189 //================================================================================
190 /*!
191  * \brief Verify whether hypothesis supports given entity type 
192   * \param type - dimension (see SMESH::Dimension enumeration)
193   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
194  * 
195  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
196  */
197 //================================================================================  
198 CORBA::Boolean StdMeshers_MaxLength_i::IsDimSupported( SMESH::Dimension type )
199 {
200   return type == SMESH::DIM_1D;
201 }
202
203 //================================================================================
204 /*!
205  * \brief Return method name corresponding to index of variable parameter
206  */
207 //================================================================================
208
209 std::string StdMeshers_MaxLength_i::getMethodOfParameter(const int, int) const
210 {
211   return "SetLength";
212 }