Easy3D 2.6.1
Loading...
Searching...
No Matches
GenericBox< DIM, FT > Class Template Reference

GenericBox represents the bounding box of shapes. More...

#include <easy3d/core/box.h>

Public Types

typedef Vec< DIM, FT > Point
 Point type.
 
typedef Vec< DIM, FT > Vector
 Vector type.
 
typedef GenericBox< DIM, FT > thisclass
 This class.
 

Public Member Functions

 GenericBox ()
 Construct a box uninitialized (which is invalid).
 
 GenericBox (const Point &pmin, const Point &pmax)
 Construct a box from its diagonal corners.
 
 GenericBox (const Point &c, FT r)
 Construct a box from its center and radius.
 
bool is_valid () const
 Check if the box is valid.
 
void clear ()
 Invalidate the box.
 
const Pointmin_point () const
 Return the coordinates of the min corner (const version).
 
Pointmin_point ()
 Return the coordinates of the min corner.
 
const Pointmax_point () const
 Return the coordinates of the max corner (const version).
 
Pointmax_point ()
 Return the coordinates of the max corner.
 
FT min_coord (unsigned int axis) const
 Return a component of the coordinates of the min corner.
 
FT max_coord (unsigned int axis) const
 Return a component of the coordinates of the max corner.
 
FT range (unsigned int axis) const
 Return the range of the box along the axis.
 
FT max_range () const
 Return the max range.
 
FT min_range () const
 Return the min range.
 
unsigned int max_range_axis () const
 Return the axis index of the max range of the box.
 
unsigned int min_range_axis () const
 Return the axis index of the min range of the box.
 
Point center () const
 Return the center of the box.
 
Vector diagonal_vector () const
 Return the diagonal vector of the box.
 
FT diagonal_length () const
 Return the length of the diagonal of the box.
 
FT radius () const
 Return the radius of the box (i.e., half of its diagonal length).
 
FT surface_area () const
 Return the surface area of the box.
 
void grow (const Point &p)
 Add a point to this box. This will compute its new extent.
 
void grow (const thisclass &b)
 Add a box to this box. This will compute its new extent.
 
thisclass operator+ (const thisclass &b) const
 Return the bounding box of 'this' and another box b.
 
thisclassoperator+= (const thisclass &b)
 Modify this box by adding another box b.
 
bool contains (Point const &p) const
 Check if this box contains a point p.
 
bool contains (thisclass const &b) const
 Check if this box contains another box b.
 
bool intersects (thisclass const &b) const
 Check if this box intersects another box b.
 

Detailed Description

template<int DIM, typename FT>
class easy3d::GenericBox< DIM, FT >

GenericBox represents the bounding box of shapes.

Template Parameters
DIMThe dimension (i.e., 2 or 3).
FTThe type of the floating point number (i.e., float or double).

Constructor & Destructor Documentation

◆ GenericBox() [1/2]

template<int DIM, typename FT>
GenericBox ( const Point & pmin,
const Point & pmax )
inline

Construct a box from its diagonal corners.

Parameters
pminThe minimum corner point.
pmaxThe maximum corner point.

◆ GenericBox() [2/2]

template<int DIM, typename FT>
GenericBox ( const Point & c,
FT r )
inline

Construct a box from its center and radius.

Parameters
cThe center point.
rThe radius.

Member Function Documentation

◆ center()

template<int DIM, typename FT>
Point center ( ) const
inline

Return the center of the box.

Returns
The center point.

◆ contains() [1/2]

template<int DIM, typename FT>
bool contains ( Point const & p) const
inline

Check if this box contains a point p.

Parameters
pThe point to check.
Returns
True if the box contains the point, false otherwise.

◆ contains() [2/2]

template<int DIM, typename FT>
bool contains ( thisclass const & b) const
inline

Check if this box contains another box b.

Parameters
bThe other box to check.
Returns
True if the box contains the other box, false otherwise.

