Salome HOME
yfr : Merge with v1.2
[modules/smesh.git] / src / SMESH / SMESH_Hexa_3D.hxx
1 //  SMESH SMESH : implementaion of SMESH idl descriptions
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESH_Hexa_3D.hxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef _SMESH_HEXA_3D_HXX_
30 #define _SMESH_HEXA_3D_HXX_
31
32 #include "SMESH_3D_Algo.hxx"
33 #include "SMESH_Mesh.hxx"
34 #include "SMESH_Quadrangle_2D.hxx"
35 #include "Utils_SALOME_Exception.hxx"
36
37 typedef struct point3Dstruct
38 {
39   int nodeId;
40 } Point3DStruct;
41
42 typedef double Pt3[3];
43
44 typedef struct conv2dstruct
45 {
46   double a1; // X = a1*x + b1*y + c1 
47   double b1; // Y = a2*x + b2*y + c2
48   double c1; // a1, b1 a2, b2 in {-1,0,1}
49   double a2; // c1, c2 in {0,1}
50   double b2;
51   double c2;
52   int ia;    // I = ia*i + ib*j + ic
53   int ib;
54   int ic;
55   int ja;    // J = ja*i + jb*j + jc
56   int jb;
57   int jc;
58 } Conv2DStruct;
59
60 typedef struct cubeStruct
61 {
62   TopoDS_Vertex V000;
63   TopoDS_Vertex V001;
64   TopoDS_Vertex V010;
65   TopoDS_Vertex V011;
66   TopoDS_Vertex V100;
67   TopoDS_Vertex V101;
68   TopoDS_Vertex V110;
69   TopoDS_Vertex V111;
70   faceQuadStruct* quad_X0;
71   faceQuadStruct* quad_X1;
72   faceQuadStruct* quad_Y0;
73   faceQuadStruct* quad_Y1;
74   faceQuadStruct* quad_Z0;
75   faceQuadStruct* quad_Z1;
76   Point3DStruct* np; // normalised 3D coordinates
77 } CubeStruct;
78
79 class SMESH_Hexa_3D:
80   public SMESH_3D_Algo
81 {
82 public:
83   SMESH_Hexa_3D(int hypId, int studyId, SMESH_Gen* gen);
84   virtual ~SMESH_Hexa_3D();
85
86   virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
87                                const TopoDS_Shape& aShape);
88
89   virtual bool Compute(SMESH_Mesh& aMesh,
90                        const TopoDS_Shape& aShape)
91     throw (SALOME_Exception);
92
93   ostream & SaveTo(ostream & save);
94   istream & LoadFrom(istream & load);
95   friend ostream & operator << (ostream & save, SMESH_Hexa_3D & hyp);
96   friend istream & operator >> (istream & load, SMESH_Hexa_3D & hyp);
97
98 protected:
99   TopoDS_Edge
100   EdgeNotInFace(SMESH_Mesh& aMesh,
101                 const TopoDS_Shape& aShape,
102                 const TopoDS_Face& aFace,
103                 const TopoDS_Vertex& aVertex,
104                 const TopTools_IndexedDataMapOfShapeListOfShape& MS);
105
106   int GetFaceIndex(SMESH_Mesh& aMesh,
107                    const TopoDS_Shape& aShape,
108                    const vector<SMESH_subMesh*>& meshFaces,
109                    const TopoDS_Vertex& V0,
110                    const TopoDS_Vertex& V1,
111                    const TopoDS_Vertex& V2,
112                    const TopoDS_Vertex& V3);
113
114   void GetConv2DCoefs(const faceQuadStruct& quad,
115                       const TopoDS_Shape& aShape,
116                       const TopoDS_Vertex& V0,
117                       const TopoDS_Vertex& V1,
118                       const TopoDS_Vertex& V2,
119                       const TopoDS_Vertex& V3,
120                       Conv2DStruct& conv);
121
122   void GetPoint(Pt3 p,
123                 int i, int j, int k,
124                 int nbx, int nby, int nbz,
125                 Point3DStruct *np,
126                 const Handle(SMESHDS_Mesh)& meshDS);
127
128   CubeStruct _cube;
129   FaceQuadStruct* _quads[6];
130   int _indX0;
131   int _indX1;
132   int _indY0;
133   int _indY1;
134   int _indZ0;
135   int _indZ1;
136 };
137
138 #endif