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