VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
DtExtent Class Reference

The DtExtent represents an axis-aligned 3d bounding box.

Extents are often used to identify terrain. They are very similar to bounding volumes (just a box offset from an origin), but they are used differently, hence the separate class with a different internal representation.

Extents are not guaranteed to be consistent (xMin <= xMax etc.), for historical reasons. The main reason is to use this inconsistent state to indicate that the extent is undefined. There are several ways to create an inconsistent, or empty extent:

  1. Call the default constructor
  2. Call the constructor which takes 6 doubles.
  3. Set an individual value erroneously.

Note, degenerate extents (where min == max) are not considered empty. Note, constructors that take pairs of points or a chord etc. will ensure that the extent is valid.

Public Member Functions

 DtExtent ()
 
 DtExtent (const DtExtent &orig)
 
 DtExtent (const double minX, const double maxX, const double minY, const double maxY, const double minZ, const double maxZ)
 
 DtExtent (const DtPoint &p0, const DtPoint &p1)
 
 DtExtent (const DtChord &lineSeg)
 
virtual ~DtExtent ()
 
DtExtentoperator= (const DtExtent &orig)
 
virtual bool operator== (const DtExtent &rhs) const
 
virtual bool operator!= (const DtExtent &rhs) const
 
virtual const DtPoint center () const
 
virtual void setCenter (const DtPoint &p)
 
virtual void setFromCenter (const DtPoint &p, const double &xDist, const double &yDist, const double &zDist)
 
virtual DtPoint maxPoint () const
 
virtual DtPoint minPoint () const
 
bool empty () const
 
virtual void expandToInclude (const DtExtent &otherExtent)
 
virtual void expandToInclude (const DtPoint &point)
 
virtual bool contains (const DtExtent &otherExtent) const
 
virtual bool contains (const DtPoint &point) const
 
virtual bool contains (const DtChord &chord) const
 
bool intersects (const DtExtent &otherExtent) const
 
bool doesNotIntersect (const DtExtent &otherExtent) const
 
bool intersects (const DtSphere &sphere) const
 
double minX () const
 
double minY () const
 
double minZ () const
 
double maxX () const
 
double maxY () const
 
double maxZ () const
 
void setMinX (double x)
 
void setMinY (double y)
 
void setMinZ (double z)
 
void setMaxX (double x)
 
void setMaxY (double y)
 
void setMaxZ (double z)
 
double xSize () const
 
double ySize () const
 
double zSize () const
 

Static Public Member Functions

static DtExtentnullExtent ()
 

Protected Member Functions

bool intersectsLineOfChord (const DtChord &chord, double &distInChordLengthsFirst, double &distInChordLengthsLast) const
 
bool intersectsSoFar (const double pointVal, const double rayVal, const double side0, const double side1, double &firstTime, double &lastTime) const
 
void guaranteeValidConstruction ()
 

Protected Attributes

double myMinX
 
double myMaxX
 
double myMinY
 
double myMaxY
 
double myMinZ
 
double myMaxZ
 

Constructor & Destructor Documentation

DtExtent::DtExtent ( )

Constructs an empty or undefined instance. Min > Max, predominantly for historical reasons. empty() will return true when the extent is in this state.

DtExtent::DtExtent ( const DtExtent orig)
DtExtent::DtExtent ( const double  minX,
const double  maxX,
const double  minY,
const double  maxY,
const double  minZ,
const double  maxZ 
)

Set the extent explicitly. The extent may be valid or inconsistent depending on the argument values.

DtExtent::DtExtent ( const DtPoint p0,
const DtPoint p1 
)

Construct the minimal extent that includes both p0 and p1. When the line segment (p0,p1) is parallel to any of the axes, a degenerate extent results.

DtExtent::DtExtent ( const DtChord lineSeg)

Construct the minimal extent that includes the chord. If the chord is parallel to any of the axes, a degenerate extent results.

virtual DtExtent::~DtExtent ( )
virtual

Member Function Documentation

DtExtent& DtExtent::operator= ( const DtExtent orig)
virtual bool DtExtent::operator== ( const DtExtent rhs) const
virtual
virtual bool DtExtent::operator!= ( const DtExtent rhs) const
virtual
double DtExtent::minX ( ) const
double DtExtent::minY ( ) const
double DtExtent::minZ ( ) const
double DtExtent::maxX ( ) const
double DtExtent::maxY ( ) const
double DtExtent::maxZ ( ) const
void DtExtent::setMinX ( double  x)

