Mantid
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Mantid::Geometry::BoundingBox Class Reference

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::V3DminPoint () const
 Returns the min point of the box. More...
 
const Kernel::V3DmaxPoint () 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::V3Dcoord_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...
 

Detailed Description

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.

Author
Martyn Gigg
Date
01/10/2010

Definition at line 34 of file BoundingBox.h.

Constructor & Destructor Documentation

◆ BoundingBox() [1/2]

Mantid::Geometry::BoundingBox::BoundingBox ( )
inline

Default constructor constructs a zero-sized box.

Definition at line 37 of file BoundingBox.h.

◆ BoundingBox() [2/2]

Mantid::Geometry::BoundingBox::BoundingBox ( double  xmax,
double  ymax,
double  zmax,
double  xmin,
double  ymin,
double  zmin 
)
inline

Constructor taking six points.

If inconsistent points are defined, i.e. xmin > xmax, then an error is thrown

Parameters
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.

Member Function Documentation

◆ angularWidth()

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.

Parameters
observer:: Viewing point
Returns
The value of the angular half-width

Definition at line 122 of file BoundingBox.cpp.

References centrePoint(), getFullBox(), and Mantid::Kernel::V3D::norm().

Referenced by Mantid::Geometry::CSGObject::rayTraceSolidAngle().

◆ centrePoint()

Kernel::V3D Mantid::Geometry::BoundingBox::centrePoint ( ) const
inline

◆ checkValid()

static void Mantid::Geometry::BoundingBox::checkValid ( double  xmax,
double  ymax,
double  zmax,
double  xmin,
double  ymin,
double  zmin 
)
inlinestatic

Do the given arguments form a valid bounding box, throws std::invalid argument if not.

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

◆ doesLineIntersect() [1/2]

bool Mantid::Geometry::BoundingBox::doesLineIntersect ( const Kernel::V3D startPoint,
const Kernel::V3D lineDir 
) const

Does a line intersect the bounding box.

Parameters
startPoint:: The starting point for the line. It is assumed that this is outside the bounding box.
lineDir:: The direction of the line
Returns
True if the line intersects this bounding box, false otherwise.

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

◆ doesLineIntersect() [2/2]

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.

Parameters
track:: A test track It is assumed that this is outside the bounding box.
Returns
True if the track intersects this bounding box, false otherwise.

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

◆ generatePointInside()

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.

Parameters
r1Flat random number in range (0,1)
r2Flat random number in range (0,1)
r3Flat random number in range (0,1)
Returns
A new point within the box such that isPointInside(pt) == true

Definition at line 146 of file BoundingBox.cpp.

References xMax(), xMin(), yMax(), yMin(), zMax(), and zMin().

Referenced by Mantid::Geometry::RandomPoint::bounded().

◆ getCoordSystem()

std::vector< Kernel::V3D > const & Mantid::Geometry::BoundingBox::getCoordSystem ( ) const
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().

◆ getFullBox()

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

◆ grow()

void Mantid::Geometry::BoundingBox::grow ( const BoundingBox other)

◆ isAxisAligned()

bool Mantid::Geometry::BoundingBox::isAxisAligned ( ) const
inline

◆ isNonNull()

bool Mantid::Geometry::BoundingBox::isNonNull ( ) const
inline

◆ isNull()

bool Mantid::Geometry::BoundingBox::isNull ( ) const
inline

◆ isPointInside()

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.

Parameters
point:: The point to query
Returns
True if the point is within the bounding box, false otherwise

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

◆ maxPoint()

const Kernel::V3D & Mantid::Geometry::BoundingBox::maxPoint ( ) const
inline

◆ minPoint()

const Kernel::V3D & Mantid::Geometry::BoundingBox::minPoint ( ) const
inline

◆ moveBy()

void Mantid::Geometry::BoundingBox::moveBy ( const Kernel::V3D v)
inline

move the BB by a vector

Definition at line 168 of file BoundingBox.h.

◆ nullify()

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

◆ realign()

void Mantid::Geometry::BoundingBox::realign ( std::vector< Kernel::V3D > const *const  pCS = nullptr)

◆ setBoxAlignment()

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

◆ width()

Kernel::V3D Mantid::Geometry::BoundingBox::width ( ) const
inline

◆ xMax() [1/2]

double & Mantid::Geometry::BoundingBox::xMax ( )
inline

Return the maximum value of X (non-const)

Definition at line 134 of file BoundingBox.h.

◆ xMax() [2/2]

double Mantid::Geometry::BoundingBox::xMax ( ) const
inline

◆ xMin() [1/2]

double & Mantid::Geometry::BoundingBox::xMin ( )
inline

Return the minimum value of X (non-const)

Definition at line 129 of file BoundingBox.h.

◆ xMin() [2/2]

double Mantid::Geometry::BoundingBox::xMin ( ) const
inline

◆ yMax() [1/2]

double & Mantid::Geometry::BoundingBox::yMax ( )
inline

Return the maximum value of Y (non-const)

Definition at line 144 of file BoundingBox.h.

◆ yMax() [2/2]

double Mantid::Geometry::BoundingBox::yMax ( ) const
inline

◆ yMin() [1/2]

double & Mantid::Geometry::BoundingBox::yMin ( )
inline

Return the minimum value of Y (non-const)

Definition at line 139 of file BoundingBox.h.

◆ yMin() [2/2]

double Mantid::Geometry::BoundingBox::yMin ( ) const
inline

◆ zMax() [1/2]

double & Mantid::Geometry::BoundingBox::zMax ( )
inline

Return the maximum value of Z (non-const)

Definition at line 154 of file BoundingBox.h.

◆ zMax() [2/2]

double Mantid::Geometry::BoundingBox::zMax ( ) const
inline

◆ zMin() [1/2]

double & Mantid::Geometry::BoundingBox::zMin ( )
inline

Return the minimum value of Z (non-const)

Definition at line 149 of file BoundingBox.h.

◆ zMin() [2/2]

double Mantid::Geometry::BoundingBox::zMin ( ) const
inline

Member Data Documentation

◆ coord_system

std::vector<Kernel::V3D> Mantid::Geometry::BoundingBox::coord_system
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().

◆ is_axis_aligned

bool Mantid::Geometry::BoundingBox::is_axis_aligned
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().

◆ m_maxPoint

Kernel::V3D Mantid::Geometry::BoundingBox::m_maxPoint
private

The maximum point of the axis-aligned box.

Definition at line 178 of file BoundingBox.h.

Referenced by grow(), and nullify().

◆ m_minPoint

Kernel::V3D Mantid::Geometry::BoundingBox::m_minPoint
private

The minimum point of the axis-aligned box.

Definition at line 176 of file BoundingBox.h.

Referenced by grow(), and nullify().

◆ m_null

bool Mantid::Geometry::BoundingBox::m_null
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.

Referenced by grow(), nullify(), and realign().


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