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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Bnd_B3d_HeaderFile
18 #define _Bnd_B3d_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Real.hxx>
25 #include <Standard_Boolean.hxx>
42 //! Empty constructor.
46 Bnd_B3d(const gp_XYZ& theCenter, const gp_XYZ& theHSize);
48 //! Returns True if the box is void (non-initialized).
49 Standard_Boolean IsVoid() const;
51 //! Reset the box data.
54 //! Update the box by a point.
55 Standard_EXPORT void Add (const gp_XYZ& thePnt);
57 //! Update the box by a point.
58 void Add (const gp_Pnt& thePnt);
60 //! Update the box by another box.
61 void Add (const Bnd_B3d& theBox);
63 //! Query the lower corner: (Center - HSize). You must make sure that
64 //! the box is NOT VOID (see IsVoid()), otherwise the method returns
65 //! irrelevant result.
66 gp_XYZ CornerMin() const;
68 //! Query the upper corner: (Center + HSize). You must make sure that
69 //! the box is NOT VOID (see IsVoid()), otherwise the method returns
70 //! irrelevant result.
71 gp_XYZ CornerMax() const;
73 //! Query the square diagonal. If the box is VOID (see method IsVoid())
74 //! then a very big real value is returned.
75 Standard_Real SquareExtent() const;
77 //! Extend the Box by the absolute value of theDiff.
78 void Enlarge (const Standard_Real theDiff);
80 //! Limit the Box by the internals of theOtherBox.
81 //! Returns True if the limitation takes place, otherwise False
82 //! indicating that the boxes do not intersect.
83 Standard_EXPORT Standard_Boolean Limit (const Bnd_B3d& theOtherBox);
85 //! Transform the bounding box with the given transformation.
86 //! The resulting box will be larger if theTrsf contains rotation.
87 Standard_NODISCARD Standard_EXPORT Bnd_B3d Transformed (const gp_Trsf& theTrsf) const;
89 //! Check the given point for the inclusion in the Box.
90 //! Returns True if the point is outside.
91 Standard_Boolean IsOut (const gp_XYZ& thePnt) const;
93 //! Check a sphere for the intersection with the current box.
94 //! Returns True if there is no intersection between boxes. If the
95 //! parameter 'IsSphereHollow' is True, then the intersection is not
96 //! reported for a box that is completely inside the sphere (otherwise
97 //! this method would report an intersection).
98 Standard_EXPORT Standard_Boolean IsOut (const gp_XYZ& theCenter, const Standard_Real theRadius, const Standard_Boolean isSphereHollow = Standard_False) const;
100 //! Check the given box for the intersection with the current box.
101 //! Returns True if there is no intersection between boxes.
102 Standard_Boolean IsOut (const Bnd_B3d& theOtherBox) const;
104 //! Check the given box oriented by the given transformation
105 //! for the intersection with the current box.
106 //! Returns True if there is no intersection between boxes.
107 Standard_EXPORT Standard_Boolean IsOut (const Bnd_B3d& theOtherBox, const gp_Trsf& theTrsf) const;
109 //! Check the given Line for the intersection with the current box.
110 //! Returns True if there is no intersection.
111 //! isRay==True means intersection check with the positive half-line
112 //! theOverthickness is the addition to the size of the current box
113 //! (may be negative). If positive, it can be treated as the thickness
114 //! of the line 'theLine' or the radius of the cylinder along 'theLine'
115 Standard_EXPORT Standard_Boolean IsOut (const gp_Ax1& theLine, const Standard_Boolean isRay = Standard_False, const Standard_Real theOverthickness = 0.0) const;
117 //! Check the given Plane for the intersection with the current box.
118 //! Returns True if there is no intersection.
119 Standard_EXPORT Standard_Boolean IsOut (const gp_Ax3& thePlane) const;
121 //! Check that the box 'this' is inside the given box 'theBox'. Returns
122 //! True if 'this' box is fully inside 'theBox'.
123 Standard_Boolean IsIn (const Bnd_B3d& theBox) const;
125 //! Check that the box 'this' is inside the given box 'theBox'
126 //! transformed by 'theTrsf'. Returns True if 'this' box is fully
127 //! inside the transformed 'theBox'.
128 Standard_EXPORT Standard_Boolean IsIn (const Bnd_B3d& theBox, const gp_Trsf& theTrsf) const;
130 //! Set the Center coordinates
131 void SetCenter (const gp_XYZ& theCenter);
133 //! Set the HSize (half-diagonal) coordinates.
134 //! All components of theHSize must be non-negative.
135 void SetHSize (const gp_XYZ& theHSize);
144 Standard_Real myCenter[3];
145 Standard_Real myHSize[3];
156 #define RealType Standard_Real
157 #define RealType_hxx <Standard_Real.hxx>
158 #define Bnd_B3x Bnd_B3d
159 #define Bnd_B3x_hxx <Bnd_B3d.hxx>
161 #include <Bnd_B3x.lxx>
171 #endif // _Bnd_B3d_HeaderFile