3ds Max C++ API Reference
Box3 Class Reference

#include <box3.h>

+ Inheritance diagram for Box3:

Public Member Functions

 Box3 ()
 
 Box3 (const Point3 &p, const Point3 &q)
 
void Init ()
 
void MakeCube (const Point3 &p, float side)
 
Point3 Min () const
 
Point3 Max () const
 
Point3 Center () const
 
Point3 Width () const
 
Point3 operator[] (int i) const
 
Box3operator+= (const Point3 &p)
 
Box3operator+= (const Box3 &b)
 
void Scale (float s)
 
void Translate (const Point3 &p)
 
void EnlargeBy (float s)
 
void IncludePoints (Point3 *pts, int numpoints, Matrix3 *tm=NULL)
 
Box3 operator* (const Matrix3 &tm) const
 
bool operator== (const Box3 &b) const
 
bool operator!= (const Box3 &b) const
 
bool IsEmpty () const
 
bool IsInitialized () const
 
bool Contains (const Point3 &p) const
 
bool Contains (const Box3 &b) const
 
bool Intersects (const Box3 &b) const
 
bool TriBoxOverlap (const Point3 vert0, const Point3 vert1, const Point3 vert2) const
 

Public Attributes

Point3 pmin
 
Point3 pmax
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

See also
Class Point3, Class Matrix3.

Description:
This class represents a 3D box volume described by two 3D corner coordinates. Box3 provides methods that return individual coordinates of the box, scale and translate it, retrieve its center, modify its size, expand it to include points or other boxes, and determine if points are inside the box. All methods are implemented by the system.
Data Members:
Point3 pmin,pmax;

The corners of the 3D box.

Constructor & Destructor Documentation

◆ Box3() [1/2]

Box3 ( )
Remarks
Constructor. The corners of the box are initialized such that the box is 'empty' and 'uninitialized'. See IsEmpty() and IsInitialized().

◆ Box3() [2/2]

Box3 ( const Point3 p,
const Point3 q 
)
inline
Remarks
Constructor. The corners of the box are initialized to the points passed. pmin=p; pmax = q.
42  {
43  pmin = p;
44  pmax = q;
45  }
Point3 pmin
Definition: box3.h:35
Point3 pmax
Definition: box3.h:35

Member Function Documentation

◆ Init()

void Init ( )
Remarks
Initializes this box such that pmin is a very large value while pmax is a small value. Thus the box is 'empty' and 'uninitialized'. See IsEmpty() and IsInitialized().

◆ MakeCube()

void MakeCube ( const Point3 p,
float  side 
)
Remarks
Modifies this box such that half the side length is subtracted from pmin and added to pmax. This creates a cube with the specified center p and side length side.
Parameters:
const Point3& p

Specifies the center point of the cube.

float side

Specifies the side length.

◆ Min()

Point3 Min ( ) const
inline
Remarks
Returns the value of corner pmin.
64  {
65  return pmin;
66  }

◆ Max()

Point3 Max ( ) const
inline
Remarks
Returns the value of corner pmax.
69  {
70  return pmax;
71  }

◆ Center()

Point3 Center ( ) const
inline
Remarks
Returns the center of this Box3 as a Point3.
74  {
75  return (pmin + pmax) / (float)2.0;
76  }

◆ Width()

Point3 Width ( ) const
inline
Remarks
Returns the width of the box as a Point3. This is pmax-pmin.
80  {
81  return (pmax - pmin);
82  }

◆ operator[]()

Point3 operator[] ( int  i) const
Remarks
Operator[] returns the 'i-th' corner point:

Mapping : X Y Z

[0] : (min,min,min)

[1] : (max,min,min)

[2] : (min,max,min)

[3] : (max,max,min)

[4] : (min,min,max)

[5] : (max,min,max)

[6] : (min,max,max)

[7] : (max,max,max)
Parameters:
int i

Specifies the corner to retrieve (0 <= i <= 7)
Returns
The 'i-th' corner point as a Point3.

◆ operator+=() [1/2]

Box3& operator+= ( const Point3 p)
Remarks
Expands this Box3 to include the Point3 p.
Parameters:
const Point3& p

Specifies the point to expand the box to include.

◆ operator+=() [2/2]

Box3& operator+= ( const Box3 b)
Remarks
Expands this Box3 to include the Box3 b.
Parameters:
const Box3& b

Specifies the Box3 to expand this box to include.

◆ Scale()

void Scale ( float  s)
Remarks
Scales this box about its center by the specified scale.
Parameters:
float s

Specifies the scale factor for this Box3.

◆ Translate()

void Translate ( const Point3 p)
Remarks
Translates this box by the distance specified. The point is added to each corner.
Parameters:
const Point3 &p

Specifies the distance to translate the box.

◆ EnlargeBy()

void EnlargeBy ( float  s)
Remarks
Enlarges this box. A Point3 is created from s as Point3(s,s,s) and added to pmax and subtracted from pmin. If the box is 'empty', the box is centered at (0,0,0) and then enlarged.

◆ IncludePoints()

void IncludePoints ( Point3 pts,
int  numpoints,
Matrix3 tm = NULL 
)

◆ operator*()

Box3 operator* ( const Matrix3 tm) const
Remarks
Returns a box that bounds the 8 transformed corners of the input box.
Parameters:
const Matrix3& tm

Specifies the matrix to transform the box corners by.

◆ operator==()

bool operator== ( const Box3 b) const
inline
Remarks
Equality operator. Determines whether b is equal to this box. Returns nonzero if the boxes are equal; 0 otherwise.
156  {
157  return (pmin == b.pmin && pmax == b.pmax);
158  }

◆ operator!=()

bool operator!= ( const Box3 b) const
inline
Remarks
Inequality operator. Determines whether b is different from this box. Returns true if the boxes are different.
162  {
163  return !(operator==(b));
164  }
bool operator==(const Box3 &b) const
Definition: box3.h:155

◆ IsEmpty()

bool IsEmpty ( ) const
Remarks
Determines if the box is empty. A box is considered empty if any component value of pmin is greater than the corresponding component value of pmax.
Returns
true if the box is empty; otherwise false.

◆ IsInitialized()

bool IsInitialized ( ) const
Remarks
Determines if the box is initialized. This indicates the box has had specific values set by the developer.
Returns
true if the box is initialized; otherwise false.

◆ Contains() [1/2]

bool Contains ( const Point3 p) const
Remarks
Determines if the specified point p is contained in this box.
Parameters:
const Point3& p

Specifies the point to check.
Returns
true if the specified point is contained in this box; otherwise false.

◆ Contains() [2/2]

bool Contains ( const Box3 b) const
Remarks
Determines if the specified Box3 is contained totally within this box.
Parameters:
const Box3& b

Specifies the box to check.
Returns
true if the specified box is entirely contained within this box; otherwise false.
Operators:

◆ Intersects()

bool Intersects ( const Box3 b) const
Remarks
Determines if the specified Box3 intersects this box.
Parameters:
const Box3& b

Specifies the box to check.
Returns
true if the specified Box3 intersects this box; otherwise false.
Operators:

◆ TriBoxOverlap()

bool TriBoxOverlap ( const Point3  vert0,
const Point3  vert1,
const Point3  vert2 
) const
Remarks
Determines if the triangle specified by the tree points vert0, vert1, vert2 is overlapping with this box.
Returns
true if the specified triangle overlaps with this box in some way; otherwise false.

Member Data Documentation

◆ pmin

Point3 pmin

◆ pmax

Point3 pmax