DBox2 Class Reference

#include <dbox2.h>

Class Description

See also
Class DPoint2.

This class represents a 2D box described by two double-precision 2D corner coordinates. DBox2 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.

+ Inheritance diagram for DBox2:

Public Member Functions

 DBox2 ()
 Constructor. More...
 
 DBox2 (const DPoint2 &p, const DPoint2 &q)
 Constructor. More...
 
void Init ()
 Initializes this box such that pmin is a very large value while pmax is a small value. More...
 
DPoint2 Min () const
 Returns the minimum corner value. More...
 
DPoint2 Max () const
 Returns the maximum corner value. More...
 
DPoint2 Center () const
 Returns the center of this DBox2 as a DPoint2. More...
 
DPoint2 Width () const
 Returns the width of the box as a DPoint2. More...
 
DBox2operator+= (const DPoint2 &p)
 Expands this DBox2 to include the DPoint2 p. More...
 
DBox2operator+= (const DBox2 &b)
 Expands this DBox2 to include the specified DBox2. More...
 
void Scale (double s)
 Scales this box about its center by the specified scale. More...
 
void Translate (const DPoint2 &p)
 Translates this box by the distance specified. More...
 
void EnlargeBy (double s)
 Enlarges this box. More...
 
int IsEmpty () const
 Determines if the box is empty. More...
 
int Contains (const DPoint2 &p) const
 Determines if the specified point p is contained in this box. More...
 
int Contains (const DBox2 &b) const
 Determines if the specified DBox2 is contained totally within this box. More...
 
int Overlaps (const DBox2 &b) const
 Determines if the specified DBox2 overlaps this box. More...
 

Public Attributes

DPoint2 pmin
 The minimum 2D point in this box. More...
 
DPoint2 pmax
 The maximum 2D point in this box. More...
 

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

Constructor & Destructor Documentation

DBox2 ( )

Constructor.

The corners of the box are initialized such that the box is 'empty'. See

See also
IsEmpty().
DBox2 ( const DPoint2 p,
const DPoint2 q 
)
inline

Constructor.

The corners of the box are initialized to the points passed.

Parameters
pThe first corner of the box
qThe second corner of the box
41 { pmin = p; pmax = q; }
DPoint2 pmax
The maximum 2D point in this box.
Definition: dbox2.h:31
DPoint2 pmin
The minimum 2D point in this box.
Definition: dbox2.h:28

Member Function Documentation

void Init ( )

Initializes this box such that pmin is a very large value while pmax is a small value.

Thus the box is 'empty'. See

See also
IsEmpty().
DPoint2 Min ( ) const
inline

Returns the minimum corner value.

Returns
the value of corner pmin
52 { return pmin; }
DPoint2 pmin
The minimum 2D point in this box.
Definition: dbox2.h:28
DPoint2 Max ( ) const
inline

Returns the maximum corner value.

Returns
the value of corner pmax.
56 { return pmax; }
DPoint2 pmax
The maximum 2D point in this box.
Definition: dbox2.h:31
DPoint2 Center ( ) const
inline

Returns the center of this DBox2 as a DPoint2.

Returns
the center of the box
60 { return(pmin + pmax) / 2.0; }
DPoint2 pmax
The maximum 2D point in this box.
Definition: dbox2.h:31
DPoint2 pmin
The minimum 2D point in this box.
Definition: dbox2.h:28
DPoint2 Width ( ) const
inline

Returns the width of the box as a DPoint2.

This is pmax-pmin.

Returns
the width of the box
65 { return(pmax - pmin); }
DPoint2 pmax
The maximum 2D point in this box.
Definition: dbox2.h:31
DPoint2 pmin
The minimum 2D point in this box.
Definition: dbox2.h:28
DBox2& operator+= ( const DPoint2 p)

Expands this DBox2 to include the DPoint2 p.

Parameters
pthe DPoint2 to include in the new size
Returns
the resulting box
DBox2& operator+= ( const DBox2 b)

Expands this DBox2 to include the specified DBox2.

Parameters
bthe box to include in the new size
Returns
the resulting box
void Scale ( double  s)

Scales this box about its center by the specified scale.

Parameters
sSpecifies the scale factor for this DBox2.
void Translate ( const DPoint2 p)

Translates this box by the distance specified.

The point is added to each corner.

Parameters
pSpecifies the distance to translate the box.
void EnlargeBy ( double  s)

Enlarges this box.

A DPoint2 is created from s as DPoint2(s,s) and added to pmax and subtracted from pmin. If the box is 'empty', the box is centered at (0,0) and then enlarged.

Parameters
sthe amount to enlarge the box on all sides
int IsEmpty ( ) const

Determines if the box is empty.

This indicates the box has not had specific values set by the developer.

Returns
Nonzero if the box is empty; otherwise 0.
int Contains ( const DPoint2 p) const

Determines if the specified point p is contained in this box.

Parameters
pSpecifies the point to check.
Returns
Nonzero if the specified point is contained in this box, otherwise 0.
int Contains ( const DBox2 b) const

Determines if the specified DBox2 is contained totally within this box.

Parameters
bSpecifies the box to check.
Returns
Nonzero if the specified box is entirely contained within this box; otherwise 0.
int Overlaps ( const DBox2 b) const

Determines if the specified DBox2 overlaps this box.

Parameters
bSpecifies the box to check.
Returns
Nonzero if the specified box overlaps this box; otherwise 0.

Member Data Documentation

DPoint2 pmin

The minimum 2D point in this box.

DPoint2 pmax

The maximum 2D point in this box.