HiRISE
 PDS_JP2

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