Public Member Functions | Private Attributes | List of all members
WireCell::BoundingBox Class Reference

#include <BoundingBox.h>

Public Member Functions

 BoundingBox ()
 Create a bounding box without an initial point or ray. More...
 
 BoundingBox (const Point &initial)
 Create a bounding box bounding an initial point. More...
 
 BoundingBox (const Ray &initial)
 Create a bounding box bounding an initial ray. More...
 
template<typename RayOrPointIterator >
 BoundingBox (const RayOrPointIterator &begin, const RayOrPointIterator &end)
 Create a bounding box from an iterator pair. More...
 
bool inside (const Point &point) const
 Return true if point is inside bounding box. More...
 
const Raybounds () const
 Return the ray representing the bounds. More...
 
void operator() (const Point &p)
 Enlarge bounds to hold point. More...
 
void operator() (const Ray &r)
 Enlarge bounds to hold ray. More...
 
template<typename RayOrPointIterator >
void operator() (const RayOrPointIterator &begin, const RayOrPointIterator &end)
 
bool empty () const
 

Private Attributes

Ray m_bounds
 
bool m_initialized = false
 

Detailed Description

A bounding box parallel to the Cartesian axes.

Definition at line 11 of file BoundingBox.h.

Constructor & Destructor Documentation

WireCell::BoundingBox::BoundingBox ( )
inline

Create a bounding box without an initial point or ray.

Definition at line 18 of file BoundingBox.h.

18 { m_bounds = Ray();}
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
WireCell::BoundingBox::BoundingBox ( const Point initial)

Create a bounding box bounding an initial point.

Definition at line 3 of file BoundingBox.cxx.

3 : m_bounds(initial, initial), m_initialized(true) {}
WireCell::BoundingBox::BoundingBox ( const Ray initial)

Create a bounding box bounding an initial ray.

Definition at line 4 of file BoundingBox.cxx.

4 : m_bounds(initial), m_initialized(true) {}
template<typename RayOrPointIterator >
WireCell::BoundingBox::BoundingBox ( const RayOrPointIterator &  begin,
const RayOrPointIterator &  end 
)
inline

Create a bounding box from an iterator pair.

Definition at line 28 of file BoundingBox.h.

28  {
29  for (auto it = begin; it != end; ++it) { (*this)(*it); }
30  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:72
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:67

Member Function Documentation

const Ray& WireCell::BoundingBox::bounds ( ) const
inline

Return the ray representing the bounds.

Definition at line 36 of file BoundingBox.h.

36 { return m_bounds; }
bool WireCell::BoundingBox::empty ( void  ) const
inline

Definition at line 49 of file BoundingBox.h.

49 { return !m_initialized; }
bool WireCell::BoundingBox::inside ( const Point point) const

Return true if point is inside bounding box.

Definition at line 29 of file BoundingBox.cxx.

30 {
31  if (empty()) {
32  return false;
33  }
34  for (int ind=0; ind<3; ++ind) {
35  const double p = point[ind];
36  const double b1 = m_bounds.first[ind];
37  const double b2 = m_bounds.second[ind];
38 
39  if (b1 < b2) {
40  if (p<b1 or p>b2) return false;
41  continue;
42  }
43  if (b2 < b1) {
44  if (p<b2 or p>b1) return false;
45  continue;
46  }
47 
48  // if equal, then zero width dimension, don't test.
49  continue;
50  }
51  return true;
52 }
bool empty() const
Definition: BoundingBox.h:49
p
Definition: test.py:223
void WireCell::BoundingBox::operator() ( const Point p)

Enlarge bounds to hold point.

Definition at line 10 of file BoundingBox.cxx.

11 {
12  if(empty()) {
13  m_bounds.first = p;
14  m_bounds.second = p;
15  m_initialized=true;
16  return;
17  }
18 
19  for (int ind=0; ind<3; ++ind) {
20  if (p[ind] < m_bounds.first[ind]) {
21  m_bounds.first[ind] = p[ind];
22  }
23  if (p[ind] > m_bounds.second[ind]) {
24  m_bounds.second[ind] = p[ind];
25  }
26  }
27 }
bool empty() const
Definition: BoundingBox.h:49
p
Definition: test.py:223
void WireCell::BoundingBox::operator() ( const Ray r)

Enlarge bounds to hold ray.

Definition at line 5 of file BoundingBox.cxx.

6 {
7  (*this)(r.first);
8  (*this)(r.second);
9 }
template<typename RayOrPointIterator >
void WireCell::BoundingBox::operator() ( const RayOrPointIterator &  begin,
const RayOrPointIterator &  end 
)
inline

Definition at line 45 of file BoundingBox.h.

45  {
46  for (auto it = begin; it != end; ++it) { (*this)(*it); }
47  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:72
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:67

Member Data Documentation

Ray WireCell::BoundingBox::m_bounds
private

Definition at line 12 of file BoundingBox.h.

bool WireCell::BoundingBox::m_initialized = false
private

Definition at line 13 of file BoundingBox.h.


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