1 // File : GEOMImpl_Block6Explorer.hxx
4 #ifndef GEOMImpl_Block6Explorer_HeaderFile
5 #define GEOMImpl_Block6Explorer_HeaderFile
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>
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
19 // face 2 face 4 | 4 face 2 face |
21 // \|/ |/_ | _\| \|/ |
23 // 8_______7__7 | 7__7_______8 |
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__\| |
38 // 3 face 1 face | face 1 face 3 |
40 // Picture 1 (right orientation) | Picture 2 (left orientation) |
42 // For the moment, the orientation of numbering is not controlled
44 // Faces: 1 - bottom, 2 - top, 3 - front, 4 - back, 5 - left (right), 6 - right (left)
47 // 4_______3__3 2 ______2__3
62 // 4/ | 5/______5__6/ | 4/ |
63 // | | face 5 ---> | | | | <--- 6 face | |
64 // | | | |__3__|____| | |
65 // | /2 | /4 | /3 | /2
68 // |/ |/__1______|/ |/
73 // 2 ______2__3 3 face 1 face
79 // | __4______| /__1______ /
82 // Picture 3 (On periferal pictures the local
83 // numeration of edges and vertices is shown)
85 class GEOMImpl_Block6Explorer
88 // ---------- PUBLIC METHODS ----------
90 GEOMImpl_Block6Explorer ();
93 // Initialization by existing solid,
94 // sub-elements regulate numeration
96 void InitByBlock (const TopoDS_Shape& theBlock);
97 // Init by hexahedral solid. First face, edge and vertex is defined randomly
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
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)
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.
118 // Initialization by parts of solid to be built
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.
126 // Access to vertices
127 TopoDS_Shape GetVertex (const Standard_Integer theVertexID); // [1-8]
129 Standard_Integer GetVertexID (const TopoDS_Shape& theVertex);
131 Standard_Integer GetVertexID (const Standard_Integer theFaceID, // [1-6]
132 const Standard_Integer theVertexNB); // [1-4]
134 Standard_Integer GetVertexOnEdgeID (const Standard_Integer theEdgeID, // [1-12]
135 const Standard_Integer theVertexNB); // [1-2]
138 TopoDS_Shape GetEdge (const Standard_Integer theEdgeID, // [1-12]
139 const Standard_Boolean doMake = Standard_False);
141 Standard_Integer GetEdgeID (const TopoDS_Shape& theEdge);
143 Standard_Integer GetEdgeID (const Standard_Integer theFaceID, // [1-6]
144 const Standard_Integer theEdgeNB); // [1-4]
146 Standard_Integer FindEdgeID (const Standard_Integer theVertex1ID,
147 const Standard_Integer theVertex2ID);
149 Standard_Integer FindCommonEdgeID (const Standard_Integer theFace1ID,
150 const Standard_Integer theFace2ID);
153 TopoDS_Shape GetFace (const Standard_Integer theFaceID, // [1-6]
154 const Standard_Boolean doMake = Standard_False);
156 Standard_Integer GetFaceID (const TopoDS_Shape& theFace);
158 Standard_Integer FindFaceID (const Standard_Integer theEdge1ID,
159 const Standard_Integer theEdge2ID);
161 Standard_Integer GetOppositeFaceID (const Standard_Integer theFaceID);
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
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);
176 static Standard_Boolean IsSimilarEdges (const TopoDS_Shape& E1,
177 const TopoDS_Shape& E2);
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
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
195 static void MakeFace (const TopoDS_Wire& theWire,
196 const Standard_Boolean isPlanarWanted,
197 TopoDS_Shape& theResult);
200 // ---------- PRIVATE FIELDS ----------
202 TopTools_Array1OfShape myFaces;
203 TopTools_Array1OfShape myEdges;
204 TopTools_Array1OfShape myVertices;