UT_BoundingBox Class Reference

Axis-aligned bounding box (AABB). More...

#include <UT_BoundingBox.h>

List of all members.

Public Member Functions

 UT_BoundingBox ()
 UT_BoundingBox (fpreal axmin, fpreal aymin, fpreal azmin, fpreal axmax, fpreal aymax, fpreal azmax)
 UT_BoundingBox (const UT_Vector3 &lowerbound, const UT_Vector3 &upperbound)
float operator() (unsigned m, unsigned n) const
float & operator() (unsigned m, unsigned n)
bool operator== (const UT_BoundingBox &bbox) const
bool operator!= (const UT_BoundingBox &bbox) const
bool isEqual (const UT_BoundingBox &bbox, fpreal tol=UT_FTOLERANCE) const
fpreal xmin () const
fpreal xmax () const
fpreal ymin () const
fpreal ymax () const
fpreal zmin () const
fpreal zmax () const
UT_Vector3 minvec () const
UT_Vector3 maxvec () const
int isInside (const UT_Vector3 &pt) const
int isInside (const UT_Vector4 &pt) const
int isInside (fpreal x, fpreal y, fpreal z) const
int isInside (const UT_BoundingBox &bbox) const
int isLineInside (const UT_Vector3 &v0, const UT_Vector3 &v1) const
 Determine whether a line between v0 & v1 intersects the box.
bool isValid () const
 Check whether the bounding box contains at least one point.
void makeInvalid ()
void setBounds (fpreal x_min, fpreal y_min, fpreal z_min, fpreal x_max, fpreal y_max, fpreal z_max)
void initMaxBounds ()
 Initialize the box to the largest size.
void initBounds ()
void initBounds (const UT_Vector3 &min, const UT_Vector3 &max)
void initBounds (const UT_Vector3 &pt)
void initBounds (const UT_Vector4 &pt)
void initBounds (fpreal x, fpreal y, fpreal z)
void initBounds (const fpreal32 *v)
void initBounds (const fpreal64 *v)
void initBounds (const UT_BoundingBox &box)
void enlargeBounds (const UT_Vector3 &min, const UT_Vector3 &max)
void enlargeBounds (const UT_Vector3 &pt)
void enlargeBounds (const UT_Vector4 &pt)
void enlargeBounds (fpreal x, fpreal y, fpreal z)
void enlargeBounds (const fpreal32 *v)
void enlargeBounds (const fpreal64 *v)
void enlargeBounds (const UT_BoundingBox &box)
void enlargeBounds (fpreal percent=0.001F, fpreal min=0.001F)
void expandBounds (fpreal dltx, fpreal dlty, fpreal dlyz)
void enlargeFloats (int bits=1, fpreal min=1e-5F)
void clipBounds (const UT_BoundingBox &box)
 Find the intersections of two bounding boxes.
void splitLeft (UT_BoundingBox &box, int axis, fpreal split)
void splitRight (UT_BoundingBox &box, int axis, fpreal split)
void transform (const UT_Matrix4 &mat)
void transform (const UT_Matrix4 &mat, UT_BoundingBox &newbbox) const
void transform (const UT_DMatrix4 &mat)
void transform (const UT_DMatrix4 &mat, UT_BoundingBox &newbbox) const
void translate (const UT_Vector3 &delta)
 Adds the given translate to each component of the bounding box.
fpreal xsize () const
fpreal ysize () const
fpreal zsize () const
fpreal sizeX () const
fpreal sizeY () const
fpreal sizeZ () const
UT_Vector3 size () const
fpreal sizeAxis (int axis) const
fpreal sizeMax () const
 Return the size of the largest dimension.
fpreal sizeMax (int &axis) const
UT_Vector3 minDistDelta (const UT_Vector3 &p) const
UT_Vector3 minDistDelta (const UT_BoundingBox &box) const
fpreal minDist2 (const UT_Vector3 &p) const
fpreal minDist2 (const UT_BoundingBox &box) const
 Minimum disance between two bboxes squared.
fpreal getRadius () const
 Returns the radius of a sphere that would fully enclose the box.
int getOutCode (const UT_Vector3 &pt) const
 Finds the out code of the point relative to this box:.
