Nori
|
Generic n-dimensional bounding box data structure. More...
#include <bbox.h>
Public Types | |
enum | { Dimension = _PointType::Dimension } |
typedef _PointType | PointType |
typedef PointType::Scalar | Scalar |
typedef PointType::VectorType | VectorType |
Public Member Functions | |
TBoundingBox () | |
Create a new invalid bounding box. | |
TBoundingBox (const PointType &p) | |
Create a collapsed bounding box from a single point. | |
TBoundingBox (const PointType &min, const PointType &max) | |
Create a bounding box from two positions. | |
bool | operator== (const TBoundingBox &bbox) const |
Test for equality against another bounding box. | |
bool | operator!= (const TBoundingBox &bbox) const |
Test for inequality against another bounding box. | |
Scalar | getVolume () const |
Calculate the n-dimensional volume of the bounding box. | |
float | getSurfaceArea () const |
Calculate the n-1 dimensional volume of the boundary. | |
PointType | getCenter () const |
Return the center point. | |
bool | contains (const PointType &p, bool strict=false) const |
Check whether a point lies on or inside the bounding box. | |
bool | contains (const TBoundingBox &bbox, bool strict=false) const |
Check whether a specified bounding box lies on or within the current bounding box. | |
bool | overlaps (const TBoundingBox &bbox, bool strict=false) const |
Check two axis-aligned bounding boxes for possible overlap. | |
Scalar | squaredDistanceTo (const PointType &p) const |
Calculate the smallest squared distance between the axis-aligned bounding box and the point p . | |
Scalar | distanceTo (const PointType &p) const |
Calculate the smallest distance between the axis-aligned bounding box and the point p . | |
Scalar | squaredDistanceTo (const TBoundingBox &bbox) const |
Calculate the smallest square distance between the axis-aligned bounding box and bbox . | |
Scalar | distanceTo (const TBoundingBox &bbox) const |
Calculate the smallest distance between the axis-aligned bounding box and bbox . | |
bool | isValid () const |
Check whether this is a valid bounding box. | |
bool | isPoint () const |
Check whether this bounding box has collapsed to a single point. | |
bool | hasVolume () const |
Check whether this bounding box has any associated volume. | |
int | getMajorAxis () const |
Return the dimension index with the largest associated side length. | |
int | getMinorAxis () const |
Return the dimension index with the shortest associated side length. | |
VectorType | getExtents () const |
Calculate the bounding box extents. | |
void | clip (const TBoundingBox &bbox) |
Clip to another bounding box. | |
void | reset () |
Mark the bounding box as invalid. | |
void | expandBy (const PointType &p) |
Expand the bounding box to contain another point. | |
void | expandBy (const TBoundingBox &bbox) |
Expand the bounding box to contain another bounding box. | |
PointType | getCorner (int index) const |
Return the position of a bounding box corner. | |
QString | toString () const |
Return a string representation of the bounding box. | |
bool | rayIntersect (const TRay< PointType, VectorType > &ray, Scalar &nearT, Scalar &farT) const |
Calculate the near and far ray-box intersection points (if they exist). | |
Public Attributes | |
PointType | min |
Component-wise minimum. | |
PointType | max |
Component-wise maximum. |
Generic n-dimensional bounding box data structure.
Maintains a minimum and maximum position along each dimension and provides various convenience functions for querying and modifying them.
This class is parameterized by the underlying point data structure, which permits the use of different scalar types and dimensionalities, e.g.
TBoundingBox<Vector3i> integerBBox(Point3i(0, 1, 3), Point3i(4, 5, 6)); TBoundingBox<Vector2d> doubleBBox(Point2d(0.0, 1.0), Point2d(4.0, 5.0));
T | The underlying point data type (e.g. Point2d ) |
typedef _PointType TBoundingBox< _PointType >::PointType |
typedef PointType::Scalar TBoundingBox< _PointType >::Scalar |
typedef PointType::VectorType TBoundingBox< _PointType >::VectorType |
anonymous enum |
TBoundingBox< _PointType >::TBoundingBox | ( | ) | [inline] |
TBoundingBox< _PointType >::TBoundingBox | ( | const PointType & | p | ) | [inline] |
TBoundingBox< _PointType >::TBoundingBox | ( | const PointType & | min, |
const PointType & | max | ||
) | [inline] |
void TBoundingBox< _PointType >::clip | ( | const TBoundingBox< _PointType > & | bbox | ) | [inline] |
bool TBoundingBox< _PointType >::contains | ( | const PointType & | p, |
bool | strict = false |
||
) | const [inline] |
bool TBoundingBox< _PointType >::contains | ( | const TBoundingBox< _PointType > & | bbox, |
bool | strict = false |
||
) | const [inline] |
Check whether a specified bounding box lies on or within the current bounding box.
Note that by definition, an 'invalid' bounding box (where min= and max=
) does not cover any space. Hence, this method will always return true when given such an argument.
strict | Set this parameter to true if the bounding box boundary should be excluded in the test |
Scalar TBoundingBox< _PointType >::distanceTo | ( | const PointType & | p | ) | const [inline] |
Scalar TBoundingBox< _PointType >::distanceTo | ( | const TBoundingBox< _PointType > & | bbox | ) | const [inline] |
void TBoundingBox< _PointType >::expandBy | ( | const PointType & | p | ) | [inline] |
void TBoundingBox< _PointType >::expandBy | ( | const TBoundingBox< _PointType > & | bbox | ) | [inline] |
PointType TBoundingBox< _PointType >::getCenter | ( | ) | const [inline] |
PointType TBoundingBox< _PointType >::getCorner | ( | int | index | ) | const [inline] |
VectorType TBoundingBox< _PointType >::getExtents | ( | ) | const [inline] |
int TBoundingBox< _PointType >::getMajorAxis | ( | ) | const [inline] |
int TBoundingBox< _PointType >::getMinorAxis | ( | ) | const [inline] |
float TBoundingBox< _PointType >::getSurfaceArea | ( | ) | const [inline] |
Scalar TBoundingBox< _PointType >::getVolume | ( | ) | const [inline] |
bool TBoundingBox< _PointType >::hasVolume | ( | ) | const [inline] |
bool TBoundingBox< _PointType >::isPoint | ( | ) | const [inline] |
bool TBoundingBox< _PointType >::isValid | ( | ) | const [inline] |
bool TBoundingBox< _PointType >::operator!= | ( | const TBoundingBox< _PointType > & | bbox | ) | const [inline] |
bool TBoundingBox< _PointType >::operator== | ( | const TBoundingBox< _PointType > & | bbox | ) | const [inline] |
bool TBoundingBox< _PointType >::overlaps | ( | const TBoundingBox< _PointType > & | bbox, |
bool | strict = false |
||
) | const [inline] |
bool TBoundingBox< _PointType >::rayIntersect | ( | const TRay< PointType, VectorType > & | ray, |
Scalar & | nearT, | ||
Scalar & | farT | ||
) | const [inline] |
void TBoundingBox< _PointType >::reset | ( | ) | [inline] |
Scalar TBoundingBox< _PointType >::squaredDistanceTo | ( | const TBoundingBox< _PointType > & | bbox | ) | const [inline] |
Scalar TBoundingBox< _PointType >::squaredDistanceTo | ( | const PointType & | p | ) | const [inline] |
QString TBoundingBox< _PointType >::toString | ( | ) | const [inline] |
PointType TBoundingBox< _PointType >::max |
PointType TBoundingBox< _PointType >::min |