HiRISE
 PDS_JP2

Dimensions.hh
Go to the documentation of this file.
1 /* Dimensions
2 
3 HiROC CVS ID: Dimensions.hh,v 1.7 2010/11/24 03:32:14 castalia Exp
4 
5 Copyright (C) 2007 Arizona Board of Regents on behalf of the
6 Planetary Image Research Laboratory, Lunar and Planetary Laboratory at
7 the University of Arizona.
8 
9 This library is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License, version 2.1,
11 as published by the Free Software Foundation.
12 
13 This library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with this library; if not, write to the Free Software Foundation,
20 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 */
22 
23 #ifndef _Dimensions_
24 #define _Dimensions_
25 
26 #include <iosfwd>
27 
28 
29 namespace UA
30 {
31 namespace HiRISE
32 {
33 //******************************************************************************
39 struct Point_2D
40 {
42 int
43  X;
45 int
46  Y;
47 
48 /*==============================================================================
49  Constructors:
50 */
52 Point_2D ();
53 
55 Point_2D (const int& x,const int& y);
56 
61 Point_2D (const Point_2D& point);
62 
67 Point_2D& operator= (const Point_2D& point);
68 
69 /*==============================================================================
70  Accessors:
71 */
76 inline int x () const
77  {return X;}
78 
84 inline Point_2D& x (const int& x_position)
85  {X = x_position; return *this;}
86 
91 inline int y () const
92  {return Y;}
93 
99 inline Point_2D& y (const int& y_position)
100  {Y = y_position; return *this;}
101 
102 }; // End of Point_2D class.
103 
110 std::ostream& operator<< (std::ostream& stream, const Point_2D& point);
111 
112 //******************************************************************************
118 struct Size_2D
119 {
121 unsigned int
124 unsigned int
126 
127 /*==============================================================================
128  Constructors:
129 */
134 Size_2D ();
135 
141 Size_2D (const unsigned int& width, const unsigned int& height);
142 
148 Size_2D (const unsigned int& side);
149 
154 Size_2D (const Size_2D& size);
155 
160 Size_2D& operator= (const Size_2D& size);
161 
162 /*==============================================================================
163  Accessors:
164 */
169 inline unsigned int width () const
170  {return Width;}
171 
177 inline Size_2D& width (const unsigned int& width)
178  {Width = width; return *this;}
179 
184 inline unsigned int height () const
185  {return Height;}
186 
192 inline Size_2D& height (const unsigned int& height)
193  {Height = height; return *this;}
194 
199 inline unsigned long area () const
200  {return Width * Height;}
201 
202 }; // End of Size_2D class.
203 
210 std::ostream& operator<< (std::ostream& stream, const Size_2D& size);
211 
212 //******************************************************************************
220 struct Rectangle
221 : public Point_2D,
222  public Size_2D
223 {
224 /*==============================================================================
225  Constructors:
226 */
231 Rectangle ();
232 
238 Rectangle (const Point_2D& position, const Size_2D& size);
239 
244 Rectangle (const Size_2D& size);
245 
253 Rectangle
254  (
255  const int x,
256  const int y,
257  const unsigned int width = 0,
258  const unsigned int height = 0
259  );
260 
265 Rectangle (const Rectangle& rectangle);
266 
273 Rectangle& operator= (const Rectangle& rectangle);
274 
275 /*==============================================================================
276  Accessors:
277 */
283 inline Point_2D position () const
284  {return Point_2D (X, Y);}
285 
292  (
293  const Point_2D& point
294  )
295 {
296 X = point.X;
297 Y = point.Y;
298 return *this;
299 }
300 
308  (
309  const int x,
310  const int y
311  )
312 {
313 X = x;
314 Y = y;
315 return *this;
316 }
317 
323 inline Size_2D size () const
324  {return Size_2D (Width, Height);}
325 
332  (
333  const Size_2D& size
334  )
335 {
336 Width = size.Width;
337 Height = size.Height;
338 return *this;
339 }
340 
348  (
349  const unsigned int width,
350  const unsigned int height
351  )
352 {
353 Width = width;
354 Height = height;
355 return *this;
356 }
357 
358 /*==============================================================================
359  Manipulators:
360 */
369 Rectangle& operator&= (const Rectangle& rectangle);
370 
371 }; // End of Rectangle class.
372 
379 std::ostream& operator<< (std::ostream& stream, const Rectangle& rectangle);
380 
381 } // namespace HiRISE
382 } // namespace UA
383 #endif
std::ostream & operator<<(std::ostream &stream, const Point_2D &point)
Print a Point_2D description to an output stream.
Definition: Dimensions.cc:80
Definition: Dimensions.cc:30
A Point_2D holds 2-dimensional position information.
Definition: Dimensions.hh:40
int x() const
Get the horizontal (x-axis) position.
Definition: Dimensions.hh:76
Point_2D()
Constructs a point at position 0,0.
Definition: Dimensions.cc:39
Point_2D & y(const int &y_position)
Set the vertical (y-axis) position.
Definition: Dimensions.hh:99
int y() const
Get the vertical (y-axis) position.
Definition: Dimensions.hh:91
int X
The horizontal (x-axis) position of the point.
Definition: Dimensions.hh:43
Point_2D & x(const int &x_position)
Set the horizontal (x-axis) position.
Definition: Dimensions.hh:84
int Y
The vertical (y-axis) position of the point.
Definition: Dimensions.hh:46
Point_2D & operator=(const Point_2D &point)
Assign the position of another point to this point.
Definition: Dimensions.cc:66
A Rectangle is a position with a size.
Definition: Dimensions.hh:223
Rectangle & operator=(const Rectangle &rectangle)
Assign the position and size of another rectangle to this rectangle.
Definition: Dimensions.cc:205
Rectangle()
Constructs an empty rectangle.
Definition: Dimensions.cc:159
Point_2D position() const
Get the rectangle position.
Definition: Dimensions.hh:283
Rectangle & size(const unsigned int width, const unsigned int height)
Set the width,height of the rectangle.
Definition: Dimensions.hh:348
Size_2D size() const
Get the rectangle size.
Definition: Dimensions.hh:323
Rectangle & operator&=(const Rectangle &rectangle)
Take the intersection with another rectangle.
Definition: Dimensions.cc:222
Rectangle & position(const Point_2D &point)
Set the position of the rectangle.
Definition: Dimensions.hh:292
Rectangle & position(const int x, const int y)
Set the x,y position of the rectangle.
Definition: Dimensions.hh:308
Rectangle & size(const Size_2D &size)
Set the size of the rectangle.
Definition: Dimensions.hh:332
A Size_2D holds 2-dimensional size information.
Definition: Dimensions.hh:119
Size_2D & width(const unsigned int &width)
Set the width of the size.
Definition: Dimensions.hh:177
Size_2D & height(const unsigned int &height)
Set the height of the size.
Definition: Dimensions.hh:192
unsigned long area() const
Get the area of this size.
Definition: Dimensions.hh:199
Size_2D & operator=(const Size_2D &size)
Assign the size of another size to this size.
Definition: Dimensions.cc:130
Size_2D()
Constructs an empty 2D size.
Definition: Dimensions.cc:95
unsigned int width() const
Get the width of the size.
Definition: Dimensions.hh:169
unsigned int Height
The height of the 2D size.
Definition: Dimensions.hh:125
unsigned int Width
The width of the 2D size.
Definition: Dimensions.hh:122
unsigned int height() const
Get the height of the size.
Definition: Dimensions.hh:184