1 -- Created on: 1991-01-28
2 -- Created by: Remi Lequette
3 -- Copyright (c) 1991-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
6 -- The content of this file is subject to the Open CASCADE Technology Public
7 -- License Version 6.5 (the "License"). You may not use the content of this file
8 -- except in compliance with the License. Please obtain a copy of the License
9 -- at http://www.opencascade.org and read it completely before using this file.
11 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 -- The Original Code and all software distributed under the License is
15 -- distributed on an "AS IS" basis, without warranty of any kind, and the
16 -- Initial Developer hereby disclaims all such warranties, including without
17 -- limitation, any warranties of merchantability, fitness for a particular
18 -- purpose or non-infringement. Please see the License for the specific terms
19 -- and conditions governing the rights and limitations under the License.
25 ---Purpose: Describes a bounding box in 2D space.
26 -- A bounding box is parallel to the axes of the coordinates
27 -- system. If it is finite, it is defined by the two intervals:
28 -- - [ Xmin,Xmax ], and
30 -- A bounding box may be infinite (i.e. open) in one or more
31 -- directions. It is said to be:
32 -- - OpenXmin if it is infinite on the negative side of the "X Direction";
33 -- - OpenXmax if it is infinite on the positive side of the "X Direction";
34 -- - OpenYmin if it is infinite on the negative side of the "Y Direction";
35 -- - OpenYmax if it is infinite on the positive side of the "Y Direction";
36 -- - WholeSpace if it is infinite in all four directions. In
37 -- this case, any point of the space is inside the box;
38 -- - Void if it is empty. In this case, there is no point included in the box.
39 -- A bounding box is defined by four bounds (Xmin, Xmax, Ymin and Ymax) which
40 -- limit the bounding box if it is finite, six flags (OpenXmin, OpenXmax, OpenYmin,
41 -- OpenYmax, WholeSpace and Void) which describe the bounding box if it is infinite or empty, and
42 -- - a gap, which is included on both sides in any direction when consulting the finite bounds of the box.
51 ConstructionError from Standard
55 Create returns Box2d from Bnd;
56 ---Purpose: Creates an empty 2D bounding box.
57 -- The constructed box is qualified Void. Its gap is null.
60 SetWhole(me : in out) is static;
61 ---Purpose: Sets this bounding box so that it covers the whole 2D
62 -- space, i.e. it is infinite in all directions.
65 SetVoid(me : in out) is static;
66 ---Purpose: Sets this 2D bounding box so that it is empty. All points are outside a void box.
69 Set(me : in out; P : Pnt2d) is static;
70 ---Purpose: Sets this 2D bounding box so that it bounds
71 -- the point P. This involves first setting this bounding box
72 -- to be void and then adding the point PThe rectangle bounds the point <P>.
75 Set(me : in out; P : Pnt2d; D : Dir2d) is static;
76 ---Purpose: Sets this 2D bounding box so that it bounds
77 -- the half-line defined by point P and direction D, i.e. all
78 -- points M defined by M=P+u*D, where u is greater than
79 -- or equal to 0, are inside the bounding area. This involves
80 -- first setting this 2D box to be void and then adding the half-line.
83 Update(me : in out; aXmin, aYmin, aXmax, aYmax : Real)
84 ---Purpose: Enlarges this 2D bounding box, if required, so that it
86 -- - interval [ aXmin,aXmax ] in the "X Direction",
87 -- - interval [ aYmin,aYmax ] in the "Y Direction"
90 Update(me : in out; X,Y : Real)
91 ---Purpose: Adds a point of coordinates (X,Y) to this bounding box.
94 GetGap(me) returns Real
95 ---Purpose: Returns the gap of this 2D bounding box.
99 SetGap(me : in out; Tol : Real)
100 ---Purpose: Set the gap of this 2D bounding box to abs(Tol).
104 Enlarge(me : in out; Tol : Real)
105 ---Purpose: Enlarges the box with a tolerance value.
106 -- This means that the minimum values of its X and Y
107 -- intervals of definition, when they are finite, are reduced by
108 -- the absolute value of Tol, while the maximum values are
109 -- increased by the same amount.
113 Get(me; aXmin, aYmin, aXmax, aYmax : out Real)
114 ---Purpose: Returns the bounds of this 2D bounding box.
115 -- The gap is included. If this bounding box is infinite (i.e. "open"), returned values
116 -- may be equal to +/- Precision::Infinite().
117 raises ConstructionError -- if IsVoid()
120 OpenXmin(me : in out)
121 ---Purpose: The Box will be infinitely long in the Xmin direction.
126 OpenXmax(me : in out)
127 ---Purpose: The Box will be infinitely long in the Xmax direction.
132 OpenYmin(me : in out)
133 ---Purpose: The Box will be infinitely long in the Ymin direction.
138 OpenYmax(me : in out)
139 ---Purpose: The Box will be infinitely long in the Ymax direction.
144 IsOpenXmin(me) returns Boolean
145 ---Purpose: Returns true if this bounding box is open in the Xmin direction.
149 IsOpenXmax(me) returns Boolean
150 ---Purpose: Returns true if this bounding box is open in the Xmax direction.
154 IsOpenYmin(me) returns Boolean
155 ---Purpose: Returns true if this bounding box is open in the Ymin direction.
159 IsOpenYmax(me) returns Boolean
160 ---Purpose: Returns true if this bounding box is open in the Ymax direction.
164 IsWhole(me) returns Boolean is static;
166 -- Returns true if this bounding box is infinite in all 4
167 -- directions (Whole Space flag).
170 IsVoid(me) returns Boolean is static;
172 -- Returns true if this 2D bounding box is empty (Void flag).
175 Transformed(me; T : Trsf2d from gp)
176 ---Purpose: Returns a bounding box which is the result of applying the
177 -- transformation T to this bounding box.
179 -- Applying a geometric transformation (for example, a
180 -- rotation) to a bounding box generally increases its
181 -- dimensions. This is not optimal for algorithms which use it.
183 returns Box2d from Bnd is static;
185 Add(me : in out; Other : Box2d) is static;
186 ---Purpose: Adds the 2d box <Other> to <me>.
189 Add(me : in out; P : Pnt2d) is static;
190 ---Purpose: Adds the 2d pnt <P> to <me>.
194 Add(me : in out; P : Pnt2d; D : Dir2d) is static;
195 ---Purpose: Extends <me> from the Pnt <P> in the direction <D>.
199 Add(me : in out; D : Dir2d) is static;
200 ---Purpose: Extends the Box in the given Direction, i.e. adds
201 -- a half-line. The box may become infinite in 1 or 2
205 IsOut(me; P : Pnt2d) returns Boolean is static;
206 ---Purpose: Returns True if the 2d pnt <P> is out <me>.
209 IsOut(me; Other : Box2d) returns Boolean is static;
210 ---Purpose: Returns True if <Box2d> is out <me>.
213 IsOut(me; Other : Box2d; T : Trsf2d from gp) returns Boolean is static;
214 ---Purpose: Returns True if transformed <Box2d> is out <me>.
218 IsOut(me; T1 : Trsf2d from gp; Other : Box2d; T2 : Trsf2d from gp)
219 returns Boolean is static;
220 ---Purpose: Compares a transformed bounding with a transformed
221 -- bounding. The default implementation is to make a copy
222 -- of <me> and <Other>, to transform them and to test.
229 returns Real from Standard;
230 --- Purpose : Computes the squared diagonal of me.
238 Flags : Integer; -- 6 flags