Nori

TBoundingBox< _PointType > Struct Template Reference

Generic n-dimensional bounding box data structure. More...

#include <bbox.h>

List of all members.

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.

Detailed Description

template<typename _PointType>
struct TBoundingBox< _PointType >

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));
Template Parameters:
TThe underlying point data type (e.g. Point2d)

Definition at line 42 of file bbox.h.


Member Typedef Documentation

template<typename _PointType>
typedef _PointType TBoundingBox< _PointType >::PointType

Definition at line 47 of file bbox.h.

template<typename _PointType>
typedef PointType::Scalar TBoundingBox< _PointType >::Scalar

Definition at line 48 of file bbox.h.

template<typename _PointType>
typedef PointType::VectorType TBoundingBox< _PointType >::VectorType

Definition at line 49 of file bbox.h.


Member Enumeration Documentation

template<typename _PointType>
anonymous enum
Enumerator:
Dimension 

Definition at line 43 of file bbox.h.


Constructor & Destructor Documentation

template<typename _PointType>
TBoundingBox< _PointType >::TBoundingBox ( ) [inline]

Create a new invalid bounding box.

Initializes the components of the minimum and maximum position to $\infty$ and $-\infty$, respectively.

Definition at line 58 of file bbox.h.

template<typename _PointType>
TBoundingBox< _PointType >::TBoundingBox ( const PointType p) [inline]

Create a collapsed bounding box from a single point.

Definition at line 63 of file bbox.h.

template<typename _PointType>
TBoundingBox< _PointType >::TBoundingBox ( const PointType min,
const PointType max 
) [inline]

Create a bounding box from two positions.

Definition at line 67 of file bbox.h.


Member Function Documentation

template<typename _PointType>
void TBoundingBox< _PointType >::clip ( const TBoundingBox< _PointType > &  bbox) [inline]

Clip to another bounding box.

Definition at line 270 of file bbox.h.

template<typename _PointType>
bool TBoundingBox< _PointType >::contains ( const PointType p,
bool  strict = false 
) const [inline]

Check whether a point lies on or inside the bounding box.

Parameters:
pThe point to be tested
strictSet this parameter to true if the bounding box boundary should be excluded in the test

Definition at line 115 of file bbox.h.

template<typename _PointType>
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= $\infty$ and max= $-\infty$) does not cover any space. Hence, this method will always return true when given such an argument.

Parameters:
strictSet this parameter to true if the bounding box boundary should be excluded in the test

Definition at line 136 of file bbox.h.

template<typename _PointType>
Scalar TBoundingBox< _PointType >::distanceTo ( const PointType p) const [inline]

Calculate the smallest distance between the axis-aligned bounding box and the point p.

Definition at line 187 of file bbox.h.

template<typename _PointType>
Scalar TBoundingBox< _PointType >::distanceTo ( const TBoundingBox< _PointType > &  bbox) const [inline]

Calculate the smallest distance between the axis-aligned bounding box and bbox.

Definition at line 214 of file bbox.h.

template<typename _PointType>
void TBoundingBox< _PointType >::expandBy ( const PointType p) [inline]

Expand the bounding box to contain another point.

Definition at line 288 of file bbox.h.

template<typename _PointType>
void TBoundingBox< _PointType >::expandBy ( const TBoundingBox< _PointType > &  bbox) [inline]

Expand the bounding box to contain another bounding box.

Definition at line 294 of file bbox.h.

template<typename _PointType>
PointType TBoundingBox< _PointType >::getCenter ( ) const [inline]

Return the center point.

Definition at line 103 of file bbox.h.

template<typename _PointType>
PointType TBoundingBox< _PointType >::getCorner ( int  index) const [inline]

Return the position of a bounding box corner.

Definition at line 300 of file bbox.h.

template<typename _PointType>
VectorType TBoundingBox< _PointType >::getExtents ( ) const [inline]

Calculate the bounding box extents.

Returns:
max-min

Definition at line 265 of file bbox.h.

