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