Add function to enlarge bbox2d.

This commit is contained in:
Hermann Kraus 2012-08-04 02:10:14 +02:00
parent 5e259bf064
commit 30672d91cb
2 changed files with 18 additions and 0 deletions

View file

@ -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;

View file

@ -403,6 +403,22 @@ box2d<T>& box2d<T>::operator+=(box2d<T> const& other)
return *this;
}
template <typename T>
box2d<T> box2d<T>::operator+ (T other)
{
return box2d<T>(minx_ - other, miny_ - other, maxx_ + other, maxy_ + other);
}
template <typename T>
box2d<T>& box2d<T>::operator+= (T other)
{
minx_ -= other;
miny_ -= other;
maxx_ += other;
maxy_ += other;
return *this;
}
template <typename T>
box2d<T>& box2d<T>::operator*=(T t)