HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GfBBox3d Class Reference

#include <bbox3d.h>

Public Member Functions

 GfBBox3d ()
 
 GfBBox3d (const GfRange3d &box)
 This constructor takes a box and sets the matrix to identity. More...
 
 GfBBox3d (const GfRange3d &box, const GfMatrix4d &matrix)
 This constructor takes a box and a transformation matrix. More...
 
void Set (const GfRange3d &box, const GfMatrix4d &matrix)
 Sets the axis-aligned box and transformation matrix. More...
 
void SetMatrix (const GfMatrix4d &matrix)
 
void SetRange (const GfRange3d &box)
 
const GfRange3dGetRange () const
 Returns the range of the axis-aligned untransformed box. More...
 
const GfRange3dGetBox () const
 
const GfMatrix4dGetMatrix () const
 Returns the transformation matrix. More...
 
const GfMatrix4dGetInverseMatrix () const
 
void SetHasZeroAreaPrimitives (bool hasThem)
 
bool HasZeroAreaPrimitives () const
 
GF_API double GetVolume () const
 Returns the volume of the box (0 for an empty box). More...
 
void Transform (const GfMatrix4d &matrix)
 
GF_API GfRange3d ComputeAlignedRange () const
 
GfRange3d ComputeAlignedBox () const
 
GF_API GfVec3d ComputeCentroid () const
 
bool operator== (const GfBBox3d &b) const
 
bool operator!= (const GfBBox3d &that) const
 

Static Public Member Functions

static GF_API GfBBox3d Combine (const GfBBox3d &b1, const GfBBox3d &b2)
 

Friends

size_t hash_value (const GfBBox3d &b)
 Hash. More...
 

Detailed Description

Basic type: arbitrarily oriented 3D bounding box.

This class represents a three-dimensional bounding box as an axis-aligned box (GfRange3d) and a matrix (GfMatrix4d) to transform it into the correct space.

A GfBBox3d is more useful than using just GfRange3d instances (which are always axis-aligned) for these reasons:

  • When an axis-aligned bounding box is transformed several times, each transformation can result in inordinate growth of the bounding box. By storing the transformation separately, it can be applied once at the end, resulting in a much better fit. For example, if the bounding box at the leaf of a scene graph is transformed through several levels of the graph hierarchy to the coordinate space at the root, a GfBBox3d is generally much smaller than the GfRange3d computed by transforming the box at each level.
  • When two or more such bounding boxes are combined, having the transformations stored separately means that there is a better opportunity to choose a better coordinate space in which to combine the boxes.

The Zero-area Primitives Flag

When bounding boxes are used in intersection test culling, it is sometimes useful to extend them a little bit to allow lower-dimensional objects with zero area, such as lines and points, to be intersected. For example, consider a cube constructed of line segments. The bounding box for this shape fits the cube exactly. If an application wants to allow a near-miss of the silhouette edges of the cube to be considered an intersection, it has to loosen the bbox culling test a little bit.

To distinguish when this loosening is necessary, each GfBBox3d instance maintains a flag indicating whether any zero-area primitives are contained within it. The application is responsible for setting this flag correctly by calling SetHasZeroAreaPrimitives(). The flag can be accessed during intersection tests by calling HasZeroAreaPrimitives(). This flag is set by default in all constructors to false.

Definition at line 84 of file bbox3d.h.

Constructor & Destructor Documentation

GfBBox3d::GfBBox3d ( )
inline

The default constructor leaves the box empty, the transformation matrix identity, and the zero-areaprimitives flag" false.

Definition at line 91 of file bbox3d.h.

GfBBox3d::GfBBox3d ( const GfRange3d box)
inline

This constructor takes a box and sets the matrix to identity.

Definition at line 99 of file bbox3d.h.

GfBBox3d::GfBBox3d ( const GfRange3d box,
const GfMatrix4d matrix 
)
inline

This constructor takes a box and a transformation matrix.

Definition at line 108 of file bbox3d.h.

Member Function Documentation

