1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : StdMeshers_ViscousLayerBuilder.cxx
22 // Author : Cesar Conopoima (cce)
25 #include "SMESHDS_Mesh.hxx"
26 #include "SMESH_ControlsDef.hxx"
27 #include "SMESH_Gen.hxx"
28 #include "SMESH_Mesh.hxx"
29 #include "SMESH_MeshAlgos.hxx"
30 #include "SMESH_MeshEditor.hxx"
31 #include "SMESH_MesherHelper.hxx"
32 #include "StdMeshers_ViscousLayerBuilder.hxx"
38 //=======================================================================
39 //function : StdMeshers_ViscousLayerBuilder
40 //purpose : Implements
41 //=======================================================================
43 StdMeshers_ViscousLayerBuilder::StdMeshers_ViscousLayerBuilder(int hypId,
45 : SMESH_2D_Algo(hypId, gen)
47 _name = "StdMeshers_ViscousLayerBuilder";
48 _hyp = new StdMeshers_ViscousLayers2D( hypId, gen );
51 bool StdMeshers_ViscousLayerBuilder::CheckHypothesis(SMESH_Mesh& aMesh,
52 const TopoDS_Shape& aShape,
53 SMESH_Hypothesis::Hypothesis_Status& aStatus)
61 bool StdMeshers_ViscousLayerBuilder::Compute(SMESH_Mesh& /*aMesh*/, const TopoDS_Shape& /*aShape*/)
66 bool StdMeshers_ViscousLayerBuilder::Evaluate(SMESH_Mesh & /*aMesh*/, const TopoDS_Shape & /*aShape*/,
67 MapShapeNbElems& /*aResMap*/ )
72 bool StdMeshers_ViscousLayerBuilder::IsApplicable( const TopoDS_Shape &S, bool /*toCheckAll*/, int algoDim )
74 if ( S.ShapeType() > TopAbs_FACE )
77 return ( std::abs( algoDim ) == 3 || std::abs( algoDim ) == 2 ) ? true : false;
80 void StdMeshers_ViscousLayerBuilder::SetBndShapes(const std::vector<int>& faceIds, bool toIgnore)
82 _hyp->SetBndShapes( faceIds, toIgnore );
83 } // --------------------------------------------------------------------------------
84 void StdMeshers_ViscousLayerBuilder::SetTotalThickness(double thickness)
86 _hyp->SetTotalThickness( thickness );
87 } // --------------------------------------------------------------------------------
88 void StdMeshers_ViscousLayerBuilder::SetNumberLayers(int nb)
90 _hyp->SetNumberLayers( nb );
91 } // --------------------------------------------------------------------------------
92 void StdMeshers_ViscousLayerBuilder::SetStretchFactor(double factor)
94 _hyp->SetStretchFactor( factor );
95 } // --------------------------------------------------------------------------------
96 void StdMeshers_ViscousLayerBuilder::SetMethod( StdMeshers_ViscousLayers::ExtrusionMethod method )
98 _hyp->SetMethod( method );
99 } // --------------------------------------------------------------------------------
100 void StdMeshers_ViscousLayerBuilder::SetGroupName(const std::string& name)
102 _hyp->SetGroupName( name );
105 //=======================================================================
106 //function : ~StdMeshers_ViscousLayerBuilder
108 //=======================================================================
110 StdMeshers_ViscousLayerBuilder::~StdMeshers_ViscousLayerBuilder()
114 TopoDS_Shape StdMeshers_ViscousLayerBuilder::GetShrinkGeometry( SMESH_Mesh & theMesh, const TopoDS_Shape& theShape )
116 _vlBuilder = new StdMeshers_Cartesian_VL::ViscousBuilder( _hyp, theMesh, theShape );
118 std::string error = "";
119 _offsetShape = _vlBuilder->MakeOffsetShape( theShape, theMesh, error );
121 throw SALOME_Exception( error );
126 bool StdMeshers_ViscousLayerBuilder::AddLayers( SMESH_Mesh & shrinkMesh, SMESH_Mesh & theMesh, const TopoDS_Shape& theShape )
128 bool success = _vlBuilder->MakeViscousLayers( shrinkMesh, theMesh, theShape );
131 throw SALOME_Exception( "Error building viscous layer from shrink geometry." );