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
9 -- under the terms of the GNU Lesser General Public 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 class BoundSortBox2d from Bnd
19 ---Purpose: A tool to compare a 2D bounding box with a set of 2D
20 -- bounding boxes. It sorts the set of bounding boxes to give
21 -- the list of boxes which intersect the element being compared.
22 -- The boxes being sorted generally bound a set of shapes,
23 -- while the box being compared bounds a shape to be
24 -- compared. The resulting list of intersecting boxes therefore
25 -- gives the list of items which potentially intersect the shape to be compared.
28 uses Integer from Standard,
30 ListOfInteger from TColStd,
32 HArray1OfBox2d from Bnd,
33 DataMapOfIntegerInteger from TColStd,
34 HArray1OfListOfInteger from TColStd
37 raises NullValue from Standard, MultiplyDefined from Standard
40 is Create returns BoundSortBox2d from Bnd;
41 ---Purpose: Constructs an empty comparison algorithm for 2D bounding boxes.
42 -- The bounding boxes are then defined using the Initialize function.
44 Initialize (me : in out;
45 CompleteBox : Box2d from Bnd;
46 SetOfBox : HArray1OfBox2d from Bnd)
48 ---Purpose: Initializes this comparison algorithm with
49 -- - the set of 2D bounding boxes SetOfBox
51 Initialize (me : in out;
52 SetOfBox : HArray1OfBox2d from Bnd)
54 ---Purpose: Initializes this comparison algorithm with
55 -- - the set of 2D bounding boxes SetOfBox, where
56 -- CompleteBox is given as the global bounding box of SetOfBox.
57 SortBoxes (me : in out)
58 raises NullValue from Standard is static private;
59 ---Purpose: Prepares BoundSortBox2d and sorts the rectangles of
64 Initialize (me : in out;
65 CompleteBox : Box2d from Bnd;
66 nbComponents : Integer from Standard)
67 raises NullValue from Standard is static;
68 ---Purpose: Initializes this comparison algorithm, giving it only
69 -- - the maximum number nbComponents, and
70 -- - the global bounding box CompleteBox,
71 -- of the 2D bounding boxes to be managed. Use the Add
72 -- function to define the array of bounding boxes to be sorted by this algorithm.
75 theBox : Box2d from Bnd;
76 boxIndex : Integer from Standard)
77 raises MultiplyDefined from Standard is static;
78 ---Purpose: Adds the 2D bounding box theBox at position boxIndex in
79 -- the array of boxes to be sorted by this comparison algorithm.
80 -- This function is used only in conjunction with the third
81 -- syntax described in the synopsis of Initialize.
83 -- - Standard_OutOfRange if boxIndex is not in the
84 -- range [ 1,nbComponents ] where
85 -- nbComponents is the maximum number of bounding
86 -- boxes declared for this comparison algorithm at
88 -- - Standard_MultiplyDefined if a box still exists at
89 -- position boxIndex in the array of boxes to be sorted by
90 -- this comparison algorithm.
94 theBox : Box2d from Bnd)
95 returns ListOfInteger from TColStd
96 ---C++: return const &
97 raises NullValue from Standard is static;
99 -- Compares the 2D bounding box theBox with the set of
100 -- bounding boxes to be sorted by this comparison algorithm,
101 -- and returns the list of intersecting bounding boxes as a list
102 -- of indexes on the array of bounding boxes used by this algorithm.
106 fields myBox : Box2d from Bnd;
107 myBndComponents : HArray1OfBox2d from Bnd;
108 Xmin : Real from Standard;
109 Ymin : Real from Standard;
110 deltaX : Real from Standard;
111 deltaY : Real from Standard;
112 discrX : Integer from Standard;
113 discrY : Integer from Standard;
114 axisX : HArray1OfListOfInteger from TColStd;
115 axisY : HArray1OfListOfInteger from TColStd;
116 theFound : Integer from Standard;
117 Crible : DataMapOfIntegerInteger from TColStd;
118 lastResult : ListOfInteger from TColStd;