PageRenderTime 39ms CodeModel.GetById 8ms app.highlight 25ms RepoModel.GetById 1ms app.codeStats 0ms

/src/contrib/geom-5.1.2.7/inc/GEOMImpl_Block6Explorer.hxx

http://pythonocc.googlecode.com/
C++ Header | 235 lines | 75 code | 32 blank | 128 comment | 0 complexity | b7e13ffda203ee7a7d6dd2c4118fe1b7 MD5 | raw file
  1// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
  2// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
  3// 
  4// This library is free software; you can redistribute it and/or
  5// modify it under the terms of the GNU Lesser General Public
  6// License as published by the Free Software Foundation; either 
  7// version 2.1 of the License.
  8// 
  9// This library is distributed in the hope that it will be useful 
 10// but WITHOUT ANY WARRANTY; without even the implied warranty of 
 11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
 12// Lesser General Public License for more details.
 13//
 14// You should have received a copy of the GNU Lesser General Public  
 15// License along with this library; if not, write to the Free Software 
 16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 17//
 18// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 19//
 20//  File   : GEOMImpl_Block6Explorer.hxx
 21//  Module : GEOMImpl
 22
 23#ifndef GEOMImpl_Block6Explorer_HeaderFile
 24#define GEOMImpl_Block6Explorer_HeaderFile
 25
 26#include <TopoDS_Shape.hxx>
 27#include <TopoDS_Wire.hxx>
 28#include <TopTools_Array1OfShape.hxx>
 29#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
 30#include <gp_Trsf.hxx>
 31
 32//!  Class GEOMImpl_Block6Explorer gives easy and fast access to a certain sub-elements of hexahedral solid
 33//!  Each face   can be accessed by its global ID [1-6]
 34//!  Each edge   can be accessed by its global ID [1-12] or by its local NB [1-4] inside certain face
 35//!  Each vertex can be accessed by its global ID [1-8] or  by its local NB [1-4] inside certain face
 36//!  Numeration of the sub-shapes is defined in constructors, see they comments
 37//!
 38//!                  face 2       face 4          |           4 face     2 face                   |
 39//!                       |           /           |            \         |                        |
 40//!                      \|/        |/_           |            _\|      \|/                       |
 41//!                       '         '             |              '       '                        |
 42//!                    8_______7__7               |               7__7_______8                    |
 43//!                   /|         /|               |               |\         |\                   |
 44//!                  8 12       6 11              |              11 6       12 8                  |
 45//!                 /  |       /  |               |               |  \       |  \                 |
 46//!               5/______5__6/   |               |               |   \6__5______\5               |
 47//!  face 5 --->  |    |     |    |  <--- 6 face  |  face 6 --->  |    |     |    |  <--- 5 face  |
 48//!               |    |__3__|____|               |               |____|__3__|    |               |
 49//!               |   /4     |   /3               |               3\   |     4\   |               |
 50//!               |  /       |  /                 |                 \  |       \  |               |
 51//!               9 4       10 2                  |                  2 10       4 9               |
 52//!               |/__1______|/                   |                   \|______1__\|               |
 53//!               1          2                    |                    2          1               |
 54//!            _.        .                        |                        .       ._             |
 55//!            /|       /|\                       |                       /|\      |\             |
 56//!           /          |                        |                        |         \            |
 57//!          3 face      1 face                   |                   face 1     face 3           |
 58//!                                               |                                               |
 59//!  Picture 1 (right orientation)                |  Picture 2 (left orientation)                 |
 60//!                                                                                               |
 61//!  For the moment, the orientation of numbering is not controlled
 62//! Faces: 1 - bottom, 2 - top, 3 - front, 4 - back, 5 - left (right), 6 - right (left)
 63//!
 64//!                             4_______3__3         2 ______2__3
 65//!                            /          /          |          |
 66//!                           4          2           1          3
 67//!                          /          /            |          |
 68//!                        1/______1__2/             |          |
 69//!                                                  |          |
 70//!                                                  | __4______|
 71//!                           face 2       face 4    1          4
 72//!                                |           /
 73//!                               \|/        |/_
 74//!                                '         '
 75//!        3                    8_______7__7                    3
 76//!       /|                   /|         /|                   /|
 77//!      3 2                  8 12       6 11                 3 2
 78//!     /  |                 /  |       /  |                 /  |
 79//!   4/   |               5/______5__6/   |               4/   |
 80//!   |    |  face 5 --->  |    |     |    |  <--- 6 face  |    |
 81//!   |    |               |    |__3__|____|               |    |
 82//!   |   /2               |   /4     |   /3               |   /2
 83//!   |  /                 |  /       |  /                 |  /
 84//!   4 1                  9 4       10 2                  4 1
 85//!   |/                   |/__1______|/                   |/
 86//!   1                    1          2                    1
 87//!                     _.        .
 88//!                     /|       /|\
 89//!                    /          |
 90//!   2 ______2__3    3 face      1 face
 91//!   |          |
 92//!   |          |               __3_______
 93//!   |          |             /4         /3
 94//!   |          |            /          /
 95//!   1          3           4          2
 96//!   | __4______|          /__1______ /
 97//!   1          4         1          2
 98//!
 99//!  Picture 3 (On periferal pictures the local
