b311480e |
1 | -- Created on: 1991-01-28 |
2 | -- Created by: Remi Lequette |
3 | -- Copyright (c) 1991-1999 Matra Datavision |
db8e4b9a |
4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
b311480e |
5 | -- |
db8e4b9a |
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. |
b311480e |
10 | -- |
db8e4b9a |
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. |
b311480e |
13 | -- |
db8e4b9a |
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. |
20 | |
21 | |
7fd59977 |
22 | |
23 | class Box2d from Bnd |
24 | |
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 |
29 | -- - [ Ymin,Ymax ]. |
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. |
43 | |
44 | |
45 | uses Pnt2d from gp, |
46 | Dir2d from gp, |
47 | Lin2d from gp, |
48 | Trsf2d from gp |
49 | |
50 | raises |
51 | ConstructionError from Standard |
52 | |
53 | is |
54 | |
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. |
58 | ---C++: inline |
59 | |
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. |
63 | ---C++: inline |
64 | |
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. |
67 | ---C++: inline |
68 | |
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>. |
73 | ---C++: inline |
74 | |
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. |
81 | ---C++: inline |
82 | |
83 | Update(me : in out; aXmin, aYmin, aXmax, aYmax : Real) |
84 | ---Purpose: Enlarges this 2D bounding box, if required, so that it |
85 | -- contains at least: |
86 | -- - interval [ aXmin,aXmax ] in the "X Direction", |
87 | -- - interval [ aYmin,aYmax ] in the "Y Direction" |
88 | is static; |
89 | |
90 | Update(me : in out; X,Y : Real) |
91 | ---Purpose: Adds a point of coordinates (X,Y) to this bounding box. |
92 | is static; |
93 | |
94 | GetGap(me) returns Real |
95 | ---Purpose: Returns the gap of this 2D bounding box. |
96 | ---C++: inline |
97 | is static; |
98 | |
99 | SetGap(me : in out; Tol : Real) |
100 | ---Purpose: Set the gap of this 2D bounding box to abs(Tol). |
101 | ---C++: inline |
102 | is static; |
103 | |
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. |
110 | ---C++: inline |
111 | is static; |
112 | |
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() |
118 | is static; |
119 | |
120 | OpenXmin(me : in out) |
121 | ---Purpose: The Box will be infinitely long in the Xmin direction. |
122 | ---Level: Public |
123 | ---C++: inline |
124 | is static; |
125 | |
126 | OpenXmax(me : in out) |
127 | ---Purpose: The Box will be infinitely long in the Xmax direction. |
128 | ---Level: Public |
129 | ---C++: inline |
130 | is static; |
131 | |
132 | OpenYmin(me : in out) |
133 | ---Purpose: The Box will be infinitely long in the Ymin direction. |
134 | ---Level: Public |
135 | ---C++: inline |
136 | is static; |
137 | |
138 | OpenYmax(me : in out) |
139 | ---Purpose: The Box will be infinitely long in the Ymax direction. |
140 | ---Level: Public |
141 | ---C++: inline |
142 | is static; |
143 | |
144 | IsOpenXmin(me) returns Boolean |
145 | ---Purpose: Returns true if this bounding box is open in the Xmin direction. |
146 | ---C++: inline |
147 | is static; |
148 | |
149 | IsOpenXmax(me) returns Boolean |
150 | ---Purpose: Returns true if this bounding box is open in the Xmax direction. |
151 | ---C++: inline |
152 | is static; |
153 | |
154 | IsOpenYmin(me) returns Boolean |
155 | ---Purpose: Returns true if this bounding box is open in the Ymin direction. |
156 | ---C++: inline |
157 | is static; |
158 | |
159 | IsOpenYmax(me) returns Boolean |
160 | ---Purpose: Returns true if this bounding box is open in the Ymax direction. |
161 | ---C++: inline |
162 | is static; |
163 | |
164 | IsWhole(me) returns Boolean is static; |
165 | ---Purpose: |
166 | -- Returns true if this bounding box is infinite in all 4 |
167 | -- directions (Whole Space flag). |
168 | ---C++: inline |
169 | |
170 | IsVoid(me) returns Boolean is static; |
171 | ---Purpose: |
172 | -- Returns true if this 2D bounding box is empty (Void flag). |
173 | ---C++: inline |
174 | |
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. |
178 | -- Warning |
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. |
182 | |
183 | returns Box2d from Bnd is static; |
184 | |
185 | Add(me : in out; Other : Box2d) is static; |
186 | ---Purpose: Adds the 2d box <Other> to <me>. |
187 | ---Level: Public |
188 | |
189 | Add(me : in out; P : Pnt2d) is static; |
190 | ---Purpose: Adds the 2d pnt <P> to <me>. |
191 | ---Level: Public |
192 | ---C++: inline |
193 | |
194 | Add(me : in out; P : Pnt2d; D : Dir2d) is static; |
195 | ---Purpose: Extends <me> from the Pnt <P> in the direction <D>. |
196 | ---Level: Public |
197 | ---C++: inline |
198 | |
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 |
202 | -- directions. |
203 | ---Level: Public |
204 | |
205 | IsOut(me; P : Pnt2d) returns Boolean is static; |
206 | ---Purpose: Returns True if the 2d pnt <P> is out <me>. |
207 | ---Level: Public |
208 | |
209 | IsOut(me; Other : Box2d) returns Boolean is static; |
210 | ---Purpose: Returns True if <Box2d> is out <me>. |
211 | ---Level: Public |
212 | |
213 | IsOut(me; Other : Box2d; T : Trsf2d from gp) returns Boolean is static; |
214 | ---Purpose: Returns True if transformed <Box2d> is out <me>. |
215 | ---Level: Public |
216 | ---C++: inline |
217 | |
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. |
223 | ---Level: Public |
224 | ---C++: inline |
225 | |
db8e4b9a |
226 | Dump(me) is static; |
227 | |
228 | SquareExtent(me) |
229 | returns Real from Standard; |
230 | --- Purpose : Computes the squared diagonal of me. |
231 | ---C++: inline |
7fd59977 |
232 | |
233 | fields Xmin : Real; |
234 | Xmax : Real; |
235 | Ymin : Real; |
236 | Ymax : Real; |
237 | Gap : Real; |
238 | Flags : Integer; -- 6 flags |
239 | |
240 | end Box2d; |