0022627: Change OCCT memory management defaults
[occt.git] / src / Select3D / Select3D_Box2d.hxx
1 #ifndef _Select3D_Box2d_HeaderFile
2 #define _Select3D_Box2d_HeaderFile
3
4 #include<Bnd_Box2d.hxx>
5 #include<Standard_ShortReal.hxx>
6 #include<Select3D_Macro.hxx>
7
8 struct Select3D_Box2d
9 {
10  Standard_ShortReal xmin, ymin, xmax, ymax;
11
12  Select3D_Box2d()
13  { 
14    SetVoid();
15  }
16
17  Select3D_Box2d(const Bnd_Box2d& theBox)
18  { 
19    SetField(theBox);
20  }
21
22  inline operator Bnd_Box2d() const
23  {
24    Bnd_Box2d aBox;
25    aBox.SetVoid();
26    if( !IsVoid() )
27      aBox.Update(xmin, ymin, xmax, ymax);
28    return aBox;
29  }
30
31  inline Select3D_Box2d operator = ( const Bnd_Box2d& theBox)
32  { 
33    SetField(theBox); 
34    return *this;
35  }
36
37  inline void Update(const gp_Pnt2d& thePnt)
38  {
39   Bnd_Box2d aBox;
40   aBox.Set(thePnt);
41   if( !IsVoid() )
42     aBox.Update(xmin, ymin, xmax, ymax);
43   SetField(aBox);
44  }
45
46  inline void SetVoid()
47  {
48    xmin = ymin = ShortRealLast();
49    xmax = ymax = ShortRealFirst();
50  }
51
52  inline Standard_Boolean IsVoid() const
53  {
54    return ( xmin == ShortRealLast() && ymin == ShortRealLast() && xmax == ShortRealFirst() && ymax == ShortRealFirst() );
55  }
56
57 private: 
58  inline void SetField(const Bnd_Box2d& theBox)
59  {
60   if( theBox.IsVoid() )
61     SetVoid();
62   else {
63     Standard_Real x, y, x1, y1;
64     theBox.Get(x, y, x1, y1);   
65
66     xmin = DToF(x);
67     ymin = DToF(y);
68     xmax = DToF(x1);
69     ymax = DToF(y1);
70   }
71  }
72
73 };
74
75 #endif
76
77
78
79