#include <box2i.h>
This class represents a two-dimensional axis-aligned bounding box whose dimensions are stored using 32-bit integers.
This class may be used to store (X,Y) coordinates. For example, the CoordBox type (used during NavData generation) uses this class as follows:
Alternatively, this class may be used to refer to elements within a regular grid according to their column and row. For example, the PixelBox, CellBox and TileBox types (used during NavData generation) use this class as follows:
Each instance of this class also maintains a count of the number of elements (or grid cells) contained by the box along its X and Y axes, accessible through the CountX() and CountY() methods. For coordinate boxes, all coordinates along the edge of the box are counted, including the corners. For grid boxes, all grid cells that are contained within the box are counted. See the images above for examples.
Friends | |
void | SwapEndianness (Kaim::Endianness::Target e, Box2i &self) |
Constructors | |
Box2i () | |
Box2i (const Vec2i &min_, const Vec2i &max_) | |
Box2i (KyInt32 min_x, KyInt32 min_y, KyInt32 max_x, KyInt32 max_y) | |
Main API Functions | |
bool | IsValid () const |
void | MakeZero () |
void | Set (const Vec2i &min_, const Vec2i &max_) |
void | Set (KyInt32 min_x, KyInt32 min_y, KyInt32 max_x, KyInt32 max_y) |
void | SetSafe (const Vec2i &min_, const Vec2i &max_) |
void | SetMin (const Vec2i &min_) |
void | SetMax (const Vec2i &max_) |
const Vec2i & | Min () const |
const Vec2i & | Max () const |
Vec2i | CornerSouthWest () const |
Vec2i | CornerNorthEast () const |
Vec2i | CornerSouthEast () const |
Vec2i | CornerNorthWest () const |
const Vec2i & | CountXY () const |
KyInt32 | CountX () const |
KyInt32 | CountY () const |
bool | IsInside (const Vec2i &pos) const |
bool | FastIsInside (const Vec2i &pos) const |
bool | IsInsideStrictly (const Vec2i &pos) const |
void | Clear () |
Box2i & | operator*= (KyInt32 s) |
Box2i & | operator/= (KyInt32 s) |
Box2i & | operator+= (const Vec2i &v) |
Box2i & | operator-= (const Vec2i &v) |
bool | operator== (const Box2i &other) const |
bool | operator!= (const Box2i &other) const |
KyInt32 | GetColumnMajorIndex (const Vec2i &pos) const |
KyInt32 | GetRowMajorIndex (const Vec2i &pos) const |
KyInt32 | GetColumnMajorIndexFromLocalPos (const Vec2i &localPos) const |
KyInt32 | GetRowMajorIndexFromLocalPos (const Vec2i &localPos) const |
void | ExpandByVec2 (const Vec2i &pos) |
void | ExpandByVec3 (const Vec3i &pos) |
void | ExpandByTriangle (const Triangle3i &triangle) |
void | ExpandByBox2 (const Box2i &box) |
void | Enlarge (KyInt32 enlargement) |
void | GetEnlarged (KyInt32 enlargement, Box2i &enlarged) const |
bool | IntersectWith (const Box2i &box) |
bool | SetAsIntersection (const Box2i &box_1, const Box2i &box_2) |
|
inline |
Creates a new Box2i with the provided extents.
min_ | The minima of the bounding box. |
max_ | The maxima of the bounding box. |
Creates a new Box2i with the provided extents.
min_x | The minimum position of the bounding box on the X axis. |
min_y | The minimum position of the bounding box on the Y axis. |
max_x | The maximum position of the bounding box on the X axis. |
max_y | The maximum position of the bounding box on the Y axis. |
|
inline |
Clears all information maintained by this object.
This method sets the extents of the box to invalid values; you must follow this method with a call to Set() before you can use the box.
|
inline |
Retrieves the coordinates of the North-East corner of the bounding box.
Since North is considered to be the positive direction of the Y axis and East is considered to be the positive direction of the Y axis, this corner is equivalent to the maxima.
|
inline |
Retrieves the coordinates of the North-West corner of the bounding box.
Since North is considered to be the positive direction of the Y axis and East is considered to be the positive direction of the Y axis, this corner has the maximum value on the Y axis and the minimum value on the X axis.
|
inline |
Retrieves the coordinates of the South-East corner of the bounding box.
Since North is considered to be the positive direction of the Y axis and East is considered to be the positive direction of the Y axis, this corner has the minimum value on the Y axis and the maximum value on the X axis.
|
inline |
Retrieves the coordinates of the South-West corner of the bounding box.
Since North is considered to be the positive direction of the Y axis and East is considered to be the positive direction of the Y axis, this corner is equivalent to the minima.
|
inline |
Retrieves the number of grid cells contained within this box along its X axis.
|
inline |
Retrieves the number of grid cells contained within this box along its X and Y axes.
|
inline |
Retrieves the number of grid cells contained within this box along its Y axis.
|
inline |
Enlarges the extents of the bounding box by the specified amount in all directions.
|
inline |
Enlarges the extents of the bounding box to include the area covered by the specified bounding box.
If the bounding box already encompasses the area of box, the bounding box is not modified.
|
inline |
Enlarges the extents of the bounding box to include the (X,Y) extents of the specified three-dimensional triangle.
If the (X,Y) extents of the triangle are already contained within the bounding box, the box is not modified.
|
inline |
Enlarges the extents of the bounding box to include the specified two-dimensional point.
If the point is already contained within the bounding box, the box is not modified.
|
inline |
Enlarges the extents of the bounding box to include the (X,Y) coordinates of the specified three-dimensional point.
If the (X,Y) coordinates of the point are already contained within the bounding box, the box is not modified.
|
inline |
Returns true if the specified position is contained within the extents of the bounding box or if the specified position is located on the edge of the bounding box.
Warning: this method can cause overflow during computation. It should not be used with integers whose values take up 31 bits.
Retrieves the index of the grid cell at the specified (X,Y) position, counting cells column-by-column.
This indexes the cells in the box according to the following pattern:
Retrieves the index of the grid cell at the specified (X,Y) position, counting cells column-by-column.
The X and Y coordinates within localPos should be relative to the minima of the box.
See also GetColumnMajorIndex() for information on the index value returned.
Enlarges the extents of the bounding box by the specified amount in all directions, and stores the new dimensions in the enlarged parameter.
enlargement | The amount to enlarge the box in each direction. | |
[out] | enlarged | Stores the enlarged bounding box. |
Retrieves the index of the grid cell at the specified (X,Y) position, counting cells row-by-row.
This indexes the cells in the box according to the following pattern:
Retrieves the index of the grid cell at the specified (X,Y) position, counting cells row-by-row.
The X and Y coordinates within localPos should be relative to the minima of the box.
See also GetRowMajorIndex() for information on the index value returned.
|
inline |
Resizes this bounding box to contain only the grid cells that are common to both it and box.
This has the following results:
|
inline |
Returns true if the specified position is contained within the extents of the bounding box or if the specified position is located on the edge of the bounding box.
|
inline |
Returns true if the specified position is contained entirely within the extents of the bounding box.
|
inline |
Indicates whether or not the extents of the bounding box are valid.
|
inline |
Sets both the minima and maxima of the bounding box to (0,0).
|
inline |
Retrieves the maxima of the bounding box.
|
inline |
Retrieves the minima of the bounding box.
Multiplies both the minima and maxima of the box by the specified value.
Adds the specified two-dimensional vector to both the minima and maxima of the box.
Subtracts the specified two-dimensional vector from both the minima and maxima of the box.
Divides both the minima and maxima of the box by the specified value.
|
inline |
Check equality.
Sets the extents of the bounding box to the specified values.
min_ | The minima of the bounding box. |
max_ | The maxima of the bounding box. |
Resizes this bounding box to contain only the grid cells that are common to both box_1 and box_2.
This has the following results:
|
inline |
Sets the maxima of the bounding box to the specified coordinates.
|
inline |
Sets the minima of the bounding box to the specified coordinates.
Sets the extents of the bounding box to the specified values.
min_ | The minima of the bounding box. |
max_ | The maxima of the bounding box. |
|
friend |
Swaps the endianness of the data in the specified object.
This function allows this type of object to be serialized through the blob framework.
The first parameter specifies the target endianness, and the second parameter provides the object whose data is to be swapped.