Ocean
|
This class implements a 2D bounding box with pixel precision. More...
Public Member Functions | |
PixelBoundingBoxT () | |
Creates a empty bounding box. More... | |
PixelBoundingBoxT (const PixelBoundingBoxT< T > &boundingBox) | |
Copy constructor. More... | |
PixelBoundingBoxT (const PixelPositionT< T > &point) | |
Creates a bounding box covering one point only. More... | |
PixelBoundingBoxT (const std::vector< PixelPositionT< T >> &points) | |
Creates a bounding box covering several points. More... | |
PixelBoundingBoxT (const T left, const T top, const T right, const T bottom) | |
Creates a bounding box with specified dimension. More... | |
PixelBoundingBoxT (const PixelPositionT< T > &topLeft, const unsigned int width, const unsigned int height) | |
Creates a bounding box by a given top left position and a width and height of the bounding box. More... | |
PixelBoundingBoxT (const PixelPositionT< T > &point0, const PixelPositionT< T > &point1) | |
Creates a bounding box covering two points. More... | |
T | left () const |
Returns the left (including) pixel position of this bounding box. More... | |
T | top () const |
Returns the top (including) pixel position of this bounding box. More... | |
T | right () const |
Returns the right (including) pixel position of this bounding box. More... | |
T | rightEnd () const |
Returns the right (excluding) pixel position of this bounding box. More... | |
T | bottom () const |
Returns the bottom (including) position of this bounding box. More... | |
T | bottomEnd () const |
Returns the bottom (excluding) pixel position of this bounding box. More... | |
PixelPositionT< T > | topLeft () const |
Returns the top left corner of this bounding box. More... | |
PixelPositionT< T > | topRight () const |
Returns the top right corner of this bounding box. More... | |
PixelPositionT< T > | bottomLeft () const |
Returns the bottom left corner of this bounding box. More... | |
PixelPositionT< T > | bottomRight () const |
Returns the bottom right corner of this bounding box. More... | |
unsigned int | width () const |
Returns the width (the number of horizontal including pixels) of this bounding box. More... | |
unsigned int | height () const |
Returns the height (the number of vertical including pixels) of this bounding box. More... | |
unsigned int | size () const |
Returns the area (the number of including pixels) this bounding box covers. More... | |
bool | isInside (const PixelPositionT< T > &point) const |
Returns whether a given point lies inside this bounding box. More... | |
bool | isInside (const PixelBoundingBoxT< T > &boundingBox) const |
Returns whether a given bounding box lies entirely inside this bounding box. More... | |
bool | hasIntersection (const PixelBoundingBoxT< T > &boundingBox) const |
Returns whether a given bounding box has an intersection with this bounding box. More... | |
bool | isTouching (const PixelBoundingBoxT< T > &boundingBox, const bool useNeighborhood8) const |
Returns whether a given bounding box is touching this bounding box. More... | |
PixelBoundingBoxT< T > | extended (const unsigned int pixels, const T minLeft, const T minTop, const T maxRight, const T maxBottom) const |
Returns a new bounding box by extending this bounding box with a given number of pixel in each direction. More... | |
bool | isValid () const |
Returns whether this bounding box covers a valid pixel area. More... | |
PixelBoundingBoxT< T > & | operator+= (const PixelPositionT< T > &point) |
Adds a new point to the bounding box. More... | |
PixelBoundingBoxT< T > & | operator= (const PixelBoundingBoxT< T > &other)=default |
Assignment operator override to match copy constructor. More... | |
bool | operator== (const PixelBoundingBoxT< T > &box) const |
Returns whether two bounding boxes are equal. More... | |
bool | operator!= (const PixelBoundingBoxT< T > &box) const |
Returns whether two bounding boxes are not equal. More... | |
PixelBoundingBoxT< T > | operator* (const T factor) const |
Multiplies this bounding box by a specified scalar (multiplies left, top, right, and bottom location by the scalar). More... | |
PixelBoundingBoxT< T > & | operator*= (const T factor) |
Multiplies this bounding box by a specified scalar (multiplies left, top, right, and bottom location by the scalar). More... | |
PixelBoundingBoxT< T > | operator/ (const T factor) const |
Divides this bounding box by a specified scalar (divides left, top, right, and bottom location by the scalar). More... | |
PixelBoundingBoxT< T > & | operator/= (const T factor) |
Divides this bounding box by a specified scalar (divides left, top, right, and bottom location by the scalar). More... | |
PixelBoundingBoxT< T > | operator|| (const PixelBoundingBoxT< T > &box) const |
Returns the union of two bounding boxes. More... | |
PixelBoundingBoxT< T > | operator&& (const PixelBoundingBoxT< T > &box) const |
Returns the intersection of two bounding boxes. More... | |
size_t | operator() (const PixelBoundingBoxT< T > &boundingBox) const |
Hash function. More... | |
operator bool () const | |
Returns whether this bounding box covers a valid pixel area. More... | |
Private Attributes | |
T | left_ |
Left (including) pixel position of this bounding box. More... | |
T | top_ |
Top (including) pixel position of this bounding box. More... | |
T | right_ |
Right (including) pixel position of this bounding box. More... | |
T | bottom_ |
Bottom (including) pixel position of this bounding box. More... | |
This class implements a 2D bounding box with pixel precision.
|
inline |
Creates a empty bounding box.
|
inline |
Copy constructor.
boundingBox | The bounding box to copy |
|
inlineexplicit |
Creates a bounding box covering one point only.
point | The point the box will cover |
|
inlineexplicit |
Creates a bounding box covering several points.
points | The points the box will cover |
|
inline |
Creates a bounding box with specified dimension.
left | Left (including) pixel position |
top | Top (including) pixel position |
right | Right (including) pixel position, with range [left, infinity) to create a valid bounding box |
bottom | Bottom (including) pixel position, with range [top, infinity) to create a valid bounding box |
|
inline |
Creates a bounding box by a given top left position and a width and height of the bounding box.
topLeft | Top left position of the box |
width | The width of the bounding box in pixel with range [1, infinity) |
height | The height of the bounding box in pixel, with range [1, infinity) |
|
inline |
Creates a bounding box covering two points.
point0 | The first point that will be converted by the bounding box |
point1 | The second point that will be converted by the bounding box |
|
inline |
Returns the bottom (including) position of this bounding box.
|
inline |
Returns the bottom (excluding) pixel position of this bounding box.
|
inline |
Returns the bottom left corner of this bounding box.
|
inline |
Returns the bottom right corner of this bounding box.
|
inline |
Returns a new bounding box by extending this bounding box with a given number of pixel in each direction.
pixels | Number of pixels to be added to each bounding box boundary |
minLeft | Minimal (including) left boundary, with minLeft <= left() |
minTop | Minimal (including) top boundary, with minTop <= top() |
maxRight | Minimal (including) right boundary, with maxRight >= right() |
maxBottom | Minimal (including) bottom boundary, with maxBottom >= bottom() |
|
inline |
Returns whether a given bounding box has an intersection with this bounding box.
boundingBox | The bounding box to be checked, must be valid |
|
inline |
Returns the height (the number of vertical including pixels) of this bounding box.
|
inline |
Returns whether a given bounding box lies entirely inside this bounding box.
boundingBox | The bounding box to be checked, must be valid |
|
inline |
Returns whether a given point lies inside this bounding box.
point | The point to be checked, must be valid |
|
inline |
Returns whether a given bounding box is touching this bounding box.
Two bounding boxes are touching if both boxes are intersecting or if both boxes have a touching edge.
When two bounding boxes are touching at the corners, the 'useNeighborhood4' property defines whether both boxes count as touching or not.
boundingBox | The bounding box to be checked, must be valid |
useNeighborhood8 | True, to use a 8-neighborhood during the check; False, to use an 4-neighborhood during the check |
|
inline |
Returns whether this bounding box covers a valid pixel area.
|
inline |
Returns the left (including) pixel position of this bounding box.
|
inlineexplicit |
Returns whether this bounding box covers a valid pixel area.
|
inline |
Returns whether two bounding boxes are not equal.
box | Second bounding box |
|
inline |
Returns the intersection of two bounding boxes.
Beware: The intersection between a valid and an invalid bounding box is an invalid bounding box.
box | Second bounding box |
|
inline |
Hash function.
boundingBox | The bounding box for which the hash value will be determined |
|
inline |
Multiplies this bounding box by a specified scalar (multiplies left, top, right, and bottom location by the scalar).
factor | The multiplication factor, with range (-infinity, infinity) |
|
inline |
Multiplies this bounding box by a specified scalar (multiplies left, top, right, and bottom location by the scalar).
factor | The multiplication factor, with range (-infinity, infinity) |
|
inline |
Adds a new point to the bounding box.
If the point lies inside the bounding box the box is unchanged, otherwise the box will be extended
point | The point extending the box |
|
inline |
Divides this bounding box by a specified scalar (divides left, top, right, and bottom location by the scalar).
factor | The division factor, with range (-infinity, infinity) \ {0} |
|
inline |
Divides this bounding box by a specified scalar (divides left, top, right, and bottom location by the scalar).
factor | The division factor, with range (-infinity, infinity) \ {0} |
|
inlinedefault |
Assignment operator override to match copy constructor.
|
inline |
Returns whether two bounding boxes are equal.
box | Second bounding box |
|
inline |
Returns the union of two bounding boxes.
box | Second bounding box |
|
inline |
Returns the right (including) pixel position of this bounding box.
|
inline |
Returns the right (excluding) pixel position of this bounding box.
|
inline |
Returns the area (the number of including pixels) this bounding box covers.
If this bounding box is invalid, than zero is returned.
|
inline |
Returns the top (including) pixel position of this bounding box.
|
inline |
Returns the top left corner of this bounding box.
|
inline |
Returns the top right corner of this bounding box.
|
inline |
Returns the width (the number of horizontal including pixels) of this bounding box.
|
private |
Bottom (including) pixel position of this bounding box.
|
private |
Left (including) pixel position of this bounding box.
|
private |
Right (including) pixel position of this bounding box.
|
private |
Top (including) pixel position of this bounding box.