1 // Copyright (C) 2007-2013 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.
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,
51 ::SMESH_Gen* theGenImpl )
52 : SALOME::GenericObj_i( thePOA ),
53 SMESH_Hypothesis_i( thePOA )
55 MESSAGE( "StdMeshers_ViscousLayers2D_i::StdMeshers_ViscousLayers2D_i" );
56 myBaseImpl = new ::StdMeshers_ViscousLayers2D( theGenImpl->GetANewId(),
61 //=============================================================================
63 * StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i
67 //=============================================================================
69 StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i()
71 MESSAGE( "StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i" );
74 //================================================================================
78 //================================================================================
80 void StdMeshers_ViscousLayers2D_i::SetEdges(const ::SMESH::long_array& edgeIDs,
81 CORBA::Boolean toIgnore)
82 throw ( SALOME::SALOME_Exception )
84 vector<int> ids( edgeIDs.length() );
85 for ( unsigned i = 0; i < ids.size(); ++i )
86 if (( ids[i] = edgeIDs[i] ) < 1 )
87 THROW_SALOME_CORBA_EXCEPTION( "Invalid edge id", SALOME::BAD_PARAM );
89 GetImpl()->SetBndShapes( ids, toIgnore );
91 SMESH::TPythonDump() << _this() << ".SetEdges( " << edgeIDs << ", " << toIgnore << " )";
94 //================================================================================
98 //================================================================================
100 void StdMeshers_ViscousLayers2D_i::SetIgnoreEdges(const ::SMESH::long_array& edgeIDs)
101 throw ( SALOME::SALOME_Exception )
103 SMESH::TPythonDump pyDump;
104 this->SetEdges( edgeIDs, true );
105 pyDump<< _this() << ".SetIgnoreEdges( " << edgeIDs << " )";
108 //================================================================================
112 //================================================================================
114 SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetEdges()
116 vector<int> idsVec = GetImpl()->GetBndShapes();
117 SMESH::long_array_var ids = new SMESH::long_array;
118 ids->length( idsVec.size() );
119 for ( unsigned i = 0; i < idsVec.size(); ++i )
124 //================================================================================
128 //================================================================================
130 SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetIgnoreEdges()
132 if ( GetImpl()->IsToIgnoreShapes() )
133 return this->GetEdges();
134 return new SMESH::long_array;
137 //================================================================================
141 //================================================================================
143 CORBA::Boolean StdMeshers_ViscousLayers2D_i::GetIsToIgnoreEdges()
145 return GetImpl()->IsToIgnoreShapes();
148 //================================================================================
152 //================================================================================
154 void StdMeshers_ViscousLayers2D_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_ViscousLayers2D_i::GetTotalThickness()
171 return GetImpl()->GetTotalThickness();
174 //================================================================================
179 //================================================================================
181 void StdMeshers_ViscousLayers2D_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_ViscousLayers2D_i::GetNumberLayers()
198 return CORBA::Short( GetImpl()->GetNumberLayers() );
201 //================================================================================
206 //================================================================================
208 void StdMeshers_ViscousLayers2D_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_ViscousLayers2D_i::GetStretchFactor()
226 return GetImpl()->GetStretchFactor();
229 //=============================================================================
233 //=============================================================================
235 ::StdMeshers_ViscousLayers2D* StdMeshers_ViscousLayers2D_i::GetImpl()
237 MESSAGE( "StdMeshers_ViscousLayers2D_i::GetImpl" );
238 return ( ::StdMeshers_ViscousLayers2D* )myBaseImpl;
241 //================================================================================
243 * \brief Verify whether hypothesis supports given entity type
244 * \param type - dimension (see SMESH::Dimension enumeration)
245 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
247 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
249 //================================================================================
251 CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type )
253 return type == SMESH::DIM_2D;
256 //================================================================================
258 * \brief Sets sub-mesh event listeners to clear sub-meshes of edges
259 * shrinked by viscous layers
261 //================================================================================
263 void StdMeshers_ViscousLayers2D_i::UpdateAsMeshesRestored()
265 GetImpl()->RestoreListeners();