9#include "MantidGeometry/DllConfig.h"
37 BoundingBox() : m_minPoint(), m_maxPoint(), m_null(true), is_axis_aligned(true) {}
48 BoundingBox(
double xmax,
double ymax,
double zmax,
double xmin,
double ymin,
double zmin)
49 : m_minPoint(xmin, ymin, zmin), m_maxPoint(xmax, ymax, zmax), m_null(false), is_axis_aligned(true) {
51 checkValid(xmax, ymax, zmax, xmin, ymin, zmin);
64 static void checkValid(
double xmax,
double ymax,
double zmax,
double xmin,
double ymin,
double zmin) {
65 if (xmax < xmin || ymax < ymin || zmax < zmin) {
66 std::ostringstream
error;
67 error <<
"Error creating bounding box, inconsistent values given:\n"
68 <<
"\txmin=" << xmin <<
", xmax=" << xmax <<
"\n"
69 <<
"\tymin=" << ymin <<
", ymax=" << ymax <<
"\n"
70 <<
"\tzmin=" << zmin <<
", zmax=" << zmax <<
"\n";
71 throw std::invalid_argument(
error.str());
78 inline double xMin()
const {
return m_minPoint.X(); }
80 inline double xMax()
const {
return m_maxPoint.X(); }
82 inline double yMin()
const {
return m_minPoint.Y(); }
84 inline double yMax()
const {
return m_maxPoint.Y(); }
86 inline double zMin()
const {
return m_minPoint.Z(); }
88 inline double zMax()
const {
return m_maxPoint.Z(); }
95 return Kernel::V3D(0.5 * (xMax() + xMin()), 0.5 * (yMax() + yMin()), 0.5 * (zMax() + zMin()));
104 inline bool isNull()
const {
return m_null; }
108 bool isPointInside(
const Kernel::V3D &point)
const;
110 bool doesLineIntersect(
const Track &track)
const;
114 double angularWidth(
const Kernel::V3D &observer)
const;
122 Kernel::V3D generatePointInside(
double r1,
double r2,
double r3)
const;
125 void getFullBox(std::vector<Kernel::V3D> &box,
const Kernel::V3D &observer)
const;
131 return m_minPoint[0];
136 return m_maxPoint[0];
141 return m_minPoint[1];
146 return m_maxPoint[1];
151 return m_minPoint[2];
156 return m_maxPoint[2];
161 void setBoxAlignment(
const Kernel::V3D &R0,
const std::vector<Kernel::V3D> &orts);
166 void realign(std::vector<Kernel::V3D>
const *
const pCS =
nullptr);
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
BoundingBox(double xmax, double ymax, double zmax, double xmin, double ymin, double zmin)
Constructor taking six points.
bool m_null
Flag marking if we've been initialized using the default constructor, with values or default values a...
BoundingBox()
Default constructor constructs a zero-sized box.
double & yMin()
Return the minimum value of Y (non-const)
double xMax() const
Return the maximum value of X.
bool isNonNull() const
Is the box considered valid. Convenience for !isNull()
double zMin() const
Return the minimum value of Z.
const Kernel::V3D & minPoint() const
Returns the min point of the box.
double & yMax()
Return the maximum value of Y (non-const)
std::vector< Kernel::V3D > const & getCoordSystem() const
returns the coordinate system to which BB is alighned to;
double & zMin()
Return the minimum value of Z (non-const)
Kernel::V3D m_maxPoint
The maximum point of the axis-aligned box.
bool isNull() const
Is this a default constructed box?
double zMax() const
Return the maximum value of Z.
Kernel::V3D width() const
Returns the width of the box.
double yMax() const
Return the maximum value of Y.
bool isAxisAligned() const
Check if it is normal axis aligned bounding box or not.
double & xMax()
Return the maximum value of X (non-const)
double xMin() const
Return the minimum value of X.
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.
Kernel::V3D centrePoint() const
Returns the centre of the bounding box.
double yMin() const
Return the minimum value of Y.
double & zMax()
Return the maximum value of Z (non-const)
std::vector< Kernel::V3D > coord_system
if the bounding box is not axis aligned, the vector below describes the coordinate system,...
Kernel::V3D m_minPoint
The minimum point of the axis-aligned box.
double & xMin()
Return the minimum value of X (non-const)
const Kernel::V3D & maxPoint() const
Returns the min point of the box.
bool is_axis_aligned
the parameter which describe if the bounding box is axis aligned or not
void moveBy(const Kernel::V3D &v)
move the BB by a vector
Defines a track as a start point and a direction.
MANTID_GEOMETRY_DLL std::ostream & operator<<(std::ostream &stream, const PointGroup &self)
Returns a streamed representation of the PointGroup object.
std::shared_ptr< BoundingBox > BoundingBox_sptr
A shared pointer to a BoundingBox.
std::shared_ptr< const BoundingBox > BoundingBox_const_sptr
A shared pointer to a const BoundingBox.
Helper class which provides the Collimation Length for SANS instruments.