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_B2f_HeaderFile |
18 | #define _Bnd_B2f_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_XY.hxx> |
27 | #include <Standard_Real.hxx> |
28 | class gp_XY; |
29 | class gp_Pnt2d; |
30 | class gp_Trsf2d; |
31 | class gp_Ax2d; |
32 | |
33 | |
34 | |
35 | class Bnd_B2f |
36 | { |
37 | public: |
38 | |
39 | DEFINE_STANDARD_ALLOC |
40 | |
41 | |
36b9ff75 |
42 | //! Empty constructor. |
42cf5bc1 |
43 | Bnd_B2f(); |
44 | |
36b9ff75 |
45 | //! Constructor. |
42cf5bc1 |
46 | Bnd_B2f(const gp_XY& theCenter, const gp_XY& theHSize); |
47 | |
36b9ff75 |
48 | //! Returns True if the box is void (non-initialized). |
42cf5bc1 |
49 | Standard_Boolean IsVoid() const; |
50 | |
36b9ff75 |
51 | //! Reset the box data. |
42cf5bc1 |
52 | void Clear(); |
53 | |
36b9ff75 |
54 | //! Update the box by a point. |
42cf5bc1 |
55 | Standard_EXPORT void Add (const gp_XY& thePnt); |
56 | |
36b9ff75 |
57 | //! Update the box by a point. |
0f57ab75 |
58 | void Add (const gp_Pnt2d& thePnt); |
42cf5bc1 |
59 | |
36b9ff75 |
60 | //! Update the box by another box. |
0f57ab75 |
61 | void Add (const Bnd_B2f& theBox); |
42cf5bc1 |
62 | |
36b9ff75 |
63 | //! Query a box corner: (Center - HSize). You must make sure that |
64 | //! the box is NOT VOID (see IsVoid()), otherwise the method returns |
65 | //! irrelevant result. |
42cf5bc1 |
66 | gp_XY CornerMin() const; |
67 | |
36b9ff75 |
68 | //! Query a box corner: (Center + HSize). You must make sure that |
69 | //! the box is NOT VOID (see IsVoid()), otherwise the method returns |
70 | //! irrelevant result. |
42cf5bc1 |
71 | gp_XY CornerMax() const; |
72 | |
36b9ff75 |
73 | //! Query the square diagonal. If the box is VOID (see method IsVoid()) |
74 | //! then a very big real value is returned. |
42cf5bc1 |
75 | Standard_Real SquareExtent() const; |
76 | |
36b9ff75 |
77 | //! Extend the Box by the absolute value of theDiff. |
42cf5bc1 |
78 | void Enlarge (const Standard_Real theDiff); |
79 | |
36b9ff75 |
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. |
42cf5bc1 |
83 | Standard_EXPORT Standard_Boolean Limit (const Bnd_B2f& theOtherBox); |
84 | |
36b9ff75 |
85 | //! Transform the bounding box with the given transformation. |
86 | //! The resulting box will be larger if theTrsf contains rotation. |
6ed44b1c |
87 | Standard_NODISCARD Standard_EXPORT Bnd_B2f Transformed (const gp_Trsf2d& theTrsf) const; |
42cf5bc1 |
88 | |
36b9ff75 |
89 | //! Check the given point for the inclusion in the Box. |
90 | //! Returns True if the point is outside. |
42cf5bc1 |
91 | Standard_Boolean IsOut (const gp_XY& thePnt) const; |
92 | |
36b9ff75 |
93 | //! Check a circle for the intersection with the current box. |
94 | //! Returns True if there is no intersection between boxes. |
42cf5bc1 |
95 | Standard_EXPORT Standard_Boolean IsOut (const gp_XY& theCenter, const Standard_Real theRadius, const Standard_Boolean isCircleHollow = Standard_False) const; |
96 | |
36b9ff75 |
97 | //! Check the given box for the intersection with the current box. |
98 | //! Returns True if there is no intersection between boxes. |
42cf5bc1 |
99 | Standard_Boolean IsOut (const Bnd_B2f& theOtherBox) const; |
100 | |
36b9ff75 |
101 | //! Check the given box oriented by the given transformation |
102 | //! for the intersection with the current box. |
103 | //! Returns True if there is no intersection between boxes. |
42cf5bc1 |
104 | Standard_EXPORT Standard_Boolean IsOut (const Bnd_B2f& theOtherBox, const gp_Trsf2d& theTrsf) const; |
105 | |
36b9ff75 |
106 | //! Check the given Line for the intersection with the current box. |
107 | //! Returns True if there is no intersection. |
42cf5bc1 |
108 | Standard_EXPORT Standard_Boolean IsOut (const gp_Ax2d& theLine) const; |
109 | |
36b9ff75 |
110 | //! Check the Segment defined by the couple of input points |
111 | //! for the intersection with the current box. |
112 | //! Returns True if there is no intersection. |
42cf5bc1 |
113 | Standard_EXPORT Standard_Boolean IsOut (const gp_XY& theP0, const gp_XY& theP1) const; |
114 | |
36b9ff75 |
115 | //! Check that the box 'this' is inside the given box 'theBox'. Returns |
116 | //! True if 'this' box is fully inside 'theBox'. |
42cf5bc1 |
117 | Standard_Boolean IsIn (const Bnd_B2f& theBox) const; |
118 | |
36b9ff75 |
119 | //! Check that the box 'this' is inside the given box 'theBox' |
120 | //! transformed by 'theTrsf'. Returns True if 'this' box is fully |
121 | //! inside the transformed 'theBox'. |
42cf5bc1 |
122 | Standard_EXPORT Standard_Boolean IsIn (const Bnd_B2f& theBox, const gp_Trsf2d& theTrsf) const; |
123 | |
36b9ff75 |
124 | //! Set the Center coordinates |
42cf5bc1 |
125 | void SetCenter (const gp_XY& theCenter); |
126 | |
36b9ff75 |
127 | //! Set the HSize (half-diagonal) coordinates. |
128 | //! All components of theHSize must be non-negative. |
42cf5bc1 |
129 | void SetHSize (const gp_XY& theHSize); |
130 | |
131 | |
132 | |
133 | |
134 | protected: |
135 | |
136 | |
137 | |
138 | Standard_ShortReal myCenter[2]; |
139 | Standard_ShortReal myHSize[2]; |
140 | |
141 | |
142 | private: |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | }; |
149 | |
150 | #define RealType Standard_ShortReal |
151 | #define RealType_hxx <Standard_ShortReal.hxx> |
152 | #define Bnd_B2x Bnd_B2f |
153 | #define Bnd_B2x_hxx <Bnd_B2f.hxx> |
154 | |
155 | #include <Bnd_B2x.lxx> |
156 | |
157 | #undef RealType |
158 | #undef RealType_hxx |
159 | #undef Bnd_B2x |
160 | #undef Bnd_B2x_hxx |
161 | |
162 | |
163 | |
164 | |
165 | #endif // _Bnd_B2f_HeaderFile |