1 // Created on: 1993-03-05
2 // Created by: Didier PIFFAULT
3 // Copyright (c) 1993-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 _Bnd_BoundSortBox2d_HeaderFile
18 #define _Bnd_BoundSortBox2d_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Bnd_Box2d.hxx>
25 #include <Bnd_HArray1OfBox2d.hxx>
26 #include <Standard_Real.hxx>
27 #include <Standard_Integer.hxx>
28 #include <TColStd_HArray1OfListOfInteger.hxx>
29 #include <TColStd_DataMapOfIntegerInteger.hxx>
30 #include <TColStd_ListOfInteger.hxx>
31 class Standard_NullValue;
32 class Standard_MultiplyDefined;
36 //! A tool to compare a 2D bounding box with a set of 2D
37 //! bounding boxes. It sorts the set of bounding boxes to give
38 //! the list of boxes which intersect the element being compared.
39 //! The boxes being sorted generally bound a set of shapes,
40 //! while the box being compared bounds a shape to be
41 //! compared. The resulting list of intersecting boxes therefore
42 //! gives the list of items which potentially intersect the shape to be compared.
43 class Bnd_BoundSortBox2d
50 //! Constructs an empty comparison algorithm for 2D bounding boxes.
51 //! The bounding boxes are then defined using the Initialize function.
52 Standard_EXPORT Bnd_BoundSortBox2d();
54 //! Initializes this comparison algorithm with
55 //! - the set of 2D bounding boxes SetOfBox
56 Standard_EXPORT void Initialize (const Bnd_Box2d& CompleteBox, const Handle(Bnd_HArray1OfBox2d)& SetOfBox);
58 //! Initializes this comparison algorithm with
59 //! - the set of 2D bounding boxes SetOfBox, where
60 //! CompleteBox is given as the global bounding box of SetOfBox.
61 Standard_EXPORT void Initialize (const Handle(Bnd_HArray1OfBox2d)& SetOfBox);
63 //! Initializes this comparison algorithm, giving it only
64 //! - the maximum number nbComponents, and
65 //! - the global bounding box CompleteBox,
66 //! of the 2D bounding boxes to be managed. Use the Add
67 //! function to define the array of bounding boxes to be sorted by this algorithm.
68 Standard_EXPORT void Initialize (const Bnd_Box2d& CompleteBox, const Standard_Integer nbComponents);
70 //! Adds the 2D bounding box theBox at position boxIndex in
71 //! the array of boxes to be sorted by this comparison algorithm.
72 //! This function is used only in conjunction with the third
73 //! syntax described in the synopsis of Initialize.
75 //! - Standard_OutOfRange if boxIndex is not in the
76 //! range [ 1,nbComponents ] where
77 //! nbComponents is the maximum number of bounding
78 //! boxes declared for this comparison algorithm at
80 //! - Standard_MultiplyDefined if a box still exists at
81 //! position boxIndex in the array of boxes to be sorted by
82 //! this comparison algorithm.
83 Standard_EXPORT void Add (const Bnd_Box2d& theBox, const Standard_Integer boxIndex);
86 //! Compares the 2D bounding box theBox with the set of
87 //! bounding boxes to be sorted by this comparison algorithm,
88 //! and returns the list of intersecting bounding boxes as a list
89 //! of indexes on the array of bounding boxes used by this algorithm.
90 Standard_EXPORT const TColStd_ListOfInteger& Compare (const Bnd_Box2d& theBox);
92 Standard_EXPORT void Dump() const;
106 //! Prepares BoundSortBox2d and sorts the rectangles of
108 Standard_EXPORT void SortBoxes();
112 Handle(Bnd_HArray1OfBox2d) myBndComponents;
115 Standard_Real deltaX;
116 Standard_Real deltaY;
117 Standard_Integer discrX;
118 Standard_Integer discrY;
119 Handle(TColStd_HArray1OfListOfInteger) axisX;
120 Handle(TColStd_HArray1OfListOfInteger) axisY;
121 Standard_Integer theFound;
122 TColStd_DataMapOfIntegerInteger Crible;
123 TColStd_ListOfInteger lastResult;
134 #endif // _Bnd_BoundSortBox2d_HeaderFile