1 // Created on: 1992-11-19
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1992-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 _BRepClass_FaceExplorer_HeaderFile
18 #define _BRepClass_FaceExplorer_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
24 
25 #include <TopAbs_Orientation.hxx>
26 #include <TopoDS_Face.hxx>
27 #include <TopExp_Explorer.hxx>
28 #include <Standard_Integer.hxx>
29 #include <Standard_Real.hxx>
30 #include <Standard_Boolean.hxx>
31 class gp_Pnt2d;
32 class gp_Lin2d;
33 class BRepClass_Edge;
34 
35 
36 //! Provide an   exploration of a  BRep Face   for the
37 //! classification. Return UV edges.
38 class BRepClass_FaceExplorer
39 {
40 public:
41 
42   DEFINE_STANDARD_ALLOC
43 
44 
45   Standard_EXPORT BRepClass_FaceExplorer(const TopoDS_Face& F);
46 
47   //! Checks the point and change its coords if it is located too far
48   //! from the bounding box of the face. New Coordinates of the point
49   //! will be on the line between the point and the center of the
50   //! bounding box. Returns True if point was not changed.
51   Standard_EXPORT Standard_Boolean CheckPoint (gp_Pnt2d& thePoint);
52 
53   //! Should  return  True  if the  point  is  outside a
54   //! bounding volume of the face.
55   Standard_EXPORT Standard_Boolean Reject (const gp_Pnt2d& P) const;
56 
57   //! Returns  in <L>, <Par>  a segment having at least
58   //! one  intersection  with  the   face  boundary  to
59   //! compute  intersections.
60   Standard_EXPORT Standard_Boolean Segment (const gp_Pnt2d& P, gp_Lin2d& L, Standard_Real& Par);
61 
62   //! Returns  in <L>, <Par>  a segment having at least
63   //! one  intersection  with  the   face  boundary  to
64   //! compute  intersections. Each call gives another segment.
65   Standard_EXPORT Standard_Boolean OtherSegment (const gp_Pnt2d& P, gp_Lin2d& L, Standard_Real& Par);
66 
67   //! Starts an exploration of the wires.
68   Standard_EXPORT void InitWires();
69 
70   //! Returns True if there is  a current wire.
71     Standard_Boolean MoreWires() const;
72 
73   //! Sets the explorer  to the  next  wire.
74     void NextWire();
75 
76   //! Returns True  if the wire  bounding volume does not
77   //! intersect the segment.
78   Standard_EXPORT Standard_Boolean RejectWire (const gp_Lin2d& L, const Standard_Real Par) const;
79 
80   //! Starts an exploration of the  edges of the current
81   //! wire.
82   Standard_EXPORT void InitEdges();
83 
84   //! Returns True if there is a current edge.
85     Standard_Boolean MoreEdges() const;
86 
87   //! Sets the explorer  to the  next  edge.
88     void NextEdge();
89 
90   //! Returns True  if the edge  bounding volume does not
91   //! intersect the segment.
92   Standard_EXPORT Standard_Boolean RejectEdge (const gp_Lin2d& L, const Standard_Real Par) const;
93 
94   //! Current edge in current wire and its orientation.
95   Standard_EXPORT void CurrentEdge (BRepClass_Edge& E, TopAbs_Orientation& Or) const;
96 
97   //! Returns the maximum tolerance
MaxTolerance() const98   Standard_Real MaxTolerance() const
99   {
100     return myMaxTolerance;
101   }
102 
103   //! Sets the maximum tolerance at
104   //! which to start checking in the intersector
SetMaxTolerance(const Standard_Real theValue)105   void SetMaxTolerance(const Standard_Real theValue)
106   {
107     myMaxTolerance = theValue;
108   }
109 
110   //! Returns true if we are using boxes
111   //! in the intersector
UseBndBox() const112   Standard_Boolean UseBndBox() const
113   {
114     return myUseBndBox;
115   }
116 
117   //! Sets the status of whether we are
118   //! using boxes or not
SetUseBndBox(const Standard_Boolean theValue)119   void SetUseBndBox(const Standard_Boolean theValue)
120   {
121     myUseBndBox = theValue;
122   }
123 
124 
125 
126 
127 protected:
128 
129   //! Computes UV bounds of a face
130   Standard_EXPORT void ComputeFaceBounds();
131 
132 
133 private:
134 
135 
136 
137   TopoDS_Face myFace;
138   TopExp_Explorer myWExplorer;
139   TopExp_Explorer myEExplorer;
140   Standard_Integer myCurEdgeInd;
141   Standard_Real myCurEdgePar;
142   Standard_Real myMaxTolerance;
143   Standard_Boolean myUseBndBox;
144   TopTools_IndexedDataMapOfShapeListOfShape myMapVE;
145 
146   Standard_Real myUMin;
147   Standard_Real myUMax;
148   Standard_Real myVMin;
149   Standard_Real myVMax;
150 };
151 
152 
153 #include <BRepClass_FaceExplorer.lxx>
154 
155 
156 
157 
158 
159 #endif // _BRepClass_FaceExplorer_HeaderFile
160