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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _BRepClass3d_SolidExplorer_HeaderFile
18 #define _BRepClass3d_SolidExplorer_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
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>
39 class BRepAdaptor_HSurface;
43 class IntCurvesFace_Intersector;
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
54 Standard_EXPORT BRepClass3d_SolidExplorer();
57 Standard_EXPORT BRepClass3d_SolidExplorer(const BRepClass3d_SolidExplorer& Oth);
59 Standard_EXPORT BRepClass3d_SolidExplorer(const TopoDS_Shape& S);
61 Standard_EXPORT virtual ~BRepClass3d_SolidExplorer();
63 Standard_EXPORT void InitShape (const TopoDS_Shape& S);
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;
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);
73 Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v, Standard_Real& Param);
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);
77 Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P, Standard_Real& u, Standard_Real& v);
79 Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, gp_Pnt& P);
81 Standard_EXPORT static Standard_Boolean FindAPointInTheFace (const TopoDS_Face& F, Standard_Real& u, Standard_Real& v);
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;
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;
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;
91 //! Starts an exploration of the shells.
92 Standard_EXPORT void InitShell();
94 //! Returns True if there is a current shell.
95 Standard_EXPORT Standard_Boolean MoreShell() const;
97 //! Sets the explorer to the next shell.
98 Standard_EXPORT void NextShell();
100 //! Returns the current shell.
101 Standard_EXPORT TopoDS_Shell CurrentShell() const;
103 //! Returns True if the Shell is rejected.
104 Standard_EXPORT virtual Standard_Boolean RejectShell (const gp_Lin& L) const;
106 //! Starts an exploration of the faces of the current shell.
107 Standard_EXPORT void InitFace();
109 //! Returns True if current face in current shell.
110 Standard_EXPORT Standard_Boolean MoreFace() const;
112 //! Sets the explorer to the next Face of the current shell.
113 Standard_EXPORT void NextFace();
115 //! Returns the current face.
116 Standard_EXPORT TopoDS_Face CurrentFace() const;
118 //! returns True if the face is rejected.
119 Standard_EXPORT virtual Standard_Boolean RejectFace (const gp_Lin& L) const;
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);
126 //! Returns in <L>, <Par> a segment having at least
127 //! one intersection with the shape boundary to
128 //! compute intersections.
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
134 Standard_EXPORT Standard_Integer OtherSegment (const gp_Pnt& P, gp_Lin& L, Standard_Real& Par);
136 //! Returns the index of face for which
137 //! last segment is calculated.
138 Standard_EXPORT Standard_Integer GetFaceSegmentIndex() const;
140 Standard_EXPORT virtual void DumpSegment (const gp_Pnt& P, const gp_Lin& L, const Standard_Real Par, const TopAbs_State S) const;
142 Standard_EXPORT const Bnd_Box& Box() const;
144 Standard_EXPORT const TopoDS_Shape& GetShape() const;
146 Standard_EXPORT IntCurvesFace_Intersector& Intersector (const TopoDS_Face& F) const;
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;}
153 Standard_EXPORT void Destroy();
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;
188 #endif // _BRepClass3d_SolidExplorer_HeaderFile