0031044: Coding - Standard_NODISCARD should be placed before Standard_EXPORT
[occt.git] / src / Bnd / Bnd_B3d.hxx
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_B3d_HeaderFile
18 #define _Bnd_B3d_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Real.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <gp_XYZ.hxx>
27 class gp_XYZ;
28 class gp_Pnt;
29 class gp_Trsf;
30 class gp_Ax1;
31 class gp_Ax3;
32
33
34
35 class Bnd_B3d 
36 {
37 public:
38
39   DEFINE_STANDARD_ALLOC
40
41   
42   //! Empty constructor.
43     Bnd_B3d();
44   
45   //! Constructor.
46     Bnd_B3d(const gp_XYZ& theCenter, const gp_XYZ& theHSize);
47   
48   //! Returns True if the box is void (non-initialized).
49     Standard_Boolean IsVoid() const;
50   
51   //! Reset the box data.
52     void Clear();
53   
54   //! Update the box by a point.
55   Standard_EXPORT void Add (const gp_XYZ& thePnt);
56   
57   //! Update the box by a point.
58     void Add (const gp_Pnt& thePnt);
59   
60   //! Update the box by another box.
61     void Add (const Bnd_B3d& theBox);
62   
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;
67   
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;
72   
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;
76   
77   //! Extend the Box by the absolute value of theDiff.
78     void Enlarge (const Standard_Real theDiff);
79   
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);
84   
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;
88   
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;
92   
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;
99   
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;
103   
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;
108   
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;
116   
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;
120   
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;
124   
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;
129   
130   //! Set the Center coordinates
131     void SetCenter (const gp_XYZ& theCenter);
132   
133   //! Set the HSize (half-diagonal) coordinates.
134   //! All components of theHSize must be non-negative.
135     void SetHSize (const gp_XYZ& theHSize);
136
137
138
139
140 protected:
141
142
143
144   Standard_Real myCenter[3];
145   Standard_Real myHSize[3];
146
147
148 private:
149
150
151
152
153
154 };
155
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>
160
161 #include <Bnd_B3x.lxx>
162
163 #undef RealType
164 #undef RealType_hxx
165 #undef Bnd_B3x
166 #undef Bnd_B3x_hxx
167
168
169
170
171 #endif // _Bnd_B3d_HeaderFile