HDK
|
Axis-aligned bounding box (AABB). More...
#include <GEO_Detail.h>
Public Types | |
using | this_type = UT_BoundingBoxT< T > |
Public Member Functions | |
UT_BoundingBoxT () | |
UT_BoundingBoxT (T axmin, T aymin, T azmin, T axmax, T aymax, T azmax) | |
UT_BoundingBoxT (const UT_Vector3T< T > &lowerbound, const UT_Vector3T< T > &upperbound) | |
template<typename S > | |
UT_BoundingBoxT (const UT_BoundingBoxT< S > &bbox) | |
template<typename S > | |
UT_BoundingBoxT & | operator= (const UT_BoundingBoxT< S > &bbox) |
T | operator() (unsigned m, unsigned n) const |
T & | operator() (unsigned m, unsigned n) |
bool | operator== (const UT_BoundingBoxT< T > &bbox) const |
bool | operator!= (const UT_BoundingBoxT< T > &bbox) const |
bool | isEqual (const UT_BoundingBoxT< T > &bbox, T tol=SYS_FTOLERANCE_R) const |
T | xmin () const |
T | xmax () const |
T | ymin () const |
T | ymax () const |
T | zmin () const |
T | zmax () const |
UT_Vector3T< T > | minvec () const |
UT_Vector3T< T > | maxvec () const |
int | isInside (const UT_Vector3T< T > &pt) const |
int | isInside (const UT_Vector4T< T > &pt) const |
int | isInside (T x, T y, T z) const |
int | isInside (const UT_BoundingBoxT< T > &bbox) const |
int | isLineInside (const UT_Vector3T< T > &v0, const UT_Vector3T< T > &idir) const |
T | approxLineDist2 (const UT_Vector3T< T > &v0, const UT_Vector3T< T > &dir) const |
SYS_FORCE_INLINE bool | isValid () const |
Check whether the bounding box contains at least one point. More... | |
SYS_FORCE_INLINE void | makeInvalid () |
SYS_FORCE_INLINE bool | isInvalidFast () const |
void | setBounds (T x_min, T y_min, T z_min, T x_max, T y_max, T z_max) |
SYS_FORCE_INLINE bool | hasVolume () const |
void | initMaxBounds () |
Initialize the box to the largest size. More... | |
SYS_FORCE_INLINE void | initBounds () |
void | initBounds (const UT_Vector3T< T > &min, const UT_Vector3T< T > &max) |
SYS_FORCE_INLINE void | initBounds (const UT_Vector3T< T > &pt) |
Initialize zero-sized bounds at the location of the point given by pt. More... | |
void | initBounds (const UT_Vector4T< T > &pt) |
Initialize zero-sized bounds at the location of the point given by pt. More... | |
SYS_FORCE_INLINE void | initBounds (T x, T y, T z) |
void | initBounds (const fpreal32 *v) |
Initialize zero-sized bounds at the location of the point given by v. More... | |
void | initBounds (const fpreal64 *v) |
Initialize zero-sized bounds at the location of the point given by v. More... | |
void | initBounds (const UT_BoundingBoxT< T > &box) |
Initialize the bounds to the same as given by box. More... | |
void | enlargeBounds (const UT_Vector3T< T > &min, const UT_Vector3T< T > &max) |
SYS_FORCE_INLINE void | enlargeBounds (const UT_Vector3T< T > &pt) |
Enlarge the existing bounds to encompass the point given by pt. More... | |
void | enlargeBounds (const UT_Vector4T< T > &pt) |
Enlarge the existing bounds to encompass the point given by pt. More... | |
SYS_FORCE_INLINE void | enlargeBounds (T x, T y, T z) |
void | enlargeBounds (const fpreal32 *v) |
Enlarge the existing bounds to encompass the point given in v. More... | |
void | enlargeBounds (const fpreal64 *v) |
Enlarge the existing bounds to encompass the point given in v. More... | |
SYS_FORCE_INLINE void | enlargeBounds (const UT_BoundingBoxT< T > &box) |
Enlarge the existing bounds to encompass the bounds given by box. More... | |
SYS_FORCE_INLINE void | expandBounds (T relative, T absolute) |
SYS_FORCE_INLINE void | expandBounds (T dltx, T dlty, T dlyz) |
void | enlargeFloats (int bits=1, T min=1e-5) |
void | clipBounds (const UT_BoundingBoxT< T > &box) |
Find the intersections of two bounding boxes. More... | |
void | splitLeft (UT_BoundingBoxT< T > &box, int axis, T split) |
void | splitRight (UT_BoundingBoxT< T > &box, int axis, T split) |
template<typename MATRIX > | |
void | transform (const MATRIX &mat) |
template<typename MATRIX > | |
void | transform (const MATRIX &mat, UT_BoundingBoxT< T > &newbbox) const |
void | translate (const UT_Vector3T< T > &delta) |
Adds the given translate to each component of the bounding box. More... | |
T | xsize () const |
T | ysize () const |
T | zsize () const |
T | sizeX () const |
T | sizeY () const |
T | sizeZ () const |
UT_Vector3T< T > | size () const |
T | sizeAxis (int axis) const |
T | sizeMax () const |
Return the size of the largest dimension. More... | |
T | sizeMax (int &axis) const |
UT_Vector3T< T > | minDistDelta (const UT_Vector3T< T > &p) const |
UT_Vector3T< T > | minDistDelta (const UT_BoundingBoxT< T > &box) const |
T | minDist2 (const UT_Vector3T< T > &p) const |
T | minDist2 (const UT_BoundingBoxT< T > &box) const |
Minimum disance between two bboxes squared. More... | |
UT_Vector3T< T > | minDistToMaxOverlap (const UT_BoundingBoxT< T > &box) const |
T | getRadius () const |
Returns the radius of a sphere that would fully enclose the box. More... | |
int | getOutCode (const UT_Vector3T< T > &pt) const |
Finds the out code of the point relative to this box: More... | |
T | xcenter () const |
T | ycenter () const |
T | zcenter () const |
T | centerX () const |
T | centerY () const |
T | centerZ () const |
T | centerAxis (int axis) const |
UT_Vector3T< T > | center () const |
T | area () const |
T | volume () const |
void | addToMin (const UT_Vector3T< T > &vec) |
void | addToMax (const UT_Vector3T< T > &vec) |
void | scaleOffset (const UT_Vector3T< T > &scale, const UT_Vector3T< T > &offset) |
Scale then offset a bounding box. More... | |
int | maxAxis () const |
int | minAxis () const |
int | intersectRay (const UT_Vector3T< T > &org, const UT_Vector3T< T > &dir, T tmax=1E17F, T *distance=0, UT_Vector3T< T > *nml=0) const |
int | intersectRange (const UT_Vector3T< T > &org, const UT_Vector3T< T > &dir, T &min, T &max) const |
int | intersectTube (const UT_Vector3T< T > &org, const UT_Vector3T< T > &dir, T radius, T tmin=-1E17f, T tmax=1E17f) const |
int | intersects (const UT_BoundingBoxT< T > &box) const |
int | computeIntersection (const UT_BoundingBoxT< T > &box) |
void | getBBoxPoints (UT_Vector3T< T >(&ptarray)[8]) const |
void | getBBoxPoints (UT_Vector4T< T >(&ptarray)[8]) const |
template<typename MATRIX > | |
int | getBBoxPoints (UT_Vector3T< T >(&ptarray)[8], const MATRIX &transform_matrix) const |
void | dump (const char *msg=0) const |
Dump the bounding box to stderr. The msg is printed before the bounds. More... | |
void | dumpGeo (FILE *fp) const |
Dump the bounding box geometry to a draw file. More... | |
void | setSerialized (const fpreal32 floats[6]) |
void | setSerialized (const fpreal64 floats[6]) |
const T * | getSerialized () const |
const T * | data () const |
T * | data () |
const T * | begin () const |
const T * | end () const |
T * | begin () |
T * | end () |
bool | save (UT_JSONWriter &w) const |
bool | save (UT_JSONValue &v) const |
bool | load (UT_JSONParser &p) |
Public Attributes | |
union { | |
T vals [3][2] | |
T myFloats [6] | |
}; | |
Here's the data for the bounding box. More... | |
Protected Member Functions | |
void | outTo (std::ostream &os) const |
Static Protected Member Functions | |
static bool | SYSisEqual (int64 a, int64 b, int64) |
Friends | |
std::ostream & | operator<< (std::ostream &os, const UT_BoundingBoxT< T > &box) |
uint64 | hash () const |
Compute UT_BoundingBox hash. More... | |
std::size_t | hash_value (const this_type &t) |
Compute UT_BoundingBox hash. More... | |
Axis-aligned bounding box (AABB).
Definition at line 43 of file GEO_Detail.h.
using UT_BoundingBoxT< T >::this_type = UT_BoundingBoxT<T> |
Definition at line 22 of file UT_BoundingBox.h.
|
inline |
Definition at line 24 of file UT_BoundingBox.h.
|
inline |
Definition at line 27 of file UT_BoundingBox.h.
|
inline |
Definition at line 33 of file UT_BoundingBox.h.
|
inline |
Definition at line 45 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::addToMax | ( | const UT_Vector3T< T > & | vec | ) |
void UT_BoundingBoxT< T >::addToMin | ( | const UT_Vector3T< T > & | vec | ) |
T UT_BoundingBoxT< T >::approxLineDist2 | ( | const UT_Vector3T< T > & | v0, |
const UT_Vector3T< T > & | dir | ||
) | const |
Determine the minimum distance of the box to a line segment, or 0 if the line segment overlaps the box. v0 is one end-point of the line, and dir is the direction vector along the line. This method conservatively underestimates the distance, so the true line/box distance may be greater than the reported value.
T UT_BoundingBoxT< T >::area | ( | ) | const |
|
inline |
Iterate over the data serially
Definition at line 190 of file UT_BoundingBox.h.
|
inline |
Iterate over the data serially
Definition at line 192 of file UT_BoundingBox.h.
|
inline |
Definition at line 365 of file UT_BoundingBox.h.
|
inline |
Definition at line 363 of file UT_BoundingBox.h.
|
inline |
Definition at line 360 of file UT_BoundingBox.h.
|
inline |
Definition at line 361 of file UT_BoundingBox.h.
|
inline |
Definition at line 362 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::clipBounds | ( | const UT_BoundingBoxT< T > & | box | ) |
Find the intersections of two bounding boxes.
int UT_BoundingBoxT< T >::computeIntersection | ( | const UT_BoundingBoxT< T > & | box | ) |
Changes the bounds to be those of the intersection of this box and the supplied BBox. Returns 1 if intersects, 0 otherwise.
|
inline |
Access to the serialized data
Definition at line 184 of file UT_BoundingBox.h.
|
inline |
Access to the serialized data
Definition at line 185 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::dump | ( | const char * | msg = 0 | ) | const |
Dump the bounding box to stderr. The msg is printed before the bounds.
void UT_BoundingBoxT< T >::dumpGeo | ( | FILE * | fp | ) | const |
Dump the bounding box geometry to a draw file.
Iterate over the data serially
Definition at line 191 of file UT_BoundingBox.h.
|
inline |
Iterate over the data serially
Definition at line 193 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::enlargeBounds | ( | const UT_Vector3T< T > & | min, |
const UT_Vector3T< T > & | max | ||
) |
Enlarge the existing bounds to encompass the bounds given by min and max.
void UT_BoundingBoxT< T >::enlargeBounds | ( | const UT_Vector3T< T > & | pt | ) |
Enlarge the existing bounds to encompass the point given by pt.
Definition at line 499 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::enlargeBounds | ( | const UT_Vector4T< T > & | pt | ) |
Enlarge the existing bounds to encompass the point given by pt.
Enlarge the existing bounds to encompass the point defined by x, y, and z.
Definition at line 511 of file UT_BoundingBox.h.
|
inline |
Enlarge the existing bounds to encompass the point given in v.
Definition at line 257 of file UT_BoundingBox.h.
|
inline |
Enlarge the existing bounds to encompass the point given in v.
Definition at line 261 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::enlargeBounds | ( | const UT_BoundingBoxT< T > & | box | ) |
Enlarge the existing bounds to encompass the bounds given by box.
Definition at line 523 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::enlargeFloats | ( | int | bits = 1 , |
T | min = 1e-5 |
||
) |
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_BoundingBoxT< T >::expandBounds | ( | T | relative, |
T | absolute | ||
) |
Expand the bounding box on all axes, as a relative fraction of the current bbox dimensions, and/or using an absolute offset.
Definition at line 535 of file UT_BoundingBox.h.
Expand the bounding box on all sides using separate absolute offsets for each axis.
Definition at line 551 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::getBBoxPoints | ( | UT_Vector3T< T >(&) | ptarray[8] | ) | const |
void UT_BoundingBoxT< T >::getBBoxPoints | ( | UT_Vector4T< T >(&) | ptarray[8] | ) | const |
int UT_BoundingBoxT< T >::getBBoxPoints | ( | UT_Vector3T< T >(&) | ptarray[8], |
const MATRIX & | transform_matrix | ||
) | const |
int UT_BoundingBoxT< T >::getOutCode | ( | const UT_Vector3T< T > & | pt | ) | const |
Finds the out code of the point relative to this box:
|
inline |
Returns the radius of a sphere that would fully enclose the box.
Definition at line 352 of file UT_BoundingBox.h.
|
inline |
Set/Get bounds in "serialized" fashion. The serialized order is (xmin, xmax, ymin, ymax, zmin, zmax).
Definition at line 179 of file UT_BoundingBox.h.
uint64 UT_BoundingBoxT< T >::hash | ( | void | ) | const |
|
inline |
Definition at line 159 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::initBounds | ( | ) |
Initialize the box such that
Definition at line 460 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::initBounds | ( | const UT_Vector3T< T > & | min, |
const UT_Vector3T< T > & | max | ||
) |
Initialize the bounds with the bounds given in min and max. No check is made to ensure that min is smaller than max.
void UT_BoundingBoxT< T >::initBounds | ( | const UT_Vector3T< T > & | pt | ) |
Initialize zero-sized bounds at the location of the point given by pt.
Definition at line 475 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::initBounds | ( | const UT_Vector4T< T > & | pt | ) |
Initialize zero-sized bounds at the location of the point given by pt.
Initialize zero-sized bounds at the location of the point defined by x, y, and z;
Definition at line 487 of file UT_BoundingBox.h.
|
inline |
Initialize zero-sized bounds at the location of the point given by v.
Definition at line 229 of file UT_BoundingBox.h.
|
inline |
Initialize zero-sized bounds at the location of the point given by v.
Definition at line 233 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::initBounds | ( | const UT_BoundingBoxT< T > & | box | ) |
Initialize the bounds to the same as given by box.
void UT_BoundingBoxT< T >::initMaxBounds | ( | ) |
Initialize the box to the largest size.
int UT_BoundingBoxT< T >::intersectRange | ( | const UT_Vector3T< T > & | org, |
const UT_Vector3T< T > & | dir, | ||
T & | min, | ||
T & | max | ||
) | const |
int UT_BoundingBoxT< T >::intersectRay | ( | const UT_Vector3T< T > & | org, |
const UT_Vector3T< T > & | dir, | ||
T | tmax = 1E17F , |
||
T * | distance = 0 , |
||
UT_Vector3T< T > * | 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_BoundingBoxT< T >::intersects | ( | const UT_BoundingBoxT< T > & | box | ) | const |
int UT_BoundingBoxT< T >::intersectTube | ( | const UT_Vector3T< T > & | org, |
const UT_Vector3T< T > & | dir, | ||
T | radius, | ||
T | tmin = -1E17f , |
||
T | tmax = 1E17f |
||
) | const |
This determines if the tube, capped at distances tmin & tmax, intersects this.
|
inline |
Definition at line 91 of file UT_BoundingBox.h.
int UT_BoundingBoxT< T >::isInside | ( | const UT_Vector3T< T > & | pt | ) | const |
int UT_BoundingBoxT< T >::isInside | ( | const UT_Vector4T< T > & | pt | ) | const |
int UT_BoundingBoxT< T >::isInside | ( | const UT_BoundingBoxT< T > & | bbox | ) | const |
Am I totally enclosed in the bounding box passed in ("intersects" method tests for partially inside)
|
inline |
Efficient test for an invalid bounding box (one comparison instead of 3 for a valid bounding box). This only checks X, not Y or Z ranges, so only works if the box is fully invalid.
Definition at line 145 of file UT_BoundingBox.h.
int UT_BoundingBoxT< T >::isLineInside | ( | const UT_Vector3T< T > & | v0, |
const UT_Vector3T< T > & | idir | ||
) | const |
Determine whether a line intersects the box. v0 is one end-point of the line, and idir is the inverse direction vector along the line.
bool UT_BoundingBoxT< T >::isValid | ( | ) | const |
Check whether the bounding box contains at least one point.
Definition at line 451 of file UT_BoundingBox.h.
bool UT_BoundingBoxT< T >::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)
|
inline |
Definition at line 139 of file UT_BoundingBox.h.
int UT_BoundingBoxT< T >::maxAxis | ( | ) | const |
|
inline |
Definition at line 111 of file UT_BoundingBox.h.
int UT_BoundingBoxT< T >::minAxis | ( | ) | const |
|
inline |
Returns minimum distance from point to bounding box squared. Returns 0 if point in bouding box.
Definition at line 341 of file UT_BoundingBox.h.
|
inline |
Minimum disance between two bboxes squared.
Definition at line 344 of file UT_BoundingBox.h.
UT_Vector3T<T> UT_BoundingBoxT< T >::minDistDelta | ( | const UT_Vector3T< T > & | p | ) | const |
Returns the minimum delta vector from the point to the bounding box or between two bounding boxes.
UT_Vector3T<T> UT_BoundingBoxT< T >::minDistDelta | ( | const UT_BoundingBoxT< T > & | box | ) | const |
UT_Vector3T<T> UT_BoundingBoxT< T >::minDistToMaxOverlap | ( | const UT_BoundingBoxT< T > & | box | ) | const |
Returns the smallest absolute translation from this to box that produces the maximum overlap between the two boxes.
|
inline |
Definition at line 109 of file UT_BoundingBox.h.
|
inline |
Definition at line 86 of file UT_BoundingBox.h.
|
inline |
Definition at line 67 of file UT_BoundingBox.h.
|
inline |
Definition at line 72 of file UT_BoundingBox.h.
|
inline |
Definition at line 56 of file UT_BoundingBox.h.
|
inline |
Definition at line 77 of file UT_BoundingBox.h.
|
protected |
bool UT_BoundingBoxT< T >::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)
bool UT_BoundingBoxT< T >::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)
void UT_BoundingBoxT< T >::scaleOffset | ( | const UT_Vector3T< T > & | scale, |
const UT_Vector3T< T > & | offset | ||
) |
Scale then offset a bounding box.
|
inline |
Definition at line 147 of file UT_BoundingBox.h.
|
inline |
Set/Get bounds in "serialized" fashion. The serialized order is (xmin, xmax, ymin, ymax, zmin, zmax).
Definition at line 169 of file UT_BoundingBox.h.
|
inline |
Set/Get bounds in "serialized" fashion. The serialized order is (xmin, xmax, ymin, ymax, zmin, zmax).
Definition at line 174 of file UT_BoundingBox.h.
|
inline |
Definition at line 320 of file UT_BoundingBox.h.
|
inline |
Definition at line 324 of file UT_BoundingBox.h.
T UT_BoundingBoxT< T >::sizeMax | ( | ) | const |
Return the size of the largest dimension.
T UT_BoundingBoxT< T >::sizeMax | ( | int & | axis | ) | const |
Return the size of the largest dimension, and store the dimension index in "axis"
|
inline |
Definition at line 316 of file UT_BoundingBox.h.
|
inline |
Definition at line 317 of file UT_BoundingBox.h.
|
inline |
Definition at line 318 of file UT_BoundingBox.h.
|
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 291 of file UT_BoundingBox.h.
|
inline |
Definition at line 297 of file UT_BoundingBox.h.
|
inlinestaticprotected |
Definition at line 443 of file UT_BoundingBox.h.
void UT_BoundingBoxT< T >::transform | ( | const MATRIX & | mat | ) |
void UT_BoundingBoxT< T >::transform | ( | const MATRIX & | mat, |
UT_BoundingBoxT< T > & | newbbox | ||
) | const |
void UT_BoundingBoxT< T >::translate | ( | const UT_Vector3T< T > & | delta | ) |
Adds the given translate to each component of the bounding box.
|
inline |
Definition at line 371 of file UT_BoundingBox.h.
|
inline |
Definition at line 357 of file UT_BoundingBox.h.
|
inline |
Definition at line 103 of file UT_BoundingBox.h.
|
inline |
Definition at line 102 of file UT_BoundingBox.h.
|
inline |
Definition at line 313 of file UT_BoundingBox.h.
|
inline |
Definition at line 358 of file UT_BoundingBox.h.
|
inline |
Definition at line 105 of file UT_BoundingBox.h.
|
inline |
Definition at line 104 of file UT_BoundingBox.h.
|
inline |
Definition at line 314 of file UT_BoundingBox.h.
|
inline |
Definition at line 359 of file UT_BoundingBox.h.
|
inline |
Definition at line 107 of file UT_BoundingBox.h.
|
inline |
Definition at line 106 of file UT_BoundingBox.h.
|
inline |
Definition at line 315 of file UT_BoundingBox.h.
|
friend |
Definition at line 435 of file UT_BoundingBox.h.
union { ... } |
Here's the data for the bounding box.
T UT_BoundingBoxT< T >::myFloats[6] |
Definition at line 410 of file UT_BoundingBox.h.
T UT_BoundingBoxT< T >::vals[3][2] |
Definition at line 409 of file UT_BoundingBox.h.