712514fb6529fd5fb9bdf42ac48eb0742e41781b
[occt.git] / src / StdPrs / StdPrs_ShapeTool.hxx
1 // Created on: 1993-01-27
2 // Created by: Jean-Louis Frenkel
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _StdPrs_ShapeTool_HeaderFile
18 #define _StdPrs_ShapeTool_HeaderFile
19
20 #include <Standard_DefineAlloc.hxx>
21 #include <TopoDS.hxx>
22 #include <TopoDS_Edge.hxx>
23 #include <TopoDS_Face.hxx>
24 #include <TopoDS_Shape.hxx>
25 #include <TopoDS_Vertex.hxx>
26 #include <TopExp_Explorer.hxx>
27 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
28 #include <TopTools_IndexedMapOfShape.hxx>
29 #include <TopTools_HSequenceOfShape.hxx>
30
31 class Bnd_Box;
32 class Poly_Triangulation;
33 class Poly_PolygonOnTriangulation;
34 class Poly_Polygon3D;
35
36 //! Describes the behaviour requested for a wireframe shape presentation.
37 class StdPrs_ShapeTool
38 {
39 public:
40   DEFINE_STANDARD_ALLOC
41
42   //! Constructs the tool and initializes it using theShape and theAllVertices
43   //! (optional) arguments. By default, only isolated and internal vertices are considered,
44   //! however if theAllVertices argument is equal to True, all shape's vertices are taken into account.
45   Standard_EXPORT StdPrs_ShapeTool (const TopoDS_Shape& theShape, const Standard_Boolean theAllVertices = Standard_False);
46
47   void InitFace() { myFaceExplorer.Init(myShape,TopAbs_FACE); }
48
49   Standard_Boolean MoreFace() const { return myFaceExplorer.More(); }
50
51   void NextFace() { myFaceExplorer.Next(); }
52
53   const TopoDS_Face& GetFace() const { return TopoDS::Face(myFaceExplorer.Current()); }
54
55   Standard_EXPORT Bnd_Box FaceBound() const;
56
57   Standard_Boolean IsPlanarFace() const
58   {
59     const TopoDS_Face& aFace = TopoDS::Face (myFaceExplorer.Current());
60     return IsPlanarFace (aFace);
61   }
62
63   void InitCurve() { myEdge = 1; }
64
65   Standard_Boolean MoreCurve() const { return myEdge <= myEdgeMap.Extent(); }
66
67   void NextCurve() { ++myEdge; }
68
69   const TopoDS_Edge& GetCurve() const { return  TopoDS::Edge(myEdgeMap.FindKey(myEdge)); }
70
71   Standard_EXPORT Bnd_Box CurveBound() const;
72   
73   Standard_EXPORT Standard_Integer Neighbours() const;
74   
75   Standard_EXPORT Handle(TopTools_HSequenceOfShape) FacesOfEdge() const;
76
77   void InitVertex() { myVertex = 1; }
78
79   Standard_Boolean MoreVertex() const { return myVertex <= myVertexMap.Extent(); }
80
81   void NextVertex() { ++myVertex; }
82
83   const TopoDS_Vertex& GetVertex() const { return TopoDS::Vertex (myVertexMap.FindKey(myVertex)); }
84
85   Standard_EXPORT Standard_Boolean HasSurface() const;
86   
87   Standard_EXPORT Handle(Poly_Triangulation) CurrentTriangulation (TopLoc_Location& l) const;
88   
89   Standard_EXPORT Standard_Boolean HasCurve() const;
90   
91   Standard_EXPORT void PolygonOnTriangulation (Handle(Poly_PolygonOnTriangulation)& Indices, Handle(Poly_Triangulation)& T, TopLoc_Location& l) const;
92   
93   Standard_EXPORT Handle(Poly_Polygon3D) Polygon3D (TopLoc_Location& l) const;
94
95 public:
96
97   Standard_EXPORT static Standard_Boolean IsPlanarFace (const TopoDS_Face& theFace);
98
99 private:
100
101   TopoDS_Shape myShape;
102   TopExp_Explorer myFaceExplorer;
103   TopTools_IndexedDataMapOfShapeListOfShape myEdgeMap;
104   TopTools_IndexedMapOfShape myVertexMap;
105   Standard_Integer myEdge;
106   Standard_Integer myVertex;
107
108 };
109
110 #endif // _StdPrs_ShapeTool_HeaderFile