mi::math::Bbox< T, DIM> Template Class Reference
[Bounding Box Class]
template< typename T, Size DIM>class mi::math::Bbox< T, DIM>
Description
Axis-aligned N-dimensional bounding box class template of fixed dimension. A bounding box is represented by two mi::math::Vector vectors representing the elementwise minimal box corner, min, and the elementwise largest box corner, max.
An instantiation of the bounding box class template is a model of the STL container concept. It provides random access to its two vectors and corresponding random access iterators.
The template parameters have the following requirements:
-
T: an arithmetic type supporting + - * / == != < > <= >= .
-
DIM: a value > 0 of type mi::Size that defines the fixed dimension of the vectors used to represent the bounding box.
See also:
The underlying POD type mi::math::Bbox_struct.
For the free functions and operators available for bounding boxes see Bounding Box Class.
Public Enumerations
- enum Uninitialized_tag{ UNINITIALIZED_TAG}
- Enum type used to tag a special constructor that does not initialize the elements of the constructed bounding box.
Public Typedefs
- typedef Bbox_struct< T, DIM> Pod_type
- POD class corresponding to this bounding box.
- typedef math::Vector< T, DIM> Vector
- Corresponding vector type.
- typedef Vector* const_pointer
- Const pointer to vector.
- typedef Vector& const_reference
- Const reference to vector.
- typedef Difference difference_type
- Difference type, signed.
- typedef Vector* pointer
- Mutable pointer to vector.
- typedef Vector& reference
- Mutable reference to vector.
- typedef Size size_type
- Size type, unsigned.
- typedef Vector value_type
- Coordinate type.
Public Constructors
- Bbox()
- Bounding box initialized to the empty space, see also the clear function. More...
- Bbox( Uninitialized_tag)
- Bounding box with its elements not initialized.
- Bbox( const Bbox < T , DIM >& other)
- Default copy constructor.
- Bbox( const Bbox_struct < T , DIM >& bbox_struct)
- Bounding box initialized from corresponding POD type.
- Bbox( const Vector& point)
- Bounding box initialized to a single point.
- Bbox( const Vector& nmin, const Vector& nmax)
- Bounding box initialized to the new extreme corner vectors, nmin and nmax.
- Bbox( T min_x, T max_x)
- 1D bounding box (interval) initialized to the new extreme corner vectors, (min_x) and (max_x). More...
- Bbox( T min_x, T min_y, T max_x, T max_y)
- 2D bounding box (interval) initialized to the new extreme corner vectors, (min_x,min_y) and (max_x,max_y). More...
- Bbox( T min_x, T min_y, T min_z, T max_x, T max_y, T max_z)
- 3D bounding box (interval) initialized to the new extreme corner vectors, (min_x,min_y,min_z) and (max_x,max_y,max_z). More...
- template< typename InputIterator> Bbox( InputIterator first, InputIterator last)
- Constructs a bounding box from a range [first, last) of items. More...
- template< typename T2> Bbox( const Bbox < T2 , DIM >& other)
- Template constructor that allows explicit conversions from other bounding boxes with assignment compatible element value type.
- template< typename T2> Bbox( const Bbox_struct < T2 , DIM >& other)
- Template constructor that allows explicit conversions from other POD type with assignment compatible element value type.
Public Member Functions
- Bbox add_motionbox( const Bbox& vbox, T t) const
- Returns the translation of this bounding box by vectors that are inside the scaled bounding box of vectors, i.e., t*vbox. More...
- Vector* begin()
- Returns the pointer to the first vector, min.
- const Vector* begin() const
- Returns the pointer to the first vector, min.
- Vector center() const
- Returns the center point of the bounding box.
- void clear()
- Reinitializes this bounding box to the empty space. More...
- bool contains( const Vector& vec) const
- Returns true if the point is inside or on the boundary of the bounding box.
- T diagonal_length() const
- Returns the length of the diagonal. More...
- bool empty() const
- Returns true if the box is empty. More...
- Vector* end()
- Returns the past-the-end pointer. More...
- const Vector* end() const
- Returns the past-the-end pointer. More...
- Vector extent() const
- Returns the size of the bounding box.
- void insert( const Bbox& other)
- Assigns the union of this bounding box and the other bounding box to this bounding box.
- void insert( const Vector& point)
- Assigns the union of this bounding box and the point to this bounding box.
- template< typename InputIterator>void insert( InputIterator first, InputIterator last)
- Inserts a range [first,last) of items into this bounding box. More...
- bool intersects( const Bbox& other) const
- Returns true if this bounding box and the other bounding box intersect in their interiors or on their boundaries.
- bool is_line() const
- Returns true the bounding box is an axis-aligned line. More...
- bool is_plane() const
- Returns true the bounding box is an axis-aligned plane. More...
- bool is_point() const
- Returns true the bounding box is a single point.
- bool is_volume() const
- Returns true the bounding box has a volume. More...
- Size largest_extent_index() const
- Returns the index of the dimension in which the bounding box has its largest extent, i.e., 0=x, 1=y, 2=z.
- operator Bbox_struct< T, DIM >() const
- Conversion to corresponding POD type.
- Bbox& operator=( const Bbox& other)
- Assignment.
- Bbox& operator=( const Bbox_struct < T , DIM >& other)
- Assignment from corresponding POD type.
- Vector& operator[]( Size i)
- Returns the vector min for i==0, and the vector max for i==1.
- const Vector& operator[]( Size i) const
- Returns the vector min for i==0, and the vector max for i==1.
- void push_back( const Bbox& other)
- Assigns the union of this bounding box and the other bounding box to this bounding box. More...
- Size rank() const
- Returns the rank of the bounding box. More...
- void robust_grow( T eps = T(1.0e-5f))
- Robustly grows the bounding box by a value computed automatically from the bounding box dimensions and location in space. More...
- T volume() const
- Returns the volume of the bounding box.
Static Public Member Functions
- static Size max_size()
- Constant maximum size of the bounding box.
- static Size size()
- Constant size of the bounding box.
Public Variables
- Vector max
- Elementwise maximal bounding box corner.
- Vector min
- Elementwise minimal bounding box corner.
Static Public Variables
- static const Size DIMENSION = DIM
- Constant dimension of the vectors.
- static const Size SIZE = 2
- Constant size of the bounding box.
Typedefs
- typedef Bbox_struct< T, DIM> mi::math::Bbox< T, DIM>::Pod_type
-
POD class corresponding to this bounding box.
- typedef math::Vector< T, DIM> mi::math::Bbox< T, DIM>::Vector
-
Corresponding vector type.
- typedef Vector* mi::math::Bbox< T, DIM>::const_pointer
-
Const pointer to vector.
- typedef Vector& mi::math::Bbox< T, DIM>::const_reference
-
Const reference to vector.
- typedef Difference mi::math::Bbox< T, DIM>::difference_type
-
Difference type, signed.
- typedef Vector* mi::math::Bbox< T, DIM>::pointer
-
Mutable pointer to vector.
- typedef Vector& mi::math::Bbox< T, DIM>::reference
-
Mutable reference to vector.
- typedef Size mi::math::Bbox< T, DIM>::size_type
-
Size type, unsigned.
- typedef Vector mi::math::Bbox< T, DIM>::value_type
-
Coordinate type.
Enums
- enum mi::math::Bbox< T, DIM>::Uninitialized_tag
-
Enum type used to tag a special constructor that does not initialize the elements of the constructed bounding box.
Constructors
- mi::math::Bbox< T, DIM>::Bbox() [inline]
-
Bounding box initialized to the empty space, see also the clear function. The vector min is set elementwise to mi::base::numeric_traits<T>::max() and the vector max is set elementwise to mi::base::numeric_traits< T>::negative_max(). This initialization allows to insert points and other bounding boxes; a cleared bounding box will take the value of the first inserted point or bound box.
- mi::math::Bbox< T, DIM>::Bbox( Uninitialized_tag) [inline, explicit]
-
Bounding box with its elements not initialized.
- mi::math::Bbox< T, DIM>::Bbox( const Bbox < T , DIM >& other)
-
Default copy constructor.
- mi::math::Bbox< T, DIM>::Bbox( const Bbox_struct < T , DIM >& bbox_struct) [inline]
-
Bounding box initialized from corresponding POD type.
- mi::math::Bbox< T, DIM>::Bbox( const Vector& point) [inline, explicit]
-
Bounding box initialized to a single point.
- mi::math::Bbox< T, DIM>::Bbox( const Vector& nmin, const Vector& nmax) [inline]
-
Bounding box initialized to the new extreme corner vectors, nmin and nmax.
Parameters
- nmin
- min corner vector
- nmax
- max corner vector
- mi::math::Bbox< T, DIM>::Bbox( T min_x, T max_x) [inline]
-
1D bounding box (interval) initialized to the new extreme corner vectors, (min_x) and (max_x).
Precondition:
DIM == 1
Parameters
- min_x
- x-coordinate of min corner vector
- max_x
- x coordinate of max corner vector
- mi::math::Bbox< T, DIM>::Bbox( T min_x, T min_y, T max_x, T max_y) [inline]
-
2D bounding box (interval) initialized to the new extreme corner vectors, (min_x,min_y) and (max_x,max_y).
Precondition:
DIM == 2
Parameters
- min_x
- x-coordinate of min corner vector
- min_y
- y-coordinate of min corner vector
- max_x
- x coordinate of max corner vector
- max_y
- y coordinate of max corner vector
- mi::math::Bbox< T, DIM>::Bbox( T min_x, T min_y, T min_z, T max_x, T max_y, T max_z) [inline]
-
3D bounding box (interval) initialized to the new extreme corner vectors, (min_x,min_y,min_z) and (max_x,max_y,max_z).
Precondition:
DIM == 3
Parameters
- min_x
- x-coordinate of min corner vector
- min_y
- y-coordinate of min corner vector
- min_z
- z-coordinate of min corner vector
- max_x
- x coordinate of max corner vector
- max_y
- y coordinate of max corner vector
- max_z
- z coordinate of max corner vector
-
template< typename InputIterator>
mi::math::Bbox< T, DIM>::Bbox( InputIterator first, InputIterator last) [inline] -
Constructs a bounding box from a range [first, last) of items. The value type of InputIterator can be either Vector to insert points, or it can be Bbox to insert bounding boxes.
Parameters
- first
- first element of the sequence to insert
- last
- past-the-end position of sequence to insert
-
template< typename T2>
mi::math::Bbox< T, DIM>::Bbox( const Bbox < T2 , DIM >& other) [inline, explicit] -
Template constructor that allows explicit conversions from other bounding boxes with assignment compatible element value type.
-
template< typename T2>
mi::math::Bbox< T, DIM>::Bbox( const Bbox_struct < T2 , DIM >& other) [inline, explicit] -
Template constructor that allows explicit conversions from other POD type with assignment compatible element value type.
Member Functions
- Bbox mi::math::Bbox< T, DIM>::add_motionbox( const Bbox& vbox, T t) const [inline]
-
Returns the translation of this bounding box by vectors that are inside the scaled bounding box of vectors, i.e., t*vbox.
Precondition:
this bounding box and vbox are not empty
Parameters
- vbox
- vector bounding box to add
- t
- scale parameter. A negative scale inverts vbox.
- Vector* mi::math::Bbox< T, DIM>::begin() [inline]
-
Returns the pointer to the first vector, min.
- const Vector* mi::math::Bbox< T, DIM>::begin() const [inline]
-
Returns the pointer to the first vector, min.
- Vector mi::math::Bbox< T, DIM>::center() const [inline]
-
Returns the center point of the bounding box.
- void mi::math::Bbox< T, DIM>::clear() [inline]
-
Reinitializes this bounding box to the empty space. The vector min is set elementwise to mi::base::numeric_traits<T>::max() and the vector max is set elementwise to mi::base::numeric_traits< T>::negative_max(). This initialization allows to insert points and other bounding boxes; a cleared bounding box will take the value of the first inserted point or bound box.
- bool mi::math::Bbox< T, DIM>::contains( const Vector& vec) const [inline]
-
Returns true if the point is inside or on the boundary of the bounding box.
- T mi::math::Bbox< T, DIM>::diagonal_length() const [inline]
-
Returns the length of the diagonal.
Precondition:
the bounding box is not empty
- bool mi::math::Bbox< T, DIM>::empty() const [inline]
-
Returns true if the box is empty. For example, the box is empty after the default constructor or the clear() method call.
- Vector* mi::math::Bbox< T, DIM>::end() [inline]
- const Vector* mi::math::Bbox< T, DIM>::end() const [inline]
- Vector mi::math::Bbox< T, DIM>::extent() const [inline]
-
Returns the size of the bounding box.
- void mi::math::Bbox< T, DIM>::insert( const Bbox& other) [inline]
-
Assigns the union of this bounding box and the other bounding box to this bounding box.
- void mi::math::Bbox< T, DIM>::insert( const Vector& point) [inline]
-
Assigns the union of this bounding box and the point to this bounding box.
-
template< typename InputIterator>
void mi::math::Bbox< T, DIM>::insert( InputIterator first, InputIterator last) [inline] -
Inserts a range [first,last) of items into this bounding box. The value type of InputIterator can be either Vector to insert points, or it can be Bbox to insert bounding boxes.
Parameters
- first
- first element of the sequence to insert
- last
- past-the-end position of sequence to insert
- bool mi::math::Bbox< T, DIM>::intersects( const Bbox& other) const [inline]
-
Returns true if this bounding box and the other bounding box intersect in their interiors or on their boundaries.
- bool mi::math::Bbox< T, DIM>::is_line() const [inline]
-
Returns true the bounding box is an axis-aligned line.
Returns
true if rank() returns 1
- bool mi::math::Bbox< T, DIM>::is_plane() const [inline]
-
Returns true the bounding box is an axis-aligned plane.
Returns
true if rank() returns 2
- bool mi::math::Bbox< T, DIM>::is_point() const [inline]
-
Returns true the bounding box is a single point.
- bool mi::math::Bbox< T, DIM>::is_volume() const [inline]
-
Returns true the bounding box has a volume.
Returns
true if rank() returns 3
- Size mi::math::Bbox< T, DIM>::largest_extent_index() const [inline]
-
Returns the index of the dimension in which the bounding box has its largest extent, i.e., 0=x, 1=y, 2=z.
- static Size mi::math::Bbox< T, DIM>::max_size() [inline, static]
-
Constant maximum size of the bounding box.
- mi::math::Bbox< T, DIM>::operator Bbox_struct< T, DIM >() const [inline]
-
Conversion to corresponding POD type.
- Bbox& mi::math::Bbox< T, DIM>::operator=( const Bbox& other) [inline]
-
Assignment.
- Bbox& mi::math::Bbox< T, DIM>::operator=( const Bbox_struct < T , DIM >& other) [inline]
-
Assignment from corresponding POD type.
- Vector& mi::math::Bbox< T, DIM>::operator[]( Size i) [inline]
-
Returns the vector min for i==0, and the vector max for i==1.
- const Vector& mi::math::Bbox< T, DIM>::operator[]( Size i) const [inline]
-
Returns the vector min for i==0, and the vector max for i==1.
- void mi::math::Bbox< T, DIM>::push_back( const Bbox& other) [inline]
-
Assigns the union of this bounding box and the other bounding box to this bounding box. Makes the bounding box compatible with the std::back_inserter function, which allows you to use STL functions, such as std::copy to compute the union of a sequence of bounding boxes.
- Size mi::math::Bbox< T, DIM>::rank() const [inline]
-
Returns the rank of the bounding box.
Returns
0 if the bounding box is a point or empty, 1 if it is an axis-aligned line, 2 if it is an axis-aligned plane, and 3 if it has a volume.
- void mi::math::Bbox< T, DIM>::robust_grow( T eps = T(1.0e-5f))
-
Robustly grows the bounding box by a value computed automatically from the bounding box dimensions and location in space. If a bounding box is far away from the origin, just enlarging the bounding box by eps * (largest box extent) may result in cancellation. To avoid cancellation problems, this method computes the value for enlarging the box by computing coordinatewise the sum of the absolute values of the min and max coordinates and the bounding box extent. It takes then the maximum of all these sums, multiplies it by eps, adds it to bbox.max and subtracts it from bbox.min, enlarging the bounding box by an equal amount on all sides. grow factor
- static Size mi::math::Bbox< T, DIM>::size() [inline, static]
-
Constant size of the bounding box.
- T mi::math::Bbox< T, DIM>::volume() const [inline]
-
Returns the volume of the bounding box.
Variables
- const Size mi::math::Bbox< T, DIM>::DIMENSION = DIM [static]
-
Constant dimension of the vectors.
- const Size mi::math::Bbox< T, DIM>::SIZE = 2 [static]
-
Constant size of the bounding box.
- Vector mi::math::Bbox< T, DIM>::max
-
Elementwise maximal bounding box corner.
- Vector mi::math::Bbox< T, DIM>::min
-
Elementwise minimal bounding box corner.