42cf5bc1 |
1 | // Created on: 1991-01-08 |
2 | // Created by: Didier Piffault |
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 | #ifndef _Bnd_B3f_HeaderFile |
18 | #define _Bnd_B3f_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_ShortReal.hxx> |
25 | #include <Standard_Boolean.hxx> |
26 | #include <gp_XYZ.hxx> |
27 | #include <Standard_Real.hxx> |
28 | class gp_XYZ; |
29 | class gp_Pnt; |
30 | class gp_Trsf; |
31 | class gp_Ax1; |
32 | class gp_Ax3; |
33 | |
34 | |
35 | |
36 | class Bnd_B3f |
37 | { |
38 | public: |
39 | |
40 | DEFINE_STANDARD_ALLOC |
41 | |
42 | |
36b9ff75 |
43 | //! Empty constructor. |
42cf5bc1 |
44 | Bnd_B3f(); |
45 | |
36b9ff75 |
46 | //! Constructor. |
42cf5bc1 |
47 | Bnd_B3f(const gp_XYZ& theCenter, const gp_XYZ& theHSize); |
48 | |
36b9ff75 |
49 | //! Returns True if the box is void (non-initialized). |
42cf5bc1 |
50 | Standard_Boolean IsVoid() const; |
51 | |
36b9ff75 |
52 | //! Reset the box data. |
42cf5bc1 |
53 | void Clear(); |
54 | |
36b9ff75 |
55 | //! Update the box by a point. |
42cf5bc1 |
56 | Standard_EXPORT void Add (const gp_XYZ& thePnt); |
57 | |
36b9ff75 |
58 | //! Update the box by a point. |
42cf5bc1 |
59 | void Add (const gp_Pnt& thePnt); |
60 | |
36b9ff75 |
61 | //! Update the box by another box. |
42cf5bc1 |
62 | void Add (const Bnd_B3f& theBox); |
63 | |
36b9ff75 |
64 | //! Query the lower corner: (Center - HSize). You must make sure that |
65 | //! the box is NOT VOID (see IsVoid()), otherwise the method returns |
66 | //! irrelevant result. |
42cf5bc1 |
67 | gp_XYZ CornerMin() const; |
68 | |
36b9ff75 |
69 | //! Query the upper corner: (Center + HSize). You must make sure that |
70 | //! the box is NOT VOID (see IsVoid()), otherwise the method returns |
71 | //! irrelevant result. |
42cf5bc1 |
72 | gp_XYZ CornerMax() const; |
73 | |
36b9ff75 |
74 | //! Query the square diagonal. If the box is VOID (see method IsVoid()) |
75 | //! then a very big real value is returned. |
42cf5bc1 |
76 | Standard_Real SquareExtent() const; |
77 | |
36b9ff75 |
78 | //! Extend the Box by the absolute value of theDiff. |
42cf5bc1 |
79 | void Enlarge (const Standard_Real theDiff); |
80 | |
36b9ff75 |
81 | //! Limit the Box by the internals of theOtherBox. |
82 | //! Returns True if the limitation takes place, otherwise False |
83 | //! indicating that the boxes do not intersect. |
42cf5bc1 |
84 | Standard_EXPORT Standard_Boolean Limit (const Bnd_B3f& theOtherBox); |
85 | |
36b9ff75 |
86 | //! Transform the bounding box with the given transformation. |
87 | //! The resulting box will be larger if theTrsf contains rotation. |
42cf5bc1 |
88 | Standard_EXPORT Bnd_B3f Transformed (const gp_Trsf& theTrsf) const; |
89 | |
36b9ff75 |
90 | //! Check the given point for the inclusion in the Box. |
91 | //! Returns True if the point is outside. |
42cf5bc1 |
92 | Standard_Boolean IsOut (const gp_XYZ& thePnt) const; |
93 | |
36b9ff75 |
94 | //! Check a sphere for the intersection with the current box. |
95 | //! Returns True if there is no intersection between boxes. If the |
96 | //! parameter 'IsSphereHollow' is True, then the intersection is not |
97 | //! reported for a box that is completely inside the sphere (otherwise |
98 | //! this method would report an intersection). |
42cf5bc1 |
99 | Standard_EXPORT Standard_Boolean IsOut (const gp_XYZ& theCenter, const Standard_Real theRadius, const Standard_Boolean isSphereHollow = Standard_False) const; |
100 | |
36b9ff75 |
101 | //! Check the given box for the intersection with the current box. |
102 | //! Returns True if there is no intersection between boxes. |
42cf5bc1 |
103 | Standard_Boolean IsOut (const Bnd_B3f& theOtherBox) const; |
104 | |
36b9ff75 |
105 | //! Check the given box oriented by the given transformation |
106 | //! for the intersection with the current box. |
107 | //! Returns True if there is no intersection between boxes. |
42cf5bc1 |
108 | Standard_EXPORT Standard_Boolean IsOut (const Bnd_B3f& theOtherBox, const gp_Trsf& theTrsf) const; |
109 | |
36b9ff75 |
110 | //! Check the given Line for the intersection with the current box. |
111 | //! Returns True if there is no intersection. |
112 | //! isRay==True means intersection check with the positive half-line |
113 | //! theOverthickness is the addition to the size of the current box |
114 | //! (may be negative). If positive, it can be treated as the thickness |
115 | //! of the line 'theLine' or the radius of the cylinder along 'theLine' |
42cf5bc1 |
116 | Standard_EXPORT Standard_Boolean IsOut (const gp_Ax1& theLine, const Standard_Boolean isRay = Standard_False, const Standard_Real theOverthickness = 0.0) const; |
117 | |
36b9ff75 |
118 | //! Check the given Plane for the intersection with the current box. |
119 | //! Returns True if there is no intersection. |
42cf5bc1 |
120 | Standard_EXPORT Standard_Boolean IsOut (const gp_Ax3& thePlane) const; |
121 | |
36b9ff75 |
122 | //! Check that the box 'this' is inside the given box 'theBox'. Returns |
123 | //! True if 'this' box is fully inside 'theBox'. |
42cf5bc1 |
124 | Standard_Boolean IsIn (const Bnd_B3f& theBox) const; |
125 | |
36b9ff75 |
126 | //! Check that the box 'this' is inside the given box 'theBox' |
127 | //! transformed by 'theTrsf'. Returns True if 'this' box is fully |
128 | //! inside the transformed 'theBox'. |
42cf5bc1 |
129 | Standard_EXPORT Standard_Boolean IsIn (const Bnd_B3f& theBox, const gp_Trsf& theTrsf) const; |
130 | |
36b9ff75 |
131 | //! Set the Center coordinates |
42cf5bc1 |
132 | void SetCenter (const gp_XYZ& theCenter); |
133 | |
36b9ff75 |
134 | //! Set the HSize (half-diagonal) coordinates. |
135 | //! All components of theHSize must be non-negative. |
42cf5bc1 |
136 | void SetHSize (const gp_XYZ& theHSize); |
137 | |
138 | |
139 | |
140 | |
141 | protected: |
142 | |
143 | |
144 | |
145 | Standard_ShortReal myCenter[3]; |
146 | Standard_ShortReal myHSize[3]; |
147 | |
148 | |
149 | private: |
150 | |
151 | |
152 | |
153 | |
154 | |
155 | }; |
156 | |
157 | #define RealType Standard_ShortReal |
158 | #define RealType_hxx <Standard_ShortReal.hxx> |
159 | #define Bnd_B3x Bnd_B3f |
160 | #define Bnd_B3x_hxx <Bnd_B3f.hxx> |
161 | |
162 | #include <Bnd_B3x.lxx> |
163 | |
164 | #undef RealType |
165 | #undef RealType_hxx |
166 | #undef Bnd_B3x |
167 | #undef Bnd_B3x_hxx |
168 | |
169 | |
170 | |
171 | |
172 | #endif // _Bnd_B3f_HeaderFile |