100//!  numeration of edges and vertices is shown)
101class GEOMImpl_Block6Explorer
102{
103 public:
104  // ---------- PUBLIC METHODS ----------
105
106  //! Constructor.
107  GEOMImpl_Block6Explorer ();
108
109  //! <I><B>Initialization by existing solid,sub-elements regulate numeration</B></I>
110  //! Init by hexahedral solid. First face, edge and vertex is defined randomly
111  void InitByBlock (const TopoDS_Shape& theBlock);
112
113  //! <I><B>Initialization by existing solid,sub-elements regulate numeration</B></I>
114  //! Constructor from hexahedral solid, making theFace the first face.
115  //! First edge and vertex is defined randomly from theFace entities
116  void InitByBlockAndFace (const TopoDS_Shape& theBlock,
117						   const TopoDS_Shape& theFace);
118
119  //! <I><B>Initialization by existing solid,sub-elements regulate numeration</B></I>
120  //! Init by hexahedral solid, making theEdge1 the first, theEdge2 the fird.
121  //! First vertex is defined randomly from theEdge1 vertices
122  //! (Picture 1 and Picture 2 shows two possible cases)
123  void InitByBlockAndEdges (const TopoDS_Shape& theBlock,
124							const TopoDS_Shape& theEdge1,
125							const TopoDS_Shape& theEdge2);
126
127  //! <I><B>Initialization by existing solid,sub-elements regulate numeration</B></I>
128  //! Init by hexahedral solid, making theVertex1 the first,
129  //! theVertex2 the second and theVertex3 the fird vertices.
130  void InitByBlockAndVertices (const TopoDS_Shape& theBlock,
131							   const TopoDS_Shape& theVertex1,
132							   const TopoDS_Shape& theVertex2,
133							   const TopoDS_Shape& theVertex3);
134
135  //! <I><B>Initialization by parts of solid to be built</B></I>
136  //! Init by two faces. TheFace1 will be the first,
137  //! theFace2 will be the second.
138  //! First edge and vertex is defined randomly from theFace1 entities.
139  void InitByTwoFaces (const TopoDS_Shape& theFace1,
140					   const TopoDS_Shape& theFace2);
141
142  //! Access to vertices
143  TopoDS_Shape GetVertex (const Standard_Integer theVertexID); // [1-8]
144
145  //! Access to vertices
146  Standard_Integer GetVertexID (const TopoDS_Shape& theVertex);
147
148  //! Access to vertices
149  Standard_Integer GetVertexID (const Standard_Integer theFaceID, // [1-6]
150								const Standard_Integer theVertexNB); // [1-4]
151
152  //! Access to vertices
153  Standard_Integer GetVertexOnEdgeID (const Standard_Integer theEdgeID, // [1-12]
154                                      const Standard_Integer theVertexNB); // [1-2]
155
156  //! Access to edges
157  TopoDS_Shape GetEdge (const Standard_Integer theEdgeID, // [1-12]
158						const Standard_Boolean doMake = Standard_False);
159
160  //! Access to edges
161  Standard_Integer GetEdgeID (const TopoDS_Shape& theEdge);
162
163  //! Access to edges
164  Standard_Integer GetEdgeID (const Standard_Integer theFaceID, // [1-6]
165                              const Standard_Integer theEdgeNB); // [1-4]
166
167  //! Access to edges
168  Standard_Integer FindEdgeID (const Standard_Integer theVertex1ID,
169							   const Standard_Integer theVertex2ID);
170
171  //! Access to edges
172  Standard_Integer FindCommonEdgeID (const Standard_Integer theFace1ID,
173                                     const Standard_Integer theFace2ID);
174
175  //! Access to faces
176  TopoDS_Shape GetFace (const Standard_Integer theFaceID, // [1-6]
177                        const Standard_Boolean doMake = Standard_False);
178
179  //! Access to faces
180  Standard_Integer GetFaceID (const TopoDS_Shape& theFace);
181
182  //! Access to faces
183  Standard_Integer FindFaceID (const Standard_Integer theEdge1ID,
184							   const Standard_Integer theEdge2ID);
185
186  //! Access to faces
187  Standard_Integer GetOppositeFaceID (const Standard_Integer theFaceID);
188
189  //! Check Block
190  //! returns true, if theFace1, transformed
191  //! by theTransformation, coincides with theFace2
192  Standard_Boolean IsSimilarFaces (const Standard_Integer theFace1ID,
193								   const Standard_Integer theFace2ID,
194								   const gp_Trsf          theTransformation);
195
196  
197 public:
198  // ---------- STATIC PUBLIC METHODS ----------
199  static void MapShapesAndAncestors (const TopoDS_Shape& S,
200                                     const TopAbs_ShapeEnum TS,
201                                     const TopAbs_ShapeEnum TA,
202                                     TopTools_IndexedDataMapOfShapeListOfShape& M);
203
204  static Standard_Boolean IsSimilarEdges (const TopoDS_Shape& E1, 
205										  const TopoDS_Shape& E2);
206  //! returns number of found edges
207  static Standard_Integer FindEdge (TopoDS_Shape&       theResult,
208									const TopoDS_Shape& V1,
209									const TopoDS_Shape& V2,
210									const TopTools_IndexedDataMapOfShapeListOfShape& MVE,
211									const Standard_Boolean findAll = Standard_False);
212  
213  //! returns number of found faces
214  static Standard_Integer FindFace (TopoDS_Shape&       theResult,
215									const TopoDS_Shape& V1,
216									const TopoDS_Shape& V2,
217									const TopoDS_Shape& V3,
218									const TopoDS_Shape& V4,
219									const TopTools_IndexedDataMapOfShapeListOfShape& MVF,
220									const Standard_Boolean findAll = Standard_False);
221  
222
223  static void MakeFace (const TopoDS_Wire&     theWire,
224                        const Standard_Boolean isPlanarWanted,
225                        TopoDS_Shape&          theResult);
226
227 private:
228  // ---------- PRIVATE FIELDS ----------
229
230  TopTools_Array1OfShape myFaces;
231  TopTools_Array1OfShape myEdges;
232  TopTools_Array1OfShape myVertices;
233};
234
235#endif