1.1 --- a/lemon/dim2.h Wed Aug 27 10:50:04 2008 +0200
1.2 +++ b/lemon/dim2.h Sat Aug 30 22:19:43 2008 +0200
1.3 @@ -28,8 +28,7 @@
1.4 /// The class \ref lemon::dim2::Point "dim2::Point" implements
1.5 /// a two dimensional vector with the usual operations.
1.6 ///
1.7 -/// The class \ref lemon::dim2::BoundingBox "dim2::BoundingBox"
1.8 -/// can be used to determine
1.9 +/// The class \ref lemon::dim2::Box "dim2::Box" can be used to determine
1.10 /// the rectangular bounding box of a set of
1.11 /// \ref lemon::dim2::Point "dim2::Point"'s.
1.12
1.13 @@ -44,7 +43,7 @@
1.14 /// \addtogroup misc
1.15 /// @{
1.16
1.17 - /// A simple two dimensional vector (plain vector) implementation
1.18 + /// Two dimensional vector (plain vector)
1.19
1.20 /// A simple two dimensional vector (plain vector) implementation
1.21 /// with the usual vector operations.
1.22 @@ -260,67 +259,67 @@
1.23
1.24
1.25
1.26 - /// A class to calculate or store the bounding box of plain vectors.
1.27 + /// Bounding box of plain vectors (\ref Point points).
1.28
1.29 - /// A class to calculate or store the bounding box of plain vectors.
1.30 - ///
1.31 - template<typename T>
1.32 - class BoundingBox {
1.33 + /// A class to calculate or store the bounding box of plain vectors
1.34 + /// (\ref Point points).
1.35 + template<typename T>
1.36 + class Box {
1.37 Point<T> _bottom_left, _top_right;
1.38 bool _empty;
1.39 public:
1.40
1.41 - ///Default constructor: creates an empty bounding box
1.42 - BoundingBox() { _empty = true; }
1.43 + ///Default constructor: creates an empty box
1.44 + Box() { _empty = true; }
1.45
1.46 - ///Construct an instance from one point
1.47 - BoundingBox(Point<T> a) {
1.48 + ///Construct a box from one point
1.49 + Box(Point<T> a) {
1.50 _bottom_left = _top_right = a;
1.51 _empty = false;
1.52 }
1.53
1.54 - ///Construct an instance from two points
1.55 + ///Construct a box from two points
1.56
1.57 - ///Construct an instance from two points.
1.58 + ///Construct a box from two points.
1.59 ///\param a The bottom left corner.
1.60 ///\param b The top right corner.
1.61 ///\warning The coordinates of the bottom left corner must be no more
1.62 ///than those of the top right one.
1.63 - BoundingBox(Point<T> a,Point<T> b)
1.64 + Box(Point<T> a,Point<T> b)
1.65 {
1.66 _bottom_left = a;
1.67 _top_right = b;
1.68 _empty = false;
1.69 }
1.70
1.71 - ///Construct an instance from four numbers
1.72 + ///Construct a box from four numbers
1.73
1.74 - ///Construct an instance from four numbers.
1.75 + ///Construct a box from four numbers.
1.76 ///\param l The left side of the box.
1.77 ///\param b The bottom of the box.
1.78 ///\param r The right side of the box.
1.79 ///\param t The top of the box.
1.80 ///\warning The left side must be no more than the right side and
1.81 ///bottom must be no more than the top.
1.82 - BoundingBox(T l,T b,T r,T t)
1.83 + Box(T l,T b,T r,T t)
1.84 {
1.85 _bottom_left=Point<T>(l,b);
1.86 _top_right=Point<T>(r,t);
1.87 _empty = false;
1.88 }
1.89
1.90 - ///Return \c true if the bounding box is empty.
1.91 + ///Return \c true if the box is empty.
1.92
1.93 - ///Return \c true if the bounding box is empty (i.e. return \c false
1.94 + ///Return \c true if the box is empty (i.e. return \c false
1.95 ///if at least one point was added to the box or the coordinates of
1.96 ///the box were set).
1.97 ///
1.98 - ///The coordinates of an empty bounding box are not defined.
1.99 + ///The coordinates of an empty box are not defined.
1.100 bool empty() const {
1.101 return _empty;
1.102 }
1.103
1.104 - ///Make the BoundingBox empty
1.105 + ///Make the box empty
1.106 void clear() {
1.107 _empty = true;
1.108 }
1.109 @@ -328,7 +327,7 @@
1.110 ///Give back the bottom left corner of the box
1.111
1.112 ///Give back the bottom left corner of the box.
1.113 - ///If the bounding box is empty, then the return value is not defined.
1.114 + ///If the box is empty, then the return value is not defined.
1.115 Point<T> bottomLeft() const {
1.116 return _bottom_left;
1.117 }
1.118 @@ -344,7 +343,7 @@
1.119 ///Give back the top right corner of the box
1.120
1.121 ///Give back the top right corner of the box.
1.122 - ///If the bounding box is empty, then the return value is not defined.
1.123 + ///If the box is empty, then the return value is not defined.
1.124 Point<T> topRight() const {
1.125 return _top_right;
1.126 }
1.127 @@ -360,7 +359,7 @@
1.128 ///Give back the bottom right corner of the box
1.129
1.130 ///Give back the bottom right corner of the box.
1.131 - ///If the bounding box is empty, then the return value is not defined.
1.132 + ///If the box is empty, then the return value is not defined.
1.133 Point<T> bottomRight() const {
1.134 return Point<T>(_top_right.x,_bottom_left.y);
1.135 }
1.136 @@ -377,7 +376,7 @@
1.137 ///Give back the top left corner of the box
1.138
1.139 ///Give back the top left corner of the box.
1.140 - ///If the bounding box is empty, then the return value is not defined.
1.141 + ///If the box is empty, then the return value is not defined.
1.142 Point<T> topLeft() const {
1.143 return Point<T>(_bottom_left.x,_top_right.y);
1.144 }
1.145 @@ -394,7 +393,7 @@
1.146 ///Give back the bottom of the box
1.147
1.148 ///Give back the bottom of the box.
1.149 - ///If the bounding box is empty, then the return value is not defined.
1.150 + ///If the box is empty, then the return value is not defined.
1.151 T bottom() const {
1.152 return _bottom_left.y;
1.153 }
1.154 @@ -410,7 +409,7 @@
1.155 ///Give back the top of the box
1.156
1.157 ///Give back the top of the box.
1.158 - ///If the bounding box is empty, then the return value is not defined.
1.159 + ///If the box is empty, then the return value is not defined.
1.160 T top() const {
1.161 return _top_right.y;
1.162 }
1.163 @@ -426,7 +425,7 @@
1.164 ///Give back the left side of the box
1.165
1.166 ///Give back the left side of the box.
1.167 - ///If the bounding box is empty, then the return value is not defined.
1.168 + ///If the box is empty, then the return value is not defined.
1.169 T left() const {
1.170 return _bottom_left.x;
1.171 }
1.172 @@ -442,7 +441,7 @@
1.173 /// Give back the right side of the box
1.174
1.175 /// Give back the right side of the box.
1.176 - ///If the bounding box is empty, then the return value is not defined.
1.177 + ///If the box is empty, then the return value is not defined.
1.178 T right() const {
1.179 return _top_right.x;
1.180 }
1.181 @@ -458,7 +457,7 @@
1.182 ///Give back the height of the box
1.183
1.184 ///Give back the height of the box.
1.185 - ///If the bounding box is empty, then the return value is not defined.
1.186 + ///If the box is empty, then the return value is not defined.
1.187 T height() const {
1.188 return _top_right.y-_bottom_left.y;
1.189 }
1.190 @@ -466,12 +465,12 @@
1.191 ///Give back the width of the box
1.192
1.193 ///Give back the width of the box.
1.194 - ///If the bounding box is empty, then the return value is not defined.
1.195 + ///If the box is empty, then the return value is not defined.
1.196 T width() const {
1.197 return _top_right.x-_bottom_left.x;
1.198 }
1.199
1.200 - ///Checks whether a point is inside a bounding box
1.201 + ///Checks whether a point is inside the box
1.202 bool inside(const Point<T>& u) const {
1.203 if (_empty)
1.204 return false;
1.205 @@ -481,11 +480,11 @@
1.206 }
1.207 }
1.208
1.209 - ///Increments a bounding box with a point
1.210 + ///Increments the box with a point
1.211
1.212 - ///Increments a bounding box with a point.
1.213 + ///Increments the box with a point.
1.214 ///
1.215 - BoundingBox& add(const Point<T>& u){
1.216 + Box& add(const Point<T>& u){
1.217 if (_empty) {
1.218 _bottom_left = _top_right = u;
1.219 _empty = false;
1.220 @@ -499,11 +498,11 @@
1.221 return *this;
1.222 }
1.223
1.224 - ///Increments a bounding box to contain another bounding box
1.225 + ///Increments the box to contain another box
1.226
1.227 - ///Increments a bounding box to contain another bounding box.
1.228 + ///Increments the box to contain another box.
1.229 ///
1.230 - BoundingBox& add(const BoundingBox &u){
1.231 + Box& add(const Box &u){
1.232 if ( !u.empty() ){
1.233 add(u._bottom_left);
1.234 add(u._top_right);
1.235 @@ -511,12 +510,12 @@
1.236 return *this;
1.237 }
1.238
1.239 - ///Intersection of two bounding boxes
1.240 + ///Intersection of two boxes
1.241
1.242 - ///Intersection of two bounding boxes.
1.243 + ///Intersection of two boxes.
1.244 ///
1.245 - BoundingBox operator&(const BoundingBox& u) const {
1.246 - BoundingBox b;
1.247 + Box operator&(const Box& u) const {
1.248 + Box b;
1.249 if (_empty || u._empty) {
1.250 b._empty = true;
1.251 } else {
1.252 @@ -530,15 +529,15 @@
1.253 return b;
1.254 }
1.255
1.256 - };//class Boundingbox
1.257 + };//class Box
1.258
1.259
1.260 - ///Read a bounding box from a stream
1.261 + ///Read a box from a stream
1.262
1.263 - ///Read a bounding box from a stream.
1.264 - ///\relates BoundingBox
1.265 + ///Read a box from a stream.
1.266 + ///\relates Box
1.267 template<typename T>
1.268 - inline std::istream& operator>>(std::istream &is, BoundingBox<T>& b) {
1.269 + inline std::istream& operator>>(std::istream &is, Box<T>& b) {
1.270 char c;
1.271 Point<T> p;
1.272 if (is >> c) {
1.273 @@ -563,12 +562,12 @@
1.274 return is;
1.275 }
1.276
1.277 - ///Write a bounding box to a stream
1.278 + ///Write a box to a stream
1.279
1.280 - ///Write a bounding box to a stream.
1.281 - ///\relates BoundingBox
1.282 + ///Write a box to a stream.
1.283 + ///\relates Box
1.284 template<typename T>
1.285 - inline std::ostream& operator<<(std::ostream &os, const BoundingBox<T>& b)
1.286 + inline std::ostream& operator<<(std::ostream &os, const Box<T>& b)
1.287 {
1.288 os << "(" << b.bottomLeft() << "," << b.topRight() << ")";
1.289 return os;
2.1 --- a/lemon/graph_to_eps.h Wed Aug 27 10:50:04 2008 +0200
2.2 +++ b/lemon/graph_to_eps.h Sat Aug 30 22:19:43 2008 +0200
2.3 @@ -725,10 +725,10 @@
2.4
2.5 double diag_len = 1;
2.6 if(!(_absoluteNodeSizes&&_absoluteArcWidths)) {
2.7 - dim2::BoundingBox<double> bb;
2.8 + dim2::Box<double> bb;
2.9 for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]);
2.10 if (bb.empty()) {
2.11 - bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
2.12 + bb = dim2::Box<double>(dim2::Point<double>(0,0));
2.13 }
2.14 diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare());
2.15 if(diag_len<EPSILON) diag_len = 1;
2.16 @@ -736,7 +736,7 @@
2.17 if(!_absoluteArcWidths) _arcWidthScale*=diag_len;
2.18 }
2.19
2.20 - dim2::BoundingBox<double> bb;
2.21 + dim2::Box<double> bb;
2.22 for(NodeIt n(g);n!=INVALID;++n) {
2.23 double ns=_nodeSizes[n]*_nodeScale;
2.24 dim2::Point<double> p(ns,ns);
2.25 @@ -758,7 +758,7 @@
2.26 }
2.27 }
2.28 if (bb.empty()) {
2.29 - bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
2.30 + bb = dim2::Box<double>(dim2::Point<double>(0,0));
2.31 }
2.32
2.33 if(_scaleToA4)
3.1 --- a/test/dim_test.cc Wed Aug 27 10:50:04 2008 +0200
3.2 +++ b/test/dim_test.cc Sat Aug 30 22:19:43 2008 +0200
3.3 @@ -50,38 +50,38 @@
3.4 p = b/l;
3.5 check(p.x==1 && p.y==2, "Wrong dim2::Point division by a scalar.");
3.6
3.7 - typedef dim2::BoundingBox<int> BB;
3.8 - BB box1;
3.9 - check(box1.empty(), "Wrong empty() in dim2::BoundingBox.");
3.10 + typedef dim2::Box<int> Box;
3.11 + Box box1;
3.12 + check(box1.empty(), "Wrong empty() in dim2::Box.");
3.13
3.14 box1.add(a);
3.15 - check(!box1.empty(), "Wrong empty() in dim2::BoundingBox.");
3.16 + check(!box1.empty(), "Wrong empty() in dim2::Box.");
3.17 box1.add(b);
3.18
3.19 check(box1.left()==1 && box1.bottom()==2 &&
3.20 box1.right()==3 && box1.top()==4,
3.21 - "Wrong addition of points to dim2::BoundingBox.");
3.22 + "Wrong addition of points to dim2::Box.");
3.23
3.24 - check(box1.inside(Point(2,3)), "Wrong inside() in dim2::BoundingBox.");
3.25 - check(box1.inside(Point(1,3)), "Wrong inside() in dim2::BoundingBox.");
3.26 - check(!box1.inside(Point(0,3)), "Wrong inside() in dim2::BoundingBox.");
3.27 + check(box1.inside(Point(2,3)), "Wrong inside() in dim2::Box.");
3.28 + check(box1.inside(Point(1,3)), "Wrong inside() in dim2::Box.");
3.29 + check(!box1.inside(Point(0,3)), "Wrong inside() in dim2::Box.");
3.30
3.31 - BB box2(Point(2,2));
3.32 - check(!box2.empty(), "Wrong empty() in dim2::BoundingBox.");
3.33 -
3.34 + Box box2(Point(2,2));
3.35 + check(!box2.empty(), "Wrong empty() in dim2::Box.");
3.36 +
3.37 box2.bottomLeft(Point(2,0));
3.38 box2.topRight(Point(5,3));
3.39 - BB box3 = box1 & box2;
3.40 + Box box3 = box1 & box2;
3.41 check(!box3.empty() &&
3.42 - box3.left()==2 && box3.bottom()==2 &&
3.43 + box3.left()==2 && box3.bottom()==2 &&
3.44 box3.right()==3 && box3.top()==3,
3.45 - "Wrong intersection of two dim2::BoundingBox objects.");
3.46 -
3.47 + "Wrong intersection of two dim2::Box objects.");
3.48 +
3.49 box1.add(box2);
3.50 check(!box1.empty() &&
3.51 box1.left()==1 && box1.bottom()==0 &&
3.52 box1.right()==5 && box1.top()==4,
3.53 - "Wrong addition of two dim2::BoundingBox objects.");
3.54 + "Wrong addition of two dim2::Box objects.");
3.55
3.56 return 0;
3.57 }