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(), myMapOfShape (theMapOfShape)
89 Standard_Boolean Reject (const Bnd_Box& theBox) const
91 return (theBox.IsOut (myL));
94 Standard_Boolean Accept (const Standard_Integer& theObj);
96 //Sets current line for boxes-line collisions
97 void SetCurrentLine (const gp_Lin& theL,
98 const Standard_Real theMaxParam)
101 myLC.Load(new Geom_Line(theL), -Precision::PConfusion(), theMaxParam);
104 void GetEdgeParam(const Standard_Integer i,
105 TopoDS_Edge& theOutE,
106 Standard_Real &theOutParam,
107 Standard_Real &outLParam ) const
109 const EdgeParam& EP = myEP.Value(i);
111 theOutParam = EP.myParam;
112 outLParam = EP.myLParam;
115 void GetVertParam(const Standard_Integer i,
116 TopoDS_Vertex& theOutV,
117 Standard_Real &outLParam ) const
119 const VertParam& VP = myVP.Value(i);
121 outLParam = VP.myLParam;
124 Standard_Integer GetNbEdgeParam() const
126 return myEP.Length();
129 Standard_Integer GetNbVertParam() const
131 return myVP.Length();
141 BRepClass3d_BndBoxTreeSelectorLine(const BRepClass3d_BndBoxTreeSelectorLine& );
142 BRepClass3d_BndBoxTreeSelectorLine& operator=(const BRepClass3d_BndBoxTreeSelectorLine& );
145 const TopTools_IndexedMapOfShape& myMapOfShape; //shapes (vertices + edges)
147 NCollection_Sequence<EdgeParam> myEP; //output result (edge vs line)
148 NCollection_Sequence<VertParam> myVP; //output result (vertex vs line)
149 GeomAdaptor_Curve myLC;