1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESHClient : tool to update client mesh structure by mesh from server
23 // File : SMESH_HexaBlocks.hxx
27 #ifndef _SMESH_HexaBlocks_HeaderFile
28 #define _SMESH_HexaBlocks_HeaderFile
30 #include <SALOMEconfig.h>
33 # if defined HEXABLOCKS_EXPORTS || defined HexaBlocks_EXPORTS
34 # define HEXABLOCKS_EXPORT __declspec( dllexport )
36 # define HEXABLOCKS_EXPORT __declspec( dllimport )
39 # define HEXABLOCKS_EXPORT
42 #include "SMESH_Mesh.hxx"
43 #include "SMESH_Group.hxx"
44 #include "hexa_base.hxx" // from HexaBlocks
46 #ifndef _Standard_Real_HeaderFile
47 #include <Standard_Real.hxx>
52 #include <TopoDS_Face.hxx>
53 #include "Handle_Geom_Curve.hxx"
54 #include <BRepAdaptor_Curve.hxx>
56 //=====================================================================
57 // SMESH_HexaBlocks : class definition
58 //=====================================================================
59 class HEXABLOCKS_EXPORT SMESH_HexaBlocks
63 // typedef std::vector<double> Xx;
64 typedef std::vector<SMDS_MeshVolume*> SMESHVolumes;
65 typedef std::vector<SMDS_MeshNode*> SMESHNodes;
66 typedef std::vector<SMDS_MeshFace*> SMESHFaces;
67 typedef std::vector<SMDS_MeshEdge*> SMESHEdges;
69 typedef std::vector< SMESHNodes > ArrayOfSMESHNodes;
78 SMESH_HexaBlocks(SMESH_Mesh& theMesh);
81 // --------------------------------------------------------------
83 // --------------------------------------------------------------
84 bool computeVertex( HEXA_NS::Vertex& vertex );
85 // Association solving
86 bool computeVertexByAssoc( HEXA_NS::Vertex& vertex );
88 bool computeVertexByModel( HEXA_NS::Vertex& vertex );
91 // --------------------------------------------------------------
93 // --------------------------------------------------------------
94 bool computeEdge( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
95 // Association solving
96 bool computeEdgeByAssoc( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
99 bool computeEdgeByShortestWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
100 bool computeEdgeByPlanWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
101 bool computeEdgeByIsoWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
102 bool computeEdgeBySegment( HEXA_NS::Edge& edge, HEXA_NS::Law& law);
104 // --------------------------------------------------------------
106 // --------------------------------------------------------------
107 std::map<HEXA_NS::Quad*, bool> computeQuadWays( HEXA_NS::Document* doc );
108 bool computeQuad( HEXA_NS::Quad& quad, bool way );
109 // Association solving
110 bool computeQuadByAssoc( HEXA_NS::Quad& quad, bool way );
112 bool computeQuadByFindingGeom( HEXA_NS::Quad& quad, bool way );
113 bool computeQuadByLinearApproximation( HEXA_NS::Quad& quad, bool way );
115 // --------------------------------------------------------------
117 // --------------------------------------------------------------
118 bool computeHexa( HEXA_NS::Document* doc );
120 // --------------------------------------------------------------
121 // Document computing: Vertex, Edge, Quad and Hexa computing
122 // --------------------------------------------------------------
123 bool computeDoc( HEXA_NS::Document* doc );
126 // --------------------------------------------------------------
128 // --------------------------------------------------------------
129 void buildGroups(HEXA_NS::Document* doc);
133 // ******** METHOD FOR MESH COMPUTATION ********
135 double _Xx( double i, HEXA_NS::Law law, double nbNodes );
137 double _edgeLength(const TopoDS_Edge & E);
140 const std::vector <HEXA_NS::Shape*>& associations, //IN
141 const gp_Pnt& myCurve_start, //IN
142 const gp_Pnt& myCurve_end, //IN
143 std::list< BRepAdaptor_Curve* >& myCurve, //INOUT
144 double& myCurve_length, //INOUT
145 std::map< BRepAdaptor_Curve*, double>& myCurve_lengths,//INOUT
146 std::map< BRepAdaptor_Curve*, bool>& myCurve_ways, //INOUT
147 std::map< BRepAdaptor_Curve*, double>& myCurve_starts ); //INOUT
149 gp_Pnt _getPtOnMyCurve(
150 const double& myCurve_u, //IN
151 std::map< BRepAdaptor_Curve*, bool>& myCurve_ways, //IN
152 std::map< BRepAdaptor_Curve*, double>& myCurve_lengths,//IN
153 std::map< BRepAdaptor_Curve*, double>& myCurve_starts, //IN
154 std::list< BRepAdaptor_Curve* >& myCurve, //INOUT
155 double& myCurve_start); //INOUT
158 void _nodeInterpolationUV( double u, double v,
159 SMDS_MeshNode* Pg, SMDS_MeshNode* Pd, SMDS_MeshNode* Ph, SMDS_MeshNode* Pb,
160 SMDS_MeshNode* S0, SMDS_MeshNode* S1, SMDS_MeshNode* S2, SMDS_MeshNode* S3,
161 double& xOut, double& yOut, double& zOut );
163 TopoDS_Shape _getShapeOrCompound( const std::vector<HEXA_NS::Shape*>& shapesIn );
165 gp_Pnt _intersect( const gp_Pnt& Pt,
166 const gp_Vec& u, const gp_Vec& v,
167 const TopoDS_Shape& s,
168 Standard_Real tol = 0.0001 );
170 bool _computeQuadInit(
172 ArrayOfSMESHNodes& nodesOnQuad,
173 std::vector<double>& xx, std::vector<double>& yy);
175 void _searchInitialQuadWay( HEXA_NS::Quad* quad, //IN
176 HEXA_NS::Vertex*& v0, //INOUT
177 HEXA_NS::Vertex*& v1 ); //INOUT
180 // ******** DATA FOR MESH COMPUTATION ********
182 std::map<HEXA_NS::Vertex*, SMDS_MeshNode*> _node; //_vertexNode;
183 std::map<const SMDS_MeshNode*, HEXA_NS::Vertex*> _vertex; //_nodeVertex;
186 std::map<HEXA_NS::Edge*, SMESHNodes> _nodesOnEdge; //_edgeNodes;
187 // std::map<HEXA_NS::Edge*, Xx> _edgeXx;
188 std::map<SMDS_MeshNode*, double> _nodeXx; //_edgeNodes;
189 std::map<HEXA_NS::Quad*, ArrayOfSMESHNodes> _quadNodes;
191 bool _computeVertexOK;
195 SMESHDS_Mesh* _theMeshDS;
196 SMESH_Mesh* _theMesh;
198 // ******** METHOD FOR GROUPS COMPUTATION ********
199 SMESH_Group* _createGroup(HEXA_NS::Group& grHex);
200 void _fillGroup(HEXA_NS::Group* grHex);
202 // ******** DATA FOR GROUPS COMPUTATION ********
203 std::map<HEXA_NS::Hexa*, SMESHVolumes> _volumesOnHexa;
204 std::map<HEXA_NS::Quad*, SMESHFaces> _facesOnQuad;
205 std::map<HEXA_NS::Edge*, SMESHEdges> _edgesOnEdge;
208 // for DEBUG purpose only:
213 // not used, for backup purpose only:
214 void _getCurve( const std::vector<HEXA_NS::Shape*>& shapesIn,
215 Handle_Geom_Curve& curveOut, double& curveFirstOut, double& curveLastOut );
216 // bool computeEdgeByAssoc2( HEXA_NS::Edge& edge, HEXA_NS::Law& law); // alternative method