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 // 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.
22 #define WholeMask 0x1e
24 #include <gp_Pnt2d.hxx>
26 //=======================================================================
27 //function : Bnd_Box2d
29 //=======================================================================
31 inline Bnd_Box2d::Bnd_Box2d()
32 : Xmin(0.), Xmax(0.), Ymin(0.), Ymax(0.), Gap(0.), Flags (VoidMask)
36 //=======================================================================
39 //=======================================================================
41 inline void Bnd_Box2d::SetWhole ()
42 { Flags = WholeMask; }
44 //=======================================================================
47 //=======================================================================
49 inline void Bnd_Box2d::SetVoid ()
55 //=======================================================================
58 //=======================================================================
60 inline void Bnd_Box2d::Set(const gp_Pnt2d& P)
67 //=======================================================================
70 //=======================================================================
72 inline void Bnd_Box2d::Set(const gp_Pnt2d& P, const gp_Dir2d& D)
79 //=======================================================================
82 //=======================================================================
84 inline Standard_Real Bnd_Box2d::GetGap () const
89 //=======================================================================
92 //=======================================================================
94 inline void Bnd_Box2d::SetGap (const Standard_Real Tol)
99 //=======================================================================
102 //=======================================================================
104 inline void Bnd_Box2d::Enlarge (const Standard_Real Tol)
106 Standard_Real t = Tol;
108 if (Gap < t) Gap = t;
111 //=======================================================================
112 //function : OpenXmin
114 //=======================================================================
116 inline void Bnd_Box2d::OpenXmin ()
117 { Flags |= XminMask; }
119 //=======================================================================
120 //function : OpenXmax
122 //=======================================================================
124 inline void Bnd_Box2d::OpenXmax ()
125 { Flags |= XmaxMask; }
127 //=======================================================================
128 //function : OpenYmin
130 //=======================================================================
132 inline void Bnd_Box2d::OpenYmin ()
133 { Flags |= YminMask; }
135 //=======================================================================
136 //function : OpenYmax
138 //=======================================================================
140 inline void Bnd_Box2d::OpenYmax ()
141 { Flags |= YmaxMask; }
143 //=======================================================================
144 //function : IsOpenXmin
146 //=======================================================================
148 inline Standard_Boolean Bnd_Box2d::IsOpenXmin () const
149 { return Flags & XminMask; }
151 //=======================================================================
152 //function : IsOpenXmax
154 //=======================================================================
156 inline Standard_Boolean Bnd_Box2d::IsOpenXmax () const
157 { return Flags & XmaxMask; }
159 //=======================================================================
160 //function : IsOpenYmin
162 //=======================================================================
164 inline Standard_Boolean Bnd_Box2d::IsOpenYmin () const
165 { return Flags & YminMask; }
167 //=======================================================================
168 //function : IsOpenYmax
170 //=======================================================================
172 inline Standard_Boolean Bnd_Box2d::IsOpenYmax () const
173 { return Flags & YmaxMask; }
175 //=======================================================================
178 //=======================================================================
180 inline Standard_Boolean Bnd_Box2d::IsWhole () const
181 { return (Flags & WholeMask) == WholeMask; }
183 //=======================================================================
186 //=======================================================================
188 inline Standard_Boolean Bnd_Box2d::IsVoid () const
189 { return Flags & VoidMask; }
191 //=======================================================================
194 //=======================================================================
196 inline void Bnd_Box2d::Add (const gp_Pnt2d& P)
201 //=======================================================================
204 //=======================================================================
206 inline void Bnd_Box2d::Add (const gp_Pnt2d& P, const gp_Dir2d& D)
212 //=======================================================================
215 //=======================================================================
217 inline Standard_Boolean Bnd_Box2d::IsOut (const Bnd_Box2d& Other,
218 const gp_Trsf2d& T) const
220 return IsOut(Other.Transformed(T));
223 //=======================================================================
226 //=======================================================================
228 inline Standard_Boolean Bnd_Box2d::IsOut (const gp_Trsf2d& T1,
229 const Bnd_Box2d& Other,
230 const gp_Trsf2d& T2) const
232 return Transformed(T1).IsOut (Other.Transformed(T2));
234 //=======================================================================
235 //function : SquareExtent
236 //purpose : Computes the squared diagonal
237 //=======================================================================
238 inline Standard_Real Bnd_Box2d::SquareExtent() const
240 if ( IsVoid() ) return 0.;
241 Standard_Real dx = Xmax-Xmin+Gap;
242 Standard_Real dy = Ymax-Ymin+Gap;
243 return dx*dx + dy*dy;