Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:17:48

0001 // Created on: 1993-01-27
0002 // Created by: Jean-Louis Frenkel
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _StdPrs_ShapeTool_HeaderFile
0018 #define _StdPrs_ShapeTool_HeaderFile
0019 
0020 #include <TopoDS.hxx>
0021 #include <TopoDS_Edge.hxx>
0022 #include <TopoDS_Shape.hxx>
0023 #include <TopExp_Explorer.hxx>
0024 #include <NCollection_List.hxx>
0025 #include <TopTools_ShapeMapHasher.hxx>
0026 #include <NCollection_IndexedDataMap.hxx>
0027 #include <NCollection_IndexedMap.hxx>
0028 #include <NCollection_Sequence.hxx>
0029 #include <NCollection_HSequence.hxx>
0030 
0031 class Bnd_Box;
0032 class Poly_Triangulation;
0033 class Poly_PolygonOnTriangulation;
0034 class Poly_Polygon3D;
0035 
0036 //! Describes the behaviour requested for a wireframe shape presentation.
0037 class StdPrs_ShapeTool
0038 {
0039 public:
0040   DEFINE_STANDARD_ALLOC
0041 
0042   //! Constructs the tool and initializes it using theShape and theAllVertices
0043   //! (optional) arguments. By default, only isolated and internal vertices are considered,
0044   //! however if theAllVertices argument is equal to True, all shape's vertices are taken into
0045   //! account.
0046   Standard_EXPORT StdPrs_ShapeTool(const TopoDS_Shape& theShape, const bool theAllVertices = false);
0047 
0048   void InitFace() { myFaceExplorer.Init(myShape, TopAbs_FACE); }
0049 
0050   bool MoreFace() const { return myFaceExplorer.More(); }
0051 
0052   void NextFace() { myFaceExplorer.Next(); }
0053 
0054   const TopoDS_Face& GetFace() const { return TopoDS::Face(myFaceExplorer.Current()); }
0055 
0056   Standard_EXPORT Bnd_Box FaceBound() const;
0057 
0058   bool IsPlanarFace() const
0059   {
0060     const TopoDS_Face& aFace = TopoDS::Face(myFaceExplorer.Current());
0061     return IsPlanarFace(aFace);
0062   }
0063 
0064   void InitCurve() { myEdge = 1; }
0065 
0066   bool MoreCurve() const { return myEdge <= myEdgeMap.Extent(); }
0067 
0068   void NextCurve() { ++myEdge; }
0069 
0070   const TopoDS_Edge& GetCurve() const { return TopoDS::Edge(myEdgeMap.FindKey(myEdge)); }
0071 
0072   Standard_EXPORT Bnd_Box CurveBound() const;
0073 
0074   Standard_EXPORT int Neighbours() const;
0075 
0076   Standard_EXPORT occ::handle<NCollection_HSequence<TopoDS_Shape>> FacesOfEdge() const;
0077 
0078   void InitVertex() { myVertex = 1; }
0079 
0080   bool MoreVertex() const { return myVertex <= myVertexMap.Extent(); }
0081 
0082   void NextVertex() { ++myVertex; }
0083 
0084   const TopoDS_Vertex& GetVertex() const { return TopoDS::Vertex(myVertexMap.FindKey(myVertex)); }
0085 
0086   Standard_EXPORT bool HasSurface() const;
0087 
0088   Standard_EXPORT occ::handle<Poly_Triangulation> CurrentTriangulation(TopLoc_Location& l) const;
0089 
0090   Standard_EXPORT bool HasCurve() const;
0091 
0092   Standard_EXPORT void PolygonOnTriangulation(occ::handle<Poly_PolygonOnTriangulation>& Indices,
0093                                               occ::handle<Poly_Triangulation>&          T,
0094                                               TopLoc_Location&                          l) const;
0095 
0096   Standard_EXPORT occ::handle<Poly_Polygon3D> Polygon3D(TopLoc_Location& l) const;
0097 
0098 public:
0099   Standard_EXPORT static bool IsPlanarFace(const TopoDS_Face& theFace);
0100 
0101 private:
0102   TopoDS_Shape    myShape;
0103   TopExp_Explorer myFaceExplorer;
0104   NCollection_IndexedDataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>
0105                                                                 myEdgeMap;
0106   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> myVertexMap;
0107   int                                                           myEdge;
0108   int                                                           myVertex;
0109 };
0110 
0111 #endif // _StdPrs_ShapeTool_HeaderFile