AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::primal::BoundingBox< T, NDIMS > Class Template Reference

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/src/axom/primal/geometry/BoundingBox.hpp>

Inheritance diagram for axom::primal::BoundingBox< T, NDIMS >:

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 PointTypegetMin () const
 Returns const reference to the min corner of the bounding box. More...
 
AXOM_HOST_DEVICE const PointTypegetMax () 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...
 
BoundingBoxintersect (const BoundingBox &otherBox)
 Intersects the current bounding box with another bounding box. More...
 
AXOM_HOST_DEVICE BoundingBoxexpand (T expansionAmount)
 Expands the lower and upper bounds by the given amount. More...
 
AXOM_HOST_DEVICE BoundingBoxscale (double scaleFactor)
 Scales the bounding box about its center by a given amount. More...
 
AXOM_HOST_DEVICE BoundingBoxshift (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 = std::numeric_limits<T>::max()
 
static constexpr T InvalidMax = std::numeric_limits<T>::lowest()
 

Member Typedef Documentation

◆ CoordType

template<typename T , int NDIMS>
using axom::primal::BoundingBox< T, NDIMS >::CoordType = T

◆ PointType

template<typename T , int NDIMS>
using axom::primal::BoundingBox< T, NDIMS >::PointType = Point<T, NDIMS>

◆ VectorType

template<typename T , int NDIMS>
using axom::primal::BoundingBox< T, NDIMS >::VectorType = Vector<T, NDIMS>

◆ BoxType

template<typename T , int NDIMS>
using axom::primal::BoundingBox< T, NDIMS >::BoxType = BoundingBox<T, NDIMS>

Constructor & Destructor Documentation

◆ BoundingBox() [1/5]

template<typename T , int NDIMS>
AXOM_HOST_DEVICE axom::primal::BoundingBox< T, NDIMS >::BoundingBox ( )
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.

◆ BoundingBox() [2/5]

template<typename T , int NDIMS>
AXOM_HOST_DEVICE axom::primal::BoundingBox< T, NDIMS >::BoundingBox ( const PointType pt)
inlineexplicit

Constructor. Creates a bounding box containing a single point.

◆ BoundingBox() [3/5]

template<typename T , int NDIMS>
AXOM_HOST_DEVICE axom::primal::BoundingBox< T, NDIMS >::BoundingBox ( const PointType pts,
int  n 
)

Constructor. Creates a bounding box containing the collection of points.

Precondition
pt must point to at least n valid point
Note
If n <= 0, defaults to default constructor values

References SLIC_ASSERT.

◆ BoundingBox() [4/5]

template<typename T , int NDIMS>
AXOM_HOST_DEVICE axom::primal::BoundingBox< T, NDIMS >::BoundingBox ( std::initializer_list< PointType pts)
inlineexplicit

Constructor. Creates a bounding box containing the initializer list of points.

Parameters
[in]ptsan initializer list containing points

◆ BoundingBox() [5/5]

template<typename T , int NDIMS>
AXOM_HOST_DEVICE axom::primal::BoundingBox< T, NDIMS >::BoundingBox ( const PointType lowerPt,
const PointType upperPt,
bool  shouldFixBounds = true 
)
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.

Member Function Documentation

◆ clear()

template<typename T , int NDIMS>
AXOM_HOST_DEVICE void axom::primal::BoundingBox< T, NDIMS >::clear

Resets the bounds to those of the default constructor.

Note
This invalidates the bounding box (i.e. isValid() will be false)

◆ getMin()

template<typename T , int NDIMS>
AXOM_HOST_DEVICE const PointType& axom::primal::BoundingBox< T, NDIMS >::getMin ( ) const
inline

Returns const reference to the min corner of the bounding box.

Returns
const reference to the min corner of the bounding box.

◆ getMax()

template<typename T , int NDIMS>
AXOM_HOST_DEVICE const PointType& axom::primal::BoundingBox< T, NDIMS >::getMax ( ) const
inline

Returns const reference to the max corner of the bounding box.

Returns
const reference to the max corner of the bounding box.

◆ getCentroid()

template<typename T , int NDIMS>
AXOM_HOST_DEVICE PointType axom::primal::BoundingBox< T, NDIMS >::getCentroid ( ) const
inline

Returns the centroid (midpoint) of the bounding box.

Returns
Point at the bounding box centroid.

References axom::primal::Point< T, NDIMS >::midpoint().

◆ range()

template<typename T , int NDIMS>
AXOM_HOST_DEVICE VectorType axom::primal::BoundingBox< T, NDIMS >::range ( ) const
inline

Returns a vector from the min to the max points of the bounding box.

Returns
Vector from min point to max point of bounding box.

◆ addPoint() [1/2]

template<typename T , int NDIMS>
template<typename OtherType >
AXOM_HOST_DEVICE void axom::primal::BoundingBox< T, NDIMS >::addPoint ( const Point< OtherType, NDIMS > &  pt)

Updates bounds to include the provided point.

Parameters
[in]ptto include.

◆ addBox() [1/2]

template<typename T , int NDIMS>
template<typename OtherType >
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.

Parameters
[in]bboxto include.

◆ dimension()

template<typename T , int NDIMS>
AXOM_HOST_DEVICE int axom::primal::BoundingBox< T, NDIMS >::dimension ( ) const
inline

Returns the dimension of the ambient space for this bounding box.

Returns
d the dimension of this bounding box instance.
Postcondition
d >= 1.

◆ getLongestDimension()

template<typename T , int NDIMS>
AXOM_HOST_DEVICE int axom::primal::BoundingBox< T, NDIMS >::getLongestDimension

Finds the longest dimension of the bounding box.

Returns
idx the index of the longest dimension.
Postcondition
idx >= 0 < NDIMS
Note
In the case of ties, where the bounding box has more than one side with the same length, the code picks the first dimension as the longest dimension.

References axom::utilities::max(), axom::utilities::min(), and SLIC_ASSERT.

◆ intersect()

template<typename T , int NDIMS>
BoundingBox< T, NDIMS > & axom::primal::BoundingBox< T, NDIMS >::intersect ( const BoundingBox< T, NDIMS > &  otherBox)

Intersects the current bounding box with another bounding box.

Parameters
[in]otherBoxThe other box to intersect
Note
If the intersection is empty, the bounding box will be cleared
Returns
A reference to the bounding box after it has been intersected

References axom::utilities::max(), and axom::utilities::min().

◆ expand()

template<typename T , int NDIMS>
AXOM_HOST_DEVICE BoundingBox< T, NDIMS > & axom::primal::BoundingBox< T, NDIMS >::expand ( expansionAmount)

Expands the lower and upper bounds by the given amount.

Parameters
[in]expansionAmountan absolute amount to expand
Note
Moves min & max point expansionAmount away from the center.
This function checks to ensure the bounding box is valid afterwards.
If expansionAmount is negative, the bounding box will contract
Returns
A reference to the bounding box after it has been expanded

◆ scale()

template<typename T , int NDIMS>
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.

Parameters
[in]scaleFactorthe multiplicative factor by which to scale
Note
Checks to ensure that the bounding box is valid after inflation.
If scaleFactor is less than 1, the bounding box will shrink.
If scaleFactor is 0, the bounding box will shrink to its midpoint
The sign of the shrinkFactor has no effect since we are shrinking towards the center, and we fix the bounds after shrinking
Returns
A reference to the bounding box after it has been scaled

References axom::primal::Point< T, NDIMS >::array(), and axom::primal::Vector< T, NDIMS >::array().

◆ shift()

template<typename T , int NDIMS>
AXOM_HOST_DEVICE BoundingBox< T, NDIMS > & axom::primal::BoundingBox< T, NDIMS >::shift ( const VectorType displacement)

Shifts the bounding box by a fixed displacement.

Parameters
[in]displacementthe amount with which to move the bounding box
Returns
A reference to the bounding box after it has been shifted

References axom::primal::Vector< T, NDIMS >::array().

◆ contains() [1/4]

template<typename T , int NDIMS>
template<typename OtherType >
AXOM_HOST_DEVICE bool axom::primal::BoundingBox< T, NDIMS >::contains ( const Point< OtherType, NDIMS > &  otherPt) const

Checks whether the box contains the point.

Parameters
[in]otherPtthe point that we are checking
Returns
status true if point inside the box, else false.
Note
This function assumes all intervals are closed (i.e. contain their boundaries). We may need to deal with open and half open boundaries in the future.

◆ contains() [2/4]

template<typename T , int NDIMS>
template<typename OtherType >
bool axom::primal::BoundingBox< T, NDIMS >::contains ( const BoundingBox< OtherType, NDIMS > &  otherBB) const

Checks whether the box fully contains another bounding box.

Parameters
[in]otherBBthe bounding box that we are checking
Returns
status true if bb is inside the box, else false.
Note
We are allowing the other bounding box to have a different coordinate type. This should work as long as the two Ts are comparable with operator<().
If otherBB is empty, we return true

◆ intersectsWith()

template<typename T , int NDIMS>
template<typename OtherType >
AXOM_HOST_DEVICE bool axom::primal::BoundingBox< T, NDIMS >::intersectsWith ( const BoundingBox< OtherType, NDIMS > &  otherBB) const
Parameters
[in]otherBBthe bounding box that we are checking.
Returns
status true if bb intersects otherBB, else false.
Note
We are allowing the other bounding box to have a different coordinate type. This should work as long as the two Ts are comparable with operator<().

◆ isValid()

template<typename T , int NDIMS>
AXOM_HOST_DEVICE bool axom::primal::BoundingBox< T, NDIMS >::isValid

Checks that we have a valid bounding box.

Note
A bounding box is valid when the length of each dimension is greater than or equal to zero.
Returns
status true if point inside the box, else false.

◆ bisect()

template<typename T , int NDIMS>
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.

Parameters
[in,out]rightthe right sub-box.
[in,out]leftthe left sub-box.
[in]dimensionthe dimension to split along (optional)
Precondition
dimension >= -1 && dimension < NDIMS
Note
if dimension==-1, the bounding box is split along its longest edge.

References axom::primal::BoundingBox< T, NDIMS >::isValid(), and SLIC_ASSERT.

◆ print()

template<typename T , int NDIMS>
std::ostream & axom::primal::BoundingBox< T, NDIMS >::print ( std::ostream &  os) const

Simple formatted print of a bounding box instance.

Parameters
osThe output stream to write to
Returns
A reference to the modified ostream

◆ getPoints() [1/2]

template<typename T , int NDIMS>
void axom::primal::BoundingBox< T, NDIMS >::getPoints ( const BoundingBox< T, 2 > &  bb,
std::vector< Point< T, 2 >> &  pnts 
)
inlinestatic

Returns the list of points of a 2-D BoundingBox instance.

Parameters
[in]bbuser-supplied instance of the bounding box.
[out]pntsthe list of points
Postcondition
pnts.size() == 4
Note
The ordering of the points has as follows:
*
*     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().

◆ getPoints() [2/2]

template<typename T , int NDIMS>
void axom::primal::BoundingBox< T, NDIMS >::getPoints ( const BoundingBox< T, 3 > &  bb,
std::vector< Point< T, 3 >> &  pnts 
)
inlinestatic

Returns the list of points of a 3-D BoundingBox instance.

Parameters
[in]bbuser-supplied instance of the bounding box.
[out]pntsthe list of points
Postcondition
pnts.size() == 8
Note
The ordering of the points has as follows:
*
*         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().

◆ contains() [3/4]

template<typename T , int NDIMS>
template<typename OtherT >
AXOM_HOST_DEVICE bool axom::primal::BoundingBox< T, NDIMS >::contains ( const Point< OtherT, NDIMS > &  otherPt) const

◆ contains() [4/4]

template<typename T , int NDIMS>
template<typename OtherT >
bool axom::primal::BoundingBox< T, NDIMS >::contains ( const BoundingBox< OtherT, NDIMS > &  otherBB) const

◆ addPoint() [2/2]

template<typename T , int NDIMS>
template<typename OtherT >
AXOM_HOST_DEVICE void axom::primal::BoundingBox< T, NDIMS >::addPoint ( const Point< OtherT, NDIMS > &  pt)

◆ addBox() [2/2]

template<typename T , int NDIMS>
template<typename OtherT >
AXOM_HOST_DEVICE void axom::primal::BoundingBox< T, NDIMS >::addBox ( const BoundingBox< OtherT, NDIMS > &  bbox)

Member Data Documentation

◆ InvalidMin

template<typename T , int NDIMS>
constexpr T axom::primal::BoundingBox< T, NDIMS >::InvalidMin = std::numeric_limits<T>::max()
staticconstexpr

◆ InvalidMax

template<typename T , int NDIMS>
constexpr T axom::primal::BoundingBox< T, NDIMS >::InvalidMax = std::numeric_limits<T>::lowest()
staticconstexpr

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