Workspace 6.21.5
|
Describes a bounding cylinder region in 3D space. More...
#include <Mesh/Geometry/boundingcylinder.h>
Public Member Functions | |
BoundingCylinder () | |
BoundingCylinder (const BoundingCylinder &cylinder) | |
BoundingCylinder (const Vector3d ¢erA, const Vector3d ¢erB, double radius) | |
double | calculateLength () const |
BoundingCylinder * | clone () const override |
BoundingCylinder * | cloneRegion () const override |
bool | contains (const Vector3d &p) const override |
void | destroy () override |
bool | getBoundingBox (Vector3d &minimum, Vector3d &maximum) const override |
bool | getBoundingSphere (Vector3d ¢er, double &radius) const override |
Vector3d | getCenterA () const |
Vector3d | getCenterB () const |
double | getRadius () const |
bool | isNull () const override |
bool | operator!= (const BoundingCylinder &v) const |
bool | operator== (const BoundingCylinder &b) const |
void | setCenterA (const Vector3d &c) |
void | setCenterB (const Vector3d &c) |
void | setRadius (double r) |
bool | visit (RegionProcessor &processor) override |
Public Member Functions inherited from Region | |
virtual | ~Region ()=default |
virtual Region * | cloneRegion () 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 ¢er, 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 |
ObjectGroup * | clone () const override=0 |
bool | empty () const |
void | ensureGroupHasData () |
void | erase (int index) |
DataObject * | getChild (const QString &name) |
const DataObject * | getChild (const QString &name) const |
DataObject & | getDataObject (int index) |
const DataObject & | getDataObject (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 Clonable * | clone () 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 () |
ObjectGroup & | operator= (const ObjectGroup &rhs) |
bool | operator== (const ObjectGroup &rhs) const |
void | swap (ObjectGroup &rhs) |
The cylinder is defined by the two circular face centers and a constant radius.
BoundingCylinder | ( | ) |
Constructs a null bounding cylinder.
BoundingCylinder | ( | const BoundingCylinder & | cylinder | ) |
cylinder | The bounding cylinder to copy. |
BoundingCylinder | ( | const Vector3d & | centerA, |
const Vector3d & | centerB, | ||
double | radius | ||
) |
centerA | The center of the bounding cylinder at one end. |
centerB | The center of the bounding cylinder at the other end. |
radius | The radius of the bounding cylinder. It must not be negative. |
double calculateLength | ( | ) | const |
This is just a convenience function. It is entirely equivalent to taking the magnitude of the difference between the two face centers.
|
overridevirtual |
We redeclare this function only so that the more derived return type is available without casting.
Implements ObjectGroup.
|
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.
|
overridevirtual |
p | The point to test. |
The computation for a bounding cylinder is relatively expensive. The current implementation uses three square root calculations. This may be optimized in future by pre-calculating some quantities to reduce this down to one square root calculation.
Implements Region.
|
overridevirtual |
minimum | If 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. |
maximum | If 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).
The implementation of this function in BoundingCylinder errs on the side of being computationally inexpensive at the cost of defining a larger than necessary bounding box if the cylinder is not axis-aligned. This is so that requests for calculating the bounding box are quick and therefore can be called frequently as an optimization for avoiding the more expensive call to contains().
Implements Region.
|
overridevirtual |
center | This will hold the center of the bounding cylinder if the function is successful. If not successful, the function leaves it unmodified from the passed in value. |
radius | This will hold the radius of the bounding cylinder if the function is successful. If not successful, the function leaves it unmodified from the passed in value. |
If the bounding cylinder is not null, this function always succeeds. Unlike getBoundingBox(), the calculation of the bounding sphere returns the smallest possible radius that bounds the cylinder. This is because the use of a square root in the calculation is unavoidable so the exact calculation is no worse than any other approximation from a computational cost perspective.
Reimplemented from Region.
Vector3d getCenterA | ( | ) | const |
Vector3d getCenterB | ( | ) | const |
double getRadius | ( | ) | const |
|
overridevirtual |
Implements Region.
|
inline |
bool operator== | ( | const BoundingCylinder & | b | ) | const |
void setCenterA | ( | const Vector3d & | c | ) |
c | The new center of the cylinder at end A. |
void setCenterB | ( | const Vector3d & | c | ) |
c | The new center of the cylinder at end B. |
void setRadius | ( | double | r | ) |
r | The new radius of the cylinder. |
|
overridevirtual |
Visit the specified region processor, invoking the correct processing function. Subclasses will need to override this to invoke the correct function.
Implements Region.