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 // 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)
78 throw ( SALOME::SALOME_Exception )
80 vector<int> ids( edgeIDs.length() );
81 for ( unsigned i = 0; i < ids.size(); ++i )
82 if (( ids[i] = edgeIDs[i] ) < 1 )
83 THROW_SALOME_CORBA_EXCEPTION( "Invalid edge id", SALOME::BAD_PARAM );
85 GetImpl()->SetBndShapes( ids, toIgnore );
87 SMESH::TPythonDump() << _this() << ".SetEdges( " << edgeIDs << ", " << toIgnore << " )";
90 //================================================================================
94 //================================================================================
96 void StdMeshers_ViscousLayers2D_i::SetIgnoreEdges(const ::SMESH::long_array& edgeIDs)
97 throw ( SALOME::SALOME_Exception )
99 SMESH::TPythonDump pyDump;
100 this->SetEdges( edgeIDs, true );
101 pyDump<< _this() << ".SetIgnoreEdges( " << edgeIDs << " )";
104 //================================================================================
108 //================================================================================
110 SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetEdges()
112 vector<int> idsVec = GetImpl()->GetBndShapes();
113 SMESH::long_array_var ids = new SMESH::long_array;
114 ids->length( idsVec.size() );
115 for ( unsigned i = 0; i < idsVec.size(); ++i )
120 //================================================================================
124 //================================================================================
126 SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetIgnoreEdges()
128 if ( GetImpl()->IsToIgnoreShapes() )
129 return this->GetEdges();
130 return new SMESH::long_array;
133 //================================================================================
137 //================================================================================
139 CORBA::Boolean StdMeshers_ViscousLayers2D_i::GetIsToIgnoreEdges()
141 return GetImpl()->IsToIgnoreShapes();
144 //================================================================================
148 //================================================================================
150 void StdMeshers_ViscousLayers2D_i::SetTotalThickness(::CORBA::Double thickness)
151 throw ( SALOME::SALOME_Exception )
153 if ( thickness < 1e-100 )
154 THROW_SALOME_CORBA_EXCEPTION( "Invalid thickness", SALOME::BAD_PARAM );
155 GetImpl()->SetTotalThickness(thickness);
156 SMESH::TPythonDump() << _this() << ".SetTotalThickness( " << SMESH::TVar(thickness) << " )";
159 //================================================================================
163 //================================================================================
165 ::CORBA::Double StdMeshers_ViscousLayers2D_i::GetTotalThickness()
167 return GetImpl()->GetTotalThickness();
170 //================================================================================
175 //================================================================================
177 void StdMeshers_ViscousLayers2D_i::SetNumberLayers(::CORBA::Short nb)
178 throw ( SALOME::SALOME_Exception )
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_ViscousLayers2D_i::GetNumberLayers()
194 return CORBA::Short( GetImpl()->GetNumberLayers() );
197 //================================================================================
202 //================================================================================
204 void StdMeshers_ViscousLayers2D_i::SetStretchFactor(::CORBA::Double factor)
205 throw ( SALOME::SALOME_Exception )
208 THROW_SALOME_CORBA_EXCEPTION( "Invalid stretch factor, it must be >= 1.0", SALOME::BAD_PARAM );
209 GetImpl()->SetStretchFactor(factor);
210 SMESH::TPythonDump() << _this() << ".SetStretchFactor( " << SMESH::TVar(factor) << " )";
213 //================================================================================
218 //================================================================================
220 ::CORBA::Double StdMeshers_ViscousLayers2D_i::GetStretchFactor()
222 return GetImpl()->GetStretchFactor();
225 //=============================================================================
229 //=============================================================================
231 ::StdMeshers_ViscousLayers2D* StdMeshers_ViscousLayers2D_i::GetImpl()
233 return ( ::StdMeshers_ViscousLayers2D* )myBaseImpl;
236 //================================================================================
238 * \brief Verify whether hypothesis supports given entity type
239 * \param type - dimension (see SMESH::Dimension enumeration)
240 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
242 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
244 //================================================================================
246 CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type )
248 return type == SMESH::DIM_2D;
251 //================================================================================
253 * \brief Sets sub-mesh event listeners to clear sub-meshes of edges
254 * shrinked by viscous layers
256 //================================================================================
258 void StdMeshers_ViscousLayers2D_i::UpdateAsMeshesRestored()
260 GetImpl()->RestoreListeners();
263 //================================================================================
265 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
267 //================================================================================
270 StdMeshers_ViscousLayers2D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
271 std::vector< int > & subIDArray ) const
273 const ::StdMeshers_ViscousLayers2D* impl =
274 static_cast<const ::StdMeshers_ViscousLayers2D*>( myBaseImpl );
276 subIDArray = impl->GetBndShapes();
281 //================================================================================
283 * \brief Set new geometry instead of that returned by getObjectsDependOn()
285 //================================================================================
288 StdMeshers_ViscousLayers2D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
289 std::vector< int > & subIDArray )
291 std::vector< int > newIDs;
292 newIDs.reserve( subIDArray.size() );
294 for ( size_t i = 0; i < subIDArray.size(); ++i )
295 if ( subIDArray[ i ] > 0 )
296 newIDs.push_back( subIDArray[ i ]);
298 GetImpl()->SetBndShapes( newIDs, GetIsToIgnoreEdges() );