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