vector_type min(const vector_type& _rhs) and vector_type max(const vector_type& _rhs) are declared const now. (Thanks to Vladimir Chalupecky for the hint)

minimize and maximize return vector_type& (reference) instead of vector_type (value) to allow chaining p.minimize(p1).minimize(p2). (Thanks to Vladimir Chalupecky for the hint)



git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@822 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Jan Möbius
2013-04-02 12:39:47 +00:00
parent a533c6e865
commit 3d72b7dbc1
2 changed files with 11 additions and 5 deletions

View File

@@ -535,7 +535,7 @@ public:
/// minimize values: same as *this = min(*this, _rhs), but faster
inline vector_type minimize(const vector_type& _rhs) {
inline vector_type& minimize(const vector_type& _rhs) {
#define expr(i) if (_rhs[i] < Base::values_[i]) Base::values_[i] = _rhs[i];
unroll(expr);
#undef expr
@@ -552,7 +552,7 @@ public:
}
/// maximize values: same as *this = max(*this, _rhs), but faster
inline vector_type maximize(const vector_type& _rhs) {
inline vector_type& maximize(const vector_type& _rhs) {
#define expr(i) if (_rhs[i] > Base::values_[i]) Base::values_[i] = _rhs[i];
unroll(expr);
#undef expr
@@ -569,12 +569,12 @@ public:
}
/// component-wise min
inline vector_type min(const vector_type& _rhs) {
inline vector_type min(const vector_type& _rhs) const {
return vector_type(*this).minimize(_rhs);
}
/// component-wise max
inline vector_type max(const vector_type& _rhs) {
inline vector_type max(const vector_type& _rhs) const {
return vector_type(*this).maximize(_rhs);
}