1 // Created on: 1997-11-27
2 // Created by: Christophe MARION
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
27 #define WholeMask 0x1e
29 #include <gp_Pnt2d.hxx>
31 //=======================================================================
32 //function : Bnd_Box2d
34 //=======================================================================
36 inline Bnd_Box2d::Bnd_Box2d()
37 : Xmin(0.), Xmax(0.), Ymin(0.), Ymax(0.), Gap(0.), Flags (VoidMask)
41 //=======================================================================
44 //=======================================================================
46 inline void Bnd_Box2d::SetWhole ()
47 { Flags = WholeMask; }
49 //=======================================================================
52 //=======================================================================
54 inline void Bnd_Box2d::SetVoid ()
60 //=======================================================================
63 //=======================================================================
65 inline void Bnd_Box2d::Set(const gp_Pnt2d& P)
72 //=======================================================================
75 //=======================================================================
77 inline void Bnd_Box2d::Set(const gp_Pnt2d& P, const gp_Dir2d& D)
84 //=======================================================================
87 //=======================================================================
89 inline Standard_Real Bnd_Box2d::GetGap () const
94 //=======================================================================
97 //=======================================================================
99 inline void Bnd_Box2d::SetGap (const Standard_Real Tol)
104 //=======================================================================
107 //=======================================================================
109 inline void Bnd_Box2d::Enlarge (const Standard_Real Tol)
111 Standard_Real t = Tol;
113 if (Gap < t) Gap = t;
116 //=======================================================================
117 //function : OpenXmin
119 //=======================================================================
121 inline void Bnd_Box2d::OpenXmin ()
122 { Flags |= XminMask; }
124 //=======================================================================
125 //function : OpenXmax
127 //=======================================================================
129 inline void Bnd_Box2d::OpenXmax ()
130 { Flags |= XmaxMask; }
132 //=======================================================================
133 //function : OpenYmin
135 //=======================================================================
137 inline void Bnd_Box2d::OpenYmin ()
138 { Flags |= YminMask; }
140 //=======================================================================
141 //function : OpenYmax
143 //=======================================================================
145 inline void Bnd_Box2d::OpenYmax ()
146 { Flags |= YmaxMask; }
148 //=======================================================================
149 //function : IsOpenXmin
151 //=======================================================================
153 inline Standard_Boolean Bnd_Box2d::IsOpenXmin () const
154 { return Flags & XminMask; }
156 //=======================================================================
157 //function : IsOpenXmax
159 //=======================================================================
161 inline Standard_Boolean Bnd_Box2d::IsOpenXmax () const
162 { return Flags & XmaxMask; }
164 //=======================================================================
165 //function : IsOpenYmin
167 //=======================================================================
169 inline Standard_Boolean Bnd_Box2d::IsOpenYmin () const
170 { return Flags & YminMask; }
172 //=======================================================================
173 //function : IsOpenYmax
175 //=======================================================================
177 inline Standard_Boolean Bnd_Box2d::IsOpenYmax () const
178 { return Flags & YmaxMask; }
180 //=======================================================================
183 //=======================================================================
185 inline Standard_Boolean Bnd_Box2d::IsWhole () const
186 { return (Flags & WholeMask) == WholeMask; }
188 //=======================================================================
191 //=======================================================================
193 inline Standard_Boolean Bnd_Box2d::IsVoid () const
194 { return Flags & VoidMask; }
196 //=======================================================================
199 //=======================================================================
201 inline void Bnd_Box2d::Add (const gp_Pnt2d& P)
206 //=======================================================================
209 //=======================================================================
211 inline void Bnd_Box2d::Add (const gp_Pnt2d& P, const gp_Dir2d& D)
217 //=======================================================================
220 //=======================================================================
222 inline Standard_Boolean Bnd_Box2d::IsOut (const Bnd_Box2d& Other,
223 const gp_Trsf2d& T) const
225 return IsOut(Other.Transformed(T));
228 //=======================================================================
231 //=======================================================================
233 inline Standard_Boolean Bnd_Box2d::IsOut (const gp_Trsf2d& T1,
234 const Bnd_Box2d& Other,
235 const gp_Trsf2d& T2) const
237 return Transformed(T1).IsOut (Other.Transformed(T2));
239 //=======================================================================
240 //function : SquareExtent
241 //purpose : Computes the squared diagonal
242 //=======================================================================
243 inline Standard_Real Bnd_Box2d::SquareExtent() const
245 if ( IsVoid() ) return 0.;
246 Standard_Real dx = Xmax-Xmin+Gap;
247 Standard_Real dy = Ymax-Ymin+Gap;
248 return dx*dx + dy*dy;