1 // Copyright (C) 2007-2019 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 classes
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,
51 ::SMESH_Gen* theGenImpl )
52 : SALOME::GenericObj_i( thePOA ),
53 SMESH_Hypothesis_i( thePOA )
55 myBaseImpl = new ::StdMeshers_ViscousLayers( theGenImpl->GetANewId(),
59 //=============================================================================
61 * StdMeshers_ViscousLayers_i::~StdMeshers_ViscousLayers_i
65 //=============================================================================
67 StdMeshers_ViscousLayers_i::~StdMeshers_ViscousLayers_i()
71 //================================================================================
75 //================================================================================
77 void StdMeshers_ViscousLayers_i::SetFaces(const ::SMESH::long_array& faceIDs,
78 CORBA::Boolean toIgnore)
79 throw ( SALOME::SALOME_Exception )
81 vector<int> ids( faceIDs.length() );
82 for ( unsigned i = 0; i < ids.size(); ++i )
83 if (( ids[i] = faceIDs[i] ) < 1 )
84 THROW_SALOME_CORBA_EXCEPTION( "Invalid face id", SALOME::BAD_PARAM );
86 GetImpl()->SetBndShapes( ids, toIgnore );
88 SMESH::TPythonDump() << _this() << ".SetFaces( " << faceIDs << ", " << toIgnore << " )";
91 //================================================================================
95 //================================================================================
97 SMESH::long_array* StdMeshers_ViscousLayers_i::GetFaces()
99 vector<int> idsVec = GetImpl()->GetBndShapes();
100 SMESH::long_array_var ids = new SMESH::long_array;
101 ids->length( idsVec.size() );
102 for ( unsigned i = 0; i < idsVec.size(); ++i )
107 //================================================================================
111 //================================================================================
113 SMESH::long_array* StdMeshers_ViscousLayers_i::GetIgnoreFaces()
115 if ( GetImpl()->IsToIgnoreShapes() )
116 return this->GetFaces();
117 return new SMESH::long_array;
120 //================================================================================
124 //================================================================================
126 CORBA::Boolean StdMeshers_ViscousLayers_i::GetIsToIgnoreFaces()
128 return GetImpl()->IsToIgnoreShapes();
131 //================================================================================
135 //================================================================================
137 void StdMeshers_ViscousLayers_i::SetIgnoreFaces(const ::SMESH::long_array& faceIDs)
138 throw ( SALOME::SALOME_Exception )
140 vector<int> ids( faceIDs.length() );
141 for ( unsigned i = 0; i < ids.size(); ++i )
142 if (( ids[i] = faceIDs[i] ) < 1 )
143 THROW_SALOME_CORBA_EXCEPTION( "Invalid face id", SALOME::BAD_PARAM );
144 GetImpl()->SetBndShapes( ids, /*toIgnore=*/true );
145 SMESH::TPythonDump() << _this() << ".SetIgnoreFaces( " << faceIDs << " )";
148 //================================================================================
152 //================================================================================
154 void StdMeshers_ViscousLayers_i::SetTotalThickness(::CORBA::Double thickness)
155 throw ( SALOME::SALOME_Exception )
157 if ( thickness < 1e-100 )
158 THROW_SALOME_CORBA_EXCEPTION( "Invalid thickness", SALOME::BAD_PARAM );
159 GetImpl()->SetTotalThickness(thickness);
160 SMESH::TPythonDump() << _this() << ".SetTotalThickness( " << SMESH::TVar(thickness) << " )";
163 //================================================================================
167 //================================================================================
169 ::CORBA::Double StdMeshers_ViscousLayers_i::GetTotalThickness()
171 return GetImpl()->GetTotalThickness();
174 //================================================================================
179 //================================================================================
181 void StdMeshers_ViscousLayers_i::SetNumberLayers(::CORBA::Short nb)
182 throw ( SALOME::SALOME_Exception )
185 THROW_SALOME_CORBA_EXCEPTION( "Invalid number of layers", SALOME::BAD_PARAM );
186 GetImpl()->SetNumberLayers( nb );
187 SMESH::TPythonDump() << _this() << ".SetNumberLayers( " << SMESH::TVar(nb) << " )";
190 //================================================================================
194 //================================================================================
196 ::CORBA::Short StdMeshers_ViscousLayers_i::GetNumberLayers()
198 return CORBA::Short( GetImpl()->GetNumberLayers() );
201 //================================================================================
206 //================================================================================
208 void StdMeshers_ViscousLayers_i::SetStretchFactor(::CORBA::Double factor)
209 throw ( SALOME::SALOME_Exception )
212 THROW_SALOME_CORBA_EXCEPTION( "Invalid stretch factor, it must be >= 1.0", SALOME::BAD_PARAM );
213 GetImpl()->SetStretchFactor(factor);
214 SMESH::TPythonDump() << _this() << ".SetStretchFactor( " << SMESH::TVar(factor) << " )";
217 //================================================================================
222 //================================================================================
224 ::CORBA::Double StdMeshers_ViscousLayers_i::GetStretchFactor()
226 return GetImpl()->GetStretchFactor();
229 //================================================================================
231 * \brief Set Method of computing translation of a node
233 //================================================================================
235 void StdMeshers_ViscousLayers_i::SetMethod( ::StdMeshers::VLExtrusionMethod how )
237 GetImpl()->SetMethod( ::StdMeshers_ViscousLayers::ExtrusionMethod( how ));
238 const char* methNames[3] = { "SURF_OFFSET_SMOOTH",
241 if ( how >= 0 && how < 3 )
242 SMESH::TPythonDump() << _this() << ".SetMethod( StdMeshers." << methNames[ how ]<< " )";
245 //================================================================================
247 * \brief Return Method of computing translation of a node
249 //================================================================================
251 ::StdMeshers::VLExtrusionMethod StdMeshers_ViscousLayers_i::GetMethod()
253 return (::StdMeshers::VLExtrusionMethod) GetImpl()->GetMethod();
256 //=============================================================================
260 //=============================================================================
262 ::StdMeshers_ViscousLayers* StdMeshers_ViscousLayers_i::GetImpl()
264 return ( ::StdMeshers_ViscousLayers* )myBaseImpl;
267 //================================================================================
269 * \brief Verify whether hypothesis supports given entity type
270 * \param type - dimension (see SMESH::Dimension enumeration)
271 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
273 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
275 //================================================================================
276 CORBA::Boolean StdMeshers_ViscousLayers_i::IsDimSupported( SMESH::Dimension type )
278 return type == SMESH::DIM_3D;
281 //================================================================================
283 * \brief Return method name corresponding to index of variable parameter
285 //================================================================================
287 std::string StdMeshers_ViscousLayers_i::getMethodOfParameter(const int paramIndex, int ) const
289 // order of methods was defined by StdMeshersGUI_StdHypothesisCreator::storeParams()
290 switch ( paramIndex )
292 case 0: return "SetTotalThickness";
293 case 1: return "SetNumberLayers";
294 case 2: return "SetStretchFactor";
300 //================================================================================
302 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
304 //================================================================================
307 StdMeshers_ViscousLayers_i::getObjectsDependOn( std::vector< std::string > & entryArray,
308 std::vector< int > & subIDArray ) const
310 const ::StdMeshers_ViscousLayers* impl =
311 static_cast<const ::StdMeshers_ViscousLayers*>( myBaseImpl );
313 subIDArray = impl->GetBndShapes();
318 //================================================================================
320 * \brief Set new geometry instead of that returned by getObjectsDependOn()
322 //================================================================================
325 StdMeshers_ViscousLayers_i::setObjectsDependOn( std::vector< std::string > & entryArray,
326 std::vector< int > & subIDArray )
328 std::vector< int > newIDs;
329 newIDs.reserve( subIDArray.size() );
331 for ( size_t i = 0; i < subIDArray.size(); ++i )
332 if ( subIDArray[ i ] > 0 )
333 newIDs.push_back( subIDArray[ i ]);
335 GetImpl()->SetBndShapes( newIDs, GetIsToIgnoreFaces() );