diff options
| author | Ted Gould <ted@gould.cx> | 2008-10-11 15:16:23 +0000 |
|---|---|---|
| committer | Ted Gould <ted@canonical.com> | 2008-10-11 15:16:23 +0000 |
| commit | 2f5eb047d9e05be5e68549ef6b75070d2faa7d2f (patch) | |
| tree | ca2e94164b6d7aaebfc17196ca46bfc825a7665a /src/2geom/rect.h | |
| parent | Merge from trunk. (diff) | |
| download | inkscape-2f5eb047d9e05be5e68549ef6b75070d2faa7d2f.tar.gz inkscape-2f5eb047d9e05be5e68549ef6b75070d2faa7d2f.zip | |
Merging from trunk
(bzr r6884)
Diffstat (limited to 'src/2geom/rect.h')
| -rw-r--r-- | src/2geom/rect.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/2geom/rect.h b/src/2geom/rect.h index f8ac7a2f7..ee1b0d764 100644 --- a/src/2geom/rect.h +++ b/src/2geom/rect.h @@ -140,6 +140,18 @@ inline Rect unify(Rect const & a, Rect const & b) { return Rect(unify(a[X], b[X]), unify(a[Y], b[Y])); } +/** Returns the smallest rectangle that encloses both rectangles. + * An empty argument is assumed to be an empty rectangle */ +inline boost::optional<Rect> unify(boost::optional<Rect> const & a, boost::optional<Rect> const & b) { + if (!a) { + return b; + } else if (!b) { + return a; + } else { + return unify(*a, *b); + } +} + inline Rect union_list(std::vector<Rect> const &r) { if(r.empty()) return Rect(Interval(0,0), Interval(0,0)); Rect ret = r[0]; |
