]> SALOME platform Git repositories - plugins/hexablockplugin.git/blob - src/HEXABLOCKPlugin/HEXABLOCKPlugin_mesh.hxx
Salome HOME
Merge remote branch 'origin/V7_dev'
[plugins/hexablockplugin.git] / src / HEXABLOCKPlugin / HEXABLOCKPlugin_mesh.hxx
1 // Copyright (C) 2009-2016  CEA/DEN, EDF R&D
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 //  File   : SMESH_HexaBlocks.hxx
20 //  Author :
21 //  Module : SMESH
22 //
23 #ifndef _SMESH_HexaBlocks_HeaderFile
24 #define _SMESH_HexaBlocks_HeaderFile
25
26 #include <SALOMEconfig.h>
27 #include "HEXABLOCKPlugin_Defs.hxx"
28
29 #include "SMESH_Mesh.hxx"
30 #include "SMESH_Group.hxx"
31 #include "hexa_base.hxx" // from HexaBlocks
32 #include "HexFaceShape.hxx" // from HexaBlocks
33
34 #ifndef _Standard_Real_HeaderFile
35 #include <Standard_Real.hxx>
36 #endif
37
38 #include <gp_Pnt.hxx>
39 #include <gp_Vec.hxx>
40 #include <TopoDS_Face.hxx>
41 #include <BRepAdaptor_Curve.hxx>
42
43 //=====================================================================
44 // SMESH_HexaBlocks : class definition
45 //=====================================================================
46 class HEXABLOCKPLUGINENGINE_EXPORT SMESH_HexaBlocks
47 {
48 public:
49
50 //   typedef std::vector<double>            Xx;
51   typedef std::vector<SMDS_MeshVolume*>  SMESHVolumes;
52   typedef std::vector<SMDS_MeshNode*>    SMESHNodes;
53   typedef std::vector<SMDS_MeshFace*>    SMESHFaces;
54   typedef std::vector<SMDS_MeshEdge*>    SMESHEdges;
55
56   typedef std::vector< SMESHNodes >      ArrayOfSMESHNodes;
57
58   struct Coord{
59     double x;
60     double y;
61     double z;
62   };
63
64
65    SMESH_HexaBlocks(SMESH_Mesh& theMesh);
66   ~SMESH_HexaBlocks();
67
68   // --------------------------------------------------------------
69   //  Vertex computing
70   // --------------------------------------------------------------
71   bool computeVertex( HEXA_NS::Vertex& vertex );
72
73   // --------------------------------------------------------------
74   //  Edge computing
75   // --------------------------------------------------------------
76   bool computeEdge( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
77   // Association solving
78   bool computeEdgeByAssoc( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
79
80   // Automatic solving
81   bool computeEdgeByShortestWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
82   bool computeEdgeByPlanWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
83   bool computeEdgeByIsoWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
84   bool computeEdgeBySegment( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
85
86   // --------------------------------------------------------------
87   //  Quad computing
88   // --------------------------------------------------------------
89   std::map<HEXA_NS::Quad*, bool>  computeQuadWays( HEXA_NS::Document* doc );
90   bool computeQuad( HEXA_NS::Quad& quad, bool way );
91   // Association solving
92   bool computeQuadByAssoc( HEXA_NS::Quad& quad, bool way );
93   // Automatic solving
94   bool computeQuadByFindingGeom( HEXA_NS::Quad& quad, bool way );
95   bool computeQuadByLinearApproximation( HEXA_NS::Quad& quad, bool way );
96
97   // --------------------------------------------------------------
98   //  Hexa computing
99   // --------------------------------------------------------------
100   bool computeHexa( HEXA_NS::Document* doc );
101
102   // --------------------------------------------------------------
103   //  Document computing: Vertex, Edge, Quad and Hexa computing
104   // --------------------------------------------------------------
105   bool computeDoc( HEXA_NS::Document* doc );
106
107
108   // --------------------------------------------------------------
109   //  Build groups
110   // --------------------------------------------------------------
111   void buildGroups(HEXA_NS::Document* doc);
112
113
114 private:
115   //    ********     METHOD FOR MESH COMPUTATION    ********
116   //  EDGE
117   double _Xx( double i, HEXA_NS::Law law, double nbNodes );
118
119   double _edgeLength(const TopoDS_Edge & E);
120
121   void _buildMyCurve(
122       const gp_Pnt&                             myCurve_start,  //IN
123       const gp_Pnt&                             myCurve_end,    //IN
124       std::list< BRepAdaptor_Curve* >&          myCurve,        //INOUT
125       double&                                   myCurve_length, //INOUT
126       std::map< BRepAdaptor_Curve*, double>&    myCurve_lengths,//INOUT
127       std::map< BRepAdaptor_Curve*, bool>&      myCurve_ways,   //INOUT
128       std::map< BRepAdaptor_Curve*, double>&    myCurve_starts,   //INOUT
129       HEXA_NS::Edge&                            edge);  // For diagnostic
130
131   gp_Pnt _getPtOnMyCurve(
132       const double&                           myCurve_u,      //IN
133       std::map< BRepAdaptor_Curve*, bool>&    myCurve_ways,   //IN
134       std::map< BRepAdaptor_Curve*, double>&  myCurve_lengths,//IN
135       std::map< BRepAdaptor_Curve*, double>&  myCurve_starts, //IN
136       std::list< BRepAdaptor_Curve* >&        myCurve,        //INOUT
137       double&                                 myCurve_start); //INOUT
138
139   // QUAD
140   void _nodeInterpolationUV( double u, double v,
141     SMDS_MeshNode* Pg, SMDS_MeshNode* Pd, SMDS_MeshNode* Ph, SMDS_MeshNode* Pb,
142     SMDS_MeshNode* S0, SMDS_MeshNode* S1, SMDS_MeshNode* S2, SMDS_MeshNode* S3,
143     double& xOut, double& yOut, double& zOut );
144
145   // TopoDS_Shape _getShapeOrCompound( const std::vector<HEXA_NS::Shape*>& shapesIn );
146   TopoDS_Shape getFaceShapes (Hex::Quad& quad);
147
148   gp_Pnt _intersect( const gp_Pnt& Pt,
149                      const gp_Vec& u, const gp_Vec& v,
150                      const TopoDS_Shape& s,
151                      Standard_Real tol = 0.0001 );
152
153   bool _computeQuadInit(
154     HEXA_NS::Quad& quad,
155     ArrayOfSMESHNodes& nodesOnQuad,
156     std::vector<double>& xx, std::vector<double>& yy);
157
158   void _searchInitialQuadWay( HEXA_NS::Quad* quad, //IN
159                               HEXA_NS::Vertex*& v0,      //INOUT
160                               HEXA_NS::Vertex*& v1 );    //INOUT
161
162
163   //    ********     DATA FOR MESH COMPUTATION    ********
164   //    NODES
165   std::map<HEXA_NS::Vertex*, SMDS_MeshNode*>        _node;    //_vertexNode;
166   std::map<const SMDS_MeshNode*, HEXA_NS::Vertex*>  _vertex;  //_nodeVertex;
167
168   //    EDGES
169   std::map<HEXA_NS::Edge*, SMESHNodes>  _nodesOnEdge; //_edgeNodes;
170 //   std::map<HEXA_NS::Edge*, Xx>                _edgeXx;
171   std::map<SMDS_MeshNode*, double>  _nodeXx; //_edgeNodes;
172   std::map<HEXA_NS::Quad*, ArrayOfSMESHNodes> _quadNodes;
173
174   bool _computeVertexOK;
175   bool _computeEdgeOK;
176   bool _computeQuadOK;
177
178   SMESHDS_Mesh* _theMeshDS;
179   SMESH_Mesh*   _theMesh;
180
181   //    ********     METHOD FOR GROUPS COMPUTATION    ********
182   SMESH_Group* _createGroup(HEXA_NS::Group& grHex);
183   void _fillGroup(HEXA_NS::Group* grHex);
184
185   //    ********     DATA FOR GROUPS COMPUTATION    ********
186   std::map<HEXA_NS::Hexa*, SMESHVolumes> _volumesOnHexa;
187   std::map<HEXA_NS::Quad*, SMESHFaces>   _facesOnQuad;
188   std::map<HEXA_NS::Edge*, SMESHEdges>   _edgesOnEdge;
189
190
191   // for DEBUG purpose only:
192   int _total;
193   int _found;
194   int _notFound;
195 };
196
197
198 #endif