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