ESyS-Particle  2.3.4
BoundingBox.hpp
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.apache.org/licenses/LICENSE-2.0 //
10 // //
12 
13 
14 namespace esys
15 {
16  namespace lsm
17  {
19  : m_minPt(Vec3::ZERO),
20  m_maxPt(Vec3::ZERO)
21  {
22  }
23 
24  BoundingBox::BoundingBox(const Vec3 &minBBoxPt, const Vec3 &maxBBoxPt)
25  : m_minPt(minBBoxPt),
26  m_maxPt(maxBBoxPt)
27  {
28  }
29 
31  {
32  }
33 
34  double BoundingBox::getVolume() const
35  {
36  Vec3 diff(m_maxPt-m_minPt);
37  return diff.X()*diff.Y()*diff.Z();
38  }
39 
40  const Vec3 &BoundingBox::getMinPt() const
41  {
42  return m_minPt;
43  }
44 
45  const Vec3 &BoundingBox::getMaxPt() const
46  {
47  return m_maxPt;
48  }
49 
50  bool BoundingBox::operator==(const BoundingBox &bbox) const
51  {
52  return
53  (
54  (getMinPt() == bbox.getMinPt())
55  &&
56  (getMaxPt() == bbox.getMaxPt())
57  );
58  }
59 
60  bool BoundingBox::contains(const Vec3 &pt, double tolerance) const
61  {
62  return
63  (
64  (getMinPt().X() <= (pt.X() + tolerance))
65  &&
66  (getMinPt().Y() <= (pt.Y() + tolerance))
67  &&
68  (getMinPt().Z() <= (pt.Z() + tolerance))
69  &&
70  (getMaxPt().X() >= (pt.X() - tolerance))
71  &&
72  (getMaxPt().Y() >= (pt.Y() - tolerance))
73  &&
74  (getMaxPt().Z() >= (pt.Z() - tolerance))
75  );
76  }
77 
79  {
80  return (getMaxPt() - getMinPt());
81  }
82 
83  std::ostream &operator<<(std::ostream &oStream, const BoundingBox &bbox)
84  {
85  oStream << bbox.getMinPt() << " " << bbox.getMaxPt();
86  return oStream;
87  }
88  }
89 }
esys::lsm::BoundingBox::getMaxPt
const Vec3 & getMaxPt() const
Definition: BoundingBox.hpp:45
esys::lsm::BoundingBox::m_maxPt
Vec3 m_maxPt
Definition: BoundingBox.h:50
esys::lsm::BoundingBox::getVolume
double getVolume() const
Definition: BoundingBox.hpp:34
Vec3::X
VEC3_INLINE double & X()
Definition: vec3.h:119
esys::lsm::BoundingBox
3D bounding box
Definition: BoundingBox.h:28
esys
Definition: CheckPointable.cpp:17
esys::lsm::BoundingBox::operator==
bool operator==(const BoundingBox &bbox) const
Definition: BoundingBox.hpp:50
esys::lsm::operator<<
std::ostream & operator<<(std::ostream &oStream, const SimpleConnectionData &connectionData)
Definition: GeometryReader.cpp:134
Vec3::Z
VEC3_INLINE double & Z()
Definition: vec3.h:121
esys::lsm::BoundingBox::getMinPt
const Vec3 & getMinPt() const
Definition: BoundingBox.hpp:40
esys::lsm::BoundingBox::contains
bool contains(const Vec3 &pt, double tolerance=0.0) const
Definition: BoundingBox.hpp:60
Vec3::Y
VEC3_INLINE double & Y()
Definition: vec3.h:120
Vec3
Definition: vec3.h:47
esys::lsm::BoundingBox::~BoundingBox
virtual ~BoundingBox()
Definition: BoundingBox.hpp:30
esys::lsm::BoundingBox::getSizes
Vec3 getSizes() const
Definition: BoundingBox.hpp:78
esys::lsm::BoundingBox::BoundingBox
BoundingBox()
Definition: BoundingBox.hpp:18
esys::lsm::BoundingBox::m_minPt
Vec3 m_minPt
Definition: BoundingBox.h:49