Changes in lemon/dim2.h [15:062f361aa520:8:a1b1d672f37a] in lemon
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/dim2.h
r15 r8 35 35 /// the rectangular bounding box of a set of 36 36 /// \ref lemon::dim2::Point "dim2::Point"'s. 37 /// 38 ///\author Attila Bernath 39 37 40 38 41 namespace lemon { … … 60 63 typedef T Value; 61 64 62 ///First co ordinate65 ///First co-ordinate 63 66 T x; 64 ///Second co ordinate67 ///Second co-ordinate 65 68 T y; 66 69 … … 73 76 ///The dimension of the vector. 74 77 75 ///Th e dimension of the vector.76 /// This function always returns 2.78 ///This class give back always 2. 79 /// 77 80 int size() const { return 2; } 78 81 … … 136 139 } 137 140 138 ///Return the neg ative of the vector141 ///Return the neg of the vectors 139 142 Point<T> operator-() const { 140 143 Point<T> b=*this; … … 173 176 }; 174 177 175 ///Return a Point176 177 ///Return a Point.178 ///Return an Point 179 180 ///Return an Point 178 181 ///\relates Point 179 182 template <typename T> … … 184 187 ///Return a vector multiplied by a scalar 185 188 186 ///Return a vector multiplied by a scalar .189 ///Return a vector multiplied by a scalar 187 190 ///\relates Point 188 191 template<typename T> Point<T> operator*(const T &u,const Point<T> &x) { … … 192 195 ///Read a plainvector from a stream 193 196 194 ///Read a plainvector from a stream .197 ///Read a plainvector from a stream 195 198 ///\relates Point 196 199 /// … … 220 223 ///Write a plainvector to a stream 221 224 222 ///Write a plainvector to a stream .225 ///Write a plainvector to a stream 223 226 ///\relates Point 224 227 /// … … 232 235 ///Rotate by 90 degrees 233 236 234 ///Returns theparameter rotated by 90 degrees in positive direction.237 ///Returns its parameter rotated by 90 degrees in positive direction. 235 238 ///\relates Point 236 239 /// … … 243 246 ///Rotate by 180 degrees 244 247 245 ///Returns theparameter rotated by 180 degrees.248 ///Returns its parameter rotated by 180 degrees. 246 249 ///\relates Point 247 250 /// … … 254 257 ///Rotate by 270 degrees 255 258 256 ///Returns theparameter rotated by 90 degrees in negative direction.259 ///Returns its parameter rotated by 90 degrees in negative direction. 257 260 ///\relates Point 258 261 /// … … 269 272 /// A class to calculate or store the bounding box of plainvectors. 270 273 /// 274 ///\author Attila Bernath 271 275 template<typename T> 272 276 class BoundingBox { … … 283 287 ///Construct an instance from two points 284 288 285 ///Construct an instance from two points. 286 ///\param a The bottom left corner. 287 ///\param b The top right corner. 288 ///\warning The coordinates of the bottom left corner must be no more 289 ///than those of the top right one. 289 ///Construct an instance from two points 290 ///\warning The coordinates of the bottom-left corner must be no more 291 ///than those of the top-right one 290 292 BoundingBox(Point<T> a,Point<T> b) 291 293 { … … 297 299 ///Construct an instance from four numbers 298 300 299 ///Construct an instance from four numbers. 300 ///\param l The left side of the box. 301 ///\param b The bottom of the box. 302 ///\param r The right side of the box. 303 ///\param t The top of the box. 304 ///\warning The left side must be no more than the right side and 305 ///bottom must be no more than the top. 301 ///Construct an instance from four numbers 302 ///\warning The coordinates of the bottom-left corner must be no more 303 ///than those of the top-right one 306 304 BoundingBox(T l,T b,T r,T t) 307 305 { … … 311 309 } 312 310 313 ///Return \c true if the bounding box is empty. 314 315 ///Return \c true if the bounding box is empty (i.e. return \c false 316 ///if at least one point was added to the box or the coordinates of 317 ///the box were set). 318 ///The coordinates of an empty bounding box are not defined. 311 ///Were any points added? 319 312 bool empty() const { 320 313 return _empty; … … 337 330 338 331 ///Set the bottom left corner. 339 ///It should only be used for non-empty box.332 ///It should only bee used for non-empty box. 340 333 void bottomLeft(Point<T> p) { 341 334 bottom_left = p; … … 353 346 354 347 ///Set the top right corner. 355 ///It should only be used for non-empty box.348 ///It should only bee used for non-empty box. 356 349 void topRight(Point<T> p) { 357 350 top_right = p; … … 369 362 370 363 ///Set the bottom right corner. 371 ///It should only be used for non-empty box.364 ///It should only bee used for non-empty box. 372 365 void bottomRight(Point<T> p) { 373 366 top_right.x = p.x; … … 386 379 387 380 ///Set the top left corner. 388 ///It should only be used for non-empty box.381 ///It should only bee used for non-empty box. 389 382 void topLeft(Point<T> p) { 390 383 top_right.y = p.y; … … 403 396 404 397 ///Set the bottom of the box. 405 ///It should only be used for non-empty box.398 ///It should only bee used for non-empty box. 406 399 void bottom(T t) { 407 400 bottom_left.y = t; … … 419 412 420 413 ///Set the top of the box. 421 ///It should only be used for non-empty box.414 ///It should only bee used for non-empty box. 422 415 void top(T t) { 423 416 top_right.y = t; … … 435 428 436 429 ///Set the left side of the box. 437 ///It should only be used for non-empty box.430 ///It should only bee used for non-empty box 438 431 void left(T t) { 439 432 bottom_left.x = t; … … 451 444 452 445 ///Set the right side of the box. 453 ///It should only be used for non-empty box.446 ///It should only bee used for non-empty box 454 447 void right(T t) { 455 448 top_right.x = t; … … 473 466 474 467 ///Checks whether a point is inside a bounding box 475 bool inside(const Point<T>& u) const{468 bool inside(const Point<T>& u){ 476 469 if (_empty) 477 470 return false; … … 483 476 484 477 ///Increments a bounding box with a point 485 486 ///Increments a bounding box with a point.487 ///488 478 BoundingBox& add(const Point<T>& u){ 489 479 if (_empty){ … … 500 490 } 501 491 502 ///Increments a bounding box to contain another bounding box 503 504 ///Increments a bounding box to contain another bounding box. 505 /// 492 ///Increments a bounding to contain another bounding box 506 493 BoundingBox& add(const BoundingBox &u){ 507 494 if ( !u.empty() ){ … … 513 500 514 501 ///Intersection of two bounding boxes 515 516 ///Intersection of two bounding boxes. 517 /// 518 BoundingBox operator&(const BoundingBox& u) const { 502 BoundingBox operator &(const BoundingBox& u){ 519 503 BoundingBox b; 520 if (this->_empty || u._empty) { 521 b._empty = true; 522 } else { 523 b.bottom_left.x = std::max(this->bottom_left.x,u.bottom_left.x); 524 b.bottom_left.y = std::max(this->bottom_left.y,u.bottom_left.y); 525 b.top_right.x = std::min(this->top_right.x,u.top_right.x); 526 b.top_right.y = std::min(this->top_right.y,u.top_right.y); 527 b._empty = b.bottom_left.x > b.top_right.x || 528 b.bottom_left.y > b.top_right.y; 529 } 504 b.bottom_left.x=std::max(this->bottom_left.x,u.bottom_left.x); 505 b.bottom_left.y=std::max(this->bottom_left.y,u.bottom_left.y); 506 b.top_right.x=std::min(this->top_right.x,u.top_right.x); 507 b.top_right.y=std::min(this->top_right.y,u.top_right.y); 508 b._empty = this->_empty || u._empty || 509 b.bottom_left.x>top_right.x && b.bottom_left.y>top_right.y; 530 510 return b; 531 511 } … … 534 514 535 515 536 ///Map of x-coordinates of a \ref Point "Point"-map537 538 ///\ingroup maps 539 ///Map of x-coordinates of a \ref Point "Point"-map.516 ///Map of x-coordinates of a dim2::Point<>-map 517 518 ///\ingroup maps 519 ///Map of x-coordinates of a dim2::Point<>-map 540 520 /// 541 521 template<class M> … … 591 571 ///Returns a \ref ConstXMap class 592 572 593 ///This function just returns a \ref ConstXMap class.573 ///This function just returns an \ref ConstXMap class. 594 574 /// 595 575 ///\ingroup maps … … 601 581 } 602 582 603 ///Map of y-coordinates of a \ref Point "Point"-map583 ///Map of y-coordinates of a dim2::Point<>-map 604 584 605 585 ///\ingroup maps 606 ///Map of y-coordinates of a \ref Point "Point"-map.586 ///Map of y-coordinates of a dim2::Point<>-map 607 587 /// 608 588 template<class M> … … 620 600 }; 621 601 622 ///Returns a \ref YMap class623 624 ///This function just returns a \ref YMap class.602 ///Returns an \ref YMap class 603 604 ///This function just returns an \ref YMap class. 625 605 /// 626 606 ///\ingroup maps … … 658 638 ///Returns a \ref ConstYMap class 659 639 660 ///This function just returns a \ref ConstYMap class.640 ///This function just returns an \ref ConstYMap class. 661 641 /// 662 642 ///\ingroup maps … … 670 650 671 651 ///\brief Map of the \ref Point::normSquare() "normSquare()" 672 ///of a \ref Point "Point"-map652 ///of an \ref Point "Point"-map 673 653 /// 674 654 ///Map of the \ref Point::normSquare() "normSquare()" 675 ///of a \ref Point "Point"-map.655 ///of an \ref Point "Point"-map 676 656 ///\ingroup maps 677 657 /// … … 691 671 ///Returns a \ref NormSquareMap class 692 672 693 ///This function just returns a \ref NormSquareMap class.673 ///This function just returns an \ref NormSquareMap class. 694 674 /// 695 675 ///\ingroup maps
Note: See TracChangeset
for help on using the changeset viewer.