summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6a23d0c)
raw | patch | inline | side by side (parent: 6a23d0c)
author | mental <mental@users.sourceforge.net> | |
Sun, 4 Mar 2007 19:06:46 +0000 (19:06 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Sun, 4 Mar 2007 19:06:46 +0000 (19:06 +0000) |
src/libnr/nr-rect.cpp | patch | blob | history | |
src/libnr/nr-rect.h | patch | blob | history |
diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp
index c4e684f1f23f6ec0929519e6d8b07a8f1f62519a..c3d23a6198e251db90aa3bc0510d5bf9d8ad8b9d 100644 (file)
--- a/src/libnr/nr-rect.cpp
+++ b/src/libnr/nr-rect.cpp
}
}
-/** returns the smallest rectangle containing both rectangles */
Maybe<Rect> Rect::union_bounds(Maybe<Rect> const &a, Maybe<Rect> const &b) {
- if ( a == Nothing() ) {
+ if (a) {
return b;
- } else if ( b == Nothing() ) {
+ } else if (b) {
return a;
} else {
- Rect const &ra=a.assume();
- Rect const &rb=b.assume();
- Rect r;
- for ( int i=0; i < 2 ; i++ ) {
- r._min[i] = MIN(ra._min[i], rb._min[i]);
- r._max[i] = MAX(ra._max[i], rb._max[i]);
- }
- return r;
+ return union_bounds(*a, *b);
+ }
+}
+
+/** returns the smallest rectangle containing both rectangles */
+Rect Rect::union_bounds(Rect const &a, Rect const &b) {
+ Rect r;
+ for ( int i=0 ; i < 2 ; i++ ) {
+ r._min[i] = MIN(a._min[i], b._min[i]);
+ r._max[i] = MAX(a._max[i], b._max[i]);
}
+ return r;
}
} // namespace NR
diff --git a/src/libnr/nr-rect.h b/src/libnr/nr-rect.h
index 91431d0e6f21a85ebc0b8d5fc0b28fda3ea0b41d..b6918c4931b77e8730b3f4c33add4b79e6d8800d 100644 (file)
--- a/src/libnr/nr-rect.h
+++ b/src/libnr/nr-rect.h
/** Returns the smallest rectangle that encloses both rectangles. */
static Maybe<Rect> union_bounds(Maybe<Rect> const &a, Maybe<Rect> const &b);
+ static Rect union_bounds(Rect const &a, Rect const &b);
/** Scales the rect by s, with origin at 0, 0 */
inline Rect operator*(double const s) const {