1 // Copyright (c) 1994-1999 Matra Datavision
2 // Copyright (c) 1999-2016 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _BRepClass3d_BndBoxTree_HeaderFile
16 #define _BRepClass3d_BndBoxTree_HeaderFile
19 #include <NCollection_Sequence.hxx>
20 #include <NCollection_UBTreeFiller.hxx>
21 #include <NCollection_UBTree.hxx>
22 #include <TopTools_IndexedMapOfShape.hxx>
23 #include <BRepBndLib.hxx>
24 #include <TopoDS_Edge.hxx>
25 #include <TopoDS_Vertex.hxx>
26 #include <Geom_Line.hxx>
27 #include <Bnd_Box.hxx>
29 #include <GeomAdaptor_Curve.hxx>
30 #include <Precision.hxx>
32 // Typedef to reduce code complexity.
33 typedef NCollection_UBTree <Standard_Integer, Bnd_Box> BRepClass3d_BndBoxTree;
35 // Class representing tree selector for point object.
36 class BRepClass3d_BndBoxTreeSelectorPoint : public BRepClass3d_BndBoxTree::Selector
39 BRepClass3d_BndBoxTreeSelectorPoint(const TopTools_IndexedMapOfShape& theMapOfShape)
40 : BRepClass3d_BndBoxTreeSelectorPoint::Selector(), myMapOfShape (theMapOfShape)
43 Standard_Boolean Reject (const Bnd_Box& theBox) const
45 return (theBox.IsOut (myP));
48 Standard_Boolean Accept (const Standard_Integer& theObj);
50 // Sets current point for boxes-point collisions.
51 void SetCurrentPoint (const gp_Pnt& theP)
57 BRepClass3d_BndBoxTreeSelectorPoint(const BRepClass3d_BndBoxTreeSelectorPoint& );
58 BRepClass3d_BndBoxTreeSelectorPoint& operator=(const BRepClass3d_BndBoxTreeSelectorPoint& );
61 const TopTools_IndexedMapOfShape& myMapOfShape; //shapes (vertices + edges)
65 // Class representing tree selector for line object.
66 class BRepClass3d_BndBoxTreeSelectorLine : public BRepClass3d_BndBoxTree::Selector
73 Standard_Real myParam; //par on myE
74 Standard_Real myLParam; //par on line
80 Standard_Real myLParam; //par on line
85 BRepClass3d_BndBoxTreeSelectorLine(const TopTools_IndexedMapOfShape& theMapOfShape)
86 : BRepClass3d_BndBoxTreeSelectorLine::Selector(),
87 myMapOfShape(theMapOfShape),
88 myIsValid(Standard_True)
91 Standard_Boolean Reject (const Bnd_Box& theBox) const
93 return (theBox.IsOut (myL));
96 Standard_Boolean Accept (const Standard_Integer& theObj);
98 //Sets current line for boxes-line collisions
99 void SetCurrentLine (const gp_Lin& theL,
100 const Standard_Real theMaxParam)
103 myLC.Load(new Geom_Line(theL), -Precision::PConfusion(), theMaxParam);
106 void GetEdgeParam(const Standard_Integer i,
107 TopoDS_Edge& theOutE,
108 Standard_Real &theOutParam,
109 Standard_Real &outLParam ) const
111 const EdgeParam& EP = myEP.Value(i);
113 theOutParam = EP.myParam;
114 outLParam = EP.myLParam;
117 void GetVertParam(const Standard_Integer i,
118 TopoDS_Vertex& theOutV,
119 Standard_Real &outLParam ) const
121 const VertParam& VP = myVP.Value(i);
123 outLParam = VP.myLParam;
126 Standard_Integer GetNbEdgeParam() const
128 return myEP.Length();
131 Standard_Integer GetNbVertParam() const
133 return myVP.Length();
140 myIsValid = Standard_True;
143 //! Returns TRUE if correct classification is possible
144 Standard_Boolean IsCorrect() const
150 BRepClass3d_BndBoxTreeSelectorLine(const BRepClass3d_BndBoxTreeSelectorLine& );
151 BRepClass3d_BndBoxTreeSelectorLine& operator=(const BRepClass3d_BndBoxTreeSelectorLine& );
154 const TopTools_IndexedMapOfShape& myMapOfShape; //shapes (vertices + edges)
156 NCollection_Sequence<EdgeParam> myEP; //output result (edge vs line)
157 NCollection_Sequence<VertParam> myVP; //output result (vertex vs line)
158 GeomAdaptor_Curve myLC;
159 Standard_Boolean myIsValid;