# HG changeset patch # User athos # Date 1080236325 0 # Node ID 0e02be2ca43c326d1e01a7eb043c84bcef196240 # Parent a85fd87460e35d9db69201ba16b3730747aa106f Betettem 1 file-ba a boundingbox-ot ?s az xy-t + egy?b apr? m?dos?t?sok. diff -r a85fd87460e3 -r 0e02be2ca43c src/work/athos/xy/boundingbox.cc --- a/src/work/athos/xy/boundingbox.cc Thu Mar 25 09:42:59 2004 +0000 +++ b/src/work/athos/xy/boundingbox.cc Thu Mar 25 17:38:45 2004 +0000 @@ -1,4 +1,4 @@ -#include +#include #include using namespace std; diff -r a85fd87460e3 -r 0e02be2ca43c src/work/athos/xy/boundingbox.h --- a/src/work/athos/xy/boundingbox.h Thu Mar 25 09:42:59 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -// -*- c++ -*- -#ifndef HUGO_BOUNDINGBOX_H -#define HUGO_BOUNDINGBOX_H - - -#include - -namespace hugo { - - /** \brief - Implementation of a bounding box of plainvectors. - - */ - template - class BoundingBox { - xy bottomleft, topright; - bool _empty; - public: - - ///Default constructor: an empty bounding box - BoundingBox() { _empty = true; } - - ///Constructing the instance from one point - BoundingBox(xy a) { bottomleft=topright=a; _empty = false; } - - ///Is there any point added - bool empty() const { - return _empty; - } - - ///Gives back the bottom left corner (if the bounding box is empty, then the return value is not defined) - xy bottomLeft() const { - return bottomleft; - }; - - ///Gives back the top right corner (if the bounding box is empty, then the return value is not defined) - xy topRight() const { - return topright; - }; - - ///Checks whether a point is inside a bounding box - bool inside(const xy& u){ - if (_empty) - return false; - else{ - return ((u.x-bottomleft.x)*(topright.x-u.x) >= 0 && - (u.y-bottomleft.y)*(topright.y-u.y) >= 0 ); - } - } - - ///Increments a bounding box with a point - BoundingBox& operator +=(const xy& u){ - if (_empty){ - bottomleft=topright=u; - _empty = false; - } - else{ - if (bottomleft.x > u.x) bottomleft.x = u.x; - if (bottomleft.y > u.y) bottomleft.y = u.y; - if (topright.x < u.x) topright.x = u.x; - if (topright.y < u.y) topright.y = u.y; - } - return *this; - }; - - ///Sums a bounding box and a point - BoundingBox operator +(const xy& u){ - BoundingBox b = *this; - return b += u; - }; - - ///Increments a bounding box with an other bounding box - BoundingBox& operator +=(const BoundingBox &u){ - if ( !u.empty() ){ - *this += u.bottomLeft(); - *this += u.topRight(); - } - return *this; - }; - - ///Sums two bounding boxes - BoundingBox operator +(const BoundingBox& u){ - BoundingBox b = *this; - return b += u; - }; - - };//class BoundingBox - - -} //namespace hugo - -#endif //HUGO_BOUNDINGBOX_H diff -r a85fd87460e3 -r 0e02be2ca43c src/work/athos/xy/xy.h --- a/src/work/athos/xy/xy.h Thu Mar 25 09:42:59 2004 +0000 +++ b/src/work/athos/xy/xy.h Thu Mar 25 17:38:45 2004 +0000 @@ -117,6 +117,89 @@ return os; } + + /** \brief + Implementation of a bounding box of plainvectors. + + */ + template + class BoundingBox { + xy bottom_left, top_right; + bool _empty; + public: + + ///Default constructor: an empty bounding box + BoundingBox() { _empty = true; } + + ///Constructing the instance from one point + BoundingBox(xy a) { bottom_left=top_right=a; _empty = false; } + + ///Is there any point added + bool empty() const { + return _empty; + } + + ///Gives back the bottom left corner (if the bounding box is empty, then the return value is not defined) + xy bottomLeft() const { + return bottom_left; + }; + + ///Gives back the top right corner (if the bounding box is empty, then the return value is not defined) + xy topRight() const { + return top_right; + }; + + ///Checks whether a point is inside a bounding box + bool inside(const xy& u){ + if (_empty) + return false; + else{ + return ((u.x-bottom_left.x)*(top_right.x-u.x) >= 0 && + (u.y-bottom_left.y)*(top_right.y-u.y) >= 0 ); + } + } + + ///Increments a bounding box with a point + BoundingBox& operator +=(const xy& u){ + if (_empty){ + bottom_left=top_right=u; + _empty = false; + } + else{ + if (bottom_left.x > u.x) bottom_left.x = u.x; + if (bottom_left.y > u.y) bottom_left.y = u.y; + if (top_right.x < u.x) top_right.x = u.x; + if (top_right.y < u.y) top_right.y = u.y; + } + return *this; + }; + + ///Sums a bounding box and a point + BoundingBox operator +(const xy& u){ + BoundingBox b = *this; + return b += u; + }; + + ///Increments a bounding box with an other bounding box + BoundingBox& operator +=(const BoundingBox &u){ + if ( !u.empty() ){ + *this += u.bottomLeft(); + *this += u.topRight(); + } + return *this; + }; + + ///Sums two bounding boxes + BoundingBox operator +(const BoundingBox& u){ + BoundingBox b = *this; + return b += u; + }; + + };//class Boundingbox + + + + } //namespace hugo #endif //HUGO_XY_H