template<typename _PointType>
int TBoundingBox< _PointType >::getMajorAxis ( ) const [inline]

Return the dimension index with the largest associated side length.

Definition at line 242 of file bbox.h.

template<typename _PointType>
int TBoundingBox< _PointType >::getMinorAxis ( ) const [inline]

Return the dimension index with the shortest associated side length.

Definition at line 252 of file bbox.h.

template<typename _PointType>
float TBoundingBox< _PointType >::getSurfaceArea ( ) const [inline]

Calculate the n-1 dimensional volume of the boundary.

Definition at line 87 of file bbox.h.

template<typename _PointType>
Scalar TBoundingBox< _PointType >::getVolume ( ) const [inline]

Calculate the n-dimensional volume of the bounding box.

Definition at line 82 of file bbox.h.

template<typename _PointType>
bool TBoundingBox< _PointType >::hasVolume ( ) const [inline]

Check whether this bounding box has any associated volume.

Definition at line 237 of file bbox.h.

template<typename _PointType>
bool TBoundingBox< _PointType >::isPoint ( ) const [inline]

Check whether this bounding box has collapsed to a single point.

Definition at line 232 of file bbox.h.

template<typename _PointType>
bool TBoundingBox< _PointType >::isValid ( ) const [inline]

Check whether this is a valid bounding box.

A bounding box bbox is valid when

 bbox.min[dim] <= bbox.max[dim]

holds along each dimension dim.

Definition at line 227 of file bbox.h.

template<typename _PointType>
bool TBoundingBox< _PointType >::operator!= ( const TBoundingBox< _PointType > &  bbox) const [inline]

Test for inequality against another bounding box.

Definition at line 77 of file bbox.h.

template<typename _PointType>
bool TBoundingBox< _PointType >::operator== ( const TBoundingBox< _PointType > &  bbox) const [inline]

Test for equality against another bounding box.

Definition at line 72 of file bbox.h.

template<typename _PointType>
bool TBoundingBox< _PointType >::overlaps ( const TBoundingBox< _PointType > &  bbox,
bool  strict = false 
) const [inline]

Check two axis-aligned bounding boxes for possible overlap.

Parameters:
strictSet this parameter to true if the bounding box boundary should be excluded in the test
Returns:
true If overlap was detected.

Definition at line 154 of file bbox.h.

template<typename _PointType>
bool TBoundingBox< _PointType >::rayIntersect ( const TRay< PointType, VectorType > &  ray,
Scalar nearT,
Scalar farT 
) const [inline]

Calculate the near and far ray-box intersection points (if they exist).

Also returns intersections along the negative ray direction.

Definition at line 324 of file bbox.h.

template<typename _PointType>
void TBoundingBox< _PointType >::reset ( ) [inline]

Mark the bounding box as invalid.

This operation sets the components of the minimum and maximum position to $\infty$ and $-\infty$, respectively.

Definition at line 282 of file bbox.h.

template<typename _PointType>
Scalar TBoundingBox< _PointType >::squaredDistanceTo ( const TBoundingBox< _PointType > &  bbox) const [inline]

Calculate the smallest square distance between the axis-aligned bounding box and bbox.

Definition at line 195 of file bbox.h.

template<typename _PointType>
Scalar TBoundingBox< _PointType >::squaredDistanceTo ( const PointType p) const [inline]

Calculate the smallest squared distance between the axis-aligned bounding box and the point p.

Definition at line 168 of file bbox.h.

template<typename _PointType>
QString TBoundingBox< _PointType >::toString ( ) const [inline]

Return a string representation of the bounding box.

Definition at line 308 of file bbox.h.


Member Data Documentation

template<typename _PointType>
PointType TBoundingBox< _PointType >::max

Component-wise maximum.

Definition at line 359 of file bbox.h.

template<typename _PointType>
PointType TBoundingBox< _PointType >::min

Component-wise minimum.

Definition at line 358 of file bbox.h.


The documentation for this struct was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines