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