Mantid
|
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object. More...
#include <BoundingBox.h>
Public Member Functions | |
BoundingBox () | |
Default constructor constructs a zero-sized box. More... | |
BoundingBox (double xmax, double ymax, double zmax, double xmin, double ymin, double zmin) | |
Constructor taking six points. More... | |
Point access | |
double | xMin () const |
Return the minimum value of X. More... | |
double | xMax () const |
Return the maximum value of X. More... | |
double | yMin () const |
Return the minimum value of Y. More... | |
double | yMax () const |
Return the maximum value of Y. More... | |
double | zMin () const |
Return the minimum value of Z. More... | |
double | zMax () const |
Return the maximum value of Z. More... | |
const Kernel::V3D & | minPoint () const |
Returns the min point of the box. More... | |
const Kernel::V3D & | maxPoint () const |
Returns the min point of the box. More... | |
Kernel::V3D | centrePoint () const |
Returns the centre of the bounding box. More... | |
Kernel::V3D | width () const |
Returns the width of the box. More... | |
Querying | |
bool | isNull () const |
Is this a default constructed box? More... | |
bool | isNonNull () const |
Is the box considered valid. Convenience for !isNull() More... | |
bool | isPointInside (const Kernel::V3D &point) const |
Is the given point within the bounding box? More... | |
bool | doesLineIntersect (const Track &track) const |
Does a specified track intersect the bounding box. More... | |
bool | doesLineIntersect (const Kernel::V3D &startPoint, const Kernel::V3D &lineDir) const |
Does a line intersect the bounding box. More... | |
double | angularWidth (const Kernel::V3D &observer) const |
Calculate the angular half width from the given point. More... | |
bool | isAxisAligned () const |
Check if it is normal axis aligned bounding box or not. More... | |
std::vector< Kernel::V3D > const & | getCoordSystem () const |
returns the coordinate system to which BB is alighned to; More... | |
Kernel::V3D | generatePointInside (double r1, double r2, double r3) const |
Generate a random point within the box. More... | |
void | getFullBox (std::vector< Kernel::V3D > &box, const Kernel::V3D &observer) const |
returns the expanded box consisting of all 8 box points, shifted into the coordinate system with the observer centre; More... | |
Static Public Member Functions | |
static void | checkValid (double xmax, double ymax, double zmax, double xmin, double ymin, double zmin) |
Do the given arguments form a valid bounding box, throws std::invalid argument if not. More... | |
Box mutation functions | |
Kernel::V3D | m_minPoint |
The minimum point of the axis-aligned box. More... | |
Kernel::V3D | m_maxPoint |
The maximum point of the axis-aligned box. More... | |
bool | m_null |
Flag marking if we've been initialized using the default constructor, with values or default values and user-set points. More... | |
bool | is_axis_aligned |
the parameter which describe if the bounding box is axis aligned or not More... | |
std::vector< Kernel::V3D > | coord_system |
if the bounding box is not axis aligned, the vector below describes the coordinate system, to which the bounding box is alighned to. More... | |
double & | xMin () |
Return the minimum value of X (non-const) More... | |
double & | xMax () |
Return the maximum value of X (non-const) More... | |
double & | yMin () |
Return the minimum value of Y (non-const) More... | |
double & | yMax () |
Return the maximum value of Y (non-const) More... | |
double & | zMin () |
Return the minimum value of Z (non-const) More... | |
double & | zMax () |
Return the maximum value of Z (non-const) More... | |
void | grow (const BoundingBox &other) |
Grow the bounding box so that it also encompasses the given box. More... | |
void | setBoxAlignment (const Kernel::V3D &R0, const std::vector< Kernel::V3D > &orts) |
change the BB alighnment, providing new coordinate system to alighn it to. More... | |
void | nullify () |
set BB in to undefined state with min=FLT_MAX>max=-FLT_MAX More... | |
void | realign (std::vector< Kernel::V3D > const *const pCS=nullptr) |
reallign the BB according to new coordinate system, provided earlier or specified as parameter; More... | |
void | moveBy (const Kernel::V3D &v) |
move the BB by a vector More... | |
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
It is a thin structure containing the 6 points that define the corners of the cuboid.
Definition at line 34 of file BoundingBox.h.
|
inline |
Default constructor constructs a zero-sized box.
Definition at line 37 of file BoundingBox.h.
|
inline |
Constructor taking six points.
If inconsistent points are defined, i.e. xmin > xmax, then an error is thrown
xmax | :: Value of maximum in X. It must be greater than xmin. |
ymax | :: Value of maximum in Y. It must be greater than ymin. |
zmax | :: Value of maximum in Z. It must be greater than zmin. |
xmin | :: Value of minimum in X. It must be less than xmax. |
ymin | :: Value of minimum in Y. It must be less than ymax. |
zmin | :: Value of minimum in Z. It must be less than zmax. |
Definition at line 48 of file BoundingBox.h.
double Mantid::Geometry::BoundingBox::angularWidth | ( | const Kernel::V3D & | observer | ) | const |
Calculate the angular half width from the given point.
Find maximum angular half width of the bounding box from the observer, that is the greatest angle between the centre point and any corner point.
observer | :: Viewing point |
Definition at line 122 of file BoundingBox.cpp.
References centrePoint(), getFullBox(), and Mantid::Kernel::V3D::norm().
Referenced by Mantid::Geometry::CSGObject::rayTraceSolidAngle().
|
inline |
Returns the centre of the bounding box.
Definition at line 94 of file BoundingBox.h.
Referenced by angularWidth(), Mantid::Algorithms::BeamProfileFactory::createBeamProfile(), export_BoundingBox(), Mantid::Geometry::CSGObject::getPointInObject(), Mantid::Geometry::MeshObject::getPointInObject(), and Mantid::Geometry::CSGObject::rayTraceSolidAngle().
|
inlinestatic |
Do the given arguments form a valid bounding box, throws std::invalid argument if not.
xmax | :: Value of maximum in X. It must be greater than xmin. |
ymax | :: Value of maximum in Y. It must be greater than ymin. |
zmax | :: Value of maximum in Z. It must be greater than zmin. |
xmin | :: Value of minimum in X. It must be less than xmax. |
ymin | :: Value of minimum in Y. It must be less than ymax. |
zmin | :: Value of minimum in Z. It must be less than zmax. |
Definition at line 64 of file BoundingBox.h.
References error.
Referenced by Mantid::Geometry::CSGObject::defineBoundingBox().
bool Mantid::Geometry::BoundingBox::doesLineIntersect | ( | const Kernel::V3D & | startPoint, |
const Kernel::V3D & | lineDir | ||
) | const |
Does a line intersect the bounding box.
startPoint | :: The starting point for the line. It is assumed that this is outside the bounding box. |
lineDir | :: The direction of the line |
Definition at line 55 of file BoundingBox.cpp.
References isAxisAligned(), isPointInside(), lambda, Mantid::Kernel::Tolerance, Mantid::Kernel::V3D::X(), xMax(), xMin(), Mantid::Kernel::V3D::Y(), yMax(), yMin(), Mantid::Kernel::V3D::Z(), zMax(), and zMin().
bool Mantid::Geometry::BoundingBox::doesLineIntersect | ( | const Track & | track | ) | const |
Does a specified track intersect the bounding box.
Does a defined track intersect the bounding box.
track | :: A test track It is assumed that this is outside the bounding box. |
Definition at line 44 of file BoundingBox.cpp.
References Mantid::Geometry::Track::direction(), doesLineIntersect(), and Mantid::Geometry::Track::startPoint().
Referenced by Mantid::API::DetectorSearcher::checkInteceptWithNeighbours(), doesLineIntersect(), export_BoundingBox(), Mantid::Geometry::InstrumentRayTracer::fireRay(), Mantid::Geometry::MeshObject::interceptSurface(), and Mantid::Geometry::CSGObject::rayTraceSolidAngle().
Kernel::V3D Mantid::Geometry::BoundingBox::generatePointInside | ( | double | r1, |
double | r2, | ||
double | r3 | ||
) | const |
Generate a random point within the box.
Generate a random point within this box assuming the 3 numbers given are random numbers in the range (0,1) & selected from a flat distribution.
r1 | Flat random number in range (0,1) |
r2 | Flat random number in range (0,1) |
r3 | Flat random number in range (0,1) |
Definition at line 146 of file BoundingBox.cpp.
References xMax(), xMin(), yMax(), yMin(), zMax(), and zMin().
Referenced by Mantid::Geometry::RandomPoint::bounded().
|
inline |
returns the coordinate system to which BB is alighned to;
Definition at line 118 of file BoundingBox.h.
Referenced by Mantid::Geometry::ComponentInfo::componentBoundingBox(), Mantid::Geometry::ObjComponent::getBoundingBox(), and Mantid::Geometry::DetectorGroup::getBoundingBox().
void Mantid::Geometry::BoundingBox::getFullBox | ( | std::vector< Kernel::V3D > & | box, |
const Kernel::V3D & | observer | ||
) | const |
returns the expanded box consisting of all 8 box points, shifted into the coordinate system with the observer centre;
Definition at line 150 of file BoundingBox.cpp.
References xMax(), xMin(), yMax(), yMin(), zMax(), and zMin().
Referenced by angularWidth(), and realign().
void Mantid::Geometry::BoundingBox::grow | ( | const BoundingBox & | other | ) |
Grow the bounding box so that it also encompasses the given box.
Enlarges this bounding box so that it encompasses that given.
other | :: The bounding box that should be encompassed |
Definition at line 231 of file BoundingBox.cpp.
References m_maxPoint, m_minPoint, and m_null.
Referenced by Mantid::Geometry::SampleEnvironment::boundingBox(), Mantid::Geometry::ComponentInfo::boundingBox(), Mantid::Geometry::Instrument::getBoundingBox(), Mantid::Geometry::CompAssembly::getBoundingBox(), Mantid::Geometry::GridDetector::getBoundingBox(), Mantid::Geometry::StructuredDetector::getBoundingBox(), Mantid::Geometry::DetectorGroup::getBoundingBox(), Mantid::Algorithms::MCInteractionVolume::getFullBoundingBox(), Mantid::Geometry::ComponentInfo::growBoundingBoxAsOutline(), Mantid::Geometry::ComponentInfo::growBoundingBoxAsRectuangularBank(), and Mantid::Algorithms::DiscusMultipleScatteringCorrection::prepareSampleBeamGeometry().
|
inline |
Check if it is normal axis aligned bounding box or not.
Definition at line 116 of file BoundingBox.h.
Referenced by Mantid::Geometry::ComponentInfo::componentBoundingBox(), doesLineIntersect(), Mantid::Geometry::ObjComponent::getBoundingBox(), Mantid::Geometry::DetectorGroup::getBoundingBox(), isPointInside(), and realign().
|
inline |
Is the box considered valid. Convenience for !isNull()
Definition at line 106 of file BoundingBox.h.
Referenced by Mantid::Geometry::CSGObject::getBoundingBox(), Mantid::Geometry::CSGObject::getPointInObject(), Mantid::Geometry::MeshObject::getPointInObject(), Mantid::Geometry::CSGObject::rayTraceSolidAngle(), and Mantid::Geometry::CSGObject::triangulatedSolidAngle().
|
inline |
Is this a default constructed box?
Definition at line 104 of file BoundingBox.h.
Referenced by Mantid::Geometry::RandomPoint::bounded(), export_BoundingBox(), Mantid::Geometry::ObjComponent::getBoundingBox(), and Mantid::Geometry::MeshObjectCommon::getBoundingBox().
bool Mantid::Geometry::BoundingBox::isPointInside | ( | const Kernel::V3D & | point | ) | const |
Is the given point within the bounding box?
Query whether the given point is inside the bounding box within a tolerance defined by Mantid::Geometry::Tolerance.
point | :: The point to query |
Definition at line 28 of file BoundingBox.cpp.
References isAxisAligned(), Mantid::Kernel::Tolerance, Mantid::Kernel::V3D::X(), xMax(), xMin(), Mantid::Kernel::V3D::Y(), yMax(), yMin(), Mantid::Kernel::V3D::Z(), zMax(), and zMin().
Referenced by Mantid::Geometry::RandomPoint::bounded(), doesLineIntersect(), Mantid::Crystal::IntegratePeakTimeSlices::exec(), Mantid::Algorithms::SpatialGrouping::expandNet(), export_BoundingBox(), Mantid::Geometry::MeshObject::isOnSide(), Mantid::Geometry::MeshObject::isValid(), Mantid::Geometry::CSGObject::rayTraceSolidAngle(), and Mantid::Geometry::CSGObject::triangulatedSolidAngle().
|
inline |
Returns the min point of the box.
Definition at line 92 of file BoundingBox.h.
Referenced by Mantid::CurveFitting::Algorithms::VesuvioCalculateGammaBackground::cacheInstrumentGeometry(), Mantid::Algorithms::RectangularBeamProfile::defineActiveRegion(), Mantid::Algorithms::CircularBeamProfile::defineActiveRegion(), export_BoundingBox(), Mantid::Algorithms::CircularBeamProfile::generatePoint(), Mantid::Algorithms::RectangularBeamProfile::generatePoint(), and Mantid::DataObjects::initAngularCaches().
|
inline |
Returns the min point of the box.
Definition at line 90 of file BoundingBox.h.
Referenced by Mantid::CurveFitting::Algorithms::VesuvioCalculateGammaBackground::cacheInstrumentGeometry(), Mantid::Algorithms::RectangularBeamProfile::defineActiveRegion(), Mantid::Algorithms::CircularBeamProfile::defineActiveRegion(), export_BoundingBox(), Mantid::Algorithms::CircularBeamProfile::generatePoint(), Mantid::Algorithms::RectangularBeamProfile::generatePoint(), and Mantid::DataObjects::initAngularCaches().
|
inline |
move the BB by a vector
Definition at line 168 of file BoundingBox.h.
void Mantid::Geometry::BoundingBox::nullify | ( | ) |
set BB in to undefined state with min=FLT_MAX>max=-FLT_MAX
Definition at line 171 of file BoundingBox.cpp.
References m_maxPoint, m_minPoint, and m_null.
Referenced by Mantid::Geometry::ObjComponent::getBoundingBox().
void Mantid::Geometry::BoundingBox::realign | ( | std::vector< Kernel::V3D > const *const | pCS = nullptr | ) |
reallign the BB according to new coordinate system, provided earlier or specified as parameter;
Definition at line 179 of file BoundingBox.cpp.
References coord_system, getFullBox(), is_axis_aligned, isAxisAligned(), m_null, Mantid::Geometry::x, xMax(), xMin(), Mantid::Geometry::y, yMax(), yMin(), Mantid::Geometry::z, zMax(), and zMin().
Referenced by Mantid::Geometry::ComponentInfo::componentBoundingBox(), Mantid::Geometry::ObjComponent::getBoundingBox(), and Mantid::Geometry::DetectorGroup::getBoundingBox().
void Mantid::Geometry::BoundingBox::setBoxAlignment | ( | const Kernel::V3D & | R0, |
const std::vector< Kernel::V3D > & | orts | ||
) |
change the BB alighnment, providing new coordinate system to alighn it to.
Definition at line 162 of file BoundingBox.cpp.
References coord_system, and is_axis_aligned.
Referenced by Mantid::DataHandling::AvrgDetector::addDetInfo().
|
inline |
Returns the width of the box.
Definition at line 98 of file BoundingBox.h.
Referenced by Mantid::API::WorkspaceNearestNeighbours::build(), Mantid::CurveFitting::Algorithms::VesuvioCalculateMS::cacheInputs(), Mantid::Algorithms::VesuvioL1ThetaResolution::calculateDetector(), Mantid::Geometry::DetectorGroup::calculateGroupTopology(), Mantid::Algorithms::BeamProfileFactory::createBeamProfile(), export_BoundingBox(), Mantid::Algorithms::RadiusSum::getMinBinSizeForInstrument(), and Mantid::Algorithms::SmoothNeighbours::translateToMeters().
|
inline |
Return the maximum value of X (non-const)
Definition at line 134 of file BoundingBox.h.
|
inline |
Return the maximum value of X.
Definition at line 80 of file BoundingBox.h.
Referenced by Mantid::Geometry::ComponentInfo::componentBoundingBox(), Mantid::Algorithms::SpatialGrouping::createBox(), doesLineIntersect(), Mantid::Algorithms::DiffractionEventCalibrateDetectors::exec(), Mantid::Crystal::IntegratePeakTimeSlices::FindPlane(), generatePointInside(), Mantid::Geometry::ObjComponent::getBoundingBox(), getFullBox(), Mantid::Crystal::IntegratePeakTimeSlices::getNeighborPixIDs(), Mantid::Geometry::ObjComponent::getWidth(), isPointInside(), Mantid::Geometry::operator<<(), realign(), and Mantid::Geometry::MeshObject::volume().
|
inline |
Return the minimum value of X (non-const)
Definition at line 129 of file BoundingBox.h.
|
inline |
Return the minimum value of X.
Definition at line 78 of file BoundingBox.h.
Referenced by Mantid::Geometry::ComponentInfo::componentBoundingBox(), Mantid::Algorithms::SpatialGrouping::createBox(), doesLineIntersect(), Mantid::Crystal::IntegratePeakTimeSlices::FindPlane(), generatePointInside(), Mantid::Geometry::ObjComponent::getBoundingBox(), getFullBox(), Mantid::Crystal::IntegratePeakTimeSlices::getNeighborPixIDs(), Mantid::Geometry::ObjComponent::getWidth(), isPointInside(), Mantid::Geometry::operator<<(), realign(), and Mantid::Geometry::MeshObject::volume().
|
inline |
Return the maximum value of Y (non-const)
Definition at line 144 of file BoundingBox.h.
|
inline |
Return the maximum value of Y.
Definition at line 84 of file BoundingBox.h.
Referenced by Mantid::DataHandling::AvrgDetector::addDetInfo(), Mantid::Geometry::ComponentInfo::componentBoundingBox(), Mantid::Algorithms::SpatialGrouping::createBox(), doesLineIntersect(), Mantid::Algorithms::DiffractionEventCalibrateDetectors::exec(), Mantid::Crystal::IntegratePeakTimeSlices::FindPlane(), generatePointInside(), Mantid::Geometry::ObjComponent::getBoundingBox(), getFullBox(), Mantid::Geometry::ObjComponent::getHeight(), Mantid::Crystal::IntegratePeakTimeSlices::getNeighborPixIDs(), Mantid::DataHandling::LoadILLDiffraction::initMovingWorkspace(), isPointInside(), Mantid::Geometry::operator<<(), realign(), and Mantid::Geometry::MeshObject::volume().
|
inline |
Return the minimum value of Y (non-const)
Definition at line 139 of file BoundingBox.h.
|
inline |
Return the minimum value of Y.
Definition at line 82 of file BoundingBox.h.
Referenced by Mantid::DataHandling::AvrgDetector::addDetInfo(), Mantid::Geometry::ComponentInfo::componentBoundingBox(), Mantid::Algorithms::SpatialGrouping::createBox(), doesLineIntersect(), Mantid::Crystal::IntegratePeakTimeSlices::FindPlane(), generatePointInside(), Mantid::Geometry::ObjComponent::getBoundingBox(), getFullBox(), Mantid::Geometry::ObjComponent::getHeight(), Mantid::Crystal::IntegratePeakTimeSlices::getNeighborPixIDs(), Mantid::DataHandling::LoadILLDiffraction::initMovingWorkspace(), isPointInside(), Mantid::Geometry::operator<<(), realign(), and Mantid::Geometry::MeshObject::volume().
|
inline |
Return the maximum value of Z (non-const)
Definition at line 154 of file BoundingBox.h.
|
inline |
Return the maximum value of Z.
Definition at line 88 of file BoundingBox.h.
Referenced by Mantid::DataHandling::AvrgDetector::addDetInfo(), Mantid::Geometry::ComponentInfo::componentBoundingBox(), Mantid::Algorithms::SpatialGrouping::createBox(), doesLineIntersect(), Mantid::Algorithms::DiffractionEventCalibrateDetectors::exec(), generatePointInside(), Mantid::Geometry::ObjComponent::getBoundingBox(), Mantid::Geometry::ObjComponent::getDepth(), getFullBox(), Mantid::Crystal::IntegratePeakTimeSlices::getNeighborPixIDs(), isPointInside(), Mantid::Geometry::operator<<(), realign(), and Mantid::Geometry::MeshObject::volume().
|
inline |
Return the minimum value of Z (non-const)
Definition at line 149 of file BoundingBox.h.
|
inline |
Return the minimum value of Z.
Definition at line 86 of file BoundingBox.h.
Referenced by Mantid::DataHandling::AvrgDetector::addDetInfo(), Mantid::Geometry::ComponentInfo::componentBoundingBox(), Mantid::Algorithms::SpatialGrouping::createBox(), doesLineIntersect(), generatePointInside(), Mantid::Geometry::ObjComponent::getBoundingBox(), Mantid::Geometry::ObjComponent::getDepth(), getFullBox(), Mantid::Crystal::IntegratePeakTimeSlices::getNeighborPixIDs(), isPointInside(), Mantid::Geometry::operator<<(), realign(), and Mantid::Geometry::MeshObject::volume().
|
private |
if the bounding box is not axis aligned, the vector below describes the coordinate system, to which the bounding box is alighned to.
The vector has 4 members, with first describing new coordinate system center and three others – orts of this system
Definition at line 189 of file BoundingBox.h.
Referenced by realign(), and setBoxAlignment().
|
private |
the parameter which describe if the bounding box is axis aligned or not
Definition at line 183 of file BoundingBox.h.
Referenced by realign(), and setBoxAlignment().
|
private |
The maximum point of the axis-aligned box.
Definition at line 178 of file BoundingBox.h.
|
private |
The minimum point of the axis-aligned box.
Definition at line 176 of file BoundingBox.h.
|
private |
Flag marking if we've been initialized using the default constructor, with values or default values and user-set points.
Definition at line 181 of file BoundingBox.h.