1 // Copyright (C) 2009-2012 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
42 #ifndef _Standard_Real_HeaderFile
43 #include <Standard_Real.hxx>
48 #include <TopoDS_Face.hxx>
49 #include "Handle_Geom_Curve.hxx"
50 #include <BRepAdaptor_Curve.hxx>
52 //=====================================================================
53 // SMESH_HexaBlocks : class definition
54 //=====================================================================
55 class HEXABLOCKS_EXPORT SMESH_HexaBlocks
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;
65 typedef std::vector< SMESHNodes > ArrayOfSMESHNodes;
74 SMESH_HexaBlocks(SMESH_Mesh& theMesh);
77 // --------------------------------------------------------------
79 // --------------------------------------------------------------
80 bool computeVertex( HEXA_NS::Vertex& vertex );
81 // Association solving
82 bool computeVertexByAssoc( HEXA_NS::Vertex& vertex );
84 bool computeVertexByModel( HEXA_NS::Vertex& vertex );
87 // --------------------------------------------------------------
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);
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);
100 // --------------------------------------------------------------
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 );
108 bool computeQuadByFindingGeom( HEXA_NS::Quad& quad, bool way );
109 bool computeQuadByLinearApproximation( HEXA_NS::Quad& quad, bool way );
111 // --------------------------------------------------------------
113 // --------------------------------------------------------------
114 bool computeHexa( HEXA_NS::Document* doc );
116 // --------------------------------------------------------------
117 // Document computing: Vertex, Edge, Quad and Hexa computing
118 // --------------------------------------------------------------
119 bool computeDoc( HEXA_NS::Document* doc );
122 // --------------------------------------------------------------
124 // --------------------------------------------------------------
125 void buildGroups(HEXA_NS::Document* doc);
129 // ******** METHOD FOR MESH COMPUTATION ********
131 double _Xx( double i, HEXA_NS::Law law, double nbNodes );
133 double _edgeLength(const TopoDS_Edge & E);
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
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
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 );
160 TopoDS_Shape _getShapeOrCompound( const std::vector<HEXA_NS::Shape*>& shapesIn );
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 );
167 bool _computeQuadInit(
169 ArrayOfSMESHNodes& nodesOnQuad,
170 std::vector<double>& xx, std::vector<double>& yy);
172 void _searchInitialQuadWay( HEXA_NS::Quad* quad, //IN
173 HEXA_NS::Vertex*& v0, //INOUT
174 HEXA_NS::Vertex*& v1 ); //INOUT
177 // ******** DATA FOR MESH COMPUTATION ********
179 std::map<HEXA_NS::Vertex*, SMDS_MeshNode*> _node; //_vertexNode;
180 std::map<const SMDS_MeshNode*, HEXA_NS::Vertex*> _vertex; //_nodeVertex;
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;
188 bool _computeVertexOK;
192 SMESHDS_Mesh* _theMeshDS;
193 SMESH_Mesh* _theMesh;
195 // ******** METHOD FOR GROUPS COMPUTATION ********
196 SMESH_Group* _createGroup(HEXA_NS::Group& grHex);
197 void _fillGroup(HEXA_NS::Group* grHex);
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;
205 // for DEBUG purpose only:
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