static GF_API GfBBox3d GfBBox3d::Combine ( const GfBBox3d b1,
const GfBBox3d b2 
)
static

Combines two bboxes, returning a new bbox that contains both. This uses the coordinate space of one of the two original boxes as the space of the result; it uses the one that produces whe smaller of the two resulting boxes.

GfRange3d GfBBox3d::ComputeAlignedBox ( ) const
inline

Returns the axis-aligned range (as a GfRange3d) that results from applying the transformation matrix to the axis-aligned box and aligning the result. This synonym for ComputeAlignedRange exists for compatibility purposes.

Definition at line 186 of file bbox3d.h.

GF_API GfRange3d GfBBox3d::ComputeAlignedRange ( ) const

Returns the axis-aligned range (as a GfRange3d) that results from applying the transformation matrix to the wxis-aligned box and aligning the result.

GF_API GfVec3d GfBBox3d::ComputeCentroid ( ) const

Returns the centroid of the bounding box. The centroid is computed as the transformed centroid of the range.

const GfRange3d& GfBBox3d::GetBox ( ) const
inline

Returns the range of the axis-aligned untransformed box. This synonym of GetRange exists for compatibility purposes.

Definition at line 138 of file bbox3d.h.

const GfMatrix4d& GfBBox3d::GetInverseMatrix ( ) const
inline

Returns the inverse of the transformation matrix. This will be the identity matrix if the transformation matrix is not invertible.

Definition at line 149 of file bbox3d.h.

const GfMatrix4d& GfBBox3d::GetMatrix ( ) const
inline

Returns the transformation matrix.

Definition at line 143 of file bbox3d.h.

const GfRange3d& GfBBox3d::GetRange ( ) const
inline

Returns the range of the axis-aligned untransformed box.

Definition at line 132 of file bbox3d.h.

GF_API double GfBBox3d::GetVolume ( ) const

Returns the volume of the box (0 for an empty box).

bool GfBBox3d::HasZeroAreaPrimitives ( ) const
inline

Returns the current state of the zero-areaprimitives flag".

Definition at line 161 of file bbox3d.h.

bool GfBBox3d::operator!= ( const GfBBox3d that) const
inline

Component-wise inequality test. The axis-aligned boxes and transformation matrices match exactly for bboxes to be considered equal. (To compare equality of the actual boxes, you can compute both aligned boxes and test the results for equality.)

Definition at line 223 of file bbox3d.h.

bool GfBBox3d::operator== ( const GfBBox3d b) const
inline

Component-wise equality test. The axis-aligned boxes and transformation matrices match exactly for bboxes to be considered equal. (To compare equality of the actual boxes, you can compute both aligned boxes and test the results for equality.)

Definition at line 214 of file bbox3d.h.

void GfBBox3d::Set ( const GfRange3d box,
const GfMatrix4d matrix 
)
inline

Sets the axis-aligned box and transformation matrix.

Definition at line 114 of file bbox3d.h.

void GfBBox3d::SetHasZeroAreaPrimitives ( bool  hasThem)
inline

Sets the zero-area primitives flag to the given value.

Definition at line 155 of file bbox3d.h.

void GfBBox3d::SetMatrix ( const GfMatrix4d matrix)
inline

Sets the transformation matrix only. The axis-aligned box is not modified.

Definition at line 121 of file bbox3d.h.

void GfBBox3d::SetRange ( const GfRange3d box)
inline

Sets the range of the axis-aligned box only. The transformation matrix is not modified.

Definition at line 127 of file bbox3d.h.

void GfBBox3d::Transform ( const GfMatrix4d matrix)
inline

Transforms the bounding box by the given matrix, which is assumed to be a global transformation to apply to the box. Therefore, this just post-multiplies the box's matrix by matrix.

Definition at line 172 of file bbox3d.h.

Friends And Related Function Documentation

size_t hash_value ( const GfBBox3d b)
friend

Hash.

Definition at line 203 of file bbox3d.h.


The documentation for this class was generated from the following file: