1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
23 // File : GEOMImpl_Block6Explorer.hxx
26 #ifndef GEOMImpl_Block6Explorer_HeaderFile
27 #define GEOMImpl_Block6Explorer_HeaderFile
29 #include <TopoDS_Shape.hxx>
30 #include <TopoDS_Wire.hxx>
31 #include <TopTools_Array1OfShape.hxx>
32 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
33 #include <TCollection_AsciiString.hxx>
34 #include <gp_Trsf.hxx>
36 // Class GEOMImpl_Block6Explorer gives easy and fast access to a certain sub-elements of hexahedral solid
37 // Each face can be accessed by its global ID [1-6]
38 // Each edge can be accessed by its global ID [1-12] or by its local NB [1-4] inside certain face
39 // Each vertex can be accessed by its global ID [1-8] or by its local NB [1-4] inside certain face
40 // Numeration of the sub-shapes is defined in constructors, see they comments
42 // face 2 face 4 | 4 face 2 face |
44 // \|/ |/_ | _\| \|/ |
46 // 8_______7__7 | 7__7_______8 |
48 // 8 12 6 11 | 11 6 12 8 |
49 // / | / | | | \ | \ |
50 // 5/______5__6/ | | | \6__5______\5 |
51 // face 5 ---> | | | | <--- 6 face | face 6 ---> | | | | <--- 5 face |
52 // | |__3__|____| | |____|__3__| | |
53 // | /4 | /3 | 3\ | 4\ | |
54 // | / | / | \ | \ | |
55 // 9 4 10 2 | 2 10 4 9 |
56 // |/__1______|/ | \|______1__\| |
61 // 3 face 1 face | face 1 face 3 |
63 // Picture 1 (right orientation) | Picture 2 (left orientation) |
65 // For the moment, the orientation of numbering is not controlled
67 // Faces: 1 - bottom, 2 - top, 3 - front, 4 - back, 5 - left (right), 6 - right (left)
70 // 4_______3__3 2 ______2__3
85 // 4/ | 5/______5__6/ | 4/ |
86 // | | face 5 ---> | | | | <--- 6 face | |
87 // | | | |__3__|____| | |
88 // | /2 | /4 | /3 | /2
91 // |/ |/__1______|/ |/
96 // 2 ______2__3 3 face 1 face
102 // | __4______| /__1______ /
105 // Picture 3 (On periferal pictures the local
106 // numeration of edges and vertices is shown)
108 class GEOMImpl_Block6Explorer
111 // ---------- PUBLIC METHODS ----------
113 GEOMImpl_Block6Explorer ();
116 // Initialization by existing solid,
117 // sub-elements regulate numeration
119 void InitByBlock (const TopoDS_Shape& theBlock);
120 // Init by hexahedral solid. First face, edge and vertex is defined randomly
122 void InitByBlockAndFace (const TopoDS_Shape& theBlock,
123 const TopoDS_Shape& theFace);
124 // Constructor from hexahedral solid, making theFace the first face.
125 // First edge and vertex is defined randomly from theFace entities
127 void InitByBlockAndEdges (const TopoDS_Shape& theBlock,
128 const TopoDS_Shape& theEdge1,
129 const TopoDS_Shape& theEdge2);
130 // Init by hexahedral solid, making theEdge1 the first, theEdge2 the fird.
131 // First vertex is defined randomly from theEdge1 vertices
132 // (Picture 1 and Picture 2 shows two possible cases)
134 void InitByBlockAndVertices (const TopoDS_Shape& theBlock,
135 const TopoDS_Shape& theVertex1,
136 const TopoDS_Shape& theVertex2,
137 const TopoDS_Shape& theVertex3);
138 // Init by hexahedral solid, making theVertex1 the first,
139 // theVertex2 the second and theVertex3 the fird vertices.
141 // Initialization by parts of solid to be built
143 void InitByTwoFaces (const TopoDS_Shape& theFace1,
144 const TopoDS_Shape& theFace2);
145 // Init by two faces. TheFace1 will be the first,
146 // theFace2 will be the second.
147 // First edge and vertex is defined randomly from theFace1 entities.
149 // Access to vertices
150 TopoDS_Shape GetVertex (const Standard_Integer theVertexID); // [1-8]
152 Standard_Integer GetVertexID (const TopoDS_Shape& theVertex);
154 Standard_Integer GetVertexID (const Standard_Integer theFaceID, // [1-6]
155 const Standard_Integer theVertexNB); // [1-4]
157 Standard_Integer GetVertexOnEdgeID (const Standard_Integer theEdgeID, // [1-12]
158 const Standard_Integer theVertexNB); // [1-2]
161 TopoDS_Shape GetEdge (const Standard_Integer theEdgeID, // [1-12]
162 const Standard_Boolean doMake = Standard_False);
164 Standard_Integer GetEdgeID (const TopoDS_Shape& theEdge);
166 Standard_Integer GetEdgeID (const Standard_Integer theFaceID, // [1-6]
167 const Standard_Integer theEdgeNB); // [1-4]
169 Standard_Integer FindEdgeID (const Standard_Integer theVertex1ID,
170 const Standard_Integer theVertex2ID);
172 Standard_Integer FindCommonEdgeID (const Standard_Integer theFace1ID,
173 const Standard_Integer theFace2ID);
176 TopoDS_Shape GetFace (const Standard_Integer theFaceID, // [1-6]
177 const Standard_Boolean doMake = Standard_False);
179 Standard_Integer GetFaceID (const TopoDS_Shape& theFace);
181 Standard_Integer FindFaceID (const Standard_Integer theEdge1ID,
182 const Standard_Integer theEdge2ID);
184 Standard_Integer GetOppositeFaceID (const Standard_Integer theFaceID);
187 Standard_Boolean IsSimilarFaces (const Standard_Integer theFace1ID,
188 const Standard_Integer theFace2ID,
189 const gp_Trsf theTransformation);
190 // returns true, if theFace1, transformed
191 // by theTransformation, coincides with theFace2
193 // ---------- STATIC PUBLIC METHODS ----------
194 static void MapShapesAndAncestors (const TopoDS_Shape& S,
195 const TopAbs_ShapeEnum TS,
196 const TopAbs_ShapeEnum TA,
197 TopTools_IndexedDataMapOfShapeListOfShape& M);
199 static Standard_Boolean IsSimilarEdges (const TopoDS_Shape& E1,
200 const TopoDS_Shape& E2);
202 static Standard_Integer FindEdge (TopoDS_Shape& theResult,
203 const TopoDS_Shape& V1,
204 const TopoDS_Shape& V2,
205 const TopTools_IndexedDataMapOfShapeListOfShape& MVE,
206 const Standard_Boolean findAll = Standard_False);
207 // returns number of found edges
209 static Standard_Integer FindFace (TopoDS_Shape& theResult,
210 const TopoDS_Shape& V1,
211 const TopoDS_Shape& V2,
212 const TopoDS_Shape& V3,
213 const TopoDS_Shape& V4,
214 const TopTools_IndexedDataMapOfShapeListOfShape& MVF,
215 const Standard_Boolean findAll = Standard_False);
216 // returns number of found faces
219 * Build a face, bound by the given wire.
220 * \param theWire The initial wire to build the face on.
221 * \param isPlanarWanted If true, try to build a planar face.
222 * \note If isPlanarWanted is true, but planar face cannot be built
223 * with acceptable tolerance, any face will be built.
224 * \param theResult The resulting shape.
225 * \return Error or warning description. Empty string in case of success.
227 static TCollection_AsciiString MakeFace (const TopoDS_Wire& theWire,
228 const Standard_Boolean isPlanarWanted,
229 TopoDS_Shape& theResult);
232 * Build a face, bound by the given wire.
233 * \param theWire The initial wire to build the face on.
234 * \param theResult The resulting shape.
235 * \return Error or warning description. Empty string in case of success.
237 static TCollection_AsciiString MakeAnyFace (const TopoDS_Wire& theWire,
238 TopoDS_Shape& theResult);
241 // ---------- PRIVATE FIELDS ----------
243 TopTools_Array1OfShape myFaces;
244 TopTools_Array1OfShape myEdges;
245 TopTools_Array1OfShape myVertices;