Merge
authorAlpar Juttner <alpar@cs.elte.hu>
Tue, 02 Sep 2008 10:23:23 +0100
changeset 255914c5432be97
parent 251 a1ffc9099c25
parent 254 43500afd5cb0
child 256 c760d691fe3c
child 259 362415050b29
Merge
     1.1 --- a/lemon/bfs.h	Tue Sep 02 00:44:17 2008 +0200
     1.2 +++ b/lemon/bfs.h	Tue Sep 02 10:23:23 2008 +0100
     1.3 @@ -1262,6 +1262,11 @@
     1.4    /// class. It works with callback mechanism, the BfsVisit object calls
     1.5    /// the member functions of the \c Visitor class on every BFS event.
     1.6    ///
     1.7 +  /// This interface of the BFS algorithm should be used in special cases
     1.8 +  /// when extra actions have to be performed in connection with certain
     1.9 +  /// events of the BFS algorithm. Otherwise consider to use Bfs or bfs()
    1.10 +  /// instead.
    1.11 +  ///
    1.12    /// \tparam _Digraph The type of the digraph the algorithm runs on.
    1.13    /// The default value is
    1.14    /// \ref ListDigraph. The value of _Digraph is not used directly by
     2.1 --- a/lemon/dfs.h	Tue Sep 02 00:44:17 2008 +0200
     2.2 +++ b/lemon/dfs.h	Tue Sep 02 10:23:23 2008 +0100
     2.3 @@ -1209,6 +1209,11 @@
     2.4    /// class. It works with callback mechanism, the DfsVisit object calls
     2.5    /// the member functions of the \c Visitor class on every DFS event.
     2.6    ///
     2.7 +  /// This interface of the DFS algorithm should be used in special cases
     2.8 +  /// when extra actions have to be performed in connection with certain
     2.9 +  /// events of the DFS algorithm. Otherwise consider to use Dfs or dfs()
    2.10 +  /// instead.
    2.11 +  ///
    2.12    /// \tparam _Digraph The type of the digraph the algorithm runs on.
    2.13    /// The default value is
    2.14    /// \ref ListDigraph. The value of _Digraph is not used directly by
     3.1 --- a/lemon/dim2.h	Tue Sep 02 00:44:17 2008 +0200
     3.2 +++ b/lemon/dim2.h	Tue Sep 02 10:23:23 2008 +0100
     3.3 @@ -28,8 +28,7 @@
     3.4  /// The class \ref lemon::dim2::Point "dim2::Point" implements
     3.5  /// a two dimensional vector with the usual operations.
     3.6  ///
     3.7 -/// The class \ref lemon::dim2::BoundingBox "dim2::BoundingBox"
     3.8 -/// can be used to determine
     3.9 +/// The class \ref lemon::dim2::Box "dim2::Box" can be used to determine
    3.10  /// the rectangular bounding box of a set of
    3.11  /// \ref lemon::dim2::Point "dim2::Point"'s.
    3.12  
    3.13 @@ -44,7 +43,7 @@
    3.14    /// \addtogroup misc
    3.15    /// @{
    3.16  
    3.17 -  /// A simple two dimensional vector (plain vector) implementation
    3.18 +  /// Two dimensional vector (plain vector)
    3.19  
    3.20    /// A simple two dimensional vector (plain vector) implementation
    3.21    /// with the usual vector operations.
    3.22 @@ -221,7 +220,7 @@
    3.23    template<typename T>
    3.24    inline std::ostream& operator<<(std::ostream &os, const Point<T>& z)
    3.25    {
    3.26 -    os << "(" << z.x << ", " << z.y << ")";
    3.27 +    os << "(" << z.x << "," << z.y << ")";
    3.28      return os;
    3.29    }
    3.30  
    3.31 @@ -260,67 +259,67 @@
    3.32  
    3.33  
    3.34  
    3.35 -    /// A class to calculate or store the bounding box of plain vectors.
    3.36 +  /// Bounding box of plain vectors (\ref Point points).
    3.37  
    3.38 -    /// A class to calculate or store the bounding box of plain vectors.
    3.39 -    ///
    3.40 -    template<typename T>
    3.41 -    class BoundingBox {
    3.42 +  /// A class to calculate or store the bounding box of plain vectors
    3.43 +  /// (\ref Point points).
    3.44 +  template<typename T>
    3.45 +  class Box {
    3.46        Point<T> _bottom_left, _top_right;
    3.47        bool _empty;
    3.48      public:
    3.49  
    3.50 -      ///Default constructor: creates an empty bounding box
    3.51 -      BoundingBox() { _empty = true; }
    3.52 +      ///Default constructor: creates an empty box
    3.53 +      Box() { _empty = true; }
    3.54  
    3.55 -      ///Construct an instance from one point
    3.56 -      BoundingBox(Point<T> a) {
    3.57 +      ///Construct a box from one point
    3.58 +      Box(Point<T> a) {
    3.59          _bottom_left = _top_right = a;
    3.60          _empty = false;
    3.61        }
    3.62  
    3.63 -      ///Construct an instance from two points
    3.64 +      ///Construct a box from two points
    3.65  
    3.66 -      ///Construct an instance from two points.
    3.67 +      ///Construct a box from two points.
    3.68        ///\param a The bottom left corner.
    3.69        ///\param b The top right corner.
    3.70        ///\warning The coordinates of the bottom left corner must be no more
    3.71        ///than those of the top right one.
    3.72 -      BoundingBox(Point<T> a,Point<T> b)
    3.73 +      Box(Point<T> a,Point<T> b)
    3.74        {
    3.75          _bottom_left = a;
    3.76          _top_right = b;
    3.77          _empty = false;
    3.78        }
    3.79  
    3.80 -      ///Construct an instance from four numbers
    3.81 +      ///Construct a box from four numbers
    3.82  
    3.83 -      ///Construct an instance from four numbers.
    3.84 +      ///Construct a box from four numbers.
    3.85        ///\param l The left side of the box.
    3.86        ///\param b The bottom of the box.
    3.87        ///\param r The right side of the box.
    3.88        ///\param t The top of the box.
    3.89        ///\warning The left side must be no more than the right side and
    3.90        ///bottom must be no more than the top.
    3.91 -      BoundingBox(T l,T b,T r,T t)
    3.92 +      Box(T l,T b,T r,T t)
    3.93        {
    3.94          _bottom_left=Point<T>(l,b);
    3.95          _top_right=Point<T>(r,t);
    3.96          _empty = false;
    3.97        }
    3.98  
    3.99 -      ///Return \c true if the bounding box is empty.
   3.100 +      ///Return \c true if the box is empty.
   3.101  
   3.102 -      ///Return \c true if the bounding box is empty (i.e. return \c false
   3.103 +      ///Return \c true if the box is empty (i.e. return \c false
   3.104        ///if at least one point was added to the box or the coordinates of
   3.105        ///the box were set).
   3.106        ///
   3.107 -      ///The coordinates of an empty bounding box are not defined.
   3.108 +      ///The coordinates of an empty box are not defined.
   3.109        bool empty() const {
   3.110          return _empty;
   3.111        }
   3.112  
   3.113 -      ///Make the BoundingBox empty
   3.114 +      ///Make the box empty
   3.115        void clear() {
   3.116          _empty = true;
   3.117        }
   3.118 @@ -328,7 +327,7 @@
   3.119        ///Give back the bottom left corner of the box
   3.120  
   3.121        ///Give back the bottom left corner of the box.
   3.122 -      ///If the bounding box is empty, then the return value is not defined.
   3.123 +      ///If the box is empty, then the return value is not defined.
   3.124        Point<T> bottomLeft() const {
   3.125          return _bottom_left;
   3.126        }
   3.127 @@ -344,7 +343,7 @@
   3.128        ///Give back the top right corner of the box
   3.129  
   3.130        ///Give back the top right corner of the box.
   3.131 -      ///If the bounding box is empty, then the return value is not defined.
   3.132 +      ///If the box is empty, then the return value is not defined.
   3.133        Point<T> topRight() const {
   3.134          return _top_right;
   3.135        }
   3.136 @@ -360,7 +359,7 @@
   3.137        ///Give back the bottom right corner of the box
   3.138  
   3.139        ///Give back the bottom right corner of the box.
   3.140 -      ///If the bounding box is empty, then the return value is not defined.
   3.141 +      ///If the box is empty, then the return value is not defined.
   3.142        Point<T> bottomRight() const {
   3.143          return Point<T>(_top_right.x,_bottom_left.y);
   3.144        }
   3.145 @@ -377,7 +376,7 @@
   3.146        ///Give back the top left corner of the box
   3.147  
   3.148        ///Give back the top left corner of the box.
   3.149 -      ///If the bounding box is empty, then the return value is not defined.
   3.150 +      ///If the box is empty, then the return value is not defined.
   3.151        Point<T> topLeft() const {
   3.152          return Point<T>(_bottom_left.x,_top_right.y);
   3.153        }
   3.154 @@ -394,7 +393,7 @@
   3.155        ///Give back the bottom of the box
   3.156  
   3.157        ///Give back the bottom of the box.
   3.158 -      ///If the bounding box is empty, then the return value is not defined.
   3.159 +      ///If the box is empty, then the return value is not defined.
   3.160        T bottom() const {
   3.161          return _bottom_left.y;
   3.162        }
   3.163 @@ -410,7 +409,7 @@
   3.164        ///Give back the top of the box
   3.165  
   3.166        ///Give back the top of the box.
   3.167 -      ///If the bounding box is empty, then the return value is not defined.
   3.168 +      ///If the box is empty, then the return value is not defined.
   3.169        T top() const {
   3.170          return _top_right.y;
   3.171        }
   3.172 @@ -426,7 +425,7 @@
   3.173        ///Give back the left side of the box
   3.174  
   3.175        ///Give back the left side of the box.
   3.176 -      ///If the bounding box is empty, then the return value is not defined.
   3.177 +      ///If the box is empty, then the return value is not defined.
   3.178        T left() const {
   3.179          return _bottom_left.x;
   3.180        }
   3.181 @@ -442,7 +441,7 @@
   3.182        /// Give back the right side of the box
   3.183  
   3.184        /// Give back the right side of the box.
   3.185 -      ///If the bounding box is empty, then the return value is not defined.
   3.186 +      ///If the box is empty, then the return value is not defined.
   3.187        T right() const {
   3.188          return _top_right.x;
   3.189        }
   3.190 @@ -458,7 +457,7 @@
   3.191        ///Give back the height of the box
   3.192  
   3.193        ///Give back the height of the box.
   3.194 -      ///If the bounding box is empty, then the return value is not defined.
   3.195 +      ///If the box is empty, then the return value is not defined.
   3.196        T height() const {
   3.197          return _top_right.y-_bottom_left.y;
   3.198        }
   3.199 @@ -466,12 +465,12 @@
   3.200        ///Give back the width of the box
   3.201  
   3.202        ///Give back the width of the box.
   3.203 -      ///If the bounding box is empty, then the return value is not defined.
   3.204 +      ///If the box is empty, then the return value is not defined.
   3.205        T width() const {
   3.206          return _top_right.x-_bottom_left.x;
   3.207        }
   3.208  
   3.209 -      ///Checks whether a point is inside a bounding box
   3.210 +      ///Checks whether a point is inside the box
   3.211        bool inside(const Point<T>& u) const {
   3.212          if (_empty)
   3.213            return false;
   3.214 @@ -481,11 +480,11 @@
   3.215          }
   3.216        }
   3.217  
   3.218 -      ///Increments a bounding box with a point
   3.219 +      ///Increments the box with a point
   3.220  
   3.221 -      ///Increments a bounding box with a point.
   3.222 +      ///Increments the box with a point.
   3.223        ///
   3.224 -      BoundingBox& add(const Point<T>& u){
   3.225 +      Box& add(const Point<T>& u){
   3.226          if (_empty) {
   3.227            _bottom_left = _top_right = u;
   3.228            _empty = false;
   3.229 @@ -499,11 +498,11 @@
   3.230          return *this;
   3.231        }
   3.232  
   3.233 -      ///Increments a bounding box to contain another bounding box
   3.234 +      ///Increments the box to contain another box
   3.235  
   3.236 -      ///Increments a bounding box to contain another bounding box.
   3.237 +      ///Increments the box to contain another box.
   3.238        ///
   3.239 -      BoundingBox& add(const BoundingBox &u){
   3.240 +      Box& add(const Box &u){
   3.241          if ( !u.empty() ){
   3.242            add(u._bottom_left);
   3.243            add(u._top_right);
   3.244 @@ -511,12 +510,12 @@
   3.245          return *this;
   3.246        }
   3.247  
   3.248 -      ///Intersection of two bounding boxes
   3.249 +      ///Intersection of two boxes
   3.250  
   3.251 -      ///Intersection of two bounding boxes.
   3.252 +      ///Intersection of two boxes.
   3.253        ///
   3.254 -      BoundingBox operator&(const BoundingBox& u) const {
   3.255 -        BoundingBox b;
   3.256 +      Box operator&(const Box& u) const {
   3.257 +        Box b;
   3.258          if (_empty || u._empty) {
   3.259            b._empty = true;
   3.260          } else {
   3.261 @@ -530,9 +529,50 @@
   3.262          return b;
   3.263        }
   3.264  
   3.265 -    };//class Boundingbox
   3.266 +  };//class Box
   3.267  
   3.268  
   3.269 +  ///Read a box from a stream
   3.270 +
   3.271 +  ///Read a box from a stream.
   3.272 +  ///\relates Box
   3.273 +  template<typename T>
   3.274 +  inline std::istream& operator>>(std::istream &is, Box<T>& b) {
   3.275 +    char c;
   3.276 +    Point<T> p;
   3.277 +    if (is >> c) {
   3.278 +      if (c != '(') is.putback(c);
   3.279 +    } else {
   3.280 +      is.clear();
   3.281 +    }
   3.282 +    if (!(is >> p)) return is;
   3.283 +    b.bottomLeft(p);
   3.284 +    if (is >> c) {
   3.285 +      if (c != ',') is.putback(c);
   3.286 +    } else {
   3.287 +      is.clear();
   3.288 +    }
   3.289 +    if (!(is >> p)) return is;
   3.290 +    b.topRight(p);
   3.291 +    if (is >> c) {
   3.292 +      if (c != ')') is.putback(c);
   3.293 +    } else {
   3.294 +      is.clear();
   3.295 +    }
   3.296 +    return is;
   3.297 +  }
   3.298 +
   3.299 +  ///Write a box to a stream
   3.300 +
   3.301 +  ///Write a box to a stream.
   3.302 +  ///\relates Box
   3.303 +  template<typename T>
   3.304 +  inline std::ostream& operator<<(std::ostream &os, const Box<T>& b)
   3.305 +  {
   3.306 +    os << "(" << b.bottomLeft() << "," << b.topRight() << ")";
   3.307 +    return os;
   3.308 +  }
   3.309 +
   3.310    ///Map of x-coordinates of a \ref Point "Point"-map
   3.311  
   3.312    ///\ingroup maps
     4.1 --- a/lemon/graph_to_eps.h	Tue Sep 02 00:44:17 2008 +0200
     4.2 +++ b/lemon/graph_to_eps.h	Tue Sep 02 10:23:23 2008 +0100
     4.3 @@ -725,10 +725,10 @@
     4.4  
     4.5      double diag_len = 1;
     4.6      if(!(_absoluteNodeSizes&&_absoluteArcWidths)) {
     4.7 -      dim2::BoundingBox<double> bb;
     4.8 +      dim2::Box<double> bb;
     4.9        for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]);
    4.10        if (bb.empty()) {
    4.11 -        bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
    4.12 +        bb = dim2::Box<double>(dim2::Point<double>(0,0));
    4.13        }
    4.14        diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare());
    4.15        if(diag_len<EPSILON) diag_len = 1;
    4.16 @@ -736,7 +736,7 @@
    4.17        if(!_absoluteArcWidths) _arcWidthScale*=diag_len;
    4.18      }
    4.19  
    4.20 -    dim2::BoundingBox<double> bb;
    4.21 +    dim2::Box<double> bb;
    4.22      for(NodeIt n(g);n!=INVALID;++n) {
    4.23        double ns=_nodeSizes[n]*_nodeScale;
    4.24        dim2::Point<double> p(ns,ns);
    4.25 @@ -758,7 +758,7 @@
    4.26        }
    4.27      }
    4.28      if (bb.empty()) {
    4.29 -      bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
    4.30 +      bb = dim2::Box<double>(dim2::Point<double>(0,0));
    4.31      }
    4.32  
    4.33      if(_scaleToA4)
     5.1 --- a/test/dim_test.cc	Tue Sep 02 00:44:17 2008 +0200
     5.2 +++ b/test/dim_test.cc	Tue Sep 02 10:23:23 2008 +0100
     5.3 @@ -50,38 +50,38 @@
     5.4    p = b/l;
     5.5    check(p.x==1 && p.y==2, "Wrong dim2::Point division by a scalar.");
     5.6  
     5.7 -  typedef dim2::BoundingBox<int> BB;
     5.8 -  BB box1;
     5.9 -  check(box1.empty(), "Wrong empty() in dim2::BoundingBox.");
    5.10 +  typedef dim2::Box<int> Box;
    5.11 +  Box box1;
    5.12 +  check(box1.empty(), "Wrong empty() in dim2::Box.");
    5.13  
    5.14    box1.add(a);
    5.15 -  check(!box1.empty(), "Wrong empty() in dim2::BoundingBox.");
    5.16 +  check(!box1.empty(), "Wrong empty() in dim2::Box.");
    5.17    box1.add(b);
    5.18  
    5.19    check(box1.left()==1 && box1.bottom()==2 &&
    5.20          box1.right()==3 && box1.top()==4,
    5.21 -        "Wrong addition of points to dim2::BoundingBox.");
    5.22 +        "Wrong addition of points to dim2::Box.");
    5.23  
    5.24 -  check(box1.inside(Point(2,3)), "Wrong inside() in dim2::BoundingBox.");
    5.25 -  check(box1.inside(Point(1,3)), "Wrong inside() in dim2::BoundingBox.");
    5.26 -  check(!box1.inside(Point(0,3)), "Wrong inside() in dim2::BoundingBox.");
    5.27 +  check(box1.inside(Point(2,3)), "Wrong inside() in dim2::Box.");
    5.28 +  check(box1.inside(Point(1,3)), "Wrong inside() in dim2::Box.");
    5.29 +  check(!box1.inside(Point(0,3)), "Wrong inside() in dim2::Box.");
    5.30  
    5.31 -  BB box2(Point(2,2));
    5.32 -  check(!box2.empty(), "Wrong empty() in dim2::BoundingBox.");
    5.33 -  
    5.34 +  Box box2(Point(2,2));
    5.35 +  check(!box2.empty(), "Wrong empty() in dim2::Box.");
    5.36 +
    5.37    box2.bottomLeft(Point(2,0));
    5.38    box2.topRight(Point(5,3));
    5.39 -  BB box3 = box1 & box2;
    5.40 +  Box box3 = box1 & box2;
    5.41    check(!box3.empty() &&
    5.42 -        box3.left()==2 && box3.bottom()==2 && 
    5.43 +        box3.left()==2 && box3.bottom()==2 &&
    5.44          box3.right()==3 && box3.top()==3,
    5.45 -        "Wrong intersection of two dim2::BoundingBox objects.");
    5.46 -  
    5.47 +        "Wrong intersection of two dim2::Box objects.");
    5.48 +
    5.49    box1.add(box2);
    5.50    check(!box1.empty() &&
    5.51          box1.left()==1 && box1.bottom()==0 &&
    5.52          box1.right()==5 && box1.top()==4,
    5.53 -        "Wrong addition of two dim2::BoundingBox objects.");
    5.54 +        "Wrong addition of two dim2::Box objects.");
    5.55  
    5.56    return 0;
    5.57  }