0027117: BRepClass3d_SolidClassifier doesn't take into account vertex/edge/face toler...
[occt.git] / src / BRepClass3d / BRepClass3d_SolidExplorer.hxx
1 // Created on: 1994-03-10
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1994-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 _BRepClass3d_SolidExplorer_HeaderFile
18 #define _BRepClass3d_SolidExplorer_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Bnd_Box.hxx>
25 #include <TopoDS_Shape.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Integer.hxx>
28 #include <Standard_Real.hxx>
29 #include <TopExp_Explorer.hxx>
30 #include <BRepClass3d_MapOfInter.hxx>
31 #include <TopAbs_State.hxx>
32 #include <BRepClass3d_BndBoxTree.hxx>
33 #include <TopTools_IndexedMapOfShape.hxx>
34
35 class TopoDS_Shape;
36 class gp_Pnt;
37 class TopoDS_Face;
38 class gp_Vec;
39 class BRepAdaptor_HSurface;
40 class TopoDS_Shell;
41 class gp_Lin;
42 class Bnd_Box;
43 class IntCurvesFace_Intersector;
44
45 //! Provide an exploration of a BRep Shape for the classification.
46 //! Provide access to the special UB tree to obtain fast search.
47 class BRepClass3d_SolidExplorer 
48 {
49 public:
50
51   DEFINE_STANDARD_ALLOC
52
53   
54   Standard_EXPORT BRepClass3d_SolidExplorer();
55   
56   //! Raise if called.
57   Standard_EXPORT BRepClass3d_SolidExplorer(const BRepClass3d_SolidExplorer& Oth);
58   
59   Standard_EXPORT BRepClass3d_SolidExplorer(const TopoDS_Shape& S);
60   
61   Standard_EXPORT virtual ~BRepClass3d_SolidExplorer();
62   
63   Standard_EXPORT void InitShape (const TopoDS_Shape& S);
64   
65   //! Should return True if P outside of bounding vol. of the shape
66   Standard_EXPORT virtual Standard_Boolean Reject (const gp_Pnt& P) const;
67   
68   //! compute a point P in the face  F. Param is a Real in
69   //! ]0,1[ and   is  used to  initialise  the algorithm. For
70   //! different values , different points are returned.
71   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& Param);
72   
73   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v, Standard_Real& Param);
74   
75   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v, Standard_Real& Param, gp_Vec& theVecD1U, gp_Vec& theVecD1V);
76   
77   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v);
78   
79   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P);
80   
81   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, Standard_Real& u, Standard_Real& v);
82   
83   Standard_EXPORT Standard_Boolean PointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v, Standard_Real& Param, Standard_Integer& Index) const;
84   
85   Standard_EXPORT Standard_Boolean PointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v, Standard_Real& Param, Standard_Integer& Index, const Handle(BRepAdaptor_HSurface)& surf, const Standard_Real u1, const Standard_Real v1, const Standard_Real u2, const Standard_Real v2) const;
86   
87   //! <Index> gives point index  to  search from and returns
88   //! point index of succeseful search
89   Standard_EXPORT Standard_Boolean PointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v, Standard_Real& Param, Standard_Integer& Index, const Handle(BRepAdaptor_HSurface)& surf, const Standard_Real u1, const Standard_Real v1, const Standard_Real u2, const Standard_Real v2, gp_Vec& theVecD1U, gp_Vec& theVecD1V) const;
90   
91   //! Starts an exploration of the shells.
92   Standard_EXPORT void InitShell();
93   
94   //! Returns True if there is a current shell.
95   Standard_EXPORT Standard_Boolean MoreShell() const;
96   
97   //! Sets the explorer to the next shell.
98   Standard_EXPORT void NextShell();
99   
100   //! Returns the current shell.
101   Standard_EXPORT TopoDS_Shell CurrentShell() const;
102   
103   //! Returns True if the Shell is rejected.
104   Standard_EXPORT virtual Standard_Boolean RejectShell (const gp_Lin& L) const;
105   
106   //! Starts an exploration of the faces of the current shell.
107   Standard_EXPORT void InitFace();
108   
109   //! Returns True if current face in current shell.
110   Standard_EXPORT Standard_Boolean MoreFace() const;
111   
112   //! Sets the explorer to the next Face of the current shell.
113   Standard_EXPORT void NextFace();
114   
115   //! Returns the current face.
116   Standard_EXPORT TopoDS_Face CurrentFace() const;
117   
118   //! returns True if the face is rejected.
119   Standard_EXPORT virtual Standard_Boolean RejectFace (const gp_Lin& L) const;
120   
121   //! Returns  in <L>, <Par>  a segment having at least
122   //! one  intersection  with  the  shape  boundary  to
123   //! compute  intersections.
124   Standard_EXPORT Standard_Integer Segment (const gp_Pnt& P, gp_Lin& L, Standard_Real& Par);
125   
126   //! Returns  in <L>, <Par>  a segment having at least
127   //! one  intersection  with  the  shape  boundary  to
128   //! compute  intersections.
129   //!
130   //! The First Call to this method returns a line which
131   //! point to a point of the first face of the shape.
132   //! The Second Call provide a line to the second face
133   //! and so on.
134   Standard_EXPORT Standard_Integer OtherSegment (const gp_Pnt& P, gp_Lin& L, Standard_Real& Par);
135   
136   //! Returns the index of face for which
137   //! last segment is calculated.
138   Standard_EXPORT Standard_Integer GetFaceSegmentIndex() const;
139   
140   Standard_EXPORT virtual void DumpSegment (const gp_Pnt& P, const gp_Lin& L, const Standard_Real Par, const TopAbs_State S) const;
141   
142   Standard_EXPORT const Bnd_Box& Box() const;
143
144   Standard_EXPORT const TopoDS_Shape& GetShape() const;
145   
146   Standard_EXPORT IntCurvesFace_Intersector& Intersector (const TopoDS_Face& F) const;
147
148   //! Return UB-tree instance which is used for edge / vertex checks.
149   const BRepClass3d_BndBoxTree& GetTree () {return myTree;}
150   //! Return edge/vertices map for current shape.
151   const TopTools_IndexedMapOfShape& GetMapEV () {return myMapEV;}
152   
153   Standard_EXPORT void Destroy();
154
155
156
157
158 protected:
159
160
161
162
163
164 private:
165
166
167
168   Bnd_Box myBox;
169   TopoDS_Shape myShape;
170   Standard_Boolean myReject;
171   Standard_Integer myFirstFace;
172   Standard_Real myParamOnEdge;
173   TopExp_Explorer myShellExplorer;
174   TopExp_Explorer myFaceExplorer;
175   BRepClass3d_MapOfInter myMapOfInter;
176   BRepClass3d_BndBoxTree myTree;
177   TopTools_IndexedMapOfShape myMapEV;
178
179
180 };
181
182
183
184
185
186
187
188 #endif // _BRepClass3d_SolidExplorer_HeaderFile