1 // Copyright (C) 2009-2016 CEA/DEN, EDF R&D
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
19 // File : SMESH_HexaBlocks.hxx
23 #ifndef _SMESH_HexaBlocks_HeaderFile
24 #define _SMESH_HexaBlocks_HeaderFile
26 #include <SALOMEconfig.h>
27 #include "HEXABLOCKPlugin_Defs.hxx"
29 #include "SMESHDS_Mesh.hxx"
30 #include "SMESH_Group.hxx"
31 #include "SMESH_Mesh.hxx"
32 #include "hexa_base.hxx" // from HexaBlocks
33 #include "HexFaceShape.hxx" // from HexaBlocks
35 #ifndef _Standard_Real_HeaderFile
36 #include <Standard_Real.hxx>
41 #include <TopoDS_Face.hxx>
42 #include <BRepAdaptor_Curve.hxx>
44 //=====================================================================
45 // SMESH_HexaBlocks : class definition
46 //=====================================================================
47 class HEXABLOCKPLUGINENGINE_EXPORT SMESH_HexaBlocks
51 // typedef std::vector<double> Xx;
52 typedef std::vector<SMDS_MeshVolume*> SMESHVolumes;
53 typedef std::vector<SMDS_MeshNode*> SMESHNodes;
54 typedef std::vector<SMDS_MeshFace*> SMESHFaces;
55 typedef std::vector<SMDS_MeshEdge*> SMESHEdges;
57 typedef std::vector< SMESHNodes > ArrayOfSMESHNodes;
66 SMESH_HexaBlocks(SMESH_Mesh& theMesh);
69 // --------------------------------------------------------------
71 // --------------------------------------------------------------
72 bool computeVertex( HEXA_NS::Vertex& vertex );
74 // --------------------------------------------------------------
76 // --------------------------------------------------------------
77 bool computeEdge( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
78 // Association solving
79 bool computeEdgeByAssoc( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
82 bool computeEdgeByShortestWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
83 bool computeEdgeByPlanWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
84 bool computeEdgeByIsoWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
85 bool computeEdgeBySegment( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
87 // --------------------------------------------------------------
89 // --------------------------------------------------------------
90 std::map<HEXA_NS::Quad*, bool> computeQuadWays( HEXA_NS::Document* doc );
91 bool computeQuad( HEXA_NS::Quad& quad, bool way );
92 // Association solving
93 bool computeQuadByAssoc( HEXA_NS::Quad& quad, bool way );
95 bool computeQuadByFindingGeom( HEXA_NS::Quad& quad, bool way );
96 bool computeQuadByLinearApproximation( HEXA_NS::Quad& quad, bool way );
98 // --------------------------------------------------------------
100 // --------------------------------------------------------------
101 bool computeHexa( HEXA_NS::Document* doc );
103 // --------------------------------------------------------------
104 // Document computing: Vertex, Edge, Quad and Hexa computing
105 // --------------------------------------------------------------
106 bool computeDoc( HEXA_NS::Document* doc );
109 // --------------------------------------------------------------
111 // --------------------------------------------------------------
112 void buildGroups(HEXA_NS::Document* doc);
116 // ******** METHOD FOR MESH COMPUTATION ********
118 double _Xx( double i, HEXA_NS::Law law, double nbNodes );
120 double _edgeLength(const TopoDS_Edge & E);
123 const gp_Pnt& myCurve_start, //IN
124 const gp_Pnt& myCurve_end, //IN
125 std::list< BRepAdaptor_Curve* >& myCurve, //INOUT
126 double& myCurve_length, //INOUT
127 std::map< BRepAdaptor_Curve*, double>& myCurve_lengths,//INOUT
128 std::map< BRepAdaptor_Curve*, bool>& myCurve_ways, //INOUT
129 std::map< BRepAdaptor_Curve*, double>& myCurve_starts, //INOUT
130 HEXA_NS::Edge& edge); // For diagnostic
132 gp_Pnt _getPtOnMyCurve(
133 const double& myCurve_u, //IN
134 std::map< BRepAdaptor_Curve*, bool>& myCurve_ways, //IN
135 std::map< BRepAdaptor_Curve*, double>& myCurve_lengths,//IN
136 std::map< BRepAdaptor_Curve*, double>& myCurve_starts, //IN
137 std::list< BRepAdaptor_Curve* >& myCurve, //INOUT
138 double& myCurve_start); //INOUT
141 void _nodeInterpolationUV( double u, double v,
142 SMDS_MeshNode* Pg, SMDS_MeshNode* Pd, SMDS_MeshNode* Ph, SMDS_MeshNode* Pb,
143 SMDS_MeshNode* S0, SMDS_MeshNode* S1, SMDS_MeshNode* S2, SMDS_MeshNode* S3,
144 double& xOut, double& yOut, double& zOut );
146 // TopoDS_Shape _getShapeOrCompound( const std::vector<HEXA_NS::Shape*>& shapesIn );
147 TopoDS_Shape getFaceShapes (Hex::Quad& quad);
149 gp_Pnt _intersect( const gp_Pnt& Pt,
150 const gp_Vec& u, const gp_Vec& v,
151 const TopoDS_Shape& s,
152 Standard_Real tol = 0.0001 );
154 bool _computeQuadInit(
156 ArrayOfSMESHNodes& nodesOnQuad,
157 std::vector<double>& xx, std::vector<double>& yy);
159 void _searchInitialQuadWay( HEXA_NS::Quad* quad, //IN
160 HEXA_NS::Vertex*& v0, //INOUT
161 HEXA_NS::Vertex*& v1 ); //INOUT
164 // ******** DATA FOR MESH COMPUTATION ********
166 std::map<HEXA_NS::Vertex*, SMDS_MeshNode*> _node; //_vertexNode;
167 std::map<const SMDS_MeshNode*, HEXA_NS::Vertex*> _vertex; //_nodeVertex;
170 std::map<HEXA_NS::Edge*, SMESHNodes> _nodesOnEdge; //_edgeNodes;
171 // std::map<HEXA_NS::Edge*, Xx> _edgeXx;
172 std::map<SMDS_MeshNode*, double> _nodeXx; //_edgeNodes;
173 std::map<HEXA_NS::Quad*, ArrayOfSMESHNodes> _quadNodes;
175 bool _computeVertexOK;
179 SMESHDS_Mesh* _theMeshDS;
180 SMESH_Mesh* _theMesh;
182 // ******** METHOD FOR GROUPS COMPUTATION ********
183 SMESH_Group* _createGroup(HEXA_NS::Group& grHex);
184 void _fillGroup(HEXA_NS::Group* grHex);
186 // ******** DATA FOR GROUPS COMPUTATION ********
187 std::map<HEXA_NS::Hexa*, SMESHVolumes> _volumesOnHexa;
188 std::map<HEXA_NS::Quad*, SMESHFaces> _facesOnQuad;
189 std::map<HEXA_NS::Edge*, SMESHEdges> _edgesOnEdge;
192 // for DEBUG purpose only: