1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
24 // File : StdMeshers_ViscousLayers_i.cxx
27 #include "StdMeshers_ViscousLayers_i.hxx"
29 #include "SMESH_Gen.hxx"
30 #include "SMESH_Gen_i.hxx"
31 #include "SMESH_PythonDump.hxx"
33 #include "Utils_CorbaException.hxx"
34 #include "utilities.h"
36 #include <TCollection_AsciiString.hxx>
38 #include CORBA_SERVER_HEADER(SMESH_Group)
42 //=============================================================================
44 * StdMeshers_ViscousLayers_i::StdMeshers_ViscousLayers_i
48 //=============================================================================
50 StdMeshers_ViscousLayers_i::StdMeshers_ViscousLayers_i( PortableServer::POA_ptr thePOA,
52 ::SMESH_Gen* theGenImpl )
53 : SALOME::GenericObj_i( thePOA ),
54 SMESH_Hypothesis_i( thePOA )
56 myBaseImpl = new ::StdMeshers_ViscousLayers( theGenImpl->GetANewId(),
61 //=============================================================================
63 * StdMeshers_ViscousLayers_i::~StdMeshers_ViscousLayers_i
67 //=============================================================================
69 StdMeshers_ViscousLayers_i::~StdMeshers_ViscousLayers_i()
73 //================================================================================
77 //================================================================================
79 void StdMeshers_ViscousLayers_i::SetFaces(const ::SMESH::long_array& faceIDs,
80 CORBA::Boolean toIgnore)
81 throw ( SALOME::SALOME_Exception )
83 vector<int> ids( faceIDs.length() );
84 for ( unsigned i = 0; i < ids.size(); ++i )
85 if (( ids[i] = faceIDs[i] ) < 1 )
86 THROW_SALOME_CORBA_EXCEPTION( "Invalid face id", SALOME::BAD_PARAM );
88 GetImpl()->SetBndShapes( ids, toIgnore );
90 SMESH::TPythonDump() << _this() << ".SetFaces( " << faceIDs << ", " << toIgnore << " )";
93 //================================================================================
97 //================================================================================
99 SMESH::long_array* StdMeshers_ViscousLayers_i::GetFaces()
101 vector<int> idsVec = GetImpl()->GetBndShapes();
102 SMESH::long_array_var ids = new SMESH::long_array;
103 ids->length( idsVec.size() );
104 for ( unsigned i = 0; i < idsVec.size(); ++i )
109 //================================================================================
113 //================================================================================
115 SMESH::long_array* StdMeshers_ViscousLayers_i::GetIgnoreFaces()
117 if ( GetImpl()->IsToIgnoreShapes() )
118 return this->GetFaces();
119 return new SMESH::long_array;
122 //================================================================================
126 //================================================================================
128 CORBA::Boolean StdMeshers_ViscousLayers_i::GetIsToIgnoreFaces()
130 return GetImpl()->IsToIgnoreShapes();
133 //================================================================================
137 //================================================================================
139 void StdMeshers_ViscousLayers_i::SetIgnoreFaces(const ::SMESH::long_array& faceIDs)
140 throw ( SALOME::SALOME_Exception )
142 vector<int> ids( faceIDs.length() );
143 for ( unsigned i = 0; i < ids.size(); ++i )
144 if (( ids[i] = faceIDs[i] ) < 1 )
145 THROW_SALOME_CORBA_EXCEPTION( "Invalid face id", SALOME::BAD_PARAM );
146 GetImpl()->SetBndShapes( ids, /*toIgnore=*/true );
147 SMESH::TPythonDump() << _this() << ".SetIgnoreFaces( " << faceIDs << " )";
150 //================================================================================
154 //================================================================================
156 void StdMeshers_ViscousLayers_i::SetTotalThickness(::CORBA::Double thickness)
157 throw ( SALOME::SALOME_Exception )
159 if ( thickness < 1e-100 )
160 THROW_SALOME_CORBA_EXCEPTION( "Invalid thickness", SALOME::BAD_PARAM );
161 GetImpl()->SetTotalThickness(thickness);
162 SMESH::TPythonDump() << _this() << ".SetTotalThickness( " << SMESH::TVar(thickness) << " )";
165 //================================================================================
169 //================================================================================
171 ::CORBA::Double StdMeshers_ViscousLayers_i::GetTotalThickness()
173 return GetImpl()->GetTotalThickness();
176 //================================================================================
181 //================================================================================
183 void StdMeshers_ViscousLayers_i::SetNumberLayers(::CORBA::Short nb)
184 throw ( SALOME::SALOME_Exception )
187 THROW_SALOME_CORBA_EXCEPTION( "Invalid number of layers", SALOME::BAD_PARAM );
188 GetImpl()->SetNumberLayers( nb );
189 SMESH::TPythonDump() << _this() << ".SetNumberLayers( " << SMESH::TVar(nb) << " )";
192 //================================================================================
196 //================================================================================
198 ::CORBA::Short StdMeshers_ViscousLayers_i::GetNumberLayers()
200 return CORBA::Short( GetImpl()->GetNumberLayers() );
203 //================================================================================
208 //================================================================================
210 void StdMeshers_ViscousLayers_i::SetStretchFactor(::CORBA::Double factor)
211 throw ( SALOME::SALOME_Exception )
214 THROW_SALOME_CORBA_EXCEPTION( "Invalid stretch factor, it must be >= 1.0", SALOME::BAD_PARAM );
215 GetImpl()->SetStretchFactor(factor);
216 SMESH::TPythonDump() << _this() << ".SetStretchFactor( " << SMESH::TVar(factor) << " )";
219 //================================================================================
224 //================================================================================
226 ::CORBA::Double StdMeshers_ViscousLayers_i::GetStretchFactor()
228 return GetImpl()->GetStretchFactor();
231 //================================================================================
233 * \brief Set Method of computing translation of a node
235 //================================================================================
237 void StdMeshers_ViscousLayers_i::SetMethod( ::StdMeshers::VLExtrusionMethod how )
239 GetImpl()->SetMethod( ::StdMeshers_ViscousLayers::ExtrusionMethod( how ));
240 const char* methNames[3] = { "SURF_OFFSET_SMOOTH",
243 if ( how >= 0 && how < 3 )
244 SMESH::TPythonDump() << _this() << ".SetMethod( StdMeshers." << methNames[ how ]<< " )";
247 //================================================================================
249 * \brief Return Method of computing translation of a node
251 //================================================================================
253 ::StdMeshers::VLExtrusionMethod StdMeshers_ViscousLayers_i::GetMethod()
255 return (::StdMeshers::VLExtrusionMethod) GetImpl()->GetMethod();
258 //=============================================================================
262 //=============================================================================
264 ::StdMeshers_ViscousLayers* StdMeshers_ViscousLayers_i::GetImpl()
266 return ( ::StdMeshers_ViscousLayers* )myBaseImpl;
269 //================================================================================
271 * \brief Verify whether hypothesis supports given entity type
272 * \param type - dimension (see SMESH::Dimension enumeration)
273 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
275 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
277 //================================================================================
278 CORBA::Boolean StdMeshers_ViscousLayers_i::IsDimSupported( SMESH::Dimension type )
280 return type == SMESH::DIM_3D;
283 //================================================================================
285 * \brief Return method name corresponding to index of variable parameter
287 //================================================================================
289 std::string StdMeshers_ViscousLayers_i::getMethodOfParameter(const int paramIndex, int ) const
291 // order of methods was defined by StdMeshersGUI_StdHypothesisCreator::storeParams()
292 switch ( paramIndex )
294 case 0: return "SetTotalThickness";
295 case 1: return "SetNumberLayers";
296 case 2: return "SetStretchFactor";