2 -- Created: Mon Jan 28 11:51:08 1991
3 -- Author: Remi Lequette
5 ---Copyright: Matra Datavision 1991, 1992
10 ---Purpose: Describes a bounding box in 2D space.
11 -- A bounding box is parallel to the axes of the coordinates
12 -- system. If it is finite, it is defined by the two intervals:
13 -- - [ Xmin,Xmax ], and
15 -- A bounding box may be infinite (i.e. open) in one or more
16 -- directions. It is said to be:
17 -- - OpenXmin if it is infinite on the negative side of the "X Direction";
18 -- - OpenXmax if it is infinite on the positive side of the "X Direction";
19 -- - OpenYmin if it is infinite on the negative side of the "Y Direction";
20 -- - OpenYmax if it is infinite on the positive side of the "Y Direction";
21 -- - WholeSpace if it is infinite in all four directions. In
22 -- this case, any point of the space is inside the box;
23 -- - Void if it is empty. In this case, there is no point included in the box.
24 -- A bounding box is defined by four bounds (Xmin, Xmax, Ymin and Ymax) which
25 -- limit the bounding box if it is finite, six flags (OpenXmin, OpenXmax, OpenYmin,
26 -- OpenYmax, WholeSpace and Void) which describe the bounding box if it is infinite or empty, and
27 -- - a gap, which is included on both sides in any direction when consulting the finite bounds of the box.
36 ConstructionError from Standard
40 Create returns Box2d from Bnd;
41 ---Purpose: Creates an empty 2D bounding box.
42 -- The constructed box is qualified Void. Its gap is null.
45 SetWhole(me : in out) is static;
46 ---Purpose: Sets this bounding box so that it covers the whole 2D
47 -- space, i.e. it is infinite in all directions.
50 SetVoid(me : in out) is static;
51 ---Purpose: Sets this 2D bounding box so that it is empty. All points are outside a void box.
54 Set(me : in out; P : Pnt2d) is static;
55 ---Purpose: Sets this 2D bounding box so that it bounds
56 -- the point P. This involves first setting this bounding box
57 -- to be void and then adding the point PThe rectangle bounds the point <P>.
60 Set(me : in out; P : Pnt2d; D : Dir2d) is static;
61 ---Purpose: Sets this 2D bounding box so that it bounds
62 -- the half-line defined by point P and direction D, i.e. all
63 -- points M defined by M=P+u*D, where u is greater than
64 -- or equal to 0, are inside the bounding area. This involves
65 -- first setting this 2D box to be void and then adding the half-line.
68 Update(me : in out; aXmin, aYmin, aXmax, aYmax : Real)
69 ---Purpose: Enlarges this 2D bounding box, if required, so that it
71 -- - interval [ aXmin,aXmax ] in the "X Direction",
72 -- - interval [ aYmin,aYmax ] in the "Y Direction"
75 Update(me : in out; X,Y : Real)
76 ---Purpose: Adds a point of coordinates (X,Y) to this bounding box.
79 GetGap(me) returns Real
80 ---Purpose: Returns the gap of this 2D bounding box.
84 SetGap(me : in out; Tol : Real)
85 ---Purpose: Set the gap of this 2D bounding box to abs(Tol).
89 Enlarge(me : in out; Tol : Real)
90 ---Purpose: Enlarges the box with a tolerance value.
91 -- This means that the minimum values of its X and Y
92 -- intervals of definition, when they are finite, are reduced by
93 -- the absolute value of Tol, while the maximum values are
94 -- increased by the same amount.
98 Get(me; aXmin, aYmin, aXmax, aYmax : out Real)
99 ---Purpose: Returns the bounds of this 2D bounding box.
100 -- The gap is included. If this bounding box is infinite (i.e. "open"), returned values
101 -- may be equal to +/- Precision::Infinite().
102 raises ConstructionError -- if IsVoid()
105 OpenXmin(me : in out)
106 ---Purpose: The Box will be infinitely long in the Xmin direction.
111 OpenXmax(me : in out)
112 ---Purpose: The Box will be infinitely long in the Xmax direction.
117 OpenYmin(me : in out)
118 ---Purpose: The Box will be infinitely long in the Ymin direction.
123 OpenYmax(me : in out)
124 ---Purpose: The Box will be infinitely long in the Ymax direction.
129 IsOpenXmin(me) returns Boolean
130 ---Purpose: Returns true if this bounding box is open in the Xmin direction.
134 IsOpenXmax(me) returns Boolean
135 ---Purpose: Returns true if this bounding box is open in the Xmax direction.
139 IsOpenYmin(me) returns Boolean
140 ---Purpose: Returns true if this bounding box is open in the Ymin direction.
144 IsOpenYmax(me) returns Boolean
145 ---Purpose: Returns true if this bounding box is open in the Ymax direction.
149 IsWhole(me) returns Boolean is static;
151 -- Returns true if this bounding box is infinite in all 4
152 -- directions (Whole Space flag).
155 IsVoid(me) returns Boolean is static;
157 -- Returns true if this 2D bounding box is empty (Void flag).
160 Transformed(me; T : Trsf2d from gp)
161 ---Purpose: Returns a bounding box which is the result of applying the
162 -- transformation T to this bounding box.
164 -- Applying a geometric transformation (for example, a
165 -- rotation) to a bounding box generally increases its
166 -- dimensions. This is not optimal for algorithms which use it.
168 returns Box2d from Bnd is static;
170 Add(me : in out; Other : Box2d) is static;
171 ---Purpose: Adds the 2d box <Other> to <me>.
174 Add(me : in out; P : Pnt2d) is static;
175 ---Purpose: Adds the 2d pnt <P> to <me>.
179 Add(me : in out; P : Pnt2d; D : Dir2d) is static;
180 ---Purpose: Extends <me> from the Pnt <P> in the direction <D>.
184 Add(me : in out; D : Dir2d) is static;
185 ---Purpose: Extends the Box in the given Direction, i.e. adds
186 -- a half-line. The box may become infinite in 1 or 2
190 IsOut(me; P : Pnt2d) returns Boolean is static;
191 ---Purpose: Returns True if the 2d pnt <P> is out <me>.
194 IsOut(me; Other : Box2d) returns Boolean is static;
195 ---Purpose: Returns True if <Box2d> is out <me>.
198 IsOut(me; Other : Box2d; T : Trsf2d from gp) returns Boolean is static;
199 ---Purpose: Returns True if transformed <Box2d> is out <me>.
203 IsOut(me; T1 : Trsf2d from gp; Other : Box2d; T2 : Trsf2d from gp)
204 returns Boolean is static;
205 ---Purpose: Compares a transformed bounding with a transformed
206 -- bounding. The default implementation is to make a copy
207 -- of <me> and <Other>, to transform them and to test.
219 Flags : Integer; -- 6 flags