Back to index

salome-geom  6.5.0
GEOMImpl_Block6Explorer.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : GEOMImpl_Block6Explorer.hxx
00024 //  Module : GEOMImpl
00025 
00026 #ifndef GEOMImpl_Block6Explorer_HeaderFile
00027 #define GEOMImpl_Block6Explorer_HeaderFile
00028 
00029 #include <TopoDS_Shape.hxx>
00030 #include <TopoDS_Wire.hxx>
00031 #include <TopTools_Array1OfShape.hxx>
00032 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
00033 #include <TCollection_AsciiString.hxx>
00034 #include <gp_Trsf.hxx>
00035 
00036   //  Class GEOMImpl_Block6Explorer gives easy and fast access to a certain sub-elements of hexahedral solid
00037   //  Each face   can be accessed by its global ID [1-6]
00038   //  Each edge   can be accessed by its global ID [1-12] or by its local NB [1-4] inside certain face
00039   //  Each vertex can be accessed by its global ID [1-8] or  by its local NB [1-4] inside certain face
00040   //  Numeration of the sub-shapes is defined in constructors, see they comments
00041   //
00042   //                  face 2       face 4          |           4 face     2 face                   |
00043   //                       |           /           |            \         |                        |
00044   //                      \|/        |/_           |            _\|      \|/                       |
00045   //                       '         '             |              '       '                        |
00046   //                    8_______7__7               |               7__7_______8                    |
00047   //                   /|         /|               |               |\         |\                   |
00048   //                  8 12       6 11              |              11 6       12 8                  |
00049   //                 /  |       /  |               |               |  \       |  \                 |
00050   //               5/______5__6/   |               |               |   \6__5______\5               |
00051   //  face 5 --->  |    |     |    |  <--- 6 face  |  face 6 --->  |    |     |    |  <--- 5 face  |
00052   //               |    |__3__|____|               |               |____|__3__|    |               |
00053   //               |   /4     |   /3               |               3\   |     4\   |               |
00054   //               |  /       |  /                 |                 \  |       \  |               |
00055   //               9 4       10 2                  |                  2 10       4 9               |
00056   //               |/__1______|/                   |                   \|______1__\|               |
00057   //               1          2                    |                    2          1               |
00058   //            _.        .                        |                        .       ._             |
00059   //            /|       /|\                       |                       /|\      |\             |
00060   //           /          |                        |                        |         \            |
00061   //          3 face      1 face                   |                   face 1     face 3           |
00062   //                                               |                                               |
00063   //  Picture 1 (right orientation)                |  Picture 2 (left orientation)                 |
00064   //                                                                                               |
00065   //  For the moment, the orientation of numbering is not controlled
00066 
00067   // Faces: 1 - bottom, 2 - top, 3 - front, 4 - back, 5 - left (right), 6 - right (left)
00068 
00069   //
00070   //                             4_______3__3         2 ______2__3
00071   //                            /          /          |          |
00072   //                           4          2           1          3
00073   //                          /          /            |          |
00074   //                        1/______1__2/             |          |
00075   //                                                  |          |
00076   //                                                  | __4______|
00077   //                           face 2       face 4    1          4
00078   //                                |           /
00079   //                               \|/        |/_
00080   //                                '         '
00081   //        3                    8_______7__7                    3
00082   //       /|                   /|         /|                   /|
00083   //      3 2                  8 12       6 11                 3 2
00084   //     /  |                 /  |       /  |                 /  |
00085   //   4/   |               5/______5__6/   |               4/   |
00086   //   |    |  face 5 --->  |    |     |    |  <--- 6 face  |    |
00087   //   |    |               |    |__3__|____|               |    |
00088   //   |   /2               |   /4     |   /3               |   /2
00089   //   |  /                 |  /       |  /                 |  /
00090   //   4 1                  9 4       10 2                  4 1
00091   //   |/                   |/__1______|/                   |/
00092   //   1                    1          2                    1
00093   //                     _.        .
00094   //                     /|       /|\
00095   //                    /          |
00096   //   2 ______2__3    3 face      1 face
00097   //   |          |
00098   //   |          |               __3_______
00099   //   |          |             /4         /3
00100   //   |          |            /          /
00101   //   1          3           4          2
00102   //   | __4______|          /__1______ /
00103   //   1          4         1          2
00104   //
00105   //  Picture 3 (On periferal pictures the local
00106   //  numeration of edges and vertices is shown)
00107 
00108 class GEOMImpl_Block6Explorer
00109 {
00110  public:
00111   // ---------- PUBLIC METHODS ----------
00112 
00113   GEOMImpl_Block6Explorer ();
00114   // Constructor.
00115 
00116   // Initialization by existing solid,
00117   // sub-elements regulate numeration
00118 
00119   void InitByBlock (const TopoDS_Shape& theBlock);
00120   // Init by hexahedral solid. First face, edge and vertex is defined randomly
00121 
00122   void InitByBlockAndFace (const TopoDS_Shape& theBlock,
00123                            const TopoDS_Shape& theFace);
00124   // Constructor from hexahedral solid, making theFace the first face.
00125   // First edge and vertex is defined randomly from theFace entities
00126 
00127   void InitByBlockAndEdges (const TopoDS_Shape& theBlock,
00128                             const TopoDS_Shape& theEdge1,
00129                             const TopoDS_Shape& theEdge2);
00130   // Init by hexahedral solid, making theEdge1 the first, theEdge2 the fird.
00131   // First vertex is defined randomly from theEdge1 vertices
00132   // (Picture 1 and Picture 2 shows two possible cases)
00133 
00134   void InitByBlockAndVertices (const TopoDS_Shape& theBlock,
00135                                const TopoDS_Shape& theVertex1,
00136                                const TopoDS_Shape& theVertex2,
00137                                const TopoDS_Shape& theVertex3);
00138   // Init by hexahedral solid, making theVertex1 the first,
00139   // theVertex2 the second and theVertex3 the fird vertices.
00140 
00141   // Initialization by parts of solid to be built
00142 
00143   void InitByTwoFaces (const TopoDS_Shape& theFace1,
00144                        const TopoDS_Shape& theFace2);
00145   // Init by two faces. TheFace1 will be the first,
00146   // theFace2 will be the second.
00147   // First edge and vertex is defined randomly from theFace1 entities.
00148 
00149   // Access to vertices
00150   TopoDS_Shape GetVertex (const Standard_Integer theVertexID); // [1-8]
00151 
00152   Standard_Integer GetVertexID (const TopoDS_Shape& theVertex);
00153 
00154   Standard_Integer GetVertexID (const Standard_Integer theFaceID, // [1-6]
00155                                 const Standard_Integer theVertexNB); // [1-4]
00156 
00157   Standard_Integer GetVertexOnEdgeID (const Standard_Integer theEdgeID, // [1-12]
00158                                       const Standard_Integer theVertexNB); // [1-2]
00159 
00160   // Access to edges
00161   TopoDS_Shape GetEdge (const Standard_Integer theEdgeID, // [1-12]
00162                         const Standard_Boolean doMake = Standard_False);
00163 
00164   Standard_Integer GetEdgeID (const TopoDS_Shape& theEdge);
00165 
00166   Standard_Integer GetEdgeID (const Standard_Integer theFaceID, // [1-6]
00167                               const Standard_Integer theEdgeNB); // [1-4]
00168 
00169   Standard_Integer FindEdgeID (const Standard_Integer theVertex1ID,
00170                                const Standard_Integer theVertex2ID);
00171 
00172   Standard_Integer FindCommonEdgeID (const Standard_Integer theFace1ID,
00173                                      const Standard_Integer theFace2ID);
00174 
00175   // Access to faces
00176   TopoDS_Shape GetFace (const Standard_Integer theFaceID, // [1-6]
00177                         const Standard_Boolean doMake = Standard_False);
00178 
00179   Standard_Integer GetFaceID (const TopoDS_Shape& theFace);
00180 
00181   Standard_Integer FindFaceID (const Standard_Integer theEdge1ID,
00182                                const Standard_Integer theEdge2ID);
00183 
00184   Standard_Integer GetOppositeFaceID (const Standard_Integer theFaceID);
00185 
00186   // Check Block
00187   Standard_Boolean IsSimilarFaces (const Standard_Integer theFace1ID,
00188                                    const Standard_Integer theFace2ID,
00189                                    const gp_Trsf          theTransformation);
00190   // returns true, if theFace1, transformed
00191   // by theTransformation, coincides with theFace2
00192  public:
00193   // ---------- STATIC PUBLIC METHODS ----------
00194   static void MapShapesAndAncestors (const TopoDS_Shape& S,
00195                                      const TopAbs_ShapeEnum TS,
00196                                      const TopAbs_ShapeEnum TA,
00197                                      TopTools_IndexedDataMapOfShapeListOfShape& M);
00198 
00199   static Standard_Boolean IsSimilarEdges (const TopoDS_Shape& E1, 
00200                                           const TopoDS_Shape& E2);
00201 
00202   static Standard_Integer FindEdge (TopoDS_Shape&       theResult,
00203                                     const TopoDS_Shape& V1,
00204                                     const TopoDS_Shape& V2,
00205                                     const TopTools_IndexedDataMapOfShapeListOfShape& MVE,
00206                                     const Standard_Boolean findAll = Standard_False);
00207   // returns number of found edges
00208 
00209   static Standard_Integer FindFace (TopoDS_Shape&       theResult,
00210                                     const TopoDS_Shape& V1,
00211                                     const TopoDS_Shape& V2,
00212                                     const TopoDS_Shape& V3,
00213                                     const TopoDS_Shape& V4,
00214                                     const TopTools_IndexedDataMapOfShapeListOfShape& MVF,
00215                                     const Standard_Boolean findAll = Standard_False);
00216   // returns number of found faces
00217 
00227   static TCollection_AsciiString MakeFace (const TopoDS_Wire&     theWire,
00228                                            const Standard_Boolean isPlanarWanted,
00229                                            TopoDS_Shape&          theResult);
00230 
00237   static TCollection_AsciiString MakeAnyFace (const TopoDS_Wire& theWire,
00238                                               TopoDS_Shape&      theResult);
00239 
00240  private:
00241   // ---------- PRIVATE FIELDS ----------
00242 
00243   TopTools_Array1OfShape myFaces;
00244   TopTools_Array1OfShape myEdges;
00245   TopTools_Array1OfShape myVertices;
00246 };
00247 
00248 #endif