HiRISE
 PDS_JP2

Public Member Functions | List of all members
Rectangle Struct Reference

A Rectangle is a position with a size. More...

#include <Dimensions.hh>

Inheritance diagram for Rectangle:
Inheritance graph
[legend]
Collaboration diagram for Rectangle:
Collaboration graph
[legend]

Public Member Functions

 Rectangle ()
 Constructs an empty rectangle. More...
 
 Rectangle (const Point_2D &position, const Size_2D &size)
 Constructs a rectangle from a position and a size. More...
 
 Rectangle (const Size_2D &size)
 Constructs a rectangle from a size at position 0,0. More...
 
 Rectangle (const int x, const int y, const unsigned int width=0, const unsigned int height=0)
 Constructs a rectangle from an x,y position and width,height size. More...
 
 Rectangle (const Rectangle &rectangle)
 Constructs a rectangle as a copy of another rectangle. More...
 
Rectangleoperator= (const Rectangle &rectangle)
 Assign the position and size of another rectangle to this rectangle. More...
 
Point_2D position () const
 Get the rectangle position. More...
 
Rectangleposition (const Point_2D &point)
 Set the position of the rectangle. More...
 
Rectangleposition (const int x, const int y)
 Set the x,y position of the rectangle. More...
 
Size_2D size () const
 Get the rectangle size. More...
 
Rectanglesize (const Size_2D &size)
 Set the size of the rectangle. More...
 
Rectanglesize (const unsigned int width, const unsigned int height)
 Set the width,height of the rectangle. More...
 
Rectangleoperator&= (const Rectangle &rectangle)
 Take the intersection with another rectangle. More...
 
- Public Member Functions inherited from Point_2D
 Point_2D ()
 Constructs a point at position 0,0. More...
 
 Point_2D (const int &x, const int &y)
 Constructs a point at position x,y. More...
 
 Point_2D (const Point_2D &point)
 Constructs a point from another point. More...
 
Point_2Doperator= (const Point_2D &point)
 Assign the position of another point to this point. More...
 
int x () const
 Get the horizontal (x-axis) position. More...
 
Point_2Dx (const int &x_position)
 Set the horizontal (x-axis) position. More...
 
int y () const
 Get the vertical (y-axis) position. More...
 
Point_2Dy (const int &y_position)
 Set the vertical (y-axis) position. More...
 
- Public Member Functions inherited from Size_2D
 Size_2D ()
 Constructs an empty 2D size. More...
 
 Size_2D (const unsigned int &width, const unsigned int &height)
 Constructs a specific size. More...
 
 Size_2D (const unsigned int &side)
 Constructs a size of equal width and height. More...
 
 Size_2D (const Size_2D &size)
 Constructs a size from another size. More...
 
Size_2Doperator= (const Size_2D &size)
 Assign the size of another size to this size. More...
 
unsigned int width () const
 Get the width of the size. More...
 
Size_2Dwidth (const unsigned int &width)
 Set the width of the size. More...
 
unsigned int height () const
 Get the height of the size. More...
 
Size_2Dheight (const unsigned int &height)
 Set the height of the size. More...
 
unsigned long area () const
 Get the area of this size. More...
 

Additional Inherited Members

- Public Attributes inherited from Point_2D
int X
 The horizontal (x-axis) position of the point. More...
 
int Y
 The vertical (y-axis) position of the point. More...
 
- Public Attributes inherited from Size_2D
unsigned int Width
 The width of the 2D size. More...
 
unsigned int Height
 The height of the 2D size. More...
 

Detailed Description

A Rectangle is a position with a size.

Author
Bradford Castalia, UA/PIRL
Version
1.7
See also
Point_2D
Size_2D

Constructor & Destructor Documentation

◆ Rectangle() [1/5]

Rectangle ( )

Constructs an empty rectangle.

The position is 0,0 and the size is 0,0.

◆ Rectangle() [2/5]

Rectangle ( const Point_2D position,
const Size_2D size 
)

Constructs a rectangle from a position and a size.

Parameters
positionA Point_2D.
sizeA Size_2D.

◆ Rectangle() [3/5]

Rectangle ( const Size_2D size)

Constructs a rectangle from a size at position 0,0.

Parameters
sizeA Size_2D.

◆ Rectangle() [4/5]

Rectangle ( const int  x,
const int  y,
const unsigned int  width = 0,
const unsigned int  height = 0 
)

Constructs a rectangle from an x,y position and width,height size.

Parameters
xThe horizontal (x-axis) position.
yThe vertical (y-axis) position.
widthThe width of the rectangle size.
heightThe height of the recangle size.

◆ Rectangle() [5/5]

Rectangle ( const Rectangle rectangle)

Constructs a rectangle as a copy of another rectangle.

Parameters
rectangleA Rectangle to be copied.

Member Function Documentation

◆ operator=()

Rectangle & operator= ( const Rectangle rectangle)

Assign the position and size of another rectangle to this rectangle.

Parameters
rectangleA Rectangle whose position and size are be assigned to this rectangle.
Returns
This Rectangle.

References Point_2D::X.

◆ position() [1/3]

Point_2D position ( ) const
inline

Get the rectangle position.

Returns
A Point_2D with the rectangle position. N.B.: Changing this point will not change the position of the rectangle.

References Point_2D::Point_2D(), Point_2D::X, and Point_2D::Y.

◆ position() [2/3]

Rectangle& position ( const Point_2D point)
inline

Set the position of the rectangle.

Parameters
pointA Point_2D for the position of the rectangle.
Returns
This Rectangle.

References Point_2D::X, and Point_2D::Y.

◆ position() [3/3]

Rectangle& position ( const int  x,
const int  y 
)
inline

Set the x,y position of the rectangle.

Parameters
xThe horizontal (x-axis) position.
yThe vertical (y-axis) position.
Returns
This Rectangle.

References Point_2D::X, Point_2D::x(), Point_2D::Y, and Point_2D::y().

◆ size() [1/3]

Size_2D size ( ) const
inline

Get the rectangle size.

Returns
A Size_2D with the rectangle size. N.B.: Changing this size will not change the size of the rectangle.

References Size_2D::Height, Size_2D::Size_2D(), and Size_2D::Width.

Referenced by Rectangle::size().

◆ size() [2/3]

Rectangle& size ( const Size_2D size)
inline

Set the size of the rectangle.

Parameters
sizeA Size_2D for the size of the rectangle.
Returns
This Rectangle.

References Size_2D::Height, Rectangle::size(), and Size_2D::Width.

◆ size() [3/3]

Rectangle& size ( const unsigned int  width,
const unsigned int  height 
)
inline

Set the width,height of the rectangle.

Parameters
widthThe width of the rectangle size.
heightThe height of the recangle size.
Returns
This Rectangle.

References Size_2D::Height, Size_2D::height(), Size_2D::Width, and Size_2D::width().

◆ operator&=()

Rectangle & operator&= ( const Rectangle rectangle)

Take the intersection with another rectangle.

Parameters
rectangleThe Rectangle to intersect with this Rectangle.
Returns
This Rectangle with its position and size set to the intersection with the other rectangle. If the rectangles do not intersect this will result in a rectangle with no area (width and height both zero) but the position will be unchanged.

References Point_2D::X.


The documentation for this struct was generated from the following files: