A Size_2D holds 2-dimensional size information. More...
#include <Dimensions.hh>
Public Member Functions | |
Size_2D () | |
Constructs an empty Size_2D. | |
Size_2D (const Dimensions_Type &width, const Dimensions_Type &height) | |
Constructs a Size_2D with width,height size. | |
Size_2D (const Dimensions_Type &side) | |
Constructs a Size_2D of equal Width and Height. | |
Size_2D (const Size_2D &size) | |
Constructs a Size_2D from another Size_2D. | |
Size_2D & | size (const Dimensions_Type &width, const Dimensions_Type &height) |
Set the size of this Size_2D. | |
Size_2D & | size (const Size_2D &size) |
Set the size of this Size_2D. | |
Size_2D & | operator= (const Size_2D &size) |
Assign the dimensions of another Size_2D to this Size_2D. | |
Size_2D & | width (const Dimensions_Type &width) |
Set the Width of the Size_2D. | |
Dimensions_Type | width () const |
Get the Width of the Size_2D. | |
Size_2D & | height (const Dimensions_Type &height) |
Set the Height of the Size_2D. | |
Dimensions_Type | height () const |
Get the Height of the Size_2D. | |
unsigned long long | area () const |
Get the area of this Size_2D. | |
bool | operator== (const Size_2D &size) const |
Test if this Size_2D is equal to another Size_2D. | |
bool | operator!= (const Size_2D &size) const |
Test if this Size_2D is not equal to another Size_2D. | |
operator bool () | |
Test for all zero dimension values. | |
bool | is_empty () |
Test for any zero dimension values. | |
Size_2D & | operator+= (const Size_2D &size) |
Add a size amount. | |
Size_2D & | operator-= (const Size_2D &size) |
Subtract a size amount. | |
Size_2D & | operator*= (double factor) |
Multiply by a factor. | |
Size_2D & | operator/= (double factor) |
Divide by a factor. | |
Public Attributes | |
Dimensions_Type | Width |
The Width of the Size_2D. | |
Dimensions_Type | Height |
The Height of the Size_2D. |
A Size_2D holds 2-dimensional size information.
PIRL::Size_2D::Size_2D | ( | ) |
PIRL::Size_2D::Size_2D | ( | const Dimensions_Type & | width, |
const Dimensions_Type & | height | ||
) |
PIRL::Size_2D::Size_2D | ( | const Dimensions_Type & | side ) |
Constructs a Size_2D of equal Width and Height.
side | The length of each side. Both Width and Height will be set to this value. |
PIRL::Size_2D::Size_2D | ( | const Size_2D & | size ) |
Size_2D& PIRL::Size_2D::size | ( | const Dimensions_Type & | width, |
const Dimensions_Type & | height | ||
) | [inline] |
Set the size of this Size_2D.
Reimplemented in PIRL::Rectangle, and PIRL::Cube.
Set the size of this Size_2D.
Reimplemented in PIRL::Rectangle, and PIRL::Cube.
Assign the dimensions of another Size_2D to this Size_2D.
Reimplemented in PIRL::Rectangle, and PIRL::Cube.
Size_2D& PIRL::Size_2D::width | ( | const Dimensions_Type & | width ) | [inline] |
Dimensions_Type PIRL::Size_2D::width | ( | ) | const [inline] |
Size_2D& PIRL::Size_2D::height | ( | const Dimensions_Type & | height ) | [inline] |
Dimensions_Type PIRL::Size_2D::height | ( | ) | const [inline] |
unsigned long long PIRL::Size_2D::area | ( | ) | const [inline] |
Get the area of this Size_2D.
Referenced by PIRL::Cube::volume().
bool PIRL::Size_2D::operator== | ( | const Size_2D & | size ) | const [inline] |
bool PIRL::Size_2D::operator!= | ( | const Size_2D & | size ) | const [inline] |
PIRL::Size_2D::operator bool | ( | ) | [inline] |
Test for all zero dimension values.
Reimplemented in PIRL::Rectangle, and PIRL::Cube.
bool PIRL::Size_2D::is_empty | ( | ) | [inline] |
Test for any zero dimension values.
Reimplemented in PIRL::Cube.
Referenced by PIRL::Cube::operator&=().
Add a size amount.
size | A Size_2D that provides the amount values. |
Reimplemented in PIRL::Rectangle.
Subtract a size amount.
N.B.: If the size Dimensions_Type values are an unsigned type (as they are by default) and a size amount to be subtracted is greater than the corresponding dimension value, the result will be zero.
size | A Size_2D that provides the amount values. |
Reimplemented in PIRL::Rectangle.
Size_2D & PIRL::Size_2D::operator*= | ( | double | factor ) |
Multiply by a factor.
The new size values will be rounded to the nearest Dimensions_Types.
factor | A factor by which to multiply the Size_2D dimensions. |
invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Reimplemented in PIRL::Rectangle, and PIRL::Cube.
References AS_STRING, DIMENSIONS_TYPE, PIRL::Point_2D::ID, and PIRL::Round().
Size_2D & PIRL::Size_2D::operator/= | ( | double | factor ) |
Divide by a factor.
The new dimension values will be rounded to the nearest Dimensions_Type values.
N.B.: Divide by zero is handled as a special case. If the coordinate value was zero it will remain zero. If the Dimensions_Type has an infinity value (determined by numeric_types) that is used, or its negative if the coordinate value is negative. Otherwise, if the Dimensions_Type is signed the type's max value is used, or the min value if the coordinate value is negative; for an unsigned value the max value is used.
factor | A factor by which to divide the Size_2D dimensions. |
invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Reimplemented in PIRL::Rectangle, and PIRL::Cube.
References AS_STRING, DIMENSIONS_TYPE, PIRL::Point_2D::ID, and PIRL::Round().
The Width of the Size_2D.
Referenced by area(), is_empty(), operator bool(), operator!=(), PIRL::Rectangle::operator&=(), operator+=(), PIRL::operator-(), operator-=(), PIRL::operator<<(), PIRL::Cube::operator=(), PIRL::Rectangle::operator=(), operator=(), operator==(), PIRL::Rectangle::operator|=(), PIRL::Rectangle::size(), size(), and width().
The Height of the Size_2D.
Referenced by area(), height(), is_empty(), operator bool(), operator!=(), PIRL::Rectangle::operator&=(), operator+=(), PIRL::operator-(), operator-=(), PIRL::operator<<(), PIRL::Cube::operator=(), PIRL::Rectangle::operator=(), operator=(), operator==(), PIRL::Rectangle::operator|=(), PIRL::Rectangle::size(), and size().