libMesh
Public Member Functions | List of all members
libMesh::BoundingBox Class Reference

Defines a Cartesian bounding box by the two corner extremum. More...

#include <bounding_box.h>

Inheritance diagram for libMesh::BoundingBox:
[legend]

Public Member Functions

 BoundingBox (const Point &new_min, const Point &new_max)
 
 BoundingBox (const std::pair< Point, Point > &bbox)
 
 BoundingBox ()
 Default constructor sets invalid bounds. More...
 
void invalidate ()
 Sets the bounding box to encompass the universe. More...
 
const Pointmin () const
 
Pointmin ()
 
const Pointmax () const
 
Pointmax ()
 
bool intersects (const BoundingBox &) const
 
bool intersects (const BoundingBox &, Real abstol) const
 
bool intersect (const BoundingBox &b) const
 
bool contains_point (const Point &) const
 
void intersect_with (const BoundingBox &)
 Sets this bounding box to be the intersection with the other bounding box. More...
 
void union_with (const Point &p)
 Enlarges this bounding box to include the given point. More...
 
void union_with (const BoundingBox &)
 Sets this bounding box to be the union with the other bounding box. More...
 
Real signed_distance (const Point &p) const
 Computes the signed distance, d, from a given Point p to this BoundingBox. More...
 

Detailed Description

Defines a Cartesian bounding box by the two corner extremum.

Definition at line 40 of file bounding_box.h.

Constructor & Destructor Documentation

◆ BoundingBox() [1/3]

libMesh::BoundingBox::BoundingBox ( const Point new_min,
const Point new_max 
)

Definition at line 44 of file bounding_box.h.

45  :
46  std::pair<Point, Point>(new_min, new_max)
47  {}

◆ BoundingBox() [2/3]

libMesh::BoundingBox::BoundingBox ( const std::pair< Point, Point > &  bbox)

Definition at line 49 of file bounding_box.h.

49  :
50  std::pair<Point, Point> (bbox)
51  {}

◆ BoundingBox() [3/3]

libMesh::BoundingBox::BoundingBox ( )

Default constructor sets invalid bounds.

Definition at line 56 of file bounding_box.h.

References invalidate().

57  {
58  this->invalidate();
59  }
void invalidate()
Sets the bounding box to encompass the universe.
Definition: bounding_box.h:64

Member Function Documentation

◆ contains_point()

bool libMesh::BoundingBox::contains_point ( const Point ) const
Returns
true if the bounding box contains the given point.

◆ intersect()

bool libMesh::BoundingBox::intersect ( const BoundingBox b) const
Returns
true if the other bounding box has a non-empty intersection with this bounding box.
Deprecated:
Use the BoundingBox::intersects() function instead.

Definition at line 121 of file bounding_box.h.

References intersects().

122  { libmesh_deprecated(); return this->intersects(b); }
bool intersects(const BoundingBox &) const

◆ intersect_with()

void libMesh::BoundingBox::intersect_with ( const BoundingBox )

Sets this bounding box to be the intersection with the other bounding box.

◆ intersects() [1/2]

bool libMesh::BoundingBox::intersects ( const BoundingBox ) const
Returns
true if the other bounding box has a non-empty intersection with this bounding box. Exact floating point <= comparisons are performed.

Referenced by intersect().

◆ intersects() [2/2]

bool libMesh::BoundingBox::intersects ( const BoundingBox ,
Real  abstol 
) const
Returns
true if the other bounding box has a non-empty intersection with this bounding box. abstol is an absolute tolerance used to make "fuzzy" comparisons. abstol must be strictly > 0.0, and both BBoxes being compared are "inflated" by abstol in each direction, i.e. (xmin, ymin, zmin) -> (xmin - abstol, ymin - abstol, zmin - abstol) (xmax, ymax, zmax) -> (xmax + abstol, ymax + abstol, zmax + abstol) before the intersection comparisons are made. This approach can be helpful for detecting intersections between two degenerate (planar) bounding boxes that lie in nearly (to within abstol) the same plane and in certain situations should be considered intersecting.

◆ invalidate()

void libMesh::BoundingBox::invalidate ( )

Sets the bounding box to encompass the universe.

Definition at line 64 of file bounding_box.h.

References std::max().

Referenced by BoundingBox().

65  {
66  for (unsigned int i=0; i<LIBMESH_DIM; i++)
67  {
68  this->first(i) = std::numeric_limits<Real>::max();
69  this->second(i) = -std::numeric_limits<Real>::max();
70  }
71  }
long double max(long double a, double b)

◆ max() [1/2]

const Point& libMesh::BoundingBox::max ( ) const
Returns
A point at the maximum x,y,z coordinates of the box.

Definition at line 85 of file bounding_box.h.

Referenced by union_with().

86  { return this->second; }

◆ max() [2/2]

Point& libMesh::BoundingBox::max ( )

Definition at line 88 of file bounding_box.h.

89  { return this->second; }

◆ min() [1/2]

const Point& libMesh::BoundingBox::min ( ) const
Returns
A point at the minimum x,y,z coordinates of the box.

Definition at line 76 of file bounding_box.h.

Referenced by union_with().

77  { return this->first; }

◆ min() [2/2]

Point& libMesh::BoundingBox::min ( )

Definition at line 79 of file bounding_box.h.

80  { return this->first; }

◆ signed_distance()

Real libMesh::BoundingBox::signed_distance ( const Point p) const

Computes the signed distance, d, from a given Point p to this BoundingBox.

The sign convention is: d > 0 if the point is outside the BoundingBox d <= 0 if the point is inside the Bounding Box

◆ union_with() [1/2]

void libMesh::BoundingBox::union_with ( const Point p)

Enlarges this bounding box to include the given point.

Definition at line 163 of file bounding_box.h.

References std::max(), max(), std::min(), and min().

164 {
165  for (unsigned int i=0; i<LIBMESH_DIM; i++)
166  {
167  min()(i) = std::min(min()(i), p(i));
168  max()(i) = std::max(max()(i), p(i));
169  }
170 }
long double max(long double a, double b)
const Point & min() const
Definition: bounding_box.h:76
const Point & max() const
Definition: bounding_box.h:85
long double min(long double a, double b)

◆ union_with() [2/2]

void libMesh::BoundingBox::union_with ( const BoundingBox )

Sets this bounding box to be the union with the other bounding box.


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