11 #ifndef BOUNDINGBOX_HPP 12 #define BOUNDINGBOX_HPP 27 typedef std::numeric_limits<T> limits;
52 if(limits::is_integer)
60 pts[0] = Point(v, v, v);
64 pts[1] = Point(0, 0, 0);
70 for(
size_t i = 0; i < N; ++i)
71 if(pts[0][i] >= pts[1][i])
77 operator bool()
const {
83 return pts[0] == other.pts[0] and pts[1] == other.pts[1];
88 return pts[0] != other.pts[0] or pts[1] != other.pts[1];
93 return pts[1] - pts[0];
102 for(
size_t i = 0; i < N; ++i) {
103 if(pts[0][i] < other.pts[0][i])
104 pts[0][i] = other.pts[0][i];
105 if(pts[1][i] > other.pts[1][i])
106 pts[1][i] = other.pts[1][i];
115 return copy &= other;
120 return (*
this) &= (other);
127 return copy &= other;
136 for(
size_t i = 0; i < N; ++i) {
137 if(pts[0][i] > other.pts[0][i])
138 pts[0][i] = other.pts[0][i];
139 if(pts[1][i] < other.pts[1][i])
140 pts[1][i] = other.pts[1][i];
149 return copy |= other;
154 return (*
this) |= (other);
161 return copy |= other;
170 for(
size_t i = 0; i < N; ++i) {
173 if(limits::is_integer) {
174 if(pts[1][i] < p[i] + 1)
175 pts[1][i] = p[i] + 1;
199 const Point& operator[](
int i)
const 207 Point& operator[](
int i)
220 return (p.
x() >= pts[0].
x() and p.
y() >= pts[0].
y() and p.
z() >= pts[0].
z() and p.
x() < pts[1].
x()
221 and p.
y() < pts[1].
y() and p.
z() < pts[1].
z());
252 friend std::ostream& operator<<(std::ostream& s,
const BoundingBox& bbox)
254 s << bbox.pts[0] <<
" " << bbox.pts[1];
259 friend std::istream& operator>>(std::istream& s,
BoundingBox& bbox)
261 s >> bbox.pts[0] >> bbox.pts[1];
268 s << bbox.pts[0] <<
" " << bbox.pts[1];
274 s >> bbox.pts[0] >> bbox.pts[1];
281 #endif // BOUNDINGBOX_HPP Definition: BoundingBox.hpp:24
CU_HOST_DEVICE BoundingBox & operator|=(const Point &p)
Adding a point.
Definition: BoundingBox.hpp:168
CU_HOST_DEVICE void x(const T &v)
Short access to the first element.
Definition: Vector.hpp:661
CU_HOST_DEVICE void y(const T &v)
Short access to the second element.
Definition: Vector.hpp:670
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
CU_HOST_DEVICE void z(const T &v)
Short access to the third element.
Definition: Vector.hpp:679
CU_HOST_DEVICE bool contains(const Point &p) const
Check if a point is in the BoundingBox.
Definition: BoundingBox.hpp:218
CU_HOST_DEVICE BoundingBox & operator&=(const BoundingBox &other)
Bounding box intersection.
Definition: BoundingBox.hpp:100
CU_HOST_DEVICE BoundingBox & operator|=(const BoundingBox &other)
Bounding box union.
Definition: BoundingBox.hpp:134
Defines the Vector class template This file is shared by cuda, do not include headers that nvcc can't...