AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/primal/geometry/BoundingBox.hpp>
Public Types | |
using | CoordType = T |
using | PointType = Point< T, NDIMS > |
using | VectorType = Vector< T, NDIMS > |
using | BoxType = BoundingBox< T, NDIMS > |
Public Member Functions | |
AXOM_HOST_DEVICE | BoundingBox () |
Constructor. Creates a bounding box with an invalid bound The lower bound is set to the greatest possible point and the upper bound is set to the smallest possible point. This way adding any point resets the bounds to a valid range. More... | |
AXOM_HOST_DEVICE | BoundingBox (const PointType &pt) |
Constructor. Creates a bounding box containing a single point. More... | |
AXOM_HOST_DEVICE | BoundingBox (const PointType *pts, int n) |
Constructor. Creates a bounding box containing the collection of points. More... | |
AXOM_HOST_DEVICE | BoundingBox (std::initializer_list< PointType > pts) |
Constructor. Creates a bounding box containing the initializer list of points. More... | |
AXOM_HOST_DEVICE | BoundingBox (const PointType &lowerPt, const PointType &upperPt, bool shouldFixBounds=true) |
Constructor. Creates a bounding box with a given min and max point The code ensures that the bounds are valid, if shouldFixBounds is true. More... | |
AXOM_HOST_DEVICE void | clear () |
Resets the bounds to those of the default constructor. More... | |
AXOM_HOST_DEVICE const PointType & | getMin () const |
Returns const reference to the min corner of the bounding box. More... | |
AXOM_HOST_DEVICE const PointType & | getMax () const |
Returns const reference to the max corner of the bounding box. More... | |
AXOM_HOST_DEVICE PointType | getCentroid () const |
Returns the centroid (midpoint) of the bounding box. More... | |
AXOM_HOST_DEVICE VectorType | range () const |
Returns a vector from the min to the max points of the bounding box. More... | |
template<typename OtherType > | |
AXOM_HOST_DEVICE void | addPoint (const Point< OtherType, NDIMS > &pt) |
Updates bounds to include the provided point. More... | |
template<typename OtherType > | |
AXOM_HOST_DEVICE void | addBox (const BoundingBox< OtherType, NDIMS > &bbox) |
Updates bounds to include the provided bounding box. Convenience function – equivalent to adding the min and max point of bbox. More... | |
AXOM_HOST_DEVICE int | dimension () const |
Returns the dimension of the ambient space for this bounding box. More... | |
AXOM_HOST_DEVICE int | getLongestDimension () const |
Finds the longest dimension of the bounding box. More... | |
BoundingBox & | intersect (const BoundingBox &otherBox) |
Intersects the current bounding box with another bounding box. More... | |
AXOM_HOST_DEVICE BoundingBox & | expand (T expansionAmount) |
Expands the lower and upper bounds by the given amount. More... | |
AXOM_HOST_DEVICE BoundingBox & | scale (double scaleFactor) |
Scales the bounding box about its center by a given amount. More... | |
AXOM_HOST_DEVICE BoundingBox & | shift (const VectorType &displacement) |
Shifts the bounding box by a fixed displacement. More... | |
template<typename OtherType > | |
AXOM_HOST_DEVICE bool | contains (const Point< OtherType, NDIMS > &otherPt) const |
Checks whether the box contains the point. More... | |
template<typename OtherType > | |
bool | contains (const BoundingBox< OtherType, NDIMS > &otherBB) const |
Checks whether the box fully contains another bounding box. More... | |
template<typename OtherType > | |
AXOM_HOST_DEVICE bool | intersectsWith (const BoundingBox< OtherType, NDIMS > &otherBB) const |
AXOM_HOST_DEVICE bool | isValid () const |
Checks that we have a valid bounding box. More... | |
void | bisect (BoxType &right, BoxType &left, int dimension=-1) const |
Subdivides this bounding box instance into two sub-boxes by splitting along the given dimension. If a dimension is not provided, this method will split the bounding box along the longest dimension. More... | |
std::ostream & | print (std::ostream &os) const |
Simple formatted print of a bounding box instance. More... | |
template<typename OtherT > | |
AXOM_HOST_DEVICE bool | contains (const Point< OtherT, NDIMS > &otherPt) const |
template<typename OtherT > | |
bool | contains (const BoundingBox< OtherT, NDIMS > &otherBB) const |
template<typename OtherT > | |
AXOM_HOST_DEVICE void | addPoint (const Point< OtherT, NDIMS > &pt) |
template<typename OtherT > | |
AXOM_HOST_DEVICE void | addBox (const BoundingBox< OtherT, NDIMS > &bbox) |
Static Public Member Functions | |
Static methods | |
static void | getPoints (const BoundingBox< T, 2 > &bb, std::vector< Point< T, 2 >> &pnts) |
Returns the list of points of a 2-D BoundingBox instance. More... | |
static void | getPoints (const BoundingBox< T, 3 > &bb, std::vector< Point< T, 3 >> &pnts) |
Returns the list of points of a 3-D BoundingBox instance. More... | |
Static Public Attributes | |
static constexpr T | InvalidMin = axom::numeric_limits<T>::max() |
static constexpr T | InvalidMax = axom::numeric_limits<T>::lowest() |
using axom::primal::BoundingBox< T, NDIMS >::CoordType = T |
using axom::primal::BoundingBox< T, NDIMS >::PointType = Point<T, NDIMS> |
using axom::primal::BoundingBox< T, NDIMS >::VectorType = Vector<T, NDIMS> |
using axom::primal::BoundingBox< T, NDIMS >::BoxType = BoundingBox<T, NDIMS> |
|
inline |
Constructor. Creates a bounding box with an invalid bound The lower bound is set to the greatest possible point and the upper bound is set to the smallest possible point. This way adding any point resets the bounds to a valid range.
|
inlineexplicit |
Constructor. Creates a bounding box containing a single point.
AXOM_HOST_DEVICE axom::primal::BoundingBox< T, NDIMS >::BoundingBox | ( | const PointType * | pts, |
int | n | ||
) |
Constructor. Creates a bounding box containing the collection of points.
References SLIC_ASSERT.
|
inlineexplicit |
Constructor. Creates a bounding box containing the initializer list of points.
[in] | pts | an initializer list containing points |
|
inline |
Constructor. Creates a bounding box with a given min and max point The code ensures that the bounds are valid, if shouldFixBounds is true.
AXOM_HOST_DEVICE void axom::primal::BoundingBox< T, NDIMS >::clear |
Resets the bounds to those of the default constructor.
|
inline |
Returns const reference to the min corner of the bounding box.
|
inline |
Returns const reference to the max corner of the bounding box.
|
inline |
Returns the centroid (midpoint) of the bounding box.
References axom::primal::Point< T, NDIMS >::midpoint().
|
inline |
Returns a vector from the min to the max points of the bounding box.
AXOM_HOST_DEVICE void axom::primal::BoundingBox< T, NDIMS >::addPoint | ( | const Point< OtherType, NDIMS > & | pt | ) |
Updates bounds to include the provided point.
[in] | pt | to include. |
AXOM_HOST_DEVICE void axom::primal::BoundingBox< T, NDIMS >::addBox | ( | const BoundingBox< OtherType, NDIMS > & | bbox | ) |
Updates bounds to include the provided bounding box. Convenience function – equivalent to adding the min and max point of bbox.
[in] | bbox | to include. |
|
inline |
Returns the dimension of the ambient space for this bounding box.
AXOM_HOST_DEVICE int axom::primal::BoundingBox< T, NDIMS >::getLongestDimension |
Finds the longest dimension of the bounding box.
References axom::utilities::max(), axom::utilities::min(), and SLIC_ASSERT.
BoundingBox< T, NDIMS > & axom::primal::BoundingBox< T, NDIMS >::intersect | ( | const BoundingBox< T, NDIMS > & | otherBox | ) |
Intersects the current bounding box with another bounding box.
[in] | otherBox | The other box to intersect |
References axom::utilities::max(), and axom::utilities::min().
AXOM_HOST_DEVICE BoundingBox< T, NDIMS > & axom::primal::BoundingBox< T, NDIMS >::expand | ( | T | expansionAmount | ) |
Expands the lower and upper bounds by the given amount.
[in] | expansionAmount | an absolute amount to expand |
AXOM_HOST_DEVICE BoundingBox< T, NDIMS > & axom::primal::BoundingBox< T, NDIMS >::scale | ( | double | scaleFactor | ) |
Scales the bounding box about its center by a given amount.
[in] | scaleFactor | the multiplicative factor by which to scale |
References axom::primal::Point< T, NDIMS >::array(), and axom::primal::Vector< T, NDIMS >::array().
AXOM_HOST_DEVICE BoundingBox< T, NDIMS > & axom::primal::BoundingBox< T, NDIMS >::shift | ( | const VectorType & | displacement | ) |
Shifts the bounding box by a fixed displacement.
[in] | displacement | the amount with which to move the bounding box |
References axom::primal::Vector< T, NDIMS >::array().
AXOM_HOST_DEVICE bool axom::primal::BoundingBox< T, NDIMS >::contains | ( | const Point< OtherType, NDIMS > & | otherPt | ) | const |
Checks whether the box contains the point.
[in] | otherPt | the point that we are checking |
bool axom::primal::BoundingBox< T, NDIMS >::contains | ( | const BoundingBox< OtherType, NDIMS > & | otherBB | ) | const |
Checks whether the box fully contains another bounding box.
[in] | otherBB | the bounding box that we are checking |
AXOM_HOST_DEVICE bool axom::primal::BoundingBox< T, NDIMS >::intersectsWith | ( | const BoundingBox< OtherType, NDIMS > & | otherBB | ) | const |
[in] | otherBB | the bounding box that we are checking. |
AXOM_HOST_DEVICE bool axom::primal::BoundingBox< T, NDIMS >::isValid |
Checks that we have a valid bounding box.
void axom::primal::BoundingBox< T, NDIMS >::bisect | ( | BoxType & | right, |
BoxType & | left, | ||
int | dimension = -1 |
||
) | const |
Subdivides this bounding box instance into two sub-boxes by splitting along the given dimension. If a dimension is not provided, this method will split the bounding box along the longest dimension.
[in,out] | right | the right sub-box. |
[in,out] | left | the left sub-box. |
[in] | dimension | the dimension to split along (optional) |
References axom::primal::BoundingBox< T, NDIMS >::isValid(), and SLIC_ASSERT.
std::ostream & axom::primal::BoundingBox< T, NDIMS >::print | ( | std::ostream & | os | ) | const |
Simple formatted print of a bounding box instance.
os | The output stream to write to |
|
inlinestatic |
Returns the list of points of a 2-D BoundingBox instance.
[in] | bb | user-supplied instance of the bounding box. |
[out] | pnts | the list of points |
* * 3 2 * +------+ * | | * | | * +------+ * 0 1 * *
References axom::primal::BoundingBox< T, NDIMS >::getMax(), axom::primal::BoundingBox< T, NDIMS >::getMin(), axom::primal::Point< T, NDIMS >::make_point(), axom::utilities::max(), and axom::utilities::min().
|
inlinestatic |
Returns the list of points of a 3-D BoundingBox instance.
[in] | bb | user-supplied instance of the bounding box. |
[out] | pnts | the list of points |
* * 4 7 * +----------+ * /| /| * 5 / | 6 / | * +--|-------+ | * | +-------|--+ * | / 0 | / 3 * |/ |/ * +----------+ * 1 2 * *
References axom::primal::BoundingBox< T, NDIMS >::getMax(), axom::primal::BoundingBox< T, NDIMS >::getMin(), axom::primal::Point< T, NDIMS >::make_point(), axom::utilities::max(), and axom::utilities::min().
AXOM_HOST_DEVICE bool axom::primal::BoundingBox< T, NDIMS >::contains | ( | const Point< OtherT, NDIMS > & | otherPt | ) | const |
bool axom::primal::BoundingBox< T, NDIMS >::contains | ( | const BoundingBox< OtherT, NDIMS > & | otherBB | ) | const |
AXOM_HOST_DEVICE void axom::primal::BoundingBox< T, NDIMS >::addPoint | ( | const Point< OtherT, NDIMS > & | pt | ) |
AXOM_HOST_DEVICE void axom::primal::BoundingBox< T, NDIMS >::addBox | ( | const BoundingBox< OtherT, NDIMS > & | bbox | ) |
|
staticconstexpr |
|
staticconstexpr |