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