From 30672d91cb23d12cb40d285dba86798e1ef5e1a4 Mon Sep 17 00:00:00 2001 From: Hermann Kraus Date: Sat, 4 Aug 2012 02:10:14 +0200 Subject: [PATCH] Add function to enlarge bbox2d. --- include/mapnik/box2d.hpp | 2 ++ src/box2d.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/mapnik/box2d.hpp b/include/mapnik/box2d.hpp index 113a69378..29ffdec2b 100644 --- a/include/mapnik/box2d.hpp +++ b/include/mapnik/box2d.hpp @@ -96,6 +96,8 @@ public: box2d_type& operator*=(T); box2d_type& operator/=(T); T operator[](int index) const; + box2d_type operator +(T other); //enlarge box by given amount + box2d_type& operator +=(T other); //enlarge box by given amount // compute the bounding box of this one transformed box2d_type operator* (agg::trans_affine const& tr) const; diff --git a/src/box2d.cpp b/src/box2d.cpp index faa2ef4c9..5f9f32349 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -403,6 +403,22 @@ box2d& box2d::operator+=(box2d const& other) return *this; } +template +box2d box2d::operator+ (T other) +{ + return box2d(minx_ - other, miny_ - other, maxx_ + other, maxy_ + other); +} + +template +box2d& box2d::operator+= (T other) +{ + minx_ -= other; + miny_ -= other; + maxx_ += other; + maxy_ += other; + return *this; +} + template box2d& box2d::operator*=(T t)