10 #ifndef INCLUDED_ATOMSMATHBOX_H
11 #define INCLUDED_ATOMSMATHBOX_H
13 #include <AtomsMath/ImathNamespace.h>
14 #include <AtomsMath/ImathVec.h>
16 ATOMSMATH_INTERNAL_NAMESPACE_HEADER_ENTER
35 template <
class V>
class Box
56 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Box() noexcept;
59 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Box (const V& point) noexcept;
62 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Box (const V& minV, const V& maxV) noexcept;
70 ATOMSMATH_HOSTDEVICE constexpr
bool operator== (const
Box<V>& src) const noexcept;
73 ATOMSMATH_HOSTDEVICE constexpr
bool operator!= (const
Box<V>& src) const noexcept;
86 ATOMSMATH_HOSTDEVICE
void extendBy (const V& point) noexcept;
89 ATOMSMATH_HOSTDEVICE
void extendBy (const
Box<V>& box) noexcept;
102 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 V
size() const noexcept;
106 ATOMSMATH_HOSTDEVICE constexpr V
center() const noexcept;
109 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool intersects (const V& point) const noexcept;
112 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool intersects (const
Box<V>& box) const noexcept;
116 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
unsigned int majorAxis() const noexcept;
120 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool isEmpty() const noexcept;
123 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool hasVolume() const noexcept;
128 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool isInfinite() const noexcept;
163 template <class V> ATOMSMATH_CONSTEXPR14 inline
Box<V>::
Box() noexcept
168 template <
class V> ATOMSMATH_CONSTEXPR14
inline Box<V>::Box (
const V& point) noexcept
174 template <
class V> ATOMSMATH_CONSTEXPR14
inline Box<V>::Box (
const V& minV,
const V& maxV) noexcept
181 constexpr
inline bool
184 return (
min == src.min &&
max == src.max);
188 constexpr
inline bool
191 return (
min != src.min ||
max != src.max);
198 min = V (V::baseTypeMax());
199 max = V (V::baseTypeLowest());
206 min = V (V::baseTypeLowest());
207 max = V (V::baseTypeMax());
214 for (
unsigned int i = 0; i <
min.dimensions(); i++)
216 if (point[i] <
min[i])
219 if (point[i] >
max[i])
228 for (
unsigned int i = 0; i <
min.dimensions(); i++)
230 if (box.min[i] <
min[i])
233 if (box.max[i] >
max[i])
239 ATOMSMATH_CONSTEXPR14
inline bool
242 for (
unsigned int i = 0; i <
min.dimensions(); i++)
244 if (point[i] <
min[i] || point[i] >
max[i])
252 ATOMSMATH_CONSTEXPR14
inline bool
255 for (
unsigned int i = 0; i <
min.dimensions(); i++)
257 if (box.max[i] <
min[i] || box.min[i] >
max[i])
265 ATOMSMATH_CONSTEXPR14
inline V
282 ATOMSMATH_CONSTEXPR14
inline bool
285 for (
unsigned int i = 0; i <
min.dimensions(); i++)
295 ATOMSMATH_CONSTEXPR14
inline bool
298 for (
unsigned int i = 0; i <
min.dimensions(); i++)
300 if (
min[i] != V::baseTypeLowest() ||
max[i] != V::baseTypeMax())
308 ATOMSMATH_CONSTEXPR14
inline bool
311 for (
unsigned int i = 0; i <
min.dimensions(); i++)
321 ATOMSMATH_CONSTEXPR14
inline unsigned int
324 unsigned int major = 0;
327 for (
unsigned int i = 1; i <
min.dimensions(); i++)
342 template <
typename V>
class Box;
369 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Box() noexcept;
372 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Box (const
Vec2<T>& point) noexcept;
375 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Box (const
Vec2<T>& minT, const
Vec2<T>& maxT) noexcept;
383 ATOMSMATH_HOSTDEVICE constexpr
bool operator== (const
Box<
Vec2<T>>& src) const noexcept;
386 ATOMSMATH_HOSTDEVICE constexpr
bool operator!= (const
Box<
Vec2<T>>& src) const noexcept;
396 ATOMSMATH_HOSTDEVICE
void makeEmpty() noexcept;
399 ATOMSMATH_HOSTDEVICE
void extendBy (const
Vec2<T>& point) noexcept;
414 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Vec2<T>
size() const noexcept;
418 ATOMSMATH_HOSTDEVICE constexpr
Vec2<T>
center() const noexcept;
421 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool intersects (const
Vec2<T>& point) const noexcept;
424 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool intersects (const
Box<
Vec2<T>>& box) const noexcept;
428 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
unsigned int majorAxis() const noexcept;
432 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool isEmpty() const noexcept;
435 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool hasVolume() const noexcept;
440 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool isInfinite() const noexcept;
449 template <class T> ATOMSMATH_CONSTEXPR14 inline
Box<
Vec2<T>>::
Box() noexcept
468 constexpr
inline bool
471 return (
min == src.min &&
max == src.max);
475 constexpr
inline bool
478 return (
min != src.min ||
max != src.max);
501 if (point[0] <
min[0])
504 if (point[0] >
max[0])
507 if (point[1] <
min[1])
510 if (point[1] >
max[1])
518 if (box.min[0] <
min[0])
521 if (box.max[0] >
max[0])
524 if (box.min[1] <
min[1])
527 if (box.max[1] >
max[1])
532 ATOMSMATH_CONSTEXPR14
inline bool
535 if (point[0] <
min[0] || point[0] >
max[0] || point[1] <
min[1] || point[1] >
max[1])
542 ATOMSMATH_CONSTEXPR14
inline bool
545 if (box.max[0] <
min[0] || box.min[0] >
max[0] || box.max[1] <
min[1] || box.min[1] >
max[1])
552 ATOMSMATH_CONSTEXPR14
inline Vec2<T>
569 ATOMSMATH_CONSTEXPR14
inline bool
579 ATOMSMATH_CONSTEXPR14
inline bool
582 if (
min[0] != std::numeric_limits<T>::lowest() ||
583 max[0] != std::numeric_limits<T>::max() ||
584 min[1] != std::numeric_limits<T>::lowest() ||
585 max[1] != std::numeric_limits<T>::max())
592 ATOMSMATH_CONSTEXPR14
inline bool
602 ATOMSMATH_CONSTEXPR14
inline unsigned int
605 unsigned int major = 0;
637 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Box() noexcept;
640 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Box (const
Vec3<T>& point) noexcept;
643 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Box (const
Vec3<T>& minT, const
Vec3<T>& maxT) noexcept;
648 ATOMSMATH_HOSTDEVICE constexpr
bool operator== (const
Box<
Vec3<T>>& src) const noexcept;
651 ATOMSMATH_HOSTDEVICE constexpr
bool operator!= (const
Box<
Vec3<T>>& src) const noexcept;
656 ATOMSMATH_HOSTDEVICE
void makeEmpty() noexcept;
659 ATOMSMATH_HOSTDEVICE
void extendBy (const
Vec3<T>& point) noexcept;
669 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Vec3<T>
size() const noexcept;
673 ATOMSMATH_HOSTDEVICE constexpr
Vec3<T>
center() const noexcept;
676 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool intersects (const
Vec3<T>& point) const noexcept;
679 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool intersects (const
Box<
Vec3<T>>& box) const noexcept;
683 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
unsigned int majorAxis() const noexcept;
687 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool isEmpty() const noexcept;
690 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool hasVolume() const noexcept;
695 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool isInfinite() const noexcept;
702 template <class T> ATOMSMATH_CONSTEXPR14 inline
Box<
Vec3<T>>::
Box() noexcept
721 constexpr
inline bool
724 return (
min == src.min &&
max == src.max);
728 constexpr
inline bool
731 return (
min != src.min ||
max != src.max);
754 if (point[0] <
min[0])
757 if (point[0] >
max[0])
760 if (point[1] <
min[1])
763 if (point[1] >
max[1])
766 if (point[2] <
min[2])
769 if (point[2] >
max[2])
777 if (box.min[0] <
min[0])
780 if (box.max[0] >
max[0])
783 if (box.min[1] <
min[1])
786 if (box.max[1] >
max[1])
789 if (box.min[2] <
min[2])
792 if (box.max[2] >
max[2])
797 ATOMSMATH_CONSTEXPR14
inline bool
800 if (point[0] <
min[0] || point[0] >
max[0] || point[1] <
min[1] || point[1] >
max[1] ||
801 point[2] <
min[2] || point[2] >
max[2])
808 ATOMSMATH_CONSTEXPR14
inline bool
811 if (box.max[0] <
min[0] || box.min[0] >
max[0] || box.max[1] <
min[1] || box.min[1] >
max[1] ||
812 box.max[2] <
min[2] || box.min[2] >
max[2])
819 ATOMSMATH_CONSTEXPR14
inline Vec3<T>
836 ATOMSMATH_CONSTEXPR14
inline bool
846 ATOMSMATH_CONSTEXPR14
inline bool
849 if (
min[0] != std::numeric_limits<T>::lowest() ||
850 max[0] != std::numeric_limits<T>::max() ||
851 min[1] != std::numeric_limits<T>::lowest() ||
852 max[1] != std::numeric_limits<T>::max() ||
853 min[2] != std::numeric_limits<T>::lowest() ||
854 max[2] != std::numeric_limits<T>::max())
861 ATOMSMATH_CONSTEXPR14
inline bool
871 ATOMSMATH_CONSTEXPR14
inline unsigned int
874 unsigned int major = 0;
886 ATOMSMATH_INTERNAL_NAMESPACE_HEADER_EXIT
Vec2< T > max
The maximum value of the box.
Definition: ImathBox.h:361
Vec2< T > min
The minimum value of the box.
Definition: ImathBox.h:358
Vec3< T > min
The minimum value of the box.
Definition: ImathBox.h:626
Vec3< T > max
The maximum value of the box.
Definition: ImathBox.h:629
Definition: ImathBox.h:36
ATOMSMATH_HOSTDEVICE void extendBy(const V &point) noexcept
Extend the box to include the given point.
Definition: ImathBox.h:212
V min
The minimum value of the box.
Definition: ImathBox.h:43
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 unsigned int majorAxis() const noexcept
Definition: ImathBox.h:322
V max
The maximum value of the box.
Definition: ImathBox.h:46
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool hasVolume() const noexcept
Return true if the box is larger than a single point, false otherwise.
Definition: ImathBox.h:309
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool intersects(const V &point) const noexcept
Return true if the given point is inside the box, false otherwise.
Definition: ImathBox.h:240
ATOMSMATH_HOSTDEVICE void makeInfinite() noexcept
Make the box include the entire range of V.
Definition: ImathBox.h:204
constexpr ATOMSMATH_HOSTDEVICE V center() const noexcept
Definition: ImathBox.h:276
constexpr ATOMSMATH_HOSTDEVICE bool operator==(const Box< V > &src) const noexcept
Equality.
Definition: ImathBox.h:182
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 V size() const noexcept
Definition: ImathBox.h:266
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool isEmpty() const noexcept
Definition: ImathBox.h:283
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Box() noexcept
Definition: ImathBox.h:163
constexpr ATOMSMATH_HOSTDEVICE bool operator!=(const Box< V > &src) const noexcept
Inequality.
Definition: ImathBox.h:189
ATOMSMATH_HOSTDEVICE void makeEmpty() noexcept
Definition: ImathBox.h:196
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool isInfinite() const noexcept
Definition: ImathBox.h:296
Definition: ImathVec.h:43
Definition: ImathVec.h:260