diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/freestyle/intern/geometry/BBox.h | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/freestyle/intern/geometry/BBox.h')
-rw-r--r-- | source/blender/freestyle/intern/geometry/BBox.h | 222 |
1 files changed, 108 insertions, 114 deletions
diff --git a/source/blender/freestyle/intern/geometry/BBox.h b/source/blender/freestyle/intern/geometry/BBox.h index 741d4e6715e..7350fabbc13 100644 --- a/source/blender/freestyle/intern/geometry/BBox.h +++ b/source/blender/freestyle/intern/geometry/BBox.h @@ -28,133 +28,127 @@ #include "BLI_utildefines.h" #ifdef WITH_CXX_GUARDEDALLOC -#include "MEM_guardedalloc.h" +# include "MEM_guardedalloc.h" #endif namespace Freestyle { -template <class Point> -class BBox -{ -public: - inline BBox() - { - _empty = true; - } - - template <class T> - inline BBox(const T& min_in, const T& max_in) : _min(min_in), _max(max_in) - { - _empty = false; - } - - template <class T> - inline BBox(const BBox<T>& b) : _min(b.getMin()), _max(b.getMax()) - { - _empty = false; - } - - template <class T> - inline void extendToContain(const T& p) - { - if (_empty) { - _min = p; - _max = p; - _empty = false; - return; - } - for (unsigned int i = 0; i < Point::dim(); i++) { - if (p[i] < _min[i]) - _min[i] = p[i]; - else if (p[i] > _max[i]) - _max[i] = p[i]; - } - _empty = false; - } - - inline void clear() - { - _empty = true; - } - - inline bool empty() const - { - return _empty; - } - - inline const Point& getMin() const - { - return _min; - } - - inline const Point& getMax() const - { - return _max; - } - - inline BBox<Point>& operator=(const BBox<Point>& b) - { - BLI_assert(!b.empty()); - _min = b.getMin(); - _max = b.getMax(); - _empty = false; - return *this; - } - - inline BBox<Point>& operator+=(const BBox<Point>& b) - { - BLI_assert(!b.empty()); - if (_empty) { - _min = b.getMin(); - _max = b.getMax(); - _empty = false; - } - else { - for (unsigned int i = 0; i < Point::dim(); i++) { - if (b.getMin()[i] < _min[i]) - _min[i] = b.getMin()[i]; - if (b.getMax()[i] > _max[i]) - _max[i] = b.getMax()[i]; - } - } - return *this; - } - - inline bool inside(const Point& p) - { - if (empty()) - return false; - for (unsigned int i = 0; i < Point::dim(); i++) { - if ((_min[i]>p[i]) || (_max[i]<p[i])) - return false; - } - return true; - } - -private: - Point _min; - Point _max; - bool _empty; +template<class Point> class BBox { + public: + inline BBox() + { + _empty = true; + } + + template<class T> inline BBox(const T &min_in, const T &max_in) : _min(min_in), _max(max_in) + { + _empty = false; + } + + template<class T> inline BBox(const BBox<T> &b) : _min(b.getMin()), _max(b.getMax()) + { + _empty = false; + } + + template<class T> inline void extendToContain(const T &p) + { + if (_empty) { + _min = p; + _max = p; + _empty = false; + return; + } + for (unsigned int i = 0; i < Point::dim(); i++) { + if (p[i] < _min[i]) + _min[i] = p[i]; + else if (p[i] > _max[i]) + _max[i] = p[i]; + } + _empty = false; + } + + inline void clear() + { + _empty = true; + } + + inline bool empty() const + { + return _empty; + } + + inline const Point &getMin() const + { + return _min; + } + + inline const Point &getMax() const + { + return _max; + } + + inline BBox<Point> &operator=(const BBox<Point> &b) + { + BLI_assert(!b.empty()); + _min = b.getMin(); + _max = b.getMax(); + _empty = false; + return *this; + } + + inline BBox<Point> &operator+=(const BBox<Point> &b) + { + BLI_assert(!b.empty()); + if (_empty) { + _min = b.getMin(); + _max = b.getMax(); + _empty = false; + } + else { + for (unsigned int i = 0; i < Point::dim(); i++) { + if (b.getMin()[i] < _min[i]) + _min[i] = b.getMin()[i]; + if (b.getMax()[i] > _max[i]) + _max[i] = b.getMax()[i]; + } + } + return *this; + } + + inline bool inside(const Point &p) + { + if (empty()) + return false; + for (unsigned int i = 0; i < Point::dim(); i++) { + if ((_min[i] > p[i]) || (_max[i] < p[i])) + return false; + } + return true; + } + + private: + Point _min; + Point _max; + bool _empty; #ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BBox") + MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BBox") #endif }; -template <class Point> -BBox<Point>& operator+(const BBox<Point> &b1, const BBox<Point> &b2) +template<class Point> BBox<Point> &operator+(const BBox<Point> &b1, const BBox<Point> &b2) { - Point new_min; - Point new_max; + Point new_min; + Point new_max; - for (unsigned int i = 0; i < Point::dim(); i++) { - new_min[i] = b1.getMin()[i] < b2.getMin()[i] ? b1.getMin()[i] : b2.getMin()[i]; - new_max[i] = b1.getMax()[i] > b2.getMax()[i] ? b1.getMax()[i] : b2.getMax()[i]; - } + for (unsigned int i = 0; i < Point::dim(); i++) { + new_min[i] = b1.getMin()[i] < b2.getMin()[i] ? b1.getMin()[i] : b2.getMin()[i]; + new_max[i] = b1.getMax()[i] > b2.getMax()[i] ? b1.getMax()[i] : b2.getMax()[i]; + } - return BBox<Point>(new_min, new_max); + return BBox<Point>(new_min, new_max); } } /* namespace Freestyle */ -#endif // __BBOX_H__ +#endif // __BBOX_H__ |