Betettem 1 file-ba a boundingbox-ot ?s az xy-t + egy?b apr? m?dos?t?sok.
1.1 --- a/src/work/athos/xy/boundingbox.cc Thu Mar 25 09:42:59 2004 +0000
1.2 +++ b/src/work/athos/xy/boundingbox.cc Thu Mar 25 17:38:45 2004 +0000
1.3 @@ -1,4 +1,4 @@
1.4 -#include <boundingbox.h>
1.5 +#include <xy.h>
1.6
1.7 #include <iostream>
1.8 using namespace std;
2.1 --- a/src/work/athos/xy/boundingbox.h Thu Mar 25 09:42:59 2004 +0000
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,92 +0,0 @@
2.4 -// -*- c++ -*-
2.5 -#ifndef HUGO_BOUNDINGBOX_H
2.6 -#define HUGO_BOUNDINGBOX_H
2.7 -
2.8 -
2.9 -#include <xy.h>
2.10 -
2.11 -namespace hugo {
2.12 -
2.13 - /** \brief
2.14 - Implementation of a bounding box of plainvectors.
2.15 -
2.16 - */
2.17 - template<typename T>
2.18 - class BoundingBox {
2.19 - xy<T> bottomleft, topright;
2.20 - bool _empty;
2.21 - public:
2.22 -
2.23 - ///Default constructor: an empty bounding box
2.24 - BoundingBox() { _empty = true; }
2.25 -
2.26 - ///Constructing the instance from one point
2.27 - BoundingBox(xy<T> a) { bottomleft=topright=a; _empty = false; }
2.28 -
2.29 - ///Is there any point added
2.30 - bool empty() const {
2.31 - return _empty;
2.32 - }
2.33 -
2.34 - ///Gives back the bottom left corner (if the bounding box is empty, then the return value is not defined)
2.35 - xy<T> bottomLeft() const {
2.36 - return bottomleft;
2.37 - };
2.38 -
2.39 - ///Gives back the top right corner (if the bounding box is empty, then the return value is not defined)
2.40 - xy<T> topRight() const {
2.41 - return topright;
2.42 - };
2.43 -
2.44 - ///Checks whether a point is inside a bounding box
2.45 - bool inside(const xy<T>& u){
2.46 - if (_empty)
2.47 - return false;
2.48 - else{
2.49 - return ((u.x-bottomleft.x)*(topright.x-u.x) >= 0 &&
2.50 - (u.y-bottomleft.y)*(topright.y-u.y) >= 0 );
2.51 - }
2.52 - }
2.53 -
2.54 - ///Increments a bounding box with a point
2.55 - BoundingBox& operator +=(const xy<T>& u){
2.56 - if (_empty){
2.57 - bottomleft=topright=u;
2.58 - _empty = false;
2.59 - }
2.60 - else{
2.61 - if (bottomleft.x > u.x) bottomleft.x = u.x;
2.62 - if (bottomleft.y > u.y) bottomleft.y = u.y;
2.63 - if (topright.x < u.x) topright.x = u.x;
2.64 - if (topright.y < u.y) topright.y = u.y;
2.65 - }
2.66 - return *this;
2.67 - };
2.68 -
2.69 - ///Sums a bounding box and a point
2.70 - BoundingBox operator +(const xy<T>& u){
2.71 - BoundingBox b = *this;
2.72 - return b += u;
2.73 - };
2.74 -
2.75 - ///Increments a bounding box with an other bounding box
2.76 - BoundingBox& operator +=(const BoundingBox &u){
2.77 - if ( !u.empty() ){
2.78 - *this += u.bottomLeft();
2.79 - *this += u.topRight();
2.80 - }
2.81 - return *this;
2.82 - };
2.83 -
2.84 - ///Sums two bounding boxes
2.85 - BoundingBox operator +(const BoundingBox& u){
2.86 - BoundingBox b = *this;
2.87 - return b += u;
2.88 - };
2.89 -
2.90 - };//class BoundingBox
2.91 -
2.92 -
2.93 -} //namespace hugo
2.94 -
2.95 -#endif //HUGO_BOUNDINGBOX_H
3.1 --- a/src/work/athos/xy/xy.h Thu Mar 25 09:42:59 2004 +0000
3.2 +++ b/src/work/athos/xy/xy.h Thu Mar 25 17:38:45 2004 +0000
3.3 @@ -117,6 +117,89 @@
3.4 return os;
3.5 }
3.6
3.7 +
3.8 + /** \brief
3.9 + Implementation of a bounding box of plainvectors.
3.10 +
3.11 + */
3.12 + template<typename T>
3.13 + class BoundingBox {
3.14 + xy<T> bottom_left, top_right;
3.15 + bool _empty;
3.16 + public:
3.17 +
3.18 + ///Default constructor: an empty bounding box
3.19 + BoundingBox() { _empty = true; }
3.20 +
3.21 + ///Constructing the instance from one point
3.22 + BoundingBox(xy<T> a) { bottom_left=top_right=a; _empty = false; }
3.23 +
3.24 + ///Is there any point added
3.25 + bool empty() const {
3.26 + return _empty;
3.27 + }
3.28 +
3.29 + ///Gives back the bottom left corner (if the bounding box is empty, then the return value is not defined)
3.30 + xy<T> bottomLeft() const {
3.31 + return bottom_left;
3.32 + };
3.33 +
3.34 + ///Gives back the top right corner (if the bounding box is empty, then the return value is not defined)
3.35 + xy<T> topRight() const {
3.36 + return top_right;
3.37 + };
3.38 +
3.39 + ///Checks whether a point is inside a bounding box
3.40 + bool inside(const xy<T>& u){
3.41 + if (_empty)
3.42 + return false;
3.43 + else{
3.44 + return ((u.x-bottom_left.x)*(top_right.x-u.x) >= 0 &&
3.45 + (u.y-bottom_left.y)*(top_right.y-u.y) >= 0 );
3.46 + }
3.47 + }
3.48 +
3.49 + ///Increments a bounding box with a point
3.50 + BoundingBox& operator +=(const xy<T>& u){
3.51 + if (_empty){
3.52 + bottom_left=top_right=u;
3.53 + _empty = false;
3.54 + }
3.55 + else{
3.56 + if (bottom_left.x > u.x) bottom_left.x = u.x;
3.57 + if (bottom_left.y > u.y) bottom_left.y = u.y;
3.58 + if (top_right.x < u.x) top_right.x = u.x;
3.59 + if (top_right.y < u.y) top_right.y = u.y;
3.60 + }
3.61 + return *this;
3.62 + };
3.63 +
3.64 + ///Sums a bounding box and a point
3.65 + BoundingBox operator +(const xy<T>& u){
3.66 + BoundingBox b = *this;
3.67 + return b += u;
3.68 + };
3.69 +
3.70 + ///Increments a bounding box with an other bounding box
3.71 + BoundingBox& operator +=(const BoundingBox &u){
3.72 + if ( !u.empty() ){
3.73 + *this += u.bottomLeft();
3.74 + *this += u.topRight();
3.75 + }
3.76 + return *this;
3.77 + };
3.78 +
3.79 + ///Sums two bounding boxes
3.80 + BoundingBox operator +(const BoundingBox& u){
3.81 + BoundingBox b = *this;
3.82 + return b += u;
3.83 + };
3.84 +
3.85 + };//class Boundingbox
3.86 +
3.87 +
3.88 +
3.89 +
3.90 } //namespace hugo
3.91
3.92 #endif //HUGO_XY_H