BoundingBox.cxx
Go to the documentation of this file.
2 
3 WireCell::BoundingBox::BoundingBox(const Point& initial) : m_bounds(initial, initial), m_initialized(true) {}
4 WireCell::BoundingBox::BoundingBox(const Ray& initial) : m_bounds(initial), m_initialized(true) {}
6 {
7  (*this)(r.first);
8  (*this)(r.second);
9 }
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 }
28 
29 bool WireCell::BoundingBox::inside(const Point& point) const
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 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
bool empty() const
Definition: BoundingBox.h:49
bool inside(const Point &point) const
Return true if point is inside bounding box.
Definition: BoundingBox.cxx:29
p
Definition: test.py:223
BoundingBox()
Create a bounding box without an initial point or ray.
Definition: BoundingBox.h:18
void operator()(const Point &p)
Enlarge bounds to hold point.
Definition: BoundingBox.cxx:10