Workspace 6.21.5
Public Member Functions | List of all members
BoundingBox Class Reference

Describes a bounding box region in 3D space.

#include <Mesh/Geometry/boundingbox.h>

Inheritance diagram for BoundingBox:
[legend]

Public Member Functions

 BoundingBox ()
 
 BoundingBox (const BoundingBox &box)
 
 BoundingBox (const BoundingBoxMinimal &box)
 
 BoundingBox (const Vector3d &corner1, const Vector3d &corner2)
 
 BoundingBox (const Vector3d &starter)
 
Vector3d calculateCenter () const
 
void clear ()
 
BoundingBoxclone () const override
 
BoundingBoxcloneRegion () const override
 
bool contains (const Vector3d &p) const override
 
void destroy () override
 
void expand (const BoundingBox &box)
 
bool expand (const Region &region)
 
void expand (const Vector3d &p)
 
bool getBoundingBox (Vector3d &minimum, Vector3d &maximum) const override
 
Vector3d getMaximum () const
 
Vector3d getMinimum () const
 
void intersect (const BoundingBox &box)
 
void intersect (const Vector3d &boxMin, const Vector3d &boxMax)
 
bool isInfinite () const
 
bool isNull () const override
 
bool operator!= (const BoundingBox &v) const
 
bool operator== (const BoundingBox &b) const
 
void setInfinite ()
 
void setMaximum (const Vector3d &max)
 
void setMinimum (const Vector3d &min)
 
bool visit (RegionProcessor &processor) override
 
- Public Member Functions inherited from Region
virtual ~Region ()=default
 
virtual RegioncloneRegion () const =0
 
virtual bool contains (const Vector3d &p) const =0
 
virtual void destroy ()=0
 
virtual bool getBoundingBox (Vector3d &minimum, Vector3d &maximum) const =0
 
virtual bool getBoundingSphere (Vector3d &center, double &radius) const
 
virtual bool isNull () const =0
 
virtual bool visit (RegionProcessor &processor)=0
 
- Public Member Functions inherited from ObjectGroup
 ~ObjectGroup () override
 
bool add (const QString &name, DataObject &obj)
 
bool canSerialize () const override
 
ObjectGroupclone () const override=0
 
bool empty () const
 
void ensureGroupHasData ()
 
void erase (int index)
 
DataObjectgetChild (const QString &name)
 
const DataObjectgetChild (const QString &name) const
 
DataObjectgetDataObject (int index)
 
const DataObjectgetDataObject (int index) const
 
int getIndex (const QString &name) const
 
const QString & getName (int index) const
 
virtual QString getPreferedWidget (const QString &name) const
 
bool hasData () const
 
bool haveName (const QString &name) const
 
bool insert (const QString &name, DataObject &obj, int index=-1)
 
bool load (const QJsonDocument &doc)
 
bool load (const SerializedItem &item) override
 
bool save (QJsonDocument &doc) const
 
bool save (SerializedItem &item) const override
 
unsigned size () const
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()=default
 
virtual Clonableclone () const =0
 
- Public Member Functions inherited from Serialize
virtual ~Serialize ()=default
 
virtual bool canSerialize () const =0
 
virtual bool load (const SerializedItem &item)=0
 
virtual bool save (SerializedItem &item) const =0
 

Additional Inherited Members

- Protected Member Functions inherited from ObjectGroup
 ObjectGroup ()
 
void clear ()
 
ObjectGroupoperator= (const ObjectGroup &rhs)
 
bool operator== (const ObjectGroup &rhs) const
 
void swap (ObjectGroup &rhs)
 

Constructor & Destructor Documentation

◆ BoundingBox() [1/5]

Constructs a null bounding box.

◆ BoundingBox() [2/5]

BoundingBox ( const BoundingBox box)
Parameters
boxThe bounding box to copy.

◆ BoundingBox() [3/5]

BoundingBox ( const BoundingBoxMinimal box)
Parameters
boxThe bounding box to copy.

◆ BoundingBox() [4/5]

BoundingBox ( const Vector3d starter)
Parameters
starterThe bounding box will be constructed with its minimum and maximum set to this value.

◆ BoundingBox() [5/5]

BoundingBox ( const Vector3d corner1,
const Vector3d corner2 
)
Parameters
corner1One corner of the bounding box.
corner2The corner diagonally opposite corner1.

The caller only needs to ensure that the two corners are diagonally opposite. The constructor works out for itself what the minimum and maximum values should be. Note that it is possible for the minimum and maximum to be different to both corner1 and corner2.

Member Function Documentation

◆ calculateCenter()

Vector3d calculateCenter ( ) const
Returns
The center of the bounding box. This is simply the average of the minimum and maximum.
Precondition
The bounding box must not be null.
See also
isNull()

◆ clear()

void clear ( )

Sets the bounding box to a null region.

◆ clone()

BoundingBox * clone ( ) const
overridevirtual
Returns
A clone of this object.
Note
Subclasses would normally return their own type rather than the Clonable type. The C++ language rules allow a more derived type to be returned from a virtual function and the compiler will still treat it as a valid override.

We redeclare this function only so that the more derived return type is available without casting.

Implements ObjectGroup.

◆ cloneRegion()

BoundingBox * cloneRegion ( ) const
inlineoverridevirtual

