b311480e |
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 |
5 | -- |
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. |
10 | -- |
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. |
13 | -- |
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 | |
7fd59977 |
21 | -- Modified : by Maria Pumborios at fri Apr 26 |
22 | -- add the method distance |
7fd59977 |
23 | |
24 | |
25 | class Box from Bnd |
26 | |
27 | ---Purpose: Describes a bounding box in 3D space. |
28 | -- A bounding box is parallel to the axes of the coordinates |
29 | -- system. If it is finite, it is defined by the three intervals: |
30 | -- - [ Xmin,Xmax ], |
31 | -- - [ Ymin,Ymax ], |
32 | -- - [ Zmin,Zmax ]. |
33 | -- A bounding box may be infinite (i.e. open) in one or more |
34 | -- directions. It is said to be: |
35 | -- - OpenXmin if it is infinite on the negative side of the "X Direction"; |
36 | -- - OpenXmax if it is infinite on the positive side of the "X Direction"; |
37 | -- - OpenYmin if it is infinite on the negative side of the "Y Direction"; |
38 | -- - OpenYmax if it is infinite on the positive side of the "Y Direction"; |
39 | -- - OpenZmin if it is infinite on the negative side of the "Z Direction"; |
40 | -- - OpenZmax if it is infinite on the positive side of the "Z Direction"; |
41 | -- - WholeSpace if it is infinite in all six directions. In this |
42 | -- case, any point of the space is inside the box; |
43 | -- - Void if it is empty. In this case, there is no point included in the box. |
44 | -- A bounding box is defined by: |
45 | -- - six bounds (Xmin, Xmax, Ymin, Ymax, Zmin and |
46 | -- Zmax) which limit the bounding box if it is finite, |
47 | -- - eight flags (OpenXmin, OpenXmax, OpenYmin, |
48 | -- OpenYmax, OpenZmin, OpenZmax, |
49 | -- WholeSpace and Void) which describe the |
50 | -- bounding box if it is infinite or empty, and |
51 | -- - a gap, which is included on both sides in any direction |
52 | -- when consulting the finite bounds of the box. |
53 | |
54 | |
55 | uses Pnt from gp, |
56 | Lin from gp, |
57 | Dir from gp, |
58 | Trsf from gp, |
59 | Pln from gp |
60 | |
61 | raises |
62 | ConstructionError from Standard |
63 | |
64 | is |
65 | |
66 | Create returns Box from Bnd; |
67 | ---Purpose: Creates an empty Box. |
68 | -- The constructed box is qualified Void. Its gap is null. |
69 | |
70 | SetWhole(me : in out) is static; |
71 | ---Purpose: Sets this bounding box so that it covers the whole of 3D space. |
72 | -- It is infinitely long in all directions. |
73 | |
74 | SetVoid(me : in out) is static; |
75 | ---Purpose: Sets this bounding box so that it is empty. All points are outside a void box. |
76 | |
77 | Set(me : in out; P : Pnt) is static; |
78 | ---Purpose: Sets this bounding box so that it bounds |
79 | -- - the point P. This involves first setting this bounding box |
80 | -- to be void and then adding the point P. |
81 | |
82 | Set(me : in out; P : Pnt; D : Dir) is static; |
83 | ---Purpose: Sets this bounding box so that it bounds |
84 | --- the half-line defined by point P and direction D, i.e. all |
85 | -- points M defined by M=P+u*D, where u is greater than |
86 | -- or equal to 0, are inside the bounding volume. This |
87 | -- involves first setting this box to be void and then adding the half-line. |
88 | |
89 | Update(me : in out; aXmin, aYmin, aZmin, aXmax, aYmax, aZmax : Real) |
90 | ---Purpose: Enlarges this bounding box, if required, so that it |
91 | -- contains at least: |
92 | -- - interval [ aXmin,aXmax ] in the "X Direction", |
93 | -- - interval [ aYmin,aYmax ] in the "Y Direction", |
94 | -- - interval [ aZmin,aZmax ] in the "Z Direction"; |
95 | is static; |
96 | |
97 | Update(me : in out; X,Y,Z : Real) |
98 | ---Purpose: Adds a point of coordinates (X,Y,Z) to this bounding box. |
99 | is static; |
100 | |
101 | GetGap(me) returns Real |
102 | ---Purpose: Returns the gap of this bounding box. |
103 | is static; |
104 | |
105 | SetGap(me : in out; Tol : Real) |
106 | ---Purpose: Set the gap of this bounding box to abs(Tol). |
107 | is static; |
108 | |
109 | Enlarge(me : in out; Tol : Real) |
110 | ---Purpose: Enlarges the box with a tolerance value. |
111 | -- (minvalues-Abs(<tol>) and maxvalues+Abs(<tol>)) |
112 | -- This means that the minimum values of its X, Y and Z |
113 | -- intervals of definition, when they are finite, are reduced by |
114 | -- the absolute value of Tol, while the maximum values are |
115 | -- increased by the same amount. |
116 | is static; |
117 | |
118 | Get(me; aXmin, aYmin, aZmin, aXmax, aYmax, aZmax : out Real) |
119 | ---Purpose: Returns the bounds of this bounding box. The gap is included. |
120 | -- If this bounding box is infinite (i.e. "open"), returned values |
121 | -- may be equal to +/- Precision::Infinite(). |
122 | raises ConstructionError -- if IsVoid() |
123 | is static; |
124 | |
125 | OpenXmin(me : in out) |
126 | ---Purpose: The Box will be infinitely long in the Xmin |
127 | -- direction. |
128 | ---Level: Public |
129 | is static; |
130 | |
131 | OpenXmax(me : in out) |
132 | ---Purpose: The Box will be infinitely long in the Xmax |
133 | -- direction. |
134 | ---Level: Public |
135 | is static; |
136 | |
137 | OpenYmin(me : in out) |
138 | ---Purpose: The Box will be infinitely long in the Ymin |
139 | -- direction. |
140 | ---Level: Public |
141 | is static; |
142 | |
143 | OpenYmax(me : in out) |
144 | ---Purpose: The Box will be infinitely long in the Ymax |
145 | -- direction. |
146 | ---Level: Public |
147 | is static; |
148 | |
149 | OpenZmin(me : in out) |
150 | ---Purpose: The Box will be infinitely long in the Zmin |
151 | -- direction. |
152 | ---Level: Public |
153 | is static; |
154 | |
155 | OpenZmax(me : in out) |
156 | ---Purpose: The Box will be infinitely long in the Zmax |
157 | -- direction. |
158 | ---Level: Public |
159 | is static; |
160 | |
161 | IsOpenXmin(me) returns Boolean |
162 | ---Purpose: Returns true if this bounding box is open in the Xmin direction. |
163 | is static; |
164 | |
165 | IsOpenXmax(me) returns Boolean |
166 | ---Purpose: Returns true if this bounding box is open in the Xmax direction. |
167 | is static; |
168 | |
169 | IsOpenYmin(me) returns Boolean |
170 | ---Purpose: Returns true if this bounding box is open in the Ymix direction. |
171 | is static; |
172 | |
173 | IsOpenYmax(me) returns Boolean |
174 | ---Purpose: Returns true if this bounding box is open in the Ymax direction. |
175 | is static; |
176 | |
177 | IsOpenZmin(me) returns Boolean |
178 | ---Purpose: Returns true if this bounding box is open in the Zmin direction. |
179 | is static; |
180 | |
181 | IsOpenZmax(me) returns Boolean |
182 | ---Purpose: Returns true if this bounding box is open in the Zmax direction. |
183 | is static; |
184 | |
185 | IsWhole(me) returns Boolean |
186 | --- Purpose: Returns true if this bounding box is infinite in all 6 directions (WholeSpace flag). |
187 | is static; |
188 | |
189 | IsVoid(me) returns Boolean |
190 | ---Purpose: Returns true if this bounding box is empty (Void flag). |
191 | is static; |
192 | |
193 | IsXThin(me; tol : Real) returns Boolean |
194 | ---Purpose: true if xmax-xmin < tol. |
195 | ---Level: Public |
196 | is static; |
197 | |
198 | IsYThin(me; tol : Real) returns Boolean |
199 | ---Purpose: true if ymax-ymin < tol. |
200 | ---Level: Public |
201 | is static; |
202 | |
203 | IsZThin(me; tol : Real) returns Boolean |
204 | ---Purpose: true if zmax-zmin < tol. |
205 | ---Level: Public |
206 | is static; |
207 | |
208 | IsThin(me; tol : Real) returns Boolean |
209 | ---Purpose: Returns true if IsXThin, IsYThin and IsZThin are all true, |
210 | -- i.e. if the box is thin in all three dimensions. |
211 | ---Level: Public |
212 | is static; |
213 | |
214 | Transformed(me; T : Trsf from gp) |
215 | ---Purpose: Returns a bounding box which is the result of applying the |
216 | -- transformation T to this bounding box. |
217 | -- Warning |
218 | -- Applying a geometric transformation (for example, a |
219 | -- rotation) to a bounding box generally increases its |
220 | -- dimensions. This is not optimal for algorithms which use it. |
221 | returns Box from Bnd |
222 | is static; |
223 | |
224 | Add(me : in out; Other : Box) |
225 | is static; |
226 | ---Purpose: Adds the box <Other> to <me>. |
227 | ---Level: Public |
228 | |
229 | Add(me : in out; P : Pnt) |
230 | is static; |
231 | ---Purpose: Adds a Pnt to the box. |
232 | ---Level: Public |
233 | |
234 | Add(me : in out; P : Pnt; D : Dir) |
235 | is static; |
236 | ---Purpose: Extends <me> from the Pnt <P> in the direction <D>. |
237 | ---Level: Public |
238 | |
239 | Add(me : in out; D : Dir) |
240 | is static; |
241 | ---Purpose: Extends the Box in the given Direction, i.e. adds |
242 | -- an half-line. The box may become infinite in |
243 | -- 1,2 or 3 directions. |
244 | ---Level: Public |
245 | |
246 | IsOut(me; P : Pnt from gp) returns Boolean |
247 | ---Purpose: Returns True if the Pnt is out the box. |
248 | ---Level: Public |
249 | is static; |
250 | |
251 | IsOut(me; L : Lin from gp) returns Boolean |
252 | ---Purpose: Returns False if the line intersects the box. |
253 | ---Level: Public |
254 | is static; |
255 | |
256 | IsOut(me; P : Pln from gp) returns Boolean |
257 | ---Purpose: Returns False if the plane intersects the box. |
258 | ---Level: Public |
259 | is static; |
260 | |
261 | IsOut(me; Other : Box) returns Boolean |
262 | is static; |
263 | ---Purpose: Returns False if the <Box> intersects or is inside <me>. |
264 | ---Level: Public |
265 | |
266 | IsOut(me; Other : Box; T : Trsf from gp) returns Boolean |
267 | is static; |
268 | ---Purpose: Returns False if the transformed <Box> intersects |
269 | -- or is inside <me>. |
270 | ---Level: Public |
271 | |
272 | IsOut(me; T1 : Trsf from gp; Other : Box; T2 : Trsf from gp) |
273 | returns Boolean |
274 | is static; |
275 | ---Purpose: Returns False if the transformed <Box> intersects |
276 | -- or is inside the transformed box <me>. |
277 | ---Level: Public |
278 | |
279 | IsOut(me; P1, P2: Pnt from gp; D: Dir from gp) |
280 | returns Boolean |
281 | is static; |
282 | ---Purpose: Returns False if the flat band lying between two parallel |
283 | -- lines represented by their reference points <P1>, <P2> and |
284 | -- direction <D> intersects the box. |
285 | ---Level: Public |
286 | |
287 | Distance (me; Other : Box) returns Real is static; |
288 | --- Purpose : Computes the minimum distance between two boxes. |
289 | |
290 | Dump (me) is static; |
291 | |
292 | SquareExtent(me) returns Real; |
293 | --- Purpose : Computes the squared diagonal of me. |
294 | ---C++: inline |
295 | |
296 | fields Xmin : Real; |
297 | Xmax : Real; |
298 | Ymin : Real; |
299 | Ymax : Real; |
300 | Zmin : Real; |
301 | Zmax : Real; |
302 | Gap : Real; |
303 | Flags : Integer; -- 8 flags |
304 | |
305 | end Box ; |