Workspace 6.21.5
Public Member Functions | List of all members
Region Class Referenceabstract

Abstract base class defining an arbitrary region in 3D space. More...

#include <Mesh/Geometry/region.h>

Inheritance diagram for Region:
[legend]

Public Member Functions

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
 

Detailed Description

Ideally, this class would inherit from Clonable, but this leads to problems when using the Visual Studio compilers. See the documentation for cloneRegion() for further details.

Constructor & Destructor Documentation

◆ ~Region()

virtual ~Region ( )
virtualdefault

Member Function Documentation

◆ cloneRegion()

virtual Region * cloneRegion ( ) const
pure virtual

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

Implemented in BoundingBox, BoundingCylinder, BoundingPlane, BoundingSphere, RegionIntersection, RegionNegate, RegionTransform, and RegionUnion.

◆ contains()

virtual bool contains ( const Vector3d p) const
pure virtual
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.

Implemented in BoundingBox, BoundingCylinder, BoundingPlane, BoundingSphere, RegionIntersection, RegionNegate, RegionTransform, and RegionUnion.

◆ destroy()

virtual void destroy ( )
pure virtual

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

See also
clone()

Implemented in BoundingBox, BoundingCylinder, BoundingPlane, BoundingSphere, RegionIntersection, RegionNegate, RegionTransform, and RegionUnion.

◆ getBoundingBox()

virtual bool getBoundingBox ( Vector3d minimum,
Vector3d maximum 
) const
pure virtual
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()

Implemented in BoundingBox, BoundingCylinder, BoundingPlane, BoundingSphere, RegionIntersection, RegionNegate, RegionTransform, and RegionUnion.

◆ getBoundingSphere()

bool getBoundingSphere ( Vector3d center,
double &  radius 
) const
virtual
Parameters
centerThis will hold the center of the bounding sphere if the function is successful. If not successful, the function leaves it unmodified from the passed in value.
radiusThis will hold the radius of the bounding sphere if the function is successful. If not successful, the function leaves it unmodified from the passed in value.

This function must work out the bounding sphere around the region such that all parts of the region will be inside or on the boundary of the bounding sphere. The default implementation is fairly naive. All it does is return the bounding sphere around the result of getBoundingBox(). If any dimensions of that bounding box are infinite, the radius returned will be infinite and the center will be left unchanged since it has no meaning in such cases. Subclasses will likely be able to return a more compact bounding sphere or perform the calculation more efficiently.

Returns
True if the bounding sphere was successfully calculated. A return value of false would normally indicate that the region is null.
See also
getBoundingBox(), isNull()

Reimplemented in BoundingCylinder, and BoundingSphere.

◆ isNull()

virtual bool isNull ( ) const
pure virtual
Returns
True if the region is null.

A null region is one that has not been fully defined or which has no possible region. Null regions are often created in the default constructor of Region subclasses to indicate that the region has not yet been set up. Another common situation where null regions are encountered is when the intersection of non-overlapping regions is calculated.

Null regions obviously cannot contain anything and therefore will always return false from contains().

Implemented in BoundingBox, BoundingCylinder, BoundingPlane, BoundingSphere, RegionIntersection, RegionNegate, RegionTransform, and RegionUnion.

◆ visit()

virtual bool visit ( RegionProcessor processor)
pure virtual

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

Implemented in BoundingBox, BoundingCylinder, BoundingPlane, BoundingSphere, RegionIntersection, RegionNegate, RegionTransform, and RegionUnion.