PIRL  PIRL++

Public Member Functions | Public Attributes

PIRL::Size_2D Struct Reference

A Size_2D holds 2-dimensional size information. More...

#include <Dimensions.hh>

Inheritance diagram for PIRL::Size_2D:
Inheritance graph
[legend]

List of all members.

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_2Dsize (const Dimensions_Type &width, const Dimensions_Type &height)
 Set the size of this Size_2D.
Size_2Dsize (const Size_2D &size)
 Set the size of this Size_2D.
Size_2Doperator= (const Size_2D &size)
 Assign the dimensions of another Size_2D to this Size_2D.
Size_2Dwidth (const Dimensions_Type &width)
 Set the Width of the Size_2D.
Dimensions_Type width () const
 Get the Width of the Size_2D.
Size_2Dheight (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_2Doperator+= (const Size_2D &size)
 Add a size amount.
Size_2Doperator-= (const Size_2D &size)
 Subtract a size amount.
Size_2Doperator*= (double factor)
 Multiply by a factor.
Size_2Doperator/= (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.

Detailed Description

A Size_2D holds 2-dimensional size information.

Author:
Bradford Castalia, UA/PIRL
Version:
Revision:
1.27

Constructor & Destructor Documentation

PIRL::Size_2D::Size_2D (  )

Constructs an empty Size_2D.

Both Width and Height are zero.

Referenced by PIRL::Rectangle::size().

PIRL::Size_2D::Size_2D ( const Dimensions_Type width,
const Dimensions_Type height 
)

Constructs a Size_2D with width,height size.

Parameters:
widthThe Width of the Size_2D.
heightThe Height of the Size_2D.
PIRL::Size_2D::Size_2D ( const Dimensions_Type side )

Constructs a Size_2D of equal Width and Height.

Parameters:
sideThe length of each side. Both Width and Height will be set to this value.
PIRL::Size_2D::Size_2D ( const Size_2D size )

Constructs a Size_2D from another Size_2D.

Parameters:
sizeA Size_2D to be copied.

Member Function Documentation

Size_2D& PIRL::Size_2D::size ( const Dimensions_Type width,
const Dimensions_Type height 
) [inline]

Set the size of this Size_2D.

Parameters:
widthThe Width of the Size_2D.
heightThe Height of the Size_2D.
Returns:
This Size_2D.

Reimplemented in PIRL::Rectangle, and PIRL::Cube.

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

Size_2D& PIRL::Size_2D::size ( const Size_2D size ) [inline]

Set the size of this Size_2D.

Parameters:
sizeA Size_2D to have its dimensions assigned to this Size_2D.
Returns:
This Size_2D.

Reimplemented in PIRL::Rectangle, and PIRL::Cube.

References Height, and Width.

Size_2D& PIRL::Size_2D::operator= ( const Size_2D size ) [inline]

Assign the dimensions of another Size_2D to this Size_2D.

Parameters:
sizeA Size_2D to have its dimensions assigned to this Size_2D.

Reimplemented in PIRL::Rectangle, and PIRL::Cube.

References Height, and Width.

Size_2D& PIRL::Size_2D::width ( const Dimensions_Type width ) [inline]

Set the Width of the Size_2D.

Parameters:
widthThe Width of the Size_2D.
Returns:
This Size_2D.

References width(), and Width.

Referenced by width().

Dimensions_Type PIRL::Size_2D::width (  ) const [inline]

Get the Width of the Size_2D.

Returns:
The Width of the Size_2D.

References Width.

Referenced by size().

Size_2D& PIRL::Size_2D::height ( const Dimensions_Type height ) [inline]

Set the Height of the Size_2D.

Parameters:
heightThe Height of the Size_2D.
Returns:
This Size_2D.

References height(), and Height.

Referenced by height().

Dimensions_Type PIRL::Size_2D::height (  ) const [inline]

Get the Height of the Size_2D.

Returns:
The Height of the Size_2D.

References Height.

Referenced by size().

unsigned long long PIRL::Size_2D::area (  ) const [inline]

Get the area of this Size_2D.

Returns:
The area (Width * Height) of the Size_2D.

References Height, and Width.

Referenced by PIRL::Cube::volume().

bool PIRL::Size_2D::operator== ( const Size_2D size ) const [inline]

Test if this Size_2D is equal to another Size_2D.

The two Size_2Ds are equal if both their Width and Height dimensions are equal.

Parameters:
sizeThe Size_2D to which this Size_2D is to be compared.
Returns:
true if the two Size_2Ds are equal; false otherwise.

References Height, and Width.

bool PIRL::Size_2D::operator!= ( const Size_2D size ) const [inline]

Test if this Size_2D is not equal to another Size_2D.

The two Size_2Ds are not equal if either their Width or Height dimensions are not equal.

Parameters:
sizeThe Size_2D to which this Size_2D is to be compared.
Returns:
true if the two Size_2Ds are not equal; false otherwise.

References Height, and Width.

PIRL::Size_2D::operator bool (  ) [inline]

Test for all zero dimension values.

Returns:
true if any dimension value is non-zero; false otherwise.

Reimplemented in PIRL::Rectangle, and PIRL::Cube.

References Height, and Width.

bool PIRL::Size_2D::is_empty (  ) [inline]

Test for any zero dimension values.

Returns:
true if any dimension is zero; false otherwise.

Reimplemented in PIRL::Cube.

References Height, and Width.

Referenced by PIRL::Cube::operator&=().

Size_2D& PIRL::Size_2D::operator+= ( const Size_2D size ) [inline]

Add a size amount.

Parameters:
sizeA Size_2D that provides the amount values.
Returns:
This Size_2D with the amount added to its values.

Reimplemented in PIRL::Rectangle.

References Height, and Width.

Size_2D & PIRL::Size_2D::operator-= ( const Size_2D size )

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.

Parameters:
sizeA Size_2D that provides the amount values.
Returns:
This Size_2D with the amount subtracted to its values.

Reimplemented in PIRL::Rectangle.

References Height, and Width.

Size_2D & PIRL::Size_2D::operator*= ( double  factor )

Multiply by a factor.

The new size values will be rounded to the nearest Dimensions_Types.

Parameters:
factorA factor by which to multiply the Size_2D dimensions.
Returns:
This Size_2D with its values changed.
Exceptions:
invalid_argumentIf 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.

Parameters:
factorA factor by which to divide the Size_2D dimensions.
Returns:
This Size_2D with its values changed.
Exceptions:
invalid_argumentIf 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().


Member Data Documentation


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