fpreal xcenter () const
fpreal ycenter () const
fpreal zcenter () const
fpreal centerX () const
fpreal centerY () const
fpreal centerZ () const
fpreal centerAxis (int axis) const
UT_Vector3 center () const
fpreal area () const
fpreal volume () const
void addToMin (const UT_Vector3 &vec)
void addToMax (const UT_Vector3 &vec)
void scaleOffset (const UT_Vector3 &scale, const UT_Vector3 &offset)
 Scale then offset a bounding box.
int maxAxis () const
int minAxis () const
int intersectRay (const UT_Vector3 &org, const UT_Vector3 &dir, fpreal tmax=1E17F, float *distance=0, UT_Vector3 *nml=0) const
int intersectRange (const UT_Vector3 &org, const UT_Vector3 &dir, float &min, float &max) const
int intersectTube (const UT_Vector3 &org, const UT_Vector3 &dir, fpreal radius, fpreal tmin=-1E17f, fpreal tmax=1E17f) const
int intersects (const UT_BoundingBox &box) const
int computeIntersection (const UT_BoundingBox &box)
void getBBoxPoints (UT_Vector3(&ptarray)[8]) const
int getBBoxPoints (UT_Vector3(&ptarray)[8], const UT_Matrix4 &transform_matrix) const
int getBBoxPoints (UT_Vector3(&ptarray)[8], const UT_DMatrix4 &transform_matrix) const
void dump (const char *msg=0) const
 Dump the bounding box to stderr. The msg is printed before the bounds.
void dumpGeo (FILE *fp) const
 Dump the bounding box geometry to a draw file.
bool save (UT_JSONWriter &w) const
bool save (UT_JSONValue &v) const
bool load (UT_JSONParser &p)

Public Attributes

union {
   float   vals [3][2]
   float   myFloats [6]
}; 
 Here's the data for the bounding box.

Protected Member Functions

void outTo (ostream &os) const
void enlargeBoundsByPtArray (UT_Vector3(&ptarray)[8], bool init=false)

Friends

ostream & operator<< (ostream &os, const UT_BoundingBox &box)


Detailed Description

Axis-aligned bounding box (AABB).
Examples:

GR/GR_BoundingBox.C, SIM/SNOW_Solver.C, SIM/SNOW_Solver.h, SOP/SOP_Flatten.C, SOP/SOP_Surface.C, standalone/geoisosurface.C, standalone/i3dsphere.C, VRAY/VRAY_DemoBox.C, VRAY/VRAY_DemoBox.h, VRAY/VRAY_DemoFile.C, VRAY/VRAY_DemoFile.h, VRAY/VRAY_DemoMountain.C, VRAY/VRAY_DemoMountain.h, VRAY/VRAY_DemoSprite.C, VRAY/VRAY_DemoSprite.h, VRAY/VRAY_DemoStamp.C, VRAY/VRAY_DemoStamp.h, VRAY/VRAY_DemoVolumeSphere.C, and VRAY/VRAY_DemoVolumeSphere.h.

Definition at line 27 of file UT_BoundingBox.h.


Constructor & Destructor Documentation

UT_BoundingBox::UT_BoundingBox (  )  [inline]

Definition at line 29 of file UT_BoundingBox.h.

UT_BoundingBox::UT_BoundingBox ( fpreal  axmin,
fpreal  aymin,
fpreal  azmin,
fpreal  axmax,
fpreal  aymax,
fpreal  azmax 
) [inline]

Definition at line 32 of file UT_BoundingBox.h.

UT_BoundingBox::UT_BoundingBox ( const UT_Vector3 lowerbound,
const UT_Vector3 upperbound 
) [inline]

Definition at line 38 of file UT_BoundingBox.h.


Member Function Documentation

void UT_BoundingBox::addToMax ( const UT_Vector3 vec  ) 

void UT_BoundingBox::addToMin ( const UT_Vector3 vec  ) 

fpreal UT_BoundingBox::area (  )  const

UT_Vector3 UT_BoundingBox::center (  )  const [inline]

Definition at line 237 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::centerAxis ( int  axis  )  const [inline]

Definition at line 235 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::centerX (  )  const [inline]

Definition at line 232 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::centerY (  )  const [inline]

Definition at line 233 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::centerZ (  )  const [inline]

Definition at line 234 of file UT_BoundingBox.h.

void UT_BoundingBox::clipBounds ( const UT_BoundingBox box  ) 

Find the intersections of two bounding boxes.

int UT_BoundingBox::computeIntersection ( const UT_BoundingBox box  ) 

