b311480e |
1 | // Created on: 2011-11-29 |
2 | // Created by: ANNA MASALSKAYA |
973c2be1 |
3 | // Copyright (c) 2011-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
82192477 |
15 | |
16 | #ifndef _BRepBuilderAPI_BndBoxTreeSelector_Header |
17 | #define _BRepBuilderAPI_BndBoxTreeSelector_Header |
18 | |
82192477 |
19 | #include <TColStd_ListOfInteger.hxx> |
82192477 |
20 | #include <Bnd_Box.hxx> |
82192477 |
21 | #include <NCollection_UBTree.hxx> |
82192477 |
22 | |
23 | typedef NCollection_UBTree <Standard_Integer, Bnd_Box> BRepBuilderAPI_BndBoxTree; |
24 | |
25 | //======================================================================= |
26 | //! Class BRepBuilderAPI_BndBoxTreeSelector |
27 | //! derived from UBTree::Selector |
28 | //! This class is used to select overlapping boxes, stored in |
29 | //! NCollection::UBTree; contains methods to maintain the selection |
30 | //! condition and to retrieve selected objects after search. |
31 | //======================================================================= |
32 | |
33 | class BRepBuilderAPI_BndBoxTreeSelector : public BRepBuilderAPI_BndBoxTree::Selector |
34 | { |
35 | public: |
36 | //! Constructor; calls the base class constructor |
37 | BRepBuilderAPI_BndBoxTreeSelector() : BRepBuilderAPI_BndBoxTree::Selector() {} |
38 | |
39 | //! Implementation of rejection method |
40 | //! @return |
41 | //! True if the bounding box does not intersect with the current |
42 | Standard_Boolean Reject (const Bnd_Box& theBox) const |
43 | { |
44 | return (myBox.IsOut (theBox)); |
45 | } |
46 | |
47 | //! Implementation of acceptance method |
48 | //! This method is called when the bounding box intersect with the current. |
49 | //! It stores the object - the index of box in the list of accepted objects. |
50 | //! @return |
51 | //! True, because the object is accepted |
52 | Standard_Boolean Accept (const Standard_Integer& theObj) |
53 | { |
54 | myResInd.Append (theObj); |
55 | return Standard_True; |
56 | } |
57 | |
58 | //! Clear the list of intersecting boxes |
59 | void ClearResList() |
60 | { |
61 | myResInd.Clear(); |
62 | } |
63 | |
64 | //! Set current box to search for overlapping with him |
65 | void SetCurrent (const Bnd_Box& theBox) |
66 | { |
67 | myBox = theBox; |
68 | } |
69 | |
70 | //! Get list of indexes of boxes intersecting with the current box |
71 | const TColStd_ListOfInteger& ResInd() |
72 | { |
73 | return myResInd; |
74 | } |
75 | |
76 | private: |
77 | TColStd_ListOfInteger myResInd; |
78 | Bnd_Box myBox; |
79 | }; |
80 | |
81 | #endif |