0030686: Visualization, SelectMgr_ViewerSelector - sorting issues of transformation...
[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   Standard_EXPORT BRepClass3d_SolidExplorer(const TopoDS_Shape& S);
57   
58   Standard_EXPORT virtual ~BRepClass3d_SolidExplorer();
59   
60   Standard_EXPORT void InitShape (const TopoDS_Shape& S);
61   
62   //! Should return True if P outside of bounding vol. of the shape
63   Standard_EXPORT virtual Standard_Boolean Reject (const gp_Pnt& P) const;
64   
65   //! compute a point P in the face  F. Param is a Real in
66   //! ]0,1[ and   is  used to  initialise  the algorithm. For
67   //! different values , different points are returned.
68   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& Param);
69   
70   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v, Standard_Real& Param);
71   
72   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);
73   
74   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v);
75   
76   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P);
77   
78   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, Standard_Real& u, Standard_Real& v);
79   
80   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;
81   
82   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;
83   
84   //! <Index> gives point index  to  search from and returns
85   //! point index of succeseful search
86   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;
87   
88   //! Starts an exploration of the shells.
89   Standard_EXPORT void InitShell();
90   
91   //! Returns True if there is a current shell.
92   Standard_EXPORT Standard_Boolean MoreShell() const;
93   
94   //! Sets the explorer to the next shell.
95   Standard_EXPORT void NextShell();
96   
97   //! Returns the current shell.
98   Standard_EXPORT TopoDS_Shell CurrentShell() const;
99   
100   //! Returns True if the Shell is rejected.
101   Standard_EXPORT virtual Standard_Boolean RejectShell (const gp_Lin& L) const;
102   
103   //! Starts an exploration of the faces of the current shell.
104   Standard_EXPORT void InitFace();
105   
106   //! Returns True if current face in current shell.
107   Standard_EXPORT Standard_Boolean MoreFace() const;
108   
109   //! Sets the explorer to the next Face of the current shell.
110   Standard_EXPORT void NextFace();
111   
112   //! Returns the current face.
113   Standard_EXPORT TopoDS_Face CurrentFace() const;
114   
115   //! returns True if the face is rejected.
116   Standard_EXPORT virtual Standard_Boolean RejectFace (const gp_Lin& L) const;
117   
118   //! Returns  in <L>, <Par>  a segment having at least
119   //! one  intersection  with  the  shape  boundary  to
120   //! compute  intersections.
121   Standard_EXPORT Standard_Integer Segment (const gp_Pnt& P, gp_Lin& L, Standard_Real& Par);
122   
123   //! Returns  in <L>, <Par>  a segment having at least
124   //! one  intersection  with  the  shape  boundary  to
125   //! compute  intersections.
126   //!
127   //! The First Call to this method returns a line which
128   //! point to a point of the first face of the shape.
129   //! The Second Call provide a line to the second face
130   //! and so on.
131   Standard_EXPORT Standard_Integer OtherSegment (const gp_Pnt& P, gp_Lin& L, Standard_Real& Par);
132   
133   //! Returns the index of face for which
134   //! last segment is calculated.
135   Standard_EXPORT Standard_Integer GetFaceSegmentIndex() const;
136   
137   Standard_EXPORT virtual void DumpSegment (const gp_Pnt& P, const gp_Lin& L, const Standard_Real Par, const TopAbs_State S) const;
138   
139   Standard_EXPORT const Bnd_Box& Box() const;
140
141   Standard_EXPORT const TopoDS_Shape& GetShape() const;
142   
143   Standard_EXPORT IntCurvesFace_Intersector& Intersector (const TopoDS_Face& F) const;
144
145   //! Return UB-tree instance which is used for edge / vertex checks.
146   const BRepClass3d_BndBoxTree& GetTree () {return myTree;}
147   //! Return edge/vertices map for current shape.
148   const TopTools_IndexedMapOfShape& GetMapEV () {return myMapEV;}
149   
150   Standard_EXPORT void Destroy();
151
152 private:
153
154   Standard_EXPORT BRepClass3d_SolidExplorer(const BRepClass3d_SolidExplorer& Oth);
155
156 protected:
157
158   Standard_EXPORT TopAbs_State ClassifyUVPoint
159                    (const IntCurvesFace_Intersector& theIntersector,
160                     const Handle(BRepAdaptor_HSurface)& theSurf,
161                     const gp_Pnt2d& theP2d) const;
162
163 private:
164
165
166
167   Bnd_Box myBox;
168   TopoDS_Shape myShape;
169   Standard_Boolean myReject;
170   Standard_Integer myFirstFace;
171   Standard_Real myParamOnEdge;
172   TopExp_Explorer myShellExplorer;
173   TopExp_Explorer myFaceExplorer;
174   BRepClass3d_MapOfInter myMapOfInter;
175   BRepClass3d_BndBoxTree myTree;
176   TopTools_IndexedMapOfShape myMapEV;
177
178
179 };
180
181
182
183
184
185
186
187 #endif // _BRepClass3d_SolidExplorer_HeaderFile