This function should be called clone() but the Visual Studio compilers do not handle covariant return types when multiple inheritance from a virtual base class is involved. Since Region is often combined with other Clonable classes such as ObjectGroup, we don't provide clone() but instead provide cloneRegion() which is effectively doing the same thing, albeit with the annoyance of a different function name.

Note that subclasses will need to tell DataExecution::TypedDataFactory about their cloneRegion() implementation explicitly if they do not also inherit from some other Clonable base class as well, since Region does not derive from Clonable (which means the template specializations for TypedDataFactory will not automatically detect cloneRegion()).

Implements Region.

◆ contains()

bool contains ( const Vector3d p) const
overridevirtual
Parameters
pThe point to test.
Returns
True if the point p is contained within the region. If p falls on the boundary of the region, the result returned must also be true. If the region is a null region (ie isNull() returns true), this function must return false.

Implements Region.

◆ destroy()

void destroy ( )
overridevirtual

Destroys the object. This function is usually implemented by calling operator delete on the object.

See also
clone()

Implements Region.

◆ expand() [1/3]

void expand ( const BoundingBox box)
Parameters
boxThe other box to use to expand the current one.

The current bounding box extents are expanded until they fully contain box. It is equivalent to calling expand(const Vector3d&) with the minimum followed by the maximum, but the function here can take advantage of compiler optimizations to make it more efficient than clients making those calls themselves.

◆ expand() [2/3]

bool expand ( const Region region)
Parameters
regionThe bounding box of the region r will be used to expand the current bounding box.

The current bounding box extents are expanded until they fully contain the bounding box of the specified region.

Returns
True if the bounding box for region could be obtained, in which case the current object's bounding box will be expanded to contain it. If the bounding box for region could not be obtained, the function returns false and the current bounding box is left unchanged.

◆ expand() [3/3]

void expand ( const Vector3d p)
Parameters
pThe point to test against the bounding box.

If p is not within the current bounding box, the box will be expanded to include it. If the bounding box is null at the time of the call, it will be made non-null and will have its minimum and maximum set to p.

◆ getBoundingBox()

bool getBoundingBox ( Vector3d minimum,
Vector3d maximum 
) const
overridevirtual
Parameters
minimumIf the function returns true, then at exit this will hold the corner of the bounding box corresponding to the minimum values of X, Y and Z.
maximumIf the function returns true, then at exit this will hold the corner of the bounding box corresponding to the maximum values of X, Y and Z.

The bounding box is guaranteed to contain all the regions for which a point passed to contains() will return true. It can be useful as a way of short-circuiting a more expensive test for whether a point is contained in a complex region. How conservative the bounding box is will be determined entirely by the subclass. It is allowable for the subclass to return the entire 3D domain as the bounding box (and indeed some subclasses logically have to do this, such as RegionNegate).

Returns
True if the bounding box could be defined. A return value of false would normally indicate that the region is null.
See also
getBoundingSphere(), isNull()

Implements Region.

◆ getMaximum()

Vector3d getMaximum ( ) const
Returns
The maximum of the bounding box.
Precondition
The bounding box must not be null.
See also
isNull()

◆ getMinimum()

Vector3d getMinimum ( ) const
Returns
The minimum of the bounding box.
Precondition
The bounding box must not be null.
See also
isNull()

◆ intersect() [1/2]

void intersect ( const BoundingBox box)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
boxThe other box with which to form an intersection.

The intersection of two bounding boxes is the overlapping region, which is also a box. If either box is null, the intersection is also null. If there is no overlapping region, the result is again null. Otherwise, the result will be the largest box that is contained by both boxes.

◆ intersect() [2/2]

void intersect ( const Vector3d boxMin,
const Vector3d boxMax 
)
Parameters
boxMinThe minimum of the bounding box with which to form an intersection.
boxMaxThe minimum of the bounding box with which to form an intersection.
Precondition
No checks are performed on boxMin or boxMax as to whether they are actually properly formed for a bounding box (ie the maximum is never less than the minimum in any of the three component directions). Callers must ensure this for themselves. If they are obtained from getMinimum() and getMaximum() from a bounding box that is not null, this property is already ensured.

The intersection of two bounding boxes is the overlapping region, which is also a box. If either box is null, the intersection is also null. If there is no overlapping region, the result is again null. Otherwise, the result will be the largest box that is contained by both boxes.

◆ isInfinite()

bool isInfinite ( ) const
Returns
True if this bounding box is considered infinite. A null bounding box is never infinite.

Internally, an infinite bounding box is one that has the maximum allowable value for the minimum and maximum of the box. Clients should use this function rather than performing that test for themselves in case the way an infinite box is defined changes.

See also
setInfinite()

◆ isNull()

bool isNull ( ) const
overridevirtual
Returns
True if the bounding box is null. Any call to expand() will make a bounding box object non-null, as will the constructors taking Vector3d parameters.

Implements Region.

◆ operator!=()

bool operator!= ( const BoundingBox v) const
inline

◆ operator==()

bool operator== ( const BoundingBox b) const

◆ setInfinite()

void setInfinite ( )
See also
isInfinite()

◆ setMaximum()

void setMaximum ( const Vector3d max)

◆ setMinimum()

void setMinimum ( const Vector3d min)

◆ visit()

bool visit ( RegionProcessor processor)
overridevirtual

Visit the specified region processor, invoking the correct processing function. Subclasses will need to override this to invoke the correct function.

Implements Region.