]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMImpl/GEOMImpl_Block6Explorer.hxx
Salome HOME
if a shape to be rotated is a vertex, and it is located ON the Revolution Axis, then...
[modules/geom.git] / src / GEOMImpl / GEOMImpl_Block6Explorer.hxx
1 //  File   : GEOMImpl_Block6Explorer.hxx
2 //  Module : GEOMImpl
3
4 #ifndef GEOMImpl_Block6Explorer_HeaderFile
5 #define GEOMImpl_Block6Explorer_HeaderFile
6
7 #include <TopoDS_Shape.hxx>
8 #include <TopoDS_Wire.hxx>
9 #include <TopTools_Array1OfShape.hxx>
10 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
11 #include <gp_Trsf.hxx>
12
13   //  Class GEOMImpl_Block6Explorer gives easy and fast access to a certain sub-elements of hexahedral solid
14   //  Each face   can be accessed by its global ID [1-6]
15   //  Each edge   can be accessed by its global ID [1-12] or by its local NB [1-4] inside certain face
16   //  Each vertex can be accessed by its global ID [1-8] or  by its local NB [1-4] inside certain face
17   //  Numeration of the sub-shapes is defined in constructors, see they comments
18   //
19   //                  face 2       face 4          |           4 face     2 face                   |
20   //                       |           /           |            \         |                        |
21   //                      \|/        |/_           |            _\|      \|/                       |
22   //                       '         '             |              '       '                        |
23   //                    8_______7__7               |               7__7_______8                    |
24   //                   /|         /|               |               |\         |\                   |
25   //                  8 12       6 11              |              11 6       12 8                  |
26   //                 /  |       /  |               |               |  \       |  \                 |
27   //               5/______5__6/   |               |               |   \6__5______\5               |
28   //  face 5 --->  |    |     |    |  <--- 6 face  |  face 6 --->  |    |     |    |  <--- 5 face  |
29   //               |    |__3__|____|               |               |____|__3__|    |               |
30   //               |   /4     |   /3               |               3\   |     4\   |               |
31   //               |  /       |  /                 |                 \  |       \  |               |
32   //               9 4       10 2                  |                  2 10       4 9               |
33   //               |/__1______|/                   |                   \|______1__\|               |
34   //               1          2                    |                    2          1               |
35   //            _.        .                        |                        .       ._             |
36   //            /|       /|\                       |                       /|\      |\             |
37   //           /          |                        |                        |         \            |
38   //          3 face      1 face                   |                   face 1     face 3           |
39   //                                               |                                               |
40   //  Picture 1 (right orientation)                |  Picture 2 (left orientation)                 |
41   //                                                                                               |
42   //  For the moment, the orientation of numbering is not controlled
43
44   // Faces: 1 - bottom, 2 - top, 3 - front, 4 - back, 5 - left (right), 6 - right (left)
45
46   //
47   //                             4_______3__3         2 ______2__3
48   //                            /          /          |          |
49   //                           4          2           1          3
50   //                          /          /            |          |
51   //                        1/______1__2/             |          |
52   //                                                  |          |
53   //                                                  | __4______|
54   //                           face 2       face 4    1          4
55   //                                |           /
56   //                               \|/        |/_
57   //                                '         '
58   //        3                    8_______7__7                    3
59   //       /|                   /|         /|                   /|
60   //      3 2                  8 12       6 11                 3 2
61   //     /  |                 /  |       /  |                 /  |
62   //   4/   |               5/______5__6/   |               4/   |
63   //   |    |  face 5 --->  |    |     |    |  <--- 6 face  |    |
64   //   |    |               |    |__3__|____|               |    |
65   //   |   /2               |   /4     |   /3               |   /2
66   //   |  /                 |  /       |  /                 |  /
67   //   4 1                  9 4       10 2                  4 1
68   //   |/                   |/__1______|/                   |/
69   //   1                    1          2                    1
70   //                     _.        .
71   //                     /|       /|\
72   //                    /          |
73   //   2 ______2__3    3 face      1 face
74   //   |          |
75   //   |          |               __3_______
76   //   |          |             /4         /3
77   //   |          |            /          /
78   //   1          3           4          2
79   //   | __4______|          /__1______ /
80   //   1          4         1          2
81   //
82   //  Picture 3 (On periferal pictures the local
83   //  numeration of edges and vertices is shown)
84
85 class GEOMImpl_Block6Explorer
86 {
87  public:
88   // ---------- PUBLIC METHODS ----------
89
90   GEOMImpl_Block6Explorer ();
91   // Constructor.
92
93   // Initialization by existing solid,
94   // sub-elements regulate numeration
95
96   void InitByBlock (const TopoDS_Shape& theBlock);
97   // Init by hexahedral solid. First face, edge and vertex is defined randomly
98
99   void InitByBlockAndFace (const TopoDS_Shape& theBlock,
100                            const TopoDS_Shape& theFace);
101   // Constructor from hexahedral solid, making theFace the first face.
102   // First edge and vertex is defined randomly from theFace entities
103
104   void InitByBlockAndEdges (const TopoDS_Shape& theBlock,
105                             const TopoDS_Shape& theEdge1,
106                             const TopoDS_Shape& theEdge2);
107   // Init by hexahedral solid, making theEdge1 the first, theEdge2 the fird.
108   // First vertex is defined randomly from theEdge1 vertices
109   // (Picture 1 and Picture 2 shows two possible cases)
110
111   void InitByBlockAndVertices (const TopoDS_Shape& theBlock,
112                                const TopoDS_Shape& theVertex1,
113                                const TopoDS_Shape& theVertex2,
114                                const TopoDS_Shape& theVertex3);
115   // Init by hexahedral solid, making theVertex1 the first,
116   // theVertex2 the second and theVertex3 the fird vertices.
117
118   // Initialization by parts of solid to be built
119
120   void InitByTwoFaces (const TopoDS_Shape& theFace1,
121                        const TopoDS_Shape& theFace2);
122   // Init by two faces. TheFace1 will be the first,
123   // theFace2 will be the second.
124   // First edge and vertex is defined randomly from theFace1 entities.
125
126   // Access to vertices
127   TopoDS_Shape GetVertex (const Standard_Integer theVertexID); // [1-8]
128
129   Standard_Integer GetVertexID (const TopoDS_Shape& theVertex);
130
131   Standard_Integer GetVertexID (const Standard_Integer theFaceID, // [1-6]
132                                 const Standard_Integer theVertexNB); // [1-4]
133
134   Standard_Integer GetVertexOnEdgeID (const Standard_Integer theEdgeID, // [1-12]
135                                       const Standard_Integer theVertexNB); // [1-2]
136
137   // Access to edges
138   TopoDS_Shape GetEdge (const Standard_Integer theEdgeID, // [1-12]
139                         const Standard_Boolean doMake = Standard_False);
140
141   Standard_Integer GetEdgeID (const TopoDS_Shape& theEdge);
142
143   Standard_Integer GetEdgeID (const Standard_Integer theFaceID, // [1-6]
144                               const Standard_Integer theEdgeNB); // [1-4]
145
146   Standard_Integer FindEdgeID (const Standard_Integer theVertex1ID,
147                                const Standard_Integer theVertex2ID);
148
149   Standard_Integer FindCommonEdgeID (const Standard_Integer theFace1ID,
150                                      const Standard_Integer theFace2ID);
151
152   // Access to faces
153   TopoDS_Shape GetFace (const Standard_Integer theFaceID, // [1-6]
154                         const Standard_Boolean doMake = Standard_False);
155
156   Standard_Integer GetFaceID (const TopoDS_Shape& theFace);
157
158   Standard_Integer FindFaceID (const Standard_Integer theEdge1ID,
159                                const Standard_Integer theEdge2ID);
160
161   Standard_Integer GetOppositeFaceID (const Standard_Integer theFaceID);
162
163   // Check Block
164   Standard_Boolean IsSimilarFaces (const Standard_Integer theFace1ID,
165                                    const Standard_Integer theFace2ID,
166                                    const gp_Trsf          theTransformation);
167   // returns true, if theFace1, transformed
168   // by theTransformation, coincides with theFace2
169  public:
170   // ---------- STATIC PUBLIC METHODS ----------
171   static void MapShapesAndAncestors (const TopoDS_Shape& S,
172                                      const TopAbs_ShapeEnum TS,
173                                      const TopAbs_ShapeEnum TA,
174                                      TopTools_IndexedDataMapOfShapeListOfShape& M);
175
176   static Standard_Boolean IsSimilarEdges (const TopoDS_Shape& E1, 
177                                           const TopoDS_Shape& E2);
178
179   static Standard_Integer FindEdge (TopoDS_Shape&       theResult,
180                                     const TopoDS_Shape& V1,
181                                     const TopoDS_Shape& V2,
182                                     const TopTools_IndexedDataMapOfShapeListOfShape& MVE,
183                                     const Standard_Boolean findAll = Standard_False);
184   // returns number of found edges
185
186   static Standard_Integer FindFace (TopoDS_Shape&       theResult,
187                                     const TopoDS_Shape& V1,
188                                     const TopoDS_Shape& V2,
189                                     const TopoDS_Shape& V3,
190                                     const TopoDS_Shape& V4,
191                                     const TopTools_IndexedDataMapOfShapeListOfShape& MVF,
192                                     const Standard_Boolean findAll = Standard_False);
193   // returns number of found faces
194
195   static void MakeFace (const TopoDS_Wire&     theWire,
196                         const Standard_Boolean isPlanarWanted,
197                         TopoDS_Shape&          theResult);
198
199  private:
200   // ---------- PRIVATE FIELDS ----------
201
202   TopTools_Array1OfShape myFaces;
203   TopTools_Array1OfShape myEdges;
204   TopTools_Array1OfShape myVertices;
205 };
206
207 #endif