Access and/or mutate individual values.

void DtExtent::setMinY ( double  y)

Access and/or mutate individual values.

void DtExtent::setMinZ ( double  z)

Access and/or mutate individual values.

void DtExtent::setMaxX ( double  x)

Access and/or mutate individual values.

void DtExtent::setMaxY ( double  y)

Access and/or mutate individual values.

void DtExtent::setMaxZ ( double  z)

Access and/or mutate individual values.

virtual const DtPoint DtExtent::center ( ) const
virtual

Compute the center point.

virtual void DtExtent::setCenter ( const DtPoint p)
virtual

Move the origin, while retaining the dimensions of the box.

virtual void DtExtent::setFromCenter ( const DtPoint p,
const double xDist,
const double yDist,
const double zDist 
)
virtual

Set the extents with the dimensions listed, centered around the point.

double DtExtent::xSize ( ) const

Return the size of the bounding box along the axis.

double DtExtent::ySize ( ) const

Return the size of the bounding box along the axis.

double DtExtent::zSize ( ) const

Return the size of the bounding box along the axis.

virtual DtPoint DtExtent::maxPoint ( ) const
virtual

Return the maximum xyz coordinate of the bounding box.

virtual DtPoint DtExtent::minPoint ( ) const
virtual

Return the minimum xyz coordinate of the bounding box.

bool DtExtent::empty ( ) const

Returns true if the exent is undefined. This can happen if the default constructor was called, or if min/max values were explicitly set inconsistently.

virtual void DtExtent::expandToInclude ( const DtExtent otherExtent)
virtual

Expand extent, if necessary, to include input extent.

Referenced by DtChordBundle::addToEnd(), DtNodeBoundingInfo::expandExtent(), and DtTriangleIndirect::extent().

virtual void DtExtent::expandToInclude ( const DtPoint point)
virtual

Expand extent, if necessary, to include input point.

virtual bool DtExtent::contains ( const DtExtent otherExtent) const
virtual

Determine if another extents box is entirely contained by this one. On the border counts as "contained".

Referenced by DtOctreeNode< const DtSimObject >::addMember().

virtual bool DtExtent::contains ( const DtPoint point) const
virtual

Determine if a point is contained in the extent. On the border counts as "contained".

virtual bool DtExtent::contains ( const DtChord chord) const
virtual

Determine if a chord is contained in the extent. On the border counts as "contained".

bool DtExtent::intersects ( const DtExtent otherExtent) const

Determine if the two extents overlap (either partially or fully). A shared "wall" counts as intersecting.

bool DtExtent::doesNotIntersect ( const DtExtent otherExtent) const

Determine if the two extents are entirely disjoint. i.e. they do not intersect at all.

bool DtExtent::intersects ( const DtSphere sphere) const

Determine if the extent of the sphere intersects with the extent.

bool DtExtent::intersectsLineOfChord ( const DtChord chord,
double distInChordLengthsFirst,
double distInChordLengthsLast 
) const
protected

Determines if the infinite line of which chord is a part intersects the extent. Returns the t-values corresponding to the intersection points in distInChordLengthsFirst, and distInChordLengthsLast, such that distInChordLengthsFirst <= distInChordLengthsLast.

bool DtExtent::intersectsSoFar ( const double  pointVal,
const double  rayVal,
const double  side0,
const double  side1,
double firstTime,
double lastTime 
) const
protected

The following is an ancillary routine to update the intersection times for a chord. What is passed in are single-axis coordinates of a point and a ray (x, y, or z coordinates), and the corresponding values for opposite faces of the extent–side0 and side1. Must have side1>side0, always. The distance in chord lengths to the first and last encounter with the bounding volume so far are passed in as scalars firstTime and lastTime. If there is no intersection, the routine returns false. Otherwise (there is an intersection), the routine returns true and returns the updated distance in chord lengths to the first and last encounter with the bounding volume so far.

void DtExtent::guaranteeValidConstruction ( )
protected

Non-virtual since called from constructors Will flip values to ensure left < right etc.

static DtExtent& DtExtent::nullExtent ( )
static

Return an invalid or empty extent, using the default constructor.

Member Data Documentation

double DtExtent::myMinX
protected
double DtExtent::myMaxX
protected
double DtExtent::myMinY
protected
double DtExtent::myMaxY
protected
double DtExtent::myMinZ
protected
double DtExtent::myMaxZ
protected

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

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)