Salome HOME
Merge remote-tracking branch 'origin/master' into V8_5_BR
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_ViscousLayers2D_i.cxx
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
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   myBaseImpl = new ::StdMeshers_ViscousLayers2D( theGenImpl->GetANewId(),
56                                                  theStudyId,
57                                                  theGenImpl );
58 }
59
60 //=============================================================================
61 /*!
62  *  StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i
63  *
64  *  Destructor
65  */
66 //=============================================================================
67
68 StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i()
69 {
70 }
71
72 //================================================================================
73 /*!
74  * \brief 
75  */
76 //================================================================================
77
78 void StdMeshers_ViscousLayers2D_i::SetEdges(const ::SMESH::long_array& edgeIDs,
79                                             CORBA::Boolean             toIgnore)
80   throw ( SALOME::SALOME_Exception )
81 {
82   vector<int> ids( edgeIDs.length() );
83   for ( unsigned i = 0; i < ids.size(); ++i )
84     if (( ids[i] = edgeIDs[i] ) < 1 )
85       THROW_SALOME_CORBA_EXCEPTION( "Invalid edge id", SALOME::BAD_PARAM );
86
87   GetImpl()->SetBndShapes( ids, toIgnore );
88
89   SMESH::TPythonDump() << _this() << ".SetEdges( " << edgeIDs << ", " << toIgnore << " )";
90 }
91
92 //================================================================================
93 /*!
94  * \brief 
95  */
96 //================================================================================
97
98 void StdMeshers_ViscousLayers2D_i::SetIgnoreEdges(const ::SMESH::long_array& edgeIDs)
99   throw ( SALOME::SALOME_Exception )
100 {
101   SMESH::TPythonDump pyDump;
102   this->SetEdges( edgeIDs, true );
103   pyDump<< _this() << ".SetIgnoreEdges( " << edgeIDs << " )";
104 }
105
106 //================================================================================
107 /*!
108  * \brief 
109  */
110 //================================================================================
111
112 SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetEdges()
113 {
114   vector<int> idsVec = GetImpl()->GetBndShapes();
115   SMESH::long_array_var ids = new SMESH::long_array;
116   ids->length( idsVec.size() );
117   for ( unsigned i = 0; i < idsVec.size(); ++i )
118     ids[i] = idsVec[i];
119   return ids._retn();
120 }
121
122 //================================================================================
123 /*!
124  * \brief 
125  */
126 //================================================================================
127
128 SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetIgnoreEdges()
129 {
130   if ( GetImpl()->IsToIgnoreShapes() )
131     return this->GetEdges();
132   return new SMESH::long_array;
133 }
134
135 //================================================================================
136 /*!
137  * \brief 
138  */
139 //================================================================================
140
141 CORBA::Boolean StdMeshers_ViscousLayers2D_i::GetIsToIgnoreEdges()
142 {
143   return GetImpl()->IsToIgnoreShapes();
144 }
145
146 //================================================================================
147 /*!
148  * \brief 
149  */
150 //================================================================================
151
152 void StdMeshers_ViscousLayers2D_i::SetTotalThickness(::CORBA::Double thickness)
153 throw ( SALOME::SALOME_Exception )
154 {
155   if ( thickness < 1e-100 )
156     THROW_SALOME_CORBA_EXCEPTION( "Invalid thickness", SALOME::BAD_PARAM );
157   GetImpl()->SetTotalThickness(thickness);
158   SMESH::TPythonDump() << _this() << ".SetTotalThickness( " << SMESH::TVar(thickness) << " )";
159 }
160
161 //================================================================================
162 /*!
163  * \brief 
164  */
165 //================================================================================
166
167 ::CORBA::Double StdMeshers_ViscousLayers2D_i::GetTotalThickness()
168 {
169   return GetImpl()->GetTotalThickness();
170 }
171
172 //================================================================================
173 /*!
174  * \brief 
175  *  \param nb - 
176  */
177 //================================================================================
178
179 void StdMeshers_ViscousLayers2D_i::SetNumberLayers(::CORBA::Short nb)
180 throw ( SALOME::SALOME_Exception )
181 {
182   if ( nb < 1 )
183     THROW_SALOME_CORBA_EXCEPTION( "Invalid number of layers", SALOME::BAD_PARAM );
184   GetImpl()->SetNumberLayers( nb );
185   SMESH::TPythonDump() << _this() << ".SetNumberLayers( " << SMESH::TVar(nb) << " )";
186 }
187
188 //================================================================================
189 /*!
190  * \brief 
191  */
192 //================================================================================
193
194 ::CORBA::Short StdMeshers_ViscousLayers2D_i::GetNumberLayers()
195 {
196   return CORBA::Short( GetImpl()->GetNumberLayers() );
197 }
198
199 //================================================================================
200 /*!
201  * \brief 
202  *  \param factor - 
203  */
204 //================================================================================
205
206 void StdMeshers_ViscousLayers2D_i::SetStretchFactor(::CORBA::Double factor)
207 throw ( SALOME::SALOME_Exception )
208 {
209   if ( factor < 1 )
210     THROW_SALOME_CORBA_EXCEPTION( "Invalid stretch factor, it must be >= 1.0", SALOME::BAD_PARAM );
211   GetImpl()->SetStretchFactor(factor);
212   SMESH::TPythonDump() << _this() << ".SetStretchFactor( " << SMESH::TVar(factor) << " )";
213 }
214
215 //================================================================================
216 /*!
217  * \brief 
218  * 
219  */
220 //================================================================================
221
222 ::CORBA::Double StdMeshers_ViscousLayers2D_i::GetStretchFactor()
223 {
224   return GetImpl()->GetStretchFactor();
225 }
226
227 //=============================================================================
228 /*!
229  *  Get implementation
230  */
231 //=============================================================================
232
233 ::StdMeshers_ViscousLayers2D* StdMeshers_ViscousLayers2D_i::GetImpl()
234 {
235   return ( ::StdMeshers_ViscousLayers2D* )myBaseImpl;
236 }
237
238 //================================================================================
239 /*!
240  * \brief Verify whether hypothesis supports given entity type 
241   * \param type - dimension (see SMESH::Dimension enumeration)
242   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
243  * 
244  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
245  */
246 //================================================================================  
247
248 CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type )
249 {
250   return type == SMESH::DIM_2D;
251 }
252
253 //================================================================================
254 /*!
255  * \brief Sets sub-mesh event listeners to clear sub-meshes of edges
256  * shrinked by viscous layers
257  */
258 //================================================================================
259
260 void StdMeshers_ViscousLayers2D_i::UpdateAsMeshesRestored()
261 {
262   GetImpl()->RestoreListeners();
263 }