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/docs-essman-container_strict/src/axom/primal/geometry/BoundingBox.hpp>

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

Public Types

typedef T CoordType
 
typedef Point< T, NDIMS > PointType
 
typedef Vector< T, NDIMS > VectorType
 
typedef BoundingBox< T, NDIMS > BoxType
 

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...
 
 BoundingBox (const PointType *pts, int n)
 Constructor. Creates a bounding box containing the collection of points. More...
 
AXOM_HOST_DEVICE BoundingBox (const PointType &lowerPt, const PointType &upperPt)
 Constructor. Creates a bounding box with a given min and max point The code ensures that the bounds are valid. More...
 
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...
 
int dimension () const
 Returns the dimension of the ambient space for this bounding box. More...
 
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...
 
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...
 
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
 
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 >
bool contains (const Point< OtherT, NDIMS > &otherPt) const
 
template<typename OtherT >
bool contains (const BoundingBox< OtherT, NDIMS > &otherBB) const
 
template<typename OtherType >
bool intersectsWith (const BoundingBox< OtherType, NDIMS > &otherBB) const
 
template<typename OtherT >
void addPoint (const Point< OtherT, NDIMS > &pt)
 
template<typename OtherT >
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>
typedef T axom::primal::BoundingBox< T, NDIMS >::CoordType

◆ PointType

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

◆ VectorType

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

◆ BoxType

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

Constructor & Destructor Documentation

◆ BoundingBox() [1/4]

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.

Referenced by axom::primal::BoundingBox< double, DIM >::BoundingBox().

◆ BoundingBox() [2/4]

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

Constructor. Creates a bounding box containing a single point.

◆ BoundingBox() [3/4]

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

◆ BoundingBox() [4/4]

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

Constructor. Creates a bounding box with a given min and max point The code ensures that the bounds are valid.

Member Function Documentation

◆ clear()

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

Referenced by axom::primal::BoundingBox< double, DIM >::BoundingBox(), and axom::primal::BoundingBox< double, DIM >::intersect().

◆ getMin()

◆ getMax()

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

Referenced by axom::primal::BoundingBox< double, DIM >::scale().

◆ range()

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

◆ 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)

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

Referenced by axom::primal::merge_boxes(), and axom::primal::BoundingBox< double, DIM >::range().

◆ dimension()

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

Referenced by axom::primal::BoundingBox< double, DIM >::dimension().

◆ getLongestDimension()

template<typename T , int NDIMS>
int axom::primal::BoundingBox< T, NDIMS >::getLongestDimension ( ) const

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.

Referenced by axom::primal::BoundingBox< double, DIM >::bisect(), and axom::primal::BoundingBox< double, DIM >::dimension().

◆ 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

Referenced by axom::primal::BoundingBox< double, DIM >::dimension().

◆ expand()

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

Referenced by axom::primal::BoundingBox< double, DIM >::dimension(), and axom::spin::ImplicitGrid< NDIMS, TheIndexType >::insert().

◆ scale()

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

Referenced by axom::primal::BoundingBox< double, DIM >::dimension(), and axom::spin::UniformGrid< T, NDIMS >::UniformGrid().

◆ shift()

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

Referenced by axom::primal::BoundingBox< double, DIM >::dimension().

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

Referenced by axom::primal::clip(), axom::quest::SignedDistance< NDIMS >::computeDistance(), axom::primal::BoundingBox< double, DIM >::contains(), axom::primal::BoundingBox< double, DIM >::dimension(), axom::spin::SpatialOctree< DIM, InOutBlockData >::findLeafBlock(), axom::spin::UniformGrid< T, NDIMS >::getBinIndex(), axom::spin::ImplicitGrid< NDIMS, TheIndexType >::getCandidates(), axom::spin::BVHTree< T, NDIMS >::insert(), and axom::primal::squared_distance().

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

◆ intersectsWith() [1/2]

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

Referenced by axom::primal::clip(), axom::primal::BoundingBox< double, DIM >::dimension(), axom::spin::UniformGrid< T, NDIMS >::getBinsForBbox(), axom::spin::ImplicitGrid< NDIMS, TheIndexType >::getCandidates(), and axom::primal::intersect().

◆ isValid()

template<typename T , int NDIMS>
bool axom::primal::BoundingBox< T, NDIMS >::isValid ( ) const

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.

Referenced by axom::primal::BoundingBox< double, DIM >::bisect(), axom::primal::BoundingBox< double, DIM >::dimension(), axom::primal::BoundingBox< double, DIM >::getLongestDimension(), axom::spin::BVHTree< T, NDIMS >::insert(), and axom::primal::BoundingBox< double, DIM >::intersect().

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

Referenced by axom::primal::BoundingBox< double, DIM >::dimension().

◆ 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

Referenced by axom::primal::BoundingBox< double, DIM >::dimension().

◆ 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
*
* 

Referenced by axom::primal::BoundingBox< double, DIM >::dimension().

◆ 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
*
* 

◆ contains() [3/4]

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

◆ intersectsWith() [2/2]

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

◆ addPoint() [2/2]

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

◆ addBox() [2/2]

template<typename T, int NDIMS>
template<typename OtherT >
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()
static

◆ InvalidMax

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

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