◆ diagonal_length()

template<int DIM, typename FT>
FT diagonal_length ( ) const
inline

Return the length of the diagonal of the box.

Returns
The diagonal length.

◆ diagonal_vector()

template<int DIM, typename FT>
Vector diagonal_vector ( ) const
inline

Return the diagonal vector of the box.

Returns
The diagonal vector.

◆ grow() [1/2]

template<int DIM, typename FT>
void grow ( const Point & p)
inline

Add a point to this box. This will compute its new extent.

Parameters
pThe point to add.

◆ grow() [2/2]

template<int DIM, typename FT>
void grow ( const thisclass & b)
inline

Add a box to this box. This will compute its new extent.

Parameters
bThe box to add.

◆ intersects()

template<int DIM, typename FT>
bool intersects ( thisclass const & b) const
inline

Check if this box intersects another box b.

Parameters
bThe other box to check.
Returns
True if the boxes intersect, false otherwise.

◆ is_valid()

template<int DIM, typename FT>
bool is_valid ( ) const
inline

Check if the box is valid.

Returns
True if the box is valid, false otherwise.

◆ max_coord()

template<int DIM, typename FT>
FT max_coord ( unsigned int axis) const
inline

Return a component of the coordinates of the max corner.

Parameters
axisThe axis index, which must be in the range [0, DIM).
Returns
The coordinate value.

◆ max_point() [1/2]

template<int DIM, typename FT>
Point & max_point ( )
inline

Return the coordinates of the max corner.

Returns
The coordinates of the max corner.

◆ max_point() [2/2]

template<int DIM, typename FT>
const Point & max_point ( ) const
inline

Return the coordinates of the max corner (const version).

Returns
The coordinates of the max corner.

◆ max_range()

template<int DIM, typename FT>
FT max_range ( ) const
inline

Return the max range.

Returns
The max range value.

◆ max_range_axis()

template<int DIM, typename FT>
unsigned int max_range_axis ( ) const
inline

Return the axis index of the max range of the box.

Returns
The axis index.

◆ min_coord()

template<int DIM, typename FT>
FT min_coord ( unsigned int axis) const
inline

Return a component of the coordinates of the min corner.

Parameters
axisThe axis index, which must be in the range [0, DIM).
Returns
The coordinate value.

◆ min_point() [1/2]

template<int DIM, typename FT>
Point & min_point ( )
inline

Return the coordinates of the min corner.

Returns
The coordinates of the min corner.

◆ min_point() [2/2]

template<int DIM, typename FT>
const Point & min_point ( ) const
inline

Return the coordinates of the min corner (const version).

Returns
The coordinates of the min corner.

◆ min_range()

template<int DIM, typename FT>
FT min_range ( ) const
inline

Return the min range.

Returns
The min range value.

◆ min_range_axis()

template<int DIM, typename FT>
unsigned int min_range_axis ( ) const
inline

Return the axis index of the min range of the box.

Returns
The axis index.

◆ operator+()

template<int DIM, typename FT>
thisclass operator+ ( const thisclass & b) const
inline

Return the bounding box of 'this' and another box b.

Parameters
bThe other box.
Returns
The resulting bounding box.

◆ operator+=()

template<int DIM, typename FT>
thisclass & operator+= ( const thisclass & b)
inline

Modify this box by adding another box b.

Parameters
bThe other box.
Returns
A reference to this box.

◆ radius()

template<int DIM, typename FT>
FT radius ( ) const
inline

Return the radius of the box (i.e., half of its diagonal length).

Returns
The radius.

◆ range()

template<int DIM, typename FT>
FT range ( unsigned int axis) const
inline

Return the range of the box along the axis.

Parameters
axisThe axis index, which must be in the range [0, DIM).
Returns
The range value.

◆ surface_area()

template<int DIM, typename FT>
FT surface_area ( ) const
inline

Return the surface area of the box.

Returns
The surface area.

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