Changes the bounds to be those of the intersection of this box and the supplied BBox. Returns 1 if intersects, 0 otherwise.

void UT_BoundingBox::dump ( const char *  msg = 0  )  const

Dump the bounding box to stderr. The msg is printed before the bounds.

void UT_BoundingBox::dumpGeo ( FILE *  fp  )  const

Dump the bounding box geometry to a draw file.

void UT_BoundingBox::enlargeBounds ( fpreal  percent = 0.001F,
fpreal  min = 0.001F 
)

void UT_BoundingBox::enlargeBounds ( const UT_BoundingBox box  ) 

void UT_BoundingBox::enlargeBounds ( const fpreal64 v  )  [inline]

Definition at line 147 of file UT_BoundingBox.h.

void UT_BoundingBox::enlargeBounds ( const fpreal32 v  )  [inline]

Definition at line 145 of file UT_BoundingBox.h.

void UT_BoundingBox::enlargeBounds ( fpreal  x,
fpreal  y,
fpreal  z 
)

void UT_BoundingBox::enlargeBounds ( const UT_Vector4 pt  ) 

void UT_BoundingBox::enlargeBounds ( const UT_Vector3 pt  ) 

void UT_BoundingBox::enlargeBounds ( const UT_Vector3 min,
const UT_Vector3 max 
)

void UT_BoundingBox::enlargeBoundsByPtArray ( UT_Vector3(&)  ptarray[8],
bool  init = false 
) [protected]

void UT_BoundingBox::enlargeFloats ( int  bits = 1,
fpreal  min = 1e-5F 
)

Perform a minimal enlargement of the floating point values in this bounding box. This enlargement guarantees that the new floating point values are always different from the prior ones. The number of mantissa bits to be changed can be adjusted using the bits parameter, and a minimum enlargement amount can be specified in min.

void UT_BoundingBox::expandBounds ( fpreal  dltx,
fpreal  dlty,
fpreal  dlyz 
)

int UT_BoundingBox::getBBoxPoints ( UT_Vector3(&)  ptarray[8],
const UT_DMatrix4 transform_matrix 
) const

int UT_BoundingBox::getBBoxPoints ( UT_Vector3(&)  ptarray[8],
const UT_Matrix4 transform_matrix 
) const

void UT_BoundingBox::getBBoxPoints ( UT_Vector3(&)  ptarray[8]  )  const

int UT_BoundingBox::getOutCode ( const UT_Vector3 pt  )  const

Finds the out code of the point relative to this box:.

fpreal UT_BoundingBox::getRadius (  )  const [inline]

Returns the radius of a sphere that would fully enclose the box.

Definition at line 224 of file UT_BoundingBox.h.

void UT_BoundingBox::initBounds ( const UT_BoundingBox box  ) 

void UT_BoundingBox::initBounds ( const fpreal64 v  )  [inline]

Definition at line 137 of file UT_BoundingBox.h.

void UT_BoundingBox::initBounds ( const fpreal32 v  )  [inline]

Definition at line 135 of file UT_BoundingBox.h.

void UT_BoundingBox::initBounds ( fpreal  x,
fpreal  y,
fpreal  z 
)

void UT_BoundingBox::initBounds ( const UT_Vector4 pt  ) 

void UT_BoundingBox::initBounds ( const UT_Vector3 pt  ) 

void UT_BoundingBox::initBounds ( const UT_Vector3 min,
const UT_Vector3 max 
)

void UT_BoundingBox::initBounds (  ) 

Initialize the box such that

  • No points are contained in the box
  • The box occupies no position in space
Examples:
SIM/SNOW_Solver.C, standalone/i3dsphere.C, VRAY/VRAY_DemoBox.C, VRAY/VRAY_DemoMountain.C, VRAY/VRAY_DemoSprite.C, and VRAY/VRAY_DemoStamp.C.

void UT_BoundingBox::initMaxBounds (  ) 

Initialize the box to the largest size.

int UT_BoundingBox::intersectRange ( const UT_Vector3 org,
const UT_Vector3 dir,
float &  min,
float &  max 
) const

int UT_BoundingBox::intersectRay ( const UT_Vector3 org,
const UT_Vector3 dir,
fpreal  tmax = 1E17F,
float *  distance = 0,
UT_Vector3 nml = 0 
) const

