GfBBox3d Class Reference

Basic type: arbitrarily oriented 3D bounding box. More...

Public Member Functions

 GfBBox3d ()
 The default constructor leaves the box empty, the transformation matrix identity, and the zero-areaprimitives flag" false. More...
 
 GfBBox3d (const GfBBox3d &rhs)
 Copy constructor. More...
 
 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)
 Sets the transformation matrix only. More...
 
void SetRange (const GfRange3d &box)
 Sets the range of the axis-aligned box only. More...
 
const GfRange3dGetRange () const
 Returns the range of the axis-aligned untransformed box. More...
 
const GfRange3dGetBox () const
 Returns the range of the axis-aligned untransformed box. More...
 
const GfMatrix4dGetMatrix () const
 Returns the transformation matrix. More...
 
const GfMatrix4dGetInverseMatrix () const
 Returns the inverse of the transformation matrix. More...
 
void SetHasZeroAreaPrimitives (bool hasThem)
 Sets the zero-area primitives flag to the given value. More...
 
bool HasZeroAreaPrimitives () const
 Returns the current state of the zero-areaprimitives flag". More...
 
GF_API double GetVolume () const
 Returns the volume of the box (0 for an empty box). More...
 
void Transform (const GfMatrix4d &matrix)
 Transforms the bounding box by the given matrix, which is assumed to be a global transformation to apply to the box. More...
 
GF_API GfRange3d 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. More...
 
GfRange3d ComputeAlignedBox () const
 Returns the axis-aligned range (as a GfRange3d) that results from applying the transformation matrix to the axis-aligned box and aligning the result. More...
 
GF_API GfVec3d ComputeCentroid () const
 Returns the centroid of the bounding box. More...
 
bool operator== (const GfBBox3d &b) const
 Component-wise equality test. More...
 
bool operator != (const GfBBox3d &that) const
 Component-wise inequality test. More...
 

Static Public Member Functions

static GF_API GfBBox3d Combine (const GfBBox3d &b1, const GfBBox3d &b2)
 Combines two bboxes, returning a new bbox that contains both. More...
 

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() [1/4]

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() [2/4]

GfBBox3d ( const GfBBox3d rhs)
inline

Copy constructor.

Definition at line 99 of file bbox3d.h.

◆ GfBBox3d() [3/4]

GfBBox3d ( const GfRange3d box)
inline

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

Definition at line 108 of file bbox3d.h.

◆ GfBBox3d() [4/4]

GfBBox3d ( const GfRange3d box,
const GfMatrix4d matrix 
)
inline

This constructor takes a box and a transformation matrix.

Definition at line 117 of file bbox3d.h.

Member Function Documentation

◆ Combine()

static GF_API 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.

◆ ComputeAlignedBox()

GfRange3d 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 195 of file bbox3d.h.

◆ ComputeAlignedRange()

GF_API GfRange3d 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.

◆ ComputeCentroid()

GF_API GfVec3d ComputeCentroid ( ) const

Returns the centroid of the bounding box.

The centroid is computed as the transformed centroid of the range.

◆ GetBox()

const GfRange3d& GetBox ( ) const
inline

Returns the range of the axis-aligned untransformed box.

This synonym of GetRange exists for compatibility purposes.

Definition at line 147 of file bbox3d.h.

◆ GetInverseMatrix()

const GfMatrix4d& 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 158 of file bbox3d.h.

◆ GetMatrix()

const GfMatrix4d& GetMatrix ( ) const
inline

Returns the transformation matrix.

Definition at line 152 of file bbox3d.h.

◆ GetRange()

const GfRange3d& GetRange ( ) const
inline

Returns the range of the axis-aligned untransformed box.

Definition at line 141 of file bbox3d.h.

◆ GetVolume()

GF_API double GetVolume ( ) const

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

◆ HasZeroAreaPrimitives()

bool HasZeroAreaPrimitives ( ) const
inline

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

Definition at line 170 of file bbox3d.h.

◆ operator !=()

bool 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 232 of file bbox3d.h.

◆ operator==()

bool 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 223 of file bbox3d.h.

◆ Set()

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

Sets the axis-aligned box and transformation matrix.

Definition at line 123 of file bbox3d.h.

◆ SetHasZeroAreaPrimitives()

void SetHasZeroAreaPrimitives ( bool  hasThem)
inline

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

Definition at line 164 of file bbox3d.h.

◆ SetMatrix()

void SetMatrix ( const GfMatrix4d matrix)
inline

Sets the transformation matrix only.

The axis-aligned box is not modified.

Definition at line 130 of file bbox3d.h.

◆ SetRange()

void SetRange ( const GfRange3d box)
inline

Sets the range of the axis-aligned box only.

The transformation matrix is not modified.

Definition at line 136 of file bbox3d.h.

◆ Transform()

void 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 181 of file bbox3d.h.

Friends And Related Function Documentation

◆ hash_value

size_t hash_value ( const GfBBox3d b)
friend

Hash.

Definition at line 212 of file bbox3d.h.


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