1.1 --- a/lemon/xy.h Tue Jul 26 13:15:13 2005 +0000
1.2 +++ b/lemon/xy.h Tue Jul 26 14:31:29 2005 +0000
1.3 @@ -306,7 +306,7 @@
1.4 }
1.5
1.6 ///Increments a bounding box with a point
1.7 - BoundingBox& operator +=(const xy<T>& u){
1.8 + BoundingBox& add(const xy<T>& u){
1.9 if (_empty){
1.10 bottom_left=top_right=u;
1.11 _empty = false;
1.12 @@ -320,17 +320,17 @@
1.13 return *this;
1.14 }
1.15
1.16 - ///Sums a bounding box and a point
1.17 - BoundingBox operator +(const xy<T>& u){
1.18 - BoundingBox b = *this;
1.19 - return b += u;
1.20 - }
1.21 +// ///Sums a bounding box and a point
1.22 +// BoundingBox operator +(const xy<T>& u){
1.23 +// BoundingBox b = *this;
1.24 +// return b += u;
1.25 +// }
1.26
1.27 ///Increments a bounding box with an other bounding box
1.28 - BoundingBox& operator +=(const BoundingBox &u){
1.29 + BoundingBox& add(const BoundingBox &u){
1.30 if ( !u.empty() ){
1.31 - *this += u.bottomLeft();
1.32 - *this += u.topRight();
1.33 + this->add(u.bottomLeft());
1.34 + this->add(u.topRight());
1.35 }
1.36 return *this;
1.37 }
1.38 @@ -338,7 +338,20 @@
1.39 ///Sums two bounding boxes
1.40 BoundingBox operator +(const BoundingBox& u){
1.41 BoundingBox b = *this;
1.42 - return b += u;
1.43 + return b.add(u);
1.44 + }
1.45 +
1.46 +
1.47 + ///Intersection of two bounding boxes
1.48 + BoundingBox operator &(const BoundingBox& u){
1.49 + BoundingBox b;
1.50 + b.bottom_left.x=std::max(this->bottom_left.x,u.bottom_left.x);
1.51 + b.bottom_left.y=std::max(this->bottom_left.y,u.bottom_left.y);
1.52 + b.top_right.x=std::min(this->top_right.x,u.top_right.x);
1.53 + b.top_right.y=std::min(this->top_right.y,u.top_right.y);
1.54 + b._empty = this->_empty || u._empty ||
1.55 + b.bottom_left.x>top_right.x && b.bottom_left.y>top_right.y;
1.56 + return b;
1.57 }
1.58
1.59 };//class Boundingbox