UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
u2d_box.hpp
1 /* u2d_box.hpp */
2 /* $Id: u2d_box.hpp,v 1.2 2008/05/27 13:26:37 sasha Exp $ */
3 #ifndef __u2d_box_hpp
4 #define __u2d_box_hpp
5 
6 #include "u2d_point.hpp"
7 
8 class U2dBox
9 {
10 public:
11 
12  U2dBox();
13 
15 
16  U2dBox(U2dPoint*, double x_size, double z_size);
17 
18  /* Temporary */
19  U2dBox(double xmin, double xmax, double zmin, double zmax);
20 
21 
23  double getXMin() const;
24 
26  double getXMax() const;
27 
29  double getZMin() const;
30 
32  double getZMax() const;
33 
34 
36  bool setXMin(double);
37 
39  bool setXMax(double);
40 
42  bool setZMin(double);
43 
45  bool setZMax(double);
46 
47 
49  double getXSize() const;
50 
52  double getZSize() const;
53 
55  double getDiag() const;
56 
57 
59  bool checkInside (const U2dPoint& p) const;
61  bool checkDefinitelyInside (const U2dPoint& p) const;
63  //bool checkInsideEps (const U2dPoint& p) const;
64 
65  bool checkOverlay(const U2dBox& box) const;
66 
67  U2dBox combineBox(U2dBox box1, U2dBox box2);
68 
69  int operator == (const U2dBox& rbox) const;
70  int operator != (const U2dBox& rbox) const {return !operator==(rbox); };
71 
72 protected:
73 
74  double m_x_range[2];
75 
76  double m_z_range[2];
77 
78 };
79 
80 
81 //---------------------------------------------------------
82 inline double U2dBox::getXMin() const
83 {
84  return m_x_range[0];
85 }
86 //---------------------------------------------------------
87 inline double U2dBox::getXMax() const
88 {
89  return m_x_range[1];
90 }
91 //---------------------------------------------------------
92 inline double U2dBox::getZMin() const
93 {
94  return m_z_range[0];
95 }
96 //---------------------------------------------------------
97 inline double U2dBox::getZMax() const
98 {
99  return m_z_range[1];
100 }
101 
102 //---------------------------------------------------------
103 inline bool U2dBox::setXMin(double xmin)
104 {
105  if (xmin >= m_x_range[1])
106  return false;
107  m_x_range[0] = xmin;
108  return true;
109 }
110 //---------------------------------------------------------
111 inline bool U2dBox::setXMax(double xmax)
112 {
113  if (xmax <= m_x_range[0])
114  return false;
115  m_x_range[1] = xmax;
116  return true;
117 }
118 //---------------------------------------------------------
119 inline bool U2dBox::setZMin(double zmin)
120 {
121  if (zmin >= m_z_range[1])
122  return false;
123  m_z_range[0] = zmin;
124  return true;
125 }
126 //---------------------------------------------------------
127 inline bool U2dBox::setZMax(double zmax)
128 {
129  if (zmax <= m_z_range[0])
130  return false;
131  m_z_range[0] = zmax;
132  return true;
133 }
134 
135 //---------------------------------------------------------
136 inline double U2dBox::getXSize() const
137 {
138  return m_x_range[1] - m_x_range[0];
139 }
140 //---------------------------------------------------------
141 inline double U2dBox::getZSize() const
142 {
143  return m_z_range[1] - m_z_range[0];
144 }
145 
146 
147 
148 #endif
double getZMax() const
Definition: u2d_box.hpp:97
bool checkOverlay(const U2dBox &box) const
double getZSize() const
Definition: u2d_box.hpp:141
bool setXMin(double)
Definition: u2d_box.hpp:103
bool setZMin(double)
Definition: u2d_box.hpp:119
Definition: u2d_point.hpp:10
double getZMin() const
Definition: u2d_box.hpp:92
bool checkInside(const U2dPoint &p) const
Definition: u2d_box.hpp:8
double getXMin() const
Definition: u2d_box.hpp:82
double getDiag() const
bool checkDefinitelyInside(const U2dPoint &p) const
double getXSize() const
Definition: u2d_box.hpp:136
bool setZMax(double)
Definition: u2d_box.hpp:127
bool setXMax(double)
Definition: u2d_box.hpp:111
double getXMax() const
Definition: u2d_box.hpp:87