Celeritas  0.5.0-86+4a8eea4
Public Member Functions | Static Public Member Functions | List of all members
celeritas::BoundingBox< T > Class Template Reference

Axis-aligned bounding box. More...

#include <BoundingBox.hh>

Public Types

Type aliases
using real_type = T
 
using Real3 = Array< real_type, 3 >
 

Public Member Functions

CELER_CONSTEXPR_FUNCTION BoundingBox ()
 Create a null bounding box. More...
 
CELER_FUNCTION BoundingBox (Real3 const &lower, Real3 const &upper)
 Create a non-null bounding box from two points. More...
 
CELER_CONSTEXPR_FUNCTION Real3 const & lower () const
 Lower bbox coordinate.
 
CELER_CONSTEXPR_FUNCTION Real3 const & upper () const
 Upper bbox coordinate.
 
CELER_CONSTEXPR_FUNCTION Real3 const & point (Bound b) const
 Access a bounding point.
 
CELER_CONSTEXPR_FUNCTION operator bool () const
 Whether the bbox is in a valid state.
 
CELER_CONSTEXPR_FUNCTION void shrink (Bound bnd, Axis axis, real_type position)
 Reduce (clip) the bounding box's extent along an axis. More...
 
CELER_CONSTEXPR_FUNCTION void grow (Bound bnd, Axis axis, real_type position)
 Increase (expand) the bounding box's extent along an axis. More...
 
CELER_CONSTEXPR_FUNCTION void grow (Axis axis, real_type position)
 Increase (expand) the bounding box's extent along an axis. More...
 

Static Public Member Functions

static CELER_FUNCTION BoundingBox from_infinite ()
 Create a bounding box with infinite extents.
 
static CELER_CONSTEXPR_FUNCTION BoundingBox from_unchecked (Real3 const &lower, Real3 const &upper)
 Create a bounding box from unchecked lower/upper bounds. More...
 

Detailed Description

template<class T = ::celeritas::real_type>
class celeritas::BoundingBox< T >

Axis-aligned bounding box.

Bounding boxes "contain" all points inside and on their faces. See is_inside in BoundingBoxUtils.hh .

The default bounding box is "null", which has at least one lower coordinate greater than its upper coordinate: it evaluates to false . A null bounding box still has the ability to be unioned and intersected with other bounding boxes with the expected effect, but geometrical operations on it (center, surface area, volume) are prohibited.

A "degenerate" bounding box is one that is well-defined but has zero volume because at least one lower coordinate is equal to the corresponding upper coordinate. Any point on the surface of this bounding box is still "inside". It may have nonzero surface area but will have zero volume.

Constructor & Destructor Documentation

◆ BoundingBox() [1/2]

Create a null bounding box.

This should naturally satisfy

calc_union(BBox{}, other) = other:
constexpr BoundingBox< T > calc_union(BoundingBox< T > const &a, BoundingBox< T > const &b)
Calculate the smallest bounding box enclosing two bounding boxes.
Definition: BoundingBoxUtils.hh:167

and

calc_intersection(BBox{}, other) = other;
constexpr BoundingBox< T > calc_intersection(BoundingBox< T > const &a, BoundingBox< T > const &b)
Calculate the intersection of two bounding boxes.
Definition: BoundingBoxUtils.hh:189

◆ BoundingBox() [2/2]

template<class T >
CELER_FUNCTION celeritas::BoundingBox< T >::BoundingBox ( Real3 const &  lo,
Real3 const &  hi 
)
inline

Create a non-null bounding box from two points.

The lower and upper points are allowed to be equal (an empty bounding box at a single point) but upper must not be less than lower.

Member Function Documentation

◆ from_unchecked()

template<class T >
CELER_CONSTEXPR_FUNCTION BoundingBox< T > celeritas::BoundingBox< T >::from_unchecked ( Real3 const &  lo,
Real3 const &  hi 
)
static

Create a bounding box from unchecked lower/upper bounds.

This should be used exclusively for utilities that understand the "null" implementation of the bounding box.

◆ grow() [1/2]

template<class T >
CELER_CONSTEXPR_FUNCTION void celeritas::BoundingBox< T >::grow ( Axis  axis,
real_type  position 
)

Increase (expand) the bounding box's extent along an axis.

If the point is outside the box, the box is expanded so the given boundary is on that point. Otherwise no change is made.

◆ grow() [2/2]

template<class T >
CELER_CONSTEXPR_FUNCTION void celeritas::BoundingBox< T >::grow ( Bound  bnd,
Axis  axis,
real_type  position 
)

Increase (expand) the bounding box's extent along an axis.

If the point is outside the box, the box is expanded so the given boundary is on that point. Otherwise no change is made.

◆ shrink()

template<class T >
CELER_CONSTEXPR_FUNCTION void celeritas::BoundingBox< T >::shrink ( Bound  bnd,
Axis  axis,
real_type  position 
)

Reduce (clip) the bounding box's extent along an axis.

If the point is inside the box, the box is clipped so the given boundary is on that point. Otherwise no change is made.


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