1 // Copyright (C) 2007-2020 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 // File : StdMeshers_ViscousLayers2D_i.cxx
26 #include "StdMeshers_ViscousLayers2D_i.hxx"
28 #include "SMESH_Gen.hxx"
29 #include "SMESH_Gen_i.hxx"
30 #include "SMESH_PythonDump.hxx"
32 #include "Utils_CorbaException.hxx"
33 #include "utilities.h"
35 #include <TCollection_AsciiString.hxx>
37 #include CORBA_SERVER_HEADER(SMESH_Group)
41 //=============================================================================
43 * StdMeshers_ViscousLayers2D_i::StdMeshers_ViscousLayers2D_i
47 //=============================================================================
49 StdMeshers_ViscousLayers2D_i::StdMeshers_ViscousLayers2D_i( PortableServer::POA_ptr thePOA,
50 ::SMESH_Gen* theGenImpl )
51 : SALOME::GenericObj_i( thePOA ),
52 SMESH_Hypothesis_i( thePOA )
54 myBaseImpl = new ::StdMeshers_ViscousLayers2D( theGenImpl->GetANewId(),
58 //=============================================================================
60 * StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i
64 //=============================================================================
66 StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i()
70 //================================================================================
74 //================================================================================
76 void StdMeshers_ViscousLayers2D_i::SetEdges(const ::SMESH::long_array& edgeIDs,
77 CORBA::Boolean toIgnore)
79 vector<int> ids( edgeIDs.length() );
80 for ( unsigned i = 0; i < ids.size(); ++i )
81 if (( ids[i] = edgeIDs[i] ) < 1 )
82 THROW_SALOME_CORBA_EXCEPTION( "Invalid edge id", SALOME::BAD_PARAM );
84 GetImpl()->SetBndShapes( ids, toIgnore );
86 SMESH::TPythonDump() << _this() << ".SetEdges( " << edgeIDs << ", " << toIgnore << " )";
89 //================================================================================
93 //================================================================================
95 void StdMeshers_ViscousLayers2D_i::SetIgnoreEdges(const ::SMESH::long_array& edgeIDs)
98 SMESH::TPythonDump pyDump;
99 this->SetEdges( edgeIDs, true );
100 pyDump<< _this() << ".SetIgnoreEdges( " << edgeIDs << " )";
103 //================================================================================
107 //================================================================================
109 SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetEdges()
111 vector<int> idsVec = GetImpl()->GetBndShapes();
112 SMESH::long_array_var ids = new SMESH::long_array;
113 ids->length( idsVec.size() );
114 for ( unsigned i = 0; i < idsVec.size(); ++i )
119 //================================================================================
123 //================================================================================
125 SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetIgnoreEdges()
127 if ( GetImpl()->IsToIgnoreShapes() )
128 return this->GetEdges();
129 return new SMESH::long_array;
132 //================================================================================
136 //================================================================================
138 CORBA::Boolean StdMeshers_ViscousLayers2D_i::GetIsToIgnoreEdges()
140 return GetImpl()->IsToIgnoreShapes();
143 //================================================================================
147 //================================================================================
149 void StdMeshers_ViscousLayers2D_i::SetTotalThickness(::CORBA::Double thickness)
152 if ( thickness < 1e-100 )
153 THROW_SALOME_CORBA_EXCEPTION( "Invalid thickness", SALOME::BAD_PARAM );
154 GetImpl()->SetTotalThickness(thickness);
155 SMESH::TPythonDump() << _this() << ".SetTotalThickness( " << SMESH::TVar(thickness) << " )";
158 //================================================================================
162 //================================================================================
164 ::CORBA::Double StdMeshers_ViscousLayers2D_i::GetTotalThickness()
166 return GetImpl()->GetTotalThickness();
169 //================================================================================
174 //================================================================================
176 void StdMeshers_ViscousLayers2D_i::SetNumberLayers(::CORBA::Short nb)
180 THROW_SALOME_CORBA_EXCEPTION( "Invalid number of layers", SALOME::BAD_PARAM );
181 GetImpl()->SetNumberLayers( nb );
182 SMESH::TPythonDump() << _this() << ".SetNumberLayers( " << SMESH::TVar(nb) << " )";
185 //================================================================================
189 //================================================================================
191 ::CORBA::Short StdMeshers_ViscousLayers2D_i::GetNumberLayers()
193 return CORBA::Short( GetImpl()->GetNumberLayers() );
196 //================================================================================
201 //================================================================================
203 void StdMeshers_ViscousLayers2D_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_ViscousLayers2D_i::GetStretchFactor()
221 return GetImpl()->GetStretchFactor();
224 //================================================================================
226 * \brief Set name of a group of layers elements
228 //================================================================================
230 void StdMeshers_ViscousLayers2D_i::SetGroupName(const char* name)
232 if ( GetImpl()->GetGroupName() != name )
234 GetImpl()->SetGroupName( name );
235 SMESH::TPythonDump() << _this() << ".SetGroupName( '" << name << "' )";
239 //================================================================================
241 * \brief Return name of a group of layers elements
243 //================================================================================
245 char* StdMeshers_ViscousLayers2D_i::GetGroupName()
247 return CORBA::string_dup( GetImpl()->GetGroupName().c_str() );
251 //=============================================================================
255 //=============================================================================
257 ::StdMeshers_ViscousLayers2D* StdMeshers_ViscousLayers2D_i::GetImpl()
259 return ( ::StdMeshers_ViscousLayers2D* )myBaseImpl;
262 //================================================================================
264 * \brief Verify whether hypothesis supports given entity type
265 * \param type - dimension (see SMESH::Dimension enumeration)
266 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
268 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
270 //================================================================================
272 CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type )
274 return type == SMESH::DIM_2D;
277 //================================================================================
279 * \brief Sets sub-mesh event listeners to clear sub-meshes of edges
280 * shrinked by viscous layers
282 //================================================================================
284 void StdMeshers_ViscousLayers2D_i::UpdateAsMeshesRestored()
286 GetImpl()->RestoreListeners();
289 //================================================================================
291 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
293 //================================================================================
296 StdMeshers_ViscousLayers2D_i::getObjectsDependOn( std::vector< std::string > & /*entryArray*/,
297 std::vector< int > & subIDArray ) const
299 const ::StdMeshers_ViscousLayers2D* impl =
300 static_cast<const ::StdMeshers_ViscousLayers2D*>( myBaseImpl );
302 subIDArray = impl->GetBndShapes();
307 //================================================================================
309 * \brief Set new geometry instead of that returned by getObjectsDependOn()
311 //================================================================================
314 StdMeshers_ViscousLayers2D_i::setObjectsDependOn( std::vector< std::string > & /*entryArray*/,
315 std::vector< int > & subIDArray )
317 std::vector< int > newIDs;
318 newIDs.reserve( subIDArray.size() );
320 for ( size_t i = 0; i < subIDArray.size(); ++i )
321 if ( subIDArray[ i ] > 0 )
322 newIDs.push_back( subIDArray[ i ]);
324 GetImpl()->SetBndShapes( newIDs, GetIsToIgnoreEdges() );