A *Cube* is a Rectangle with depth.
More...

`#include <Dimensions.hh>`

Inheritance diagram for PIRL::Cube:

Collaboration diagram for PIRL::Cube:

## Public Member Functions | |

Cube () | |

Constructs an empty Cube. | |

Cube (const Coordinate_Type x, const Coordinate_Type y, const Dimensions_Type width=0, const Dimensions_Type height=0, const Dimensions_Type depth=0) | |

Constructs a Cube from an x,y position, width,height size, and depth. | |

Cube (const Point_2D &position, const Size_2D &size) | |

Constructs a Cube from a position and a size. | |

Cube (const Size_2D &size) | |

Constructs a Cube from a size. | |

Cube (const Rectangle &rectangle) | |

Constructs a Cube from a Rectangle. | |

Cube (const Cube &cube) | |

Constructs a Cube as a copy of another Cube. | |

Cube & | position (const Coordinate_Type &x, const Coordinate_Type &y) |

Set the position of this Cube. | |

Cube & | position (const Point_2D &point) |

Set the position of this Cube. | |

Cube & | operator= (const Point_2D &point) |

Assign the position of the Cube from a Point_2D. | |

Cube & | size (const Dimensions_Type &width, const Dimensions_Type &height) |

Set the size of this Cube. | |

Cube & | size (const Size_2D &size) |

Set the size of this Cube. | |

Cube & | depth (Dimensions_Type depth) |

Set the Depth of this Cube. | |

Dimensions_Type | depth () const |

Get the Depth of this Cube. | |

Cube & | operator= (const Size_2D &size) |

Assign the size of the Cube from a Size_2D. | |

Cube & | dimensions (const Rectangle &rectangle) |

Set the dimensions of this Cube from a Rectangle. | |

Cube & | operator= (const Rectangle &rectangle) |

Set the dimensions of this Cube from a Rectangle. | |

Cube & | operator= (const Cube &cube) |

Assign the dimensions of another Cube to this Cube. | |

unsigned long long | volume () const |

Get the volume of this Cube. | |

bool | operator== (const Cube &cube) const |

Test if this Cube is equal to another Cube. | |

bool | operator!= (const Cube &cube) const |

Test if this Cube is not equal to another Cube. | |

operator bool () | |

Test for all zero dimension values. | |

bool | is_empty () |

Test for any zero dimension values. | |

Cube & | operator+= (int amount) |

Add an amount to the Cube Depth. | |

Cube & | operator+= (const Cube &cube) |

Add another Cube's point coordinate offset, and depth and size amount. | |

Cube & | operator-= (int amount) |

Subtract an amount from the Cube Depth. | |

Cube & | operator-= (const Cube &cube) |

Subtract another Cube's point coordinate and depth offset and size amount. | |

Cube & | operator*= (double factor) |

Multiply by a factor. | |

Cube & | operator/= (double factor) |

Divide by a factor. | |

Cube & | operator&= (const Cube &cube) |

Take the intersection with another Cube. | |

Cube & | operator|= (const Cube &cube) |

Take the union with another Cube. | |

## Public Attributes | |

Dimensions_Type | Depth |

The Depth of the Cube. |

A *Cube* is a Rectangle with depth.

A Cube does not have a Z-dimension position. Instead it has a Depth with the position of the Cube having an implicit Z-coordinate of zero; i.e. the facing surface of the Cube defined by its Rectangle is at the Z-coordinate origin with the Z-axis Depth increasing away from the observer (right handed coordinate system).

**Version:**

**Revision:**- 1.27

**See also:**- Rectangle

PIRL::Cube::Cube | ( | ) |

Constructs an empty Cube.

The position is 0,0; the size is 0,0; the Depth is 0.

PIRL::Cube::Cube | ( | const Coordinate_Type | x, |

const Coordinate_Type | y, |
||

const Dimensions_Type | width = `0` , |
||

const Dimensions_Type | height = `0` , |
||

const Dimensions_Type | depth = `0` |
||

) |

PIRL::Cube::Cube | ( | const Size_2D & | size ) |

PIRL::Cube::Cube | ( | const Rectangle & | rectangle ) |

PIRL::Cube::Cube | ( | const Cube & | cube ) |

Cube& PIRL::Cube::position | ( | const Coordinate_Type & | x, |

const Coordinate_Type & | y |
||

) | ` [inline]` |

Set the position of this Cube.

**Parameters:**-
x The horizontal (x-axis) position of the Cube. y The vertical (y-axis) position of the Cube.

**Returns:**- This Cube.

Reimplemented from PIRL::Rectangle.

References PIRL::Rectangle::position().

Set the position of this Cube.

**Returns:**- This Cube.

Reimplemented from PIRL::Rectangle.

References PIRL::Rectangle::position().

Assign the position of the Cube from a Point_2D.

**Returns:**- This Cube.

Reimplemented from PIRL::Rectangle.

Referenced by dimensions(), and operator=().

Cube& PIRL::Cube::size | ( | const Dimensions_Type & | width, |

const Dimensions_Type & | height |
||

) | ` [inline]` |

Set the size of this Cube.

**Returns:**- This Cube.

