diff options
| author | MenTaLguY <mental@rydia.net> | 2007-03-04 19:06:46 +0000 |
|---|---|---|
| committer | mental <mental@users.sourceforge.net> | 2007-03-04 19:06:46 +0000 |
| commit | 72289096ed747e793ca5a01200560a0ba6decb0e (patch) | |
| tree | 9afe77aeaa91058fbde951b4199a771f4d086929 /src/libnr/nr-rect.cpp | |
| parent | communicate bbox type via flags for now (diff) | |
| download | inkscape-72289096ed747e793ca5a01200560a0ba6decb0e.tar.gz inkscape-72289096ed747e793ca5a01200560a0ba6decb0e.zip | |
return plain rect if both union arguments are also plain rects
(bzr r2540)
Diffstat (limited to 'src/libnr/nr-rect.cpp')
| -rw-r--r-- | src/libnr/nr-rect.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp index c4e684f1f..c3d23a619 100644 --- a/src/libnr/nr-rect.cpp +++ b/src/libnr/nr-rect.cpp @@ -278,22 +278,24 @@ Maybe<Rect> Rect::intersection(Maybe<Rect> const &a, Maybe<Rect> const &b) { } } -/** 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 |