Intersect a ray with the box. Returns 0 if no intersection found. distance will be set to the intersection distance (between 0 & tmax) The normal will also be set. The direction of the normal is indeterminant (to fix it, you might want to dot(dir, *nml) to check the orientation.

int UT_BoundingBox::intersects ( const UT_BoundingBox box  )  const

int UT_BoundingBox::intersectTube ( const UT_Vector3 org,
const UT_Vector3 dir,
fpreal  radius,
fpreal  tmin = -1E17f,
fpreal  tmax = 1E17f 
) const

This determines if the tube, capped at distances tmin & tmax, intersects this.

bool UT_BoundingBox::isEqual ( const UT_BoundingBox bbox,
fpreal  tol = UT_FTOLERANCE 
) const [inline]

Definition at line 75 of file UT_BoundingBox.h.

int UT_BoundingBox::isInside ( const UT_BoundingBox bbox  )  const

Am I totally enclosed in the bounding box passed in ("intersects" method tests for partially inside)

int UT_BoundingBox::isInside ( fpreal  x,
fpreal  y,
fpreal  z 
) const

int UT_BoundingBox::isInside ( const UT_Vector4 pt  )  const

int UT_BoundingBox::isInside ( const UT_Vector3 pt  )  const

int UT_BoundingBox::isLineInside ( const UT_Vector3 v0,
const UT_Vector3 v1 
) const

Determine whether a line between v0 & v1 intersects the box.

bool UT_BoundingBox::isValid (  )  const

Check whether the bounding box contains at least one point.

bool UT_BoundingBox::load ( UT_JSONParser p  ) 

Methods to serialize to a JSON stream. The vector is stored as an array of 6 reals (xmin, xmax, ymin, ymax, zmin, zmax)

void UT_BoundingBox::makeInvalid (  )  [inline]

Definition at line 111 of file UT_BoundingBox.h.

int UT_BoundingBox::maxAxis (  )  const

UT_Vector3 UT_BoundingBox::maxvec (  )  const [inline]

Definition at line 95 of file UT_BoundingBox.h.

int UT_BoundingBox::minAxis (  )  const

fpreal UT_BoundingBox::minDist2 ( const UT_BoundingBox box  )  const [inline]

Minimum disance between two bboxes squared.

Definition at line 220 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::minDist2 ( const UT_Vector3 p  )  const [inline]

Returns minimum distance from point to bounding box squared. Returns 0 if point in bouding box.

Definition at line 217 of file UT_BoundingBox.h.

UT_Vector3 UT_BoundingBox::minDistDelta ( const UT_BoundingBox box  )  const

UT_Vector3 UT_BoundingBox::minDistDelta ( const UT_Vector3 p  )  const

Returns the minimum delta vector from the point to the bounding box or between two bounding boxes.

UT_Vector3 UT_BoundingBox::minvec (  )  const [inline]

Definition at line 93 of file UT_BoundingBox.h.

bool UT_BoundingBox::operator!= ( const UT_BoundingBox bbox  )  const [inline]

Definition at line 71 of file UT_BoundingBox.h.

float& UT_BoundingBox::operator() ( unsigned  m,
unsigned  n 
) [inline]

Definition at line 57 of file UT_BoundingBox.h.

float UT_BoundingBox::operator() ( unsigned  m,
unsigned  n 
) const [inline]

Definition at line 52 of file UT_BoundingBox.h.

bool UT_BoundingBox::operator== ( const UT_BoundingBox bbox  )  const [inline]

Definition at line 62 of file UT_BoundingBox.h.

void UT_BoundingBox::outTo ( ostream &  os  )  const [protected]

bool UT_BoundingBox::save ( UT_JSONValue v  )  const

Methods to serialize to a JSON stream. The vector is stored as an array of 6 reals (xmin, xmax, ymin, ymax, zmin, zmax)

bool UT_BoundingBox::save ( UT_JSONWriter w  )  const

Methods to serialize to a JSON stream. The vector is stored as an array of 6 reals (xmin, xmax, ymin, ymax, zmin, zmax)

void UT_BoundingBox::scaleOffset ( const UT_Vector3 scale,
const UT_Vector3 offset 
)

Scale then offset a bounding box.

void UT_BoundingBox::setBounds ( fpreal  x_min,
fpreal  y_min,
fpreal  z_min,
fpreal  x_max,
fpreal  y_max,
fpreal  z_max 
) [inline]

Examples:
standalone/geoisosurface.C.

Definition at line 113 of file UT_BoundingBox.h.

UT_Vector3 UT_BoundingBox::size (  )  const [inline]

Definition at line 196 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::sizeAxis ( int  axis  )  const [inline]

Definition at line 200 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::sizeMax ( int &  axis  )  const

Return the size of the largest dimension, and store the dimension index in "axis"

fpreal UT_BoundingBox::sizeMax (  )  const

Return the size of the largest dimension.

Examples:
VRAY/VRAY_DemoSprite.C.

fpreal UT_BoundingBox::sizeX (  )  const [inline]

Examples:
SOP/SOP_Flatten.C, and VRAY/VRAY_DemoSprite.C.

Definition at line 192 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::sizeY (  )  const [inline]

Examples:
SOP/SOP_Flatten.C, and VRAY/VRAY_DemoSprite.C.

Definition at line 193 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::sizeZ (  )  const [inline]

Examples:
SOP/SOP_Flatten.C, and VRAY/VRAY_DemoSprite.C.

Definition at line 194 of file UT_BoundingBox.h.

void UT_BoundingBox::splitLeft ( UT_BoundingBox box,
int  axis,
fpreal  split 
) [inline]

Splits a box into two disjoint subboxes at the given splitting point. This box is set to the left subbox for splitLeft() and the right subbox for splitRight().

Definition at line 166 of file UT_BoundingBox.h.

void UT_BoundingBox::splitRight ( UT_BoundingBox box,
int  axis,
fpreal  split 
) [inline]

Definition at line 172 of file UT_BoundingBox.h.

void UT_BoundingBox::transform ( const UT_DMatrix4 mat,
UT_BoundingBox newbbox 
) const

void UT_BoundingBox::transform ( const UT_DMatrix4 mat  ) 

void UT_BoundingBox::transform ( const UT_Matrix4 mat,
UT_BoundingBox newbbox 
) const

void UT_BoundingBox::transform ( const UT_Matrix4 mat  ) 

Examples:
SIM/SNOW_Solver.C.

void UT_BoundingBox::translate ( const UT_Vector3 delta  ) 

Adds the given translate to each component of the bounding box.

Examples:
VRAY/VRAY_DemoSprite.C.

fpreal UT_BoundingBox::volume (  )  const [inline]

Definition at line 243 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::xcenter (  )  const [inline]

Definition at line 229 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::xmax (  )  const [inline]

Examples:
SIM/SNOW_Solver.C, and VRAY/VRAY_DemoStamp.C.

Definition at line 87 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::xmin (  )  const [inline]

Examples:
SIM/SNOW_Solver.C, and VRAY/VRAY_DemoStamp.C.

Definition at line 86 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::xsize (  )  const [inline]

Definition at line 189 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::ycenter (  )  const [inline]

Definition at line 230 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::ymax (  )  const [inline]

Examples:
SIM/SNOW_Solver.C, and VRAY/VRAY_DemoStamp.C.

Definition at line 89 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::ymin (  )  const [inline]

Examples:
SIM/SNOW_Solver.C, and VRAY/VRAY_DemoStamp.C.

Definition at line 88 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::ysize (  )  const [inline]

Definition at line 190 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::zcenter (  )  const [inline]

Definition at line 231 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::zmax (  )  const [inline]

Examples:
SIM/SNOW_Solver.C, and VRAY/VRAY_DemoStamp.C.

Definition at line 91 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::zmin (  )  const [inline]

Examples:
SIM/SNOW_Solver.C, and VRAY/VRAY_DemoStamp.C.

Definition at line 90 of file UT_BoundingBox.h.

fpreal UT_BoundingBox::zsize (  )  const [inline]

Definition at line 191 of file UT_BoundingBox.h.


Friends And Related Function Documentation

ostream& operator<< ( ostream &  os,
const UT_BoundingBox box 
) [friend]

Definition at line 307 of file UT_BoundingBox.h.


Member Data Documentation

union { ... }

Here's the data for the bounding box.

Definition at line 282 of file UT_BoundingBox.h.

float UT_BoundingBox::vals[3][2]

Examples:
VRAY/VRAY_DemoBox.C, and VRAY/VRAY_DemoSprite.C.

Definition at line 281 of file UT_BoundingBox.h.


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

Generated on Mon Jan 28 00:30:05 2013 for HDK by  doxygen 1.5.9