Reimplemented from PIRL::Rectangle.

References PIRL::Rectangle::size().

Set the size of this Cube.

**Returns:**- This Cube.

Reimplemented from PIRL::Rectangle.

References PIRL::Rectangle::size().

Cube& PIRL::Cube::depth | ( | Dimensions_Type | depth ) |
` [inline]` |

Dimensions_Type PIRL::Cube::depth | ( | ) | const` [inline]` |

Assign the size of the Cube from a Size_2D.

**Returns:**- This Cube.

Reimplemented from PIRL::Rectangle.

References operator=().

Set the dimensions of this Cube from a Rectangle.

**Returns:**- This Cube.

Reimplemented from PIRL::Rectangle.

References operator=().

Assign the dimensions of another Cube to this Cube.

**Returns:**- This Cube.

References Depth, PIRL::Size_2D::Height, PIRL::Size_2D::Width, PIRL::Point_2D::X, and PIRL::Point_2D::Y.

unsigned long long PIRL::Cube::volume | ( | ) | const` [inline]` |

Get the volume of this Cube.

**Returns:**- The volume (Width * Height * Depth) of the Cube.

References PIRL::Size_2D::area(), and Depth.

bool PIRL::Cube::operator== | ( | const Cube & | cube ) |
const` [inline]` |

bool PIRL::Cube::operator!= | ( | const Cube & | cube ) |
const` [inline]` |

PIRL::Cube::operator bool | ( | ) | ` [inline]` |

Test for all zero dimension values.

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

Reimplemented from PIRL::Rectangle.

References Depth.

bool PIRL::Cube::is_empty | ( | ) | ` [inline]` |

Test for any zero dimension values.

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

Reimplemented from PIRL::Size_2D.

References Depth.

Cube & PIRL::Cube::operator+= | ( | int | amount ) |

Add an amount to the Cube Depth.

**N.B.**: If the Depth Dimensions_Type is unsigned (the default) and the amount is negative, the resulting Depth will not be less than zero.

**Parameters:**-
amount An integer amount to add to the Depth.

**Returns:**- This Cube with the amount applied.

Referenced by operator+=(), and operator-=().

Add another Cube's point coordinate offset, and depth and size amount.

**Parameters:**-
cube A Cube.

**Returns:**- This Cube with its point coordinate offset by the other Cube's point coordinate values, its Depth increased the other Cube's Depth, and the other Cube's size amount added to its size dimensions.

References Depth, and operator+=().

Cube& PIRL::Cube::operator-= | ( | int | amount ) |
` [inline]` |

Subtract an amount from the Cube Depth.

**N.B.**: If the Depth Dimensions_Type is unsigned (the default) and the amount is positive, the resulting Depth will not be less than zero.

**Parameters:**-
amount An integer amount to subtract from the Depth.

**Returns:**- This Cube with the amount applied.

References operator+=().

Referenced by operator-=().

Subtract another Cube's point coordinate and depth offset and size amount.

**Parameters:**-
cube A Cube.

**Returns:**- This Cube with its point coordinate offset negatively by the other Cube's point coordinate values, its Depth offset negatively by the other Cube's Depth, and the other Cube's size amount subtracted from its size dimensions.

References Depth, and operator-=().

Cube& PIRL::Cube::operator*= | ( | double | factor ) |
` [inline]` |

Multiply by a factor.

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

**Parameters:**-
factor A factor by which to multiply the dimensions.

**Returns:**- This Cube with its dimension values changed.

**Exceptions:**-
invalid_argument If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default).

Reimplemented from PIRL::Rectangle.

References Depth, and PIRL::Round().

Cube & PIRL::Cube::operator/= | ( | double | factor ) |

Divide by a factor.

The new size dimensions 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:**-
factor A factor by which to divide the dimensions.

**Returns:**- This Cube with its dimension values changed.

**Exceptions:**-
invalid_argument If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default).

Reimplemented from PIRL::Rectangle.

References PIRL::Rectangle::operator/=(), and PIRL::Round().

Take the intersection with another Cube.

The intersection of the Depths of two Cubes is the minimum Depth; i.e. the two Cubes are assumed to be aligned at the zero X-Y plane.

**Returns:**- This Cube with its position, size and depth set to the intersection with the other Cube. If the Cubes do not intersect this will result in an emtpy Cube (Width, Height and Depth zero) but the position will be unchanged.

References Depth, PIRL::Size_2D::is_empty(), and PIRL::Rectangle::operator&=().

Take the union with another Cube.

The union of the Depths of two Cubes is the maximum Depth; i.e. the two Cubes are assumed to be aligned at the zero X-Y plane.

**Returns:**- This Cube with its position, size and depth set to the union - i.e. the bounding volume - with the other Cube.

References Depth, and PIRL::Rectangle::operator|=().

The Depth of the Cube.

Referenced by depth(), is_empty(), operator bool(), operator!=(), operator&=(), operator*=(), operator+=(), operator-=(), PIRL::operator<<(), operator=(), operator==(), operator|=(), and volume().

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

Generated on Thu Jan 19 2017 14:47:10 for PIRL++ by 1.7.2