CommitLineData
7fd59977 1-- File: Bnd_BoundSortBox2d.cdl
2-- Created: Fri Mar 5 15:45:24 1993
3-- Author: Didier PIFFAULT
4-- <dpf@phylox>
5---Copyright: Matra Datavision 1993
6
7class BoundSortBox2d from Bnd
8
9 ---Purpose: A tool to compare a 2D bounding box with a set of 2D
10 -- bounding boxes. It sorts the set of bounding boxes to give
11 -- the list of boxes which intersect the element being compared.
12 -- The boxes being sorted generally bound a set of shapes,
13 -- while the box being compared bounds a shape to be
14 -- compared. The resulting list of intersecting boxes therefore
15 -- gives the list of items which potentially intersect the shape to be compared.
16
17
18uses Integer from Standard,
19 Real from Standard,
20 ListOfInteger from TColStd,
21 Box2d from Bnd,
22 HArray1OfBox2d from Bnd,
23 DataMapOfIntegerInteger from TColStd,
24 HArray1OfListOfInteger from TColStd
25
26
27raises NullValue from Standard, MultiplyDefined from Standard
28
29
30is Create returns BoundSortBox2d from Bnd;
31 ---Purpose: Constructs an empty comparison algorithm for 2D bounding boxes.
32 -- The bounding boxes are then defined using the Initialize function.
33
34 Initialize (me : in out;
35 CompleteBox : Box2d from Bnd;
36 SetOfBox : HArray1OfBox2d from Bnd)
37 is static;
38 ---Purpose: Initializes this comparison algorithm with
39 -- - the set of 2D bounding boxes SetOfBox
40
41 Initialize (me : in out;
42 SetOfBox : HArray1OfBox2d from Bnd)
43 is static;
44 ---Purpose: Initializes this comparison algorithm with
45 -- - the set of 2D bounding boxes SetOfBox, where
46 -- CompleteBox is given as the global bounding box of SetOfBox.
47 SortBoxes (me : in out)
48 raises NullValue from Standard is static private;
49 ---Purpose: Prepares BoundSortBox2d and sorts the rectangles of
50 -- <SetOfBox> .
51
52
53
54 Initialize (me : in out;
55 CompleteBox : Box2d from Bnd;
56 nbComponents : Integer from Standard)
57 raises NullValue from Standard is static;
58 ---Purpose: Initializes this comparison algorithm, giving it only
59 -- - the maximum number nbComponents, and
60 -- - the global bounding box CompleteBox,
61 -- of the 2D bounding boxes to be managed. Use the Add
62 -- function to define the array of bounding boxes to be sorted by this algorithm.
63
64 Add (me : in out;
65 theBox : Box2d from Bnd;
66 boxIndex : Integer from Standard)
67 raises MultiplyDefined from Standard is static;
68 ---Purpose: Adds the 2D bounding box theBox at position boxIndex in
69 -- the array of boxes to be sorted by this comparison algorithm.
70 -- This function is used only in conjunction with the third
71 -- syntax described in the synopsis of Initialize.
72 -- Exceptions
73 -- - Standard_OutOfRange if boxIndex is not in the
74 -- range [ 1,nbComponents ] where
75 -- nbComponents is the maximum number of bounding
76 -- boxes declared for this comparison algorithm at
77 -- initialization.
78 -- - Standard_MultiplyDefined if a box still exists at
79 -- position boxIndex in the array of boxes to be sorted by
80 -- this comparison algorithm.
81
82
83 Compare (me : in out;
84 theBox : Box2d from Bnd)
85 returns ListOfInteger from TColStd
86 ---C++: return const &
87 raises NullValue from Standard is static;
88 ---Purpose:
89 -- Compares the 2D bounding box theBox with the set of
90 -- bounding boxes to be sorted by this comparison algorithm,
91 -- and returns the list of intersecting bounding boxes as a list
92 -- of indexes on the array of bounding boxes used by this algorithm.
93 Dump (me) is static;
94
95
96fields myBox : Box2d from Bnd;
97 myBndComponents : HArray1OfBox2d from Bnd;
98 Xmin : Real from Standard;
99 Ymin : Real from Standard;
100 deltaX : Real from Standard;
101 deltaY : Real from Standard;
102 discrX : Integer from Standard;
103 discrY : Integer from Standard;
104 axisX : HArray1OfListOfInteger from TColStd;
105 axisY : HArray1OfListOfInteger from TColStd;
106 theFound : Integer from Standard;
107 Crible : DataMapOfIntegerInteger from TColStd;
108 lastResult : ListOfInteger from TColStd;
109
110end BoundSortBox2d;