0022972: Eliminate macro definitions that has compiler-provided analogs (WNT and...
[occt.git] / src / Bnd / Bnd_BoundSortBox2d.hxx
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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Bnd_BoundSortBox2d_HeaderFile
18 #define _Bnd_BoundSortBox2d_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
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;
33 class Bnd_Box2d;
34
35
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 
44 {
45 public:
46
47   DEFINE_STANDARD_ALLOC
48
49   
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();
53   
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);
57   
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);
62   
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);
69   
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.
74   //! Exceptions
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
79   //! initialization.
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);
84   
85
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);
91   
92   Standard_EXPORT void Dump() const;
93
94
95
96
97 protected:
98
99
100
101
102
103 private:
104
105   
106   //! Prepares BoundSortBox2d and sorts the rectangles of
107   //! <SetOfBox> .
108   Standard_EXPORT void SortBoxes();
109
110
111   Bnd_Box2d myBox;
112   Handle(Bnd_HArray1OfBox2d) myBndComponents;
113   Standard_Real Xmin;
114   Standard_Real Ymin;
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;
124
125
126 };
127
128
129
130
131
132
133
134 #endif // _Bnd_BoundSortBox2d_HeaderFile