1 // Copyright (C) 2007-2022 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)
80 vector<int> ids( faceIDs.length() );
81 for ( unsigned i = 0; i < ids.size(); ++i )
82 if (( ids[i] = faceIDs[i] ) < 1 )
83 THROW_SALOME_CORBA_EXCEPTION( "Invalid face id", SALOME::BAD_PARAM );
85 GetImpl()->SetBndShapes( ids, toIgnore );
87 SMESH::TPythonDump() << _this() << ".SetFaces( " << faceIDs << ", " << toIgnore << " )";
90 //================================================================================
94 //================================================================================
96 SMESH::long_array* StdMeshers_ViscousLayers_i::GetFaces()
98 vector<int> idsVec = GetImpl()->GetBndShapes();
99 SMESH::long_array_var ids = new SMESH::long_array;
100 ids->length( idsVec.size() );
101 for ( unsigned i = 0; i < idsVec.size(); ++i )
106 //================================================================================
110 //================================================================================
112 SMESH::long_array* StdMeshers_ViscousLayers_i::GetIgnoreFaces()
114 if ( GetImpl()->IsToIgnoreShapes() )
115 return this->GetFaces();
116 return new SMESH::long_array;
119 //================================================================================
123 //================================================================================
125 CORBA::Boolean StdMeshers_ViscousLayers_i::GetIsToIgnoreFaces()
127 return GetImpl()->IsToIgnoreShapes();
130 //================================================================================
134 //================================================================================
136 void StdMeshers_ViscousLayers_i::SetIgnoreFaces(const ::SMESH::long_array& faceIDs)
138 vector<int> ids( faceIDs.length() );
139 for ( unsigned i = 0; i < ids.size(); ++i )
140 if (( ids[i] = faceIDs[i] ) < 1 )
141 THROW_SALOME_CORBA_EXCEPTION( "Invalid face id", SALOME::BAD_PARAM );
142 GetImpl()->SetBndShapes( ids, /*toIgnore=*/true );
143 SMESH::TPythonDump() << _this() << ".SetIgnoreFaces( " << faceIDs << " )";
146 //================================================================================
150 //================================================================================
152 void StdMeshers_ViscousLayers_i::SetTotalThickness(::CORBA::Double thickness)
154 if ( thickness < 1e-100 )
155 THROW_SALOME_CORBA_EXCEPTION( "Invalid thickness", SALOME::BAD_PARAM );
156 GetImpl()->SetTotalThickness(thickness);
157 SMESH::TPythonDump() << _this() << ".SetTotalThickness( " << SMESH::TVar(thickness) << " )";
160 //================================================================================
164 //================================================================================
166 ::CORBA::Double StdMeshers_ViscousLayers_i::GetTotalThickness()
168 return GetImpl()->GetTotalThickness();
171 //================================================================================
176 //================================================================================
178 void StdMeshers_ViscousLayers_i::SetNumberLayers(::CORBA::Short nb)
181 THROW_SALOME_CORBA_EXCEPTION( "Invalid number of layers", SALOME::BAD_PARAM );
182 GetImpl()->SetNumberLayers( nb );
183 SMESH::TPythonDump() << _this() << ".SetNumberLayers( " << SMESH::TVar(nb) << " )";
186 //================================================================================
190 //================================================================================
192 ::CORBA::Short StdMeshers_ViscousLayers_i::GetNumberLayers()
194 return CORBA::Short( GetImpl()->GetNumberLayers() );
197 //================================================================================
202 //================================================================================
204 void StdMeshers_ViscousLayers_i::SetStretchFactor(::CORBA::Double factor)
207 THROW_SALOME_CORBA_EXCEPTION( "Invalid stretch factor, it must be >= 1.0", SALOME::BAD_PARAM );
208 GetImpl()->SetStretchFactor(factor);
209 SMESH::TPythonDump() << _this() << ".SetStretchFactor( " << SMESH::TVar(factor) << " )";
212 //================================================================================
217 //================================================================================
219 ::CORBA::Double StdMeshers_ViscousLayers_i::GetStretchFactor()
221 return GetImpl()->GetStretchFactor();
224 //================================================================================
226 * \brief Set Method of computing translation of a node
228 //================================================================================
230 void StdMeshers_ViscousLayers_i::SetMethod( ::StdMeshers::VLExtrusionMethod how )
232 GetImpl()->SetMethod( ::StdMeshers_ViscousLayers::ExtrusionMethod( how ));
233 const char* methNames[3] = { "SURF_OFFSET_SMOOTH",
236 if ( how >= 0 && how < 3 )
237 SMESH::TPythonDump() << _this() << ".SetMethod( StdMeshers." << methNames[ how ]<< " )";
240 //================================================================================
242 * \brief Return Method of computing translation of a node
244 //================================================================================
246 ::StdMeshers::VLExtrusionMethod StdMeshers_ViscousLayers_i::GetMethod()
248 return (::StdMeshers::VLExtrusionMethod) GetImpl()->GetMethod();
251 //================================================================================
253 * \brief Set name of a group of layers elements
255 //================================================================================
257 void StdMeshers_ViscousLayers_i::SetGroupName(const char* name)
259 if ( GetImpl()->GetGroupName() != name )
261 GetImpl()->SetGroupName( name );
262 SMESH::TPythonDump() << _this() << ".SetGroupName( '" << name << "' )";
266 //================================================================================
268 * \brief Return name of a group of layers elements
270 //================================================================================
272 char* StdMeshers_ViscousLayers_i::GetGroupName()
274 return CORBA::string_dup( GetImpl()->GetGroupName().c_str() );
277 //=============================================================================
281 //=============================================================================
283 ::StdMeshers_ViscousLayers* StdMeshers_ViscousLayers_i::GetImpl()
285 return ( ::StdMeshers_ViscousLayers* )myBaseImpl;
288 //================================================================================
290 * \brief Verify whether hypothesis supports given entity type
291 * \param type - dimension (see SMESH::Dimension enumeration)
292 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
294 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
296 //================================================================================
297 CORBA::Boolean StdMeshers_ViscousLayers_i::IsDimSupported( SMESH::Dimension type )
299 return type == SMESH::DIM_3D;
302 //================================================================================
304 * \brief Return method name corresponding to index of variable parameter
306 //================================================================================
308 std::string StdMeshers_ViscousLayers_i::getMethodOfParameter(const int paramIndex, int ) const
310 // order of methods was defined by StdMeshersGUI_StdHypothesisCreator::storeParams()
311 switch ( paramIndex )
313 case 0: return "SetTotalThickness";
314 case 1: return "SetNumberLayers";
315 case 2: return "SetStretchFactor";
321 //================================================================================
323 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
325 //================================================================================
328 StdMeshers_ViscousLayers_i::getObjectsDependOn( std::vector< std::string > & /*entryArray*/,
329 std::vector< int > & subIDArray ) const
331 const ::StdMeshers_ViscousLayers* impl =
332 static_cast<const ::StdMeshers_ViscousLayers*>( myBaseImpl );
334 subIDArray = impl->GetBndShapes();
339 //================================================================================
341 * \brief Set new geometry instead of that returned by getObjectsDependOn()
343 //================================================================================
346 StdMeshers_ViscousLayers_i::setObjectsDependOn( std::vector< std::string > & /*entryArray*/,
347 std::vector< int > & subIDArray )
349 std::vector< int > newIDs;
350 newIDs.reserve( subIDArray.size() );
352 for ( size_t i = 0; i < subIDArray.size(); ++i )
353 if ( subIDArray[ i ] > 0 )
354 newIDs.push_back( subIDArray[ i ]);
356 GetImpl()->SetBndShapes( newIDs, GetIsToIgnoreFaces() );