Celeritas 0.7+8dd8460
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | 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 >
 
using Extents = Array< real_type, 2 >
 
using Extents3 = Array< Extents, 3 >
 

Public Member Functions

constexpr BoundingBox () noexcept
 Create a null bounding box.
 
 BoundingBox (Real3 const &lower, Real3 const &upper) noexcept(! 0)
 Create a non-null bounding box from two points.
 
 BoundingBox (Extents3 const &extents) noexcept(! 0)
 Create a non-null bounding box from lo/hi extents.
 
constexpr Real3 constlower () const
 Lower bbox coordinate.
 
constexpr Real3 constupper () const
 Upper bbox coordinate.
 
constexpr Real3 constpoint (Bound b) const noexcept(! 0)
 Access a bounding point.
 
constexpr real_type constpoint (Bound b, Axis ax) const &noexcept(! 0)
 Access a bounding point coordinate (const ref to support LDG)
 
constexpr real_type point (Bound b, Axis ax) const &&noexcept(! 0)
 Access a bounding point coordinate.
 
constexpr operator bool () const noexcept
 Whether the bbox contains any point in space.
 
constexpr void shrink (Bound b, Axis ax, real_type p)
 Reduce (clip) the bounding box's extent along an axis.
 
constexpr void grow (Bound b, Axis ax, real_type p)
 Increase (expand) the bounding box's extent along an axis.
 
constexpr void grow (Axis ax, real_type p)
 Increase (expand) the bounding box's extent along an axis.
 

Static Public Member Functions

static BoundingBox from_infinite () noexcept
 Create a bounding box with infinite extents.
 
static constexpr BoundingBox from_unchecked (Real3 const &lower, Real3 const &upper) noexcept
 Create a bounding box from unchecked lower/upper points.
 
static constexpr BoundingBox from_unchecked (Extents3 const &) noexcept
 Create a bounding box from unchecked lo/hi extents.
 

Friends

constexpr friend bool operator== (BoundingBox const &lhs, BoundingBox const &rhs)
 Test equality of two bounding boxes.
 
constexpr friend bool operator!= (BoundingBox const &lhs, BoundingBox const &rhs)
 Test inequality of two bounding boxes.
 
constexpr friend BoundingBox ldg (BoundingBox const *bb) noexcept
 Allow loading via ldg.
 
std::ostream & operator<< (std::ostream &os, BoundingBox const &bbox)
 Write box to a stream.
 

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 strictly 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]

template<class T >
constexpr celeritas::BoundingBox< T >::BoundingBox ( )
inlineconstexprnoexcept

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:193
Axis-aligned bounding box.
Definition BoundingBox.hh:48

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:215

◆ BoundingBox() [2/2]

template<class T >
celeritas::BoundingBox< T >::BoundingBox ( Real3 const lo,
Real3 const hi 
)
inlinenoexcept

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

◆ grow() [1/2]

template<class T >
constexpr void celeritas::BoundingBox< T >::grow ( Axis  ax,
real_type  p 
)
inlineconstexpr

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.

Postcondition
If the box is non-null, some point on the axis is_inside the bounding box.

◆ grow() [2/2]

template<class T >
constexpr void celeritas::BoundingBox< T >::grow ( Bound  b,
Axis  ax,
real_type  v 
)
inlineconstexpr

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.

◆ operator bool()

template<class T >
constexpr celeritas::BoundingBox< T >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Whether the bbox contains any point in space.

A null box contains no points, and a degenerate point/edge/face contains that point.

◆ shrink()

template<class T >
constexpr void celeritas::BoundingBox< T >::shrink ( Bound  b,
Axis  ax,
real_type  v 
)
inlineconstexpr

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: