Salome HOME
bd709e593ebb9ee02a4c18fbc05e813e2766f3ec
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_ViscousLayers2D_i.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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
23 //  File   : StdMeshers_ViscousLayers2D_i.cxx
24 //  Module : SMESH
25 //
26 #include "StdMeshers_ViscousLayers2D_i.hxx"
27
28 #include "SMESH_Gen.hxx"
29 #include "SMESH_Gen_i.hxx"
30 #include "SMESH_PythonDump.hxx"
31
32 #include "Utils_CorbaException.hxx"
33 #include "utilities.h"
34
35 #include <TCollection_AsciiString.hxx>
36
37 #include CORBA_SERVER_HEADER(SMESH_Group)
38
39 using namespace std;
40
41 //=============================================================================
42 /*!
43  *  StdMeshers_ViscousLayers2D_i::StdMeshers_ViscousLayers2D_i
44  *
45  *  Constructor
46  */
47 //=============================================================================
48
49 StdMeshers_ViscousLayers2D_i::StdMeshers_ViscousLayers2D_i( PortableServer::POA_ptr thePOA,
50                                                             int                     theStudyId,
51                                                             ::SMESH_Gen*            theGenImpl )
52   : SALOME::GenericObj_i( thePOA ),
53     SMESH_Hypothesis_i( thePOA )
54 {
55   MESSAGE( "StdMeshers_ViscousLayers2D_i::StdMeshers_ViscousLayers2D_i" );
56   myBaseImpl = new ::StdMeshers_ViscousLayers2D( theGenImpl->GetANewId(),
57                                                  theStudyId,
58                                                  theGenImpl );
59 }
60
61 //=============================================================================
62 /*!
63  *  StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i
64  *
65  *  Destructor
66  */
67 //=============================================================================
68
69 StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i()
70 {
71   MESSAGE( "StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i" );
72 }
73
74 //================================================================================
75 /*!
76  * \brief 
77  */
78 //================================================================================
79
80 void StdMeshers_ViscousLayers2D_i::SetIgnoreEdges(const ::SMESH::long_array& edgeIDs)
81 throw ( SALOME::SALOME_Exception )
82 {
83   vector<int> ids( edgeIDs.length() );
84   for ( unsigned i = 0; i < ids.size(); ++i )
85     if (( ids[i] = edgeIDs[i] ) < 1 )
86       THROW_SALOME_CORBA_EXCEPTION( "Invalid edge id", SALOME::BAD_PARAM );
87   GetImpl()->SetBndShapesToIgnore( ids );
88   SMESH::TPythonDump() << _this() << ".SetIgnoreEdges( " << edgeIDs << " )";
89 }
90
91 //================================================================================
92 /*!
93  * \brief 
94  */
95 //================================================================================
96
97 SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetIgnoreEdges()
98 {
99   vector<int> idsVec = GetImpl()->GetBndShapesToIgnore();
100   SMESH::long_array_var ids = new SMESH::long_array;
101   ids->length( idsVec.size() );
102   for ( unsigned i = 0; i < idsVec.size(); ++i )
103     ids[i] = idsVec[i];
104   return ids._retn();
105 }
106
107 //================================================================================
108 /*!
109  * \brief 
110  */
111 //================================================================================
112
113 void StdMeshers_ViscousLayers2D_i::SetTotalThickness(::CORBA::Double thickness)
114 throw ( SALOME::SALOME_Exception )
115 {
116   if ( thickness < 1e-100 )
117     THROW_SALOME_CORBA_EXCEPTION( "Invalid thickness", SALOME::BAD_PARAM );
118   GetImpl()->SetTotalThickness(thickness);
119   SMESH::TPythonDump() << _this() << ".SetTotalThickness( " << SMESH::TVar(thickness) << " )";
120 }
121
122 //================================================================================
123 /*!
124  * \brief 
125  */
126 //================================================================================
127
128 ::CORBA::Double StdMeshers_ViscousLayers2D_i::GetTotalThickness()
129 {
130   return GetImpl()->GetTotalThickness();
131 }
132
133 //================================================================================
134 /*!
135  * \brief 
136  *  \param nb - 
137  */
138 //================================================================================
139
140 void StdMeshers_ViscousLayers2D_i::SetNumberLayers(::CORBA::Short nb)
141 throw ( SALOME::SALOME_Exception )
142 {
143   if ( nb < 1 )
144     THROW_SALOME_CORBA_EXCEPTION( "Invalid number of layers", SALOME::BAD_PARAM );
145   GetImpl()->SetNumberLayers( nb );
146   SMESH::TPythonDump() << _this() << ".SetNumberLayers( " << SMESH::TVar(nb) << " )";
147 }
148
149 //================================================================================
150 /*!
151  * \brief 
152  */
153 //================================================================================
154
155 ::CORBA::Short StdMeshers_ViscousLayers2D_i::GetNumberLayers()
156 {
157   return CORBA::Short( GetImpl()->GetNumberLayers() );
158 }
159
160 //================================================================================
161 /*!
162  * \brief 
163  *  \param factor - 
164  */
165 //================================================================================
166
167 void StdMeshers_ViscousLayers2D_i::SetStretchFactor(::CORBA::Double factor)
168 throw ( SALOME::SALOME_Exception )
169 {
170   if ( factor < 1 )
171     THROW_SALOME_CORBA_EXCEPTION( "Invalid stretch factor, it must be >= 1.0", SALOME::BAD_PARAM );
172   GetImpl()->SetStretchFactor(factor);
173   SMESH::TPythonDump() << _this() << ".SetStretchFactor( " << SMESH::TVar(factor) << " )";
174 }
175
176 //================================================================================
177 /*!
178  * \brief 
179  * 
180  */
181 //================================================================================
182
183 ::CORBA::Double StdMeshers_ViscousLayers2D_i::GetStretchFactor()
184 {
185   return GetImpl()->GetStretchFactor();
186 }
187
188 //=============================================================================
189 /*!
190  *  Get implementation
191  */
192 //=============================================================================
193
194 ::StdMeshers_ViscousLayers2D* StdMeshers_ViscousLayers2D_i::GetImpl()
195 {
196   MESSAGE( "StdMeshers_ViscousLayers2D_i::GetImpl" );
197   return ( ::StdMeshers_ViscousLayers2D* )myBaseImpl;
198 }
199
200 //================================================================================
201 /*!
202  * \brief Verify whether hypothesis supports given entity type 
203   * \param type - dimension (see SMESH::Dimension enumeration)
204   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
205  * 
206  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
207  */
208 //================================================================================  
209
210 CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type )
211 {
212   return type == SMESH::DIM_2D;
213 }
214
215 //================================================================================
216 /*!
217  * \brief Sets sub-mesh event listeners to clear sub-meshes of edges
218  * shrinked by viscous layers
219  */
220 //================================================================================
221
222 void StdMeshers_ViscousLayers2D_i::UpdateAsMeshesRestored()
223 {
224   GetImpl()->RestoreListeners();
225 }