|
1 | 1 | #ifndef _VRENDER_AXISALIGNEDBOX_H |
2 | 2 | #define _VRENDER_AXISALIGNEDBOX_H |
3 | 3 |
|
4 | | -namespace vrender { |
5 | | -class Vector2; |
6 | | -class Vector3; |
7 | | - |
8 | | -template <class T> class AxisAlignedBox { |
9 | | -public: |
10 | | - AxisAlignedBox(); |
11 | | - AxisAlignedBox(const T &v); |
12 | | - AxisAlignedBox(const T &v, const T &w); |
13 | | - |
14 | | - const T &mini() const { return _min; } |
15 | | - const T &maxi() const { return _max; } |
16 | | - |
17 | | - void include(const T &v); |
18 | | - void include(const AxisAlignedBox<T> &b); |
19 | | - |
20 | | -private: |
21 | | - T _min; |
22 | | - T _max; |
23 | | -}; |
24 | | - |
25 | | -typedef AxisAlignedBox<Vector2> AxisAlignedBox_xy; |
26 | | -typedef AxisAlignedBox<Vector3> AxisAlignedBox_xyz; |
27 | | - |
28 | | -template <class T> |
29 | | -AxisAlignedBox<T>::AxisAlignedBox() : _min(T::inf), _max(-T::inf) {} |
30 | | - |
31 | | -template <class T> |
32 | | -AxisAlignedBox<T>::AxisAlignedBox(const T &v) : _min(v), _max(v) {} |
33 | | - |
34 | | -template <class T> |
35 | | -AxisAlignedBox<T>::AxisAlignedBox(const T &v, const T &w) : _min(v), _max(v) { |
36 | | - include(w); |
37 | | -} |
38 | | - |
39 | | -template <class T> void AxisAlignedBox<T>::include(const T &v) { |
40 | | - _min = T::mini(_min, v); |
41 | | - _max = T::maxi(_max, v); |
42 | | -} |
43 | | - |
44 | | -template <class T> void AxisAlignedBox<T>::include(const AxisAlignedBox<T> &b) { |
45 | | - include(b._min); |
46 | | - include(b._max); |
| 4 | +namespace vrender |
| 5 | +{ |
| 6 | + class Vector2; |
| 7 | + class Vector3; |
| 8 | + |
| 9 | + template<class T> class AxisAlignedBox |
| 10 | + { |
| 11 | + public: |
| 12 | + AxisAlignedBox() ; |
| 13 | + AxisAlignedBox(const T& v) ; |
| 14 | + AxisAlignedBox(const T& v,const T& w) ; |
| 15 | + |
| 16 | + const T& mini() const { return _min ; } |
| 17 | + const T& maxi() const { return _max ; } |
| 18 | + |
| 19 | + void include(const T& v) ; |
| 20 | + void include(const AxisAlignedBox<T>& b) ; |
| 21 | + private: |
| 22 | + T _min ; |
| 23 | + T _max ; |
| 24 | + }; |
| 25 | + |
| 26 | + typedef AxisAlignedBox< Vector2 > AxisAlignedBox_xy ; |
| 27 | + typedef AxisAlignedBox< Vector3 > AxisAlignedBox_xyz ; |
| 28 | + |
| 29 | + template<class T> AxisAlignedBox<T>::AxisAlignedBox() |
| 30 | + : _min(T::inf), _max(-T::inf) |
| 31 | + { |
| 32 | + } |
| 33 | + |
| 34 | + template<class T> AxisAlignedBox<T>::AxisAlignedBox(const T& v) |
| 35 | + : _min(v), _max(v) |
| 36 | + { |
| 37 | + } |
| 38 | + |
| 39 | + template<class T> AxisAlignedBox<T>::AxisAlignedBox(const T& v,const T& w) |
| 40 | + : _min(v), _max(v) |
| 41 | + { |
| 42 | + include(w) ; |
| 43 | + } |
| 44 | + |
| 45 | + template<class T> void AxisAlignedBox<T>::include(const T& v) |
| 46 | + { |
| 47 | + _min = T::mini(_min,v) ; |
| 48 | + _max = T::maxi(_max,v) ; |
| 49 | + } |
| 50 | + |
| 51 | + template<class T> void AxisAlignedBox<T>::include(const AxisAlignedBox<T>& b) |
| 52 | + { |
| 53 | + include(b._min) ; |
| 54 | + include(b._max) ; |
| 55 | + } |
47 | 56 | } |
48 | | -} // namespace vrender |
49 | 57 | #endif |
0 commit comments