1 // Copyright (C) 2009-2013 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.
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>
29 # if defined HEXABLOCKS_EXPORTS || defined HexaBlocks_EXPORTS
30 # define HEXABLOCKS_EXPORT __declspec( dllexport )
32 # define HEXABLOCKS_EXPORT __declspec( dllimport )
35 # define HEXABLOCKS_EXPORT
38 #include "SMESH_Mesh.hxx"
39 #include "SMESH_Group.hxx"
40 #include "hexa_base.hxx" // from HexaBlocks
41 #include "HexFaceShape.hxx" // from HexaBlocks
43 #ifndef _Standard_Real_HeaderFile
44 #include <Standard_Real.hxx>
49 #include <TopoDS_Face.hxx>
50 #include "Handle_Geom_Curve.hxx"
51 #include <BRepAdaptor_Curve.hxx>
53 //=====================================================================
54 // SMESH_HexaBlocks : class definition
55 //=====================================================================
56 class HEXABLOCKS_EXPORT SMESH_HexaBlocks
60 // typedef std::vector<double> Xx;
61 typedef std::vector<SMDS_MeshVolume*> SMESHVolumes;
62 typedef std::vector<SMDS_MeshNode*> SMESHNodes;
63 typedef std::vector<SMDS_MeshFace*> SMESHFaces;
64 typedef std::vector<SMDS_MeshEdge*> SMESHEdges;
66 typedef std::vector< SMESHNodes > ArrayOfSMESHNodes;
75 SMESH_HexaBlocks(SMESH_Mesh& theMesh);
78 // --------------------------------------------------------------
80 // --------------------------------------------------------------
81 bool computeVertex( HEXA_NS::Vertex& vertex );
83 // --------------------------------------------------------------
85 // --------------------------------------------------------------
86 bool computeEdge( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
87 // Association solving
88 bool computeEdgeByAssoc( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
91 bool computeEdgeByShortestWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
92 bool computeEdgeByPlanWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
93 bool computeEdgeByIsoWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
94 bool computeEdgeBySegment( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
96 // --------------------------------------------------------------
98 // --------------------------------------------------------------
99 std::map<HEXA_NS::Quad*, bool> computeQuadWays( HEXA_NS::Document* doc );
100 bool computeQuad( HEXA_NS::Quad& quad, bool way );
101 // Association solving
102 bool computeQuadByAssoc( HEXA_NS::Quad& quad, bool way );
104 bool computeQuadByFindingGeom( HEXA_NS::Quad& quad, bool way );
105 bool computeQuadByLinearApproximation( HEXA_NS::Quad& quad, bool way );
107 // --------------------------------------------------------------
109 // --------------------------------------------------------------
110 bool computeHexa( HEXA_NS::Document* doc );
112 // --------------------------------------------------------------
113 // Document computing: Vertex, Edge, Quad and Hexa computing
114 // --------------------------------------------------------------
115 bool computeDoc( HEXA_NS::Document* doc );
118 // --------------------------------------------------------------
120 // --------------------------------------------------------------
121 void buildGroups(HEXA_NS::Document* doc);
125 // ******** METHOD FOR MESH COMPUTATION ********
127 double _Xx( double i, HEXA_NS::Law law, double nbNodes );
129 double _edgeLength(const TopoDS_Edge & E);
132 const gp_Pnt& myCurve_start, //IN
133 const gp_Pnt& myCurve_end, //IN
134 std::list< BRepAdaptor_Curve* >& myCurve, //INOUT
135 double& myCurve_length, //INOUT
136 std::map< BRepAdaptor_Curve*, double>& myCurve_lengths,//INOUT
137 std::map< BRepAdaptor_Curve*, bool>& myCurve_ways, //INOUT
138 std::map< BRepAdaptor_Curve*, double>& myCurve_starts, //INOUT
139 HEXA_NS::Edge& edge); // For diagnostic
141 gp_Pnt _getPtOnMyCurve(
142 const double& myCurve_u, //IN
143 std::map< BRepAdaptor_Curve*, bool>& myCurve_ways, //IN
144 std::map< BRepAdaptor_Curve*, double>& myCurve_lengths,//IN
145 std::map< BRepAdaptor_Curve*, double>& myCurve_starts, //IN
146 std::list< BRepAdaptor_Curve* >& myCurve, //INOUT
147 double& myCurve_start); //INOUT
150 void _nodeInterpolationUV( double u, double v,
151 SMDS_MeshNode* Pg, SMDS_MeshNode* Pd, SMDS_MeshNode* Ph, SMDS_MeshNode* Pb,
152 SMDS_MeshNode* S0, SMDS_MeshNode* S1, SMDS_MeshNode* S2, SMDS_MeshNode* S3,
153 double& xOut, double& yOut, double& zOut );
155 // TopoDS_Shape _getShapeOrCompound( const std::vector<HEXA_NS::Shape*>& shapesIn );
156 TopoDS_Shape getFaceShapes (Hex::Quad& quad);
158 gp_Pnt _intersect( const gp_Pnt& Pt,
159 const gp_Vec& u, const gp_Vec& v,
160 const TopoDS_Shape& s,
161 Standard_Real tol = 0.0001 );
163 bool _computeQuadInit(
165 ArrayOfSMESHNodes& nodesOnQuad,
166 std::vector<double>& xx, std::vector<double>& yy);
168 void _searchInitialQuadWay( HEXA_NS::Quad* quad, //IN
169 HEXA_NS::Vertex*& v0, //INOUT
170 HEXA_NS::Vertex*& v1 ); //INOUT
173 // ******** DATA FOR MESH COMPUTATION ********
175 std::map<HEXA_NS::Vertex*, SMDS_MeshNode*> _node; //_vertexNode;
176 std::map<const SMDS_MeshNode*, HEXA_NS::Vertex*> _vertex; //_nodeVertex;
179 std::map<HEXA_NS::Edge*, SMESHNodes> _nodesOnEdge; //_edgeNodes;
180 // std::map<HEXA_NS::Edge*, Xx> _edgeXx;
181 std::map<SMDS_MeshNode*, double> _nodeXx; //_edgeNodes;
182 std::map<HEXA_NS::Quad*, ArrayOfSMESHNodes> _quadNodes;
184 bool _computeVertexOK;
188 SMESHDS_Mesh* _theMeshDS;
189 SMESH_Mesh* _theMesh;
191 // ******** METHOD FOR GROUPS COMPUTATION ********
192 SMESH_Group* _createGroup(HEXA_NS::Group& grHex);
193 void _fillGroup(HEXA_NS::Group* grHex);
195 // ******** DATA FOR GROUPS COMPUTATION ********
196 std::map<HEXA_NS::Hexa*, SMESHVolumes> _volumesOnHexa;
197 std::map<HEXA_NS::Quad*, SMESHFaces> _facesOnQuad;
198 std::map<HEXA_NS::Edge*, SMESHEdges> _edgesOnEdge;
201 // for DEBUG purpose only: