8db650a8f326b3336068b768d27d4af3feda7e6f
[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 class TopoDS_Shape;
33 class gp_Pnt;
34 class TopoDS_Face;
35 class gp_Vec;
36 class BRepAdaptor_HSurface;
37 class TopoDS_Shell;
38 class gp_Lin;
39 class Bnd_Box;
40 class IntCurvesFace_Intersector;
41
42
43 //! Provide an   exploration of a  BRep Shape   for the
44 //! classification.
45 class BRepClass3d_SolidExplorer 
46 {
47 public:
48
49   DEFINE_STANDARD_ALLOC
50
51   
52   Standard_EXPORT BRepClass3d_SolidExplorer();
53   
54   //! Raise if called.
55   Standard_EXPORT BRepClass3d_SolidExplorer(const BRepClass3d_SolidExplorer& Oth);
56   
57   Standard_EXPORT BRepClass3d_SolidExplorer(const TopoDS_Shape& S);
58   
59   Standard_EXPORT virtual ~BRepClass3d_SolidExplorer();
60   
61   Standard_EXPORT void InitShape (const TopoDS_Shape& S);
62   
63   //! Should return True if P outside of bounding vol. of the shape
64   Standard_EXPORT virtual Standard_Boolean Reject (const gp_Pnt& P) const;
65   
66   //! compute a point P in the face  F. Param is a Real in
67   //! ]0,1[ and   is  used to  initialise  the algorithm. For
68   //! different values , different points are returned.
69   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& Param);
70   
71   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v, 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, gp_Vec& theVecD1U, gp_Vec& theVecD1V);
74   
75   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v);
76   
77   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P);
78   
79   Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, Standard_Real& u, Standard_Real& v);
80   
81   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;
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 Handle(BRepAdaptor_HSurface)& surf, const Standard_Real u1, const Standard_Real v1, const Standard_Real u2, const Standard_Real v2) const;
84   
85   //! <Index> gives point index  to  search from and returns
86   //! point index of succeseful search
87   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;
88   
89   //! Starts an exploration of the shells.
90   Standard_EXPORT void InitShell();
91   
92   //! Returns True if there is a current shell.
93   Standard_EXPORT Standard_Boolean MoreShell() const;
94   
95   //! Sets the explorer to the next shell.
96   Standard_EXPORT void NextShell();
97   
98   //! Returns the current shell.
99   Standard_EXPORT TopoDS_Shell CurrentShell() const;
100   
101   //! Returns True if the Shell is rejected.
102   Standard_EXPORT virtual Standard_Boolean RejectShell (const gp_Lin& L) const;
103   
104   //! Starts an exploration of the faces of the current shell.
105   Standard_EXPORT void InitFace();
106   
107   //! Returns True if current face in current shell.
108   Standard_EXPORT Standard_Boolean MoreFace() const;
109   
110   //! Sets the explorer to the next Face of the current shell.
111   Standard_EXPORT void NextFace();
112   
113   //! Returns the current face.
114   Standard_EXPORT TopoDS_Face CurrentFace() const;
115   
116   //! returns True if the face is rejected.
117   Standard_EXPORT virtual Standard_Boolean RejectFace (const gp_Lin& L) const;
118   
119   //! Returns  in <L>, <Par>  a segment having at least
120   //! one  intersection  with  the  shape  boundary  to
121   //! compute  intersections.
122   Standard_EXPORT Standard_Integer Segment (const gp_Pnt& P, gp_Lin& L, Standard_Real& Par);
123   
124   //! Returns  in <L>, <Par>  a segment having at least
125   //! one  intersection  with  the  shape  boundary  to
126   //! compute  intersections.
127   //!
128   //! The First Call to this method returns a line which
129   //! point to a point of the first face of the shape.
130   //! The Second Call provide a line to the second face
131   //! and so on.
132   Standard_EXPORT Standard_Integer OtherSegment (const gp_Pnt& P, gp_Lin& L, Standard_Real& Par);
133   
134   //! Returns the index of face for which
135   //! last segment is calculated.
136   Standard_EXPORT Standard_Integer GetFaceSegmentIndex() const;
137   
138   Standard_EXPORT virtual void DumpSegment (const gp_Pnt& P, const gp_Lin& L, const Standard_Real Par, const TopAbs_State S) const;
139   
140   Standard_EXPORT const Bnd_Box& Box() const;
141   
142   Standard_EXPORT IntCurvesFace_Intersector& Intersector (const TopoDS_Face& F) const;
143   
144   Standard_EXPORT void Destroy();
145
146
147
148
149 protected:
150
151
152
153
154
155 private:
156
157
158
159   Bnd_Box myBox;
160   TopoDS_Shape myShape;
161   Standard_Boolean myReject;
162   Standard_Integer myFirstFace;
163   Standard_Real myParamOnEdge;
164   TopExp_Explorer myShellExplorer;
165   TopExp_Explorer myFaceExplorer;
166   BRepClass3d_MapOfInter myMapOfInter;
167
168
169 };
170
171
172
173
174
175
176
177 #endif // _BRepClass3d_SolidExplorer_HeaderFile