]> SALOME platform Git repositories - modules/smesh.git/blob - src/StdMeshers/StdMeshers_ViscousLayerBuilder.cxx
Salome HOME
Merge branch 'V9_12_BR'
[modules/smesh.git] / src / StdMeshers / StdMeshers_ViscousLayerBuilder.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File      : StdMeshers_ViscousLayerBuilder.cxx
21 // Module    : SMESH
22 // Author    : Cesar Conopoima (cce)
23 //
24
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"
33
34 #include <TopoDS.hxx>
35
36 #include <vector>
37
38 //=======================================================================
39 //function : StdMeshers_ViscousLayerBuilder
40 //purpose  : Implements 
41 //=======================================================================
42
43 StdMeshers_ViscousLayerBuilder::StdMeshers_ViscousLayerBuilder(int        hypId,
44                                                                 SMESH_Gen* gen)
45   : SMESH_2D_Algo(hypId, gen)
46 {
47   _name = "StdMeshers_ViscousLayerBuilder";
48   _hyp    = new StdMeshers_ViscousLayers2D( hypId, gen );  
49 }
50
51 bool StdMeshers_ViscousLayerBuilder::CheckHypothesis(SMESH_Mesh&                          aMesh,
52                                                       const TopoDS_Shape&                  aShape,
53                                                       SMESH_Hypothesis::Hypothesis_Status& aStatus)
54 {
55   (void) aMesh;
56   (void) aShape;
57   (void) aStatus;
58   return true;
59 }
60
61 bool StdMeshers_ViscousLayerBuilder::Compute(SMESH_Mesh& /*aMesh*/, const TopoDS_Shape& /*aShape*/)
62 {
63   return true;
64 }
65
66 bool StdMeshers_ViscousLayerBuilder::Evaluate(SMESH_Mesh & /*aMesh*/, const TopoDS_Shape & /*aShape*/,
67                                                 MapShapeNbElems& /*aResMap*/ )
68 {
69   return true;
70 }
71
72 bool StdMeshers_ViscousLayerBuilder::IsApplicable( const TopoDS_Shape &S, bool /*toCheckAll*/, int algoDim )
73 {
74   if ( S.ShapeType() > TopAbs_FACE )
75     return false;
76
77   return ( std::abs( algoDim ) == 3 || std::abs( algoDim ) == 2 ) ? true : false;
78 }
79
80 void StdMeshers_ViscousLayerBuilder::SetBndShapes(const std::vector<int>& faceIds, bool toIgnore)
81 {
82   _hyp->SetBndShapes( faceIds, toIgnore );  
83 } // --------------------------------------------------------------------------------
84 void StdMeshers_ViscousLayerBuilder::SetTotalThickness(double thickness)
85 {
86   _hyp->SetTotalThickness( thickness );
87 } // --------------------------------------------------------------------------------
88 void StdMeshers_ViscousLayerBuilder::SetNumberLayers(int nb)
89 {
90   _hyp->SetNumberLayers( nb );
91 } // --------------------------------------------------------------------------------
92 void StdMeshers_ViscousLayerBuilder::SetStretchFactor(double factor)
93 {
94   _hyp->SetStretchFactor( factor );
95 } // --------------------------------------------------------------------------------
96 void StdMeshers_ViscousLayerBuilder::SetMethod( StdMeshers_ViscousLayers::ExtrusionMethod method )
97 {
98   _hyp->SetMethod( method );
99 } // --------------------------------------------------------------------------------
100 void StdMeshers_ViscousLayerBuilder::SetGroupName(const std::string& name)
101 {
102   _hyp->SetGroupName( name );
103
104
105 //=======================================================================
106 //function : ~StdMeshers_ViscousLayerBuilder
107 //purpose  :
108 //=======================================================================
109
110 StdMeshers_ViscousLayerBuilder::~StdMeshers_ViscousLayerBuilder()
111 {
112 }
113
114 TopoDS_Shape StdMeshers_ViscousLayerBuilder::GetShrinkGeometry( SMESH_Mesh & theMesh, const TopoDS_Shape& theShape )
115 {
116   _vlBuilder  = new StdMeshers_Cartesian_VL::ViscousBuilder( _hyp, theMesh, theShape );
117
118   std::string error = "";
119   _offsetShape = _vlBuilder->MakeOffsetShape( theShape, theMesh, error );
120   if ( error != "" )
121     throw SALOME_Exception( error );
122   
123   return _offsetShape;
124 }
125
126 bool StdMeshers_ViscousLayerBuilder::AddLayers( SMESH_Mesh & shrinkMesh, SMESH_Mesh & theMesh, const TopoDS_Shape& theShape )
127 {
128   bool success = _vlBuilder->MakeViscousLayers( shrinkMesh, theMesh, theShape );
129   
130   if ( !success )
131     throw SALOME_Exception( "Error building viscous layer from shrink geometry." );
132
133   return success;
134 }