... |
... |
@@ -30,4 +30,3 @@
|
30 |
30 |
///
|
31 |
|
/// The class \ref lemon::dim2::BoundingBox "dim2::BoundingBox"
|
32 |
|
/// can be used to determine
|
|
31 |
/// The class \ref lemon::dim2::Box "dim2::Box" can be used to determine
|
33 |
32 |
/// the rectangular bounding box of a set of
|
... |
... |
@@ -46,3 +45,3 @@
|
46 |
45 |
|
47 |
|
/// A simple two dimensional vector (plain vector) implementation
|
|
46 |
/// Two dimensional vector (plain vector)
|
48 |
47 |
|
... |
... |
@@ -262,8 +261,8 @@
|
262 |
261 |
|
263 |
|
/// A class to calculate or store the bounding box of plain vectors.
|
|
262 |
/// Bounding box of plain vectors (\ref Point points).
|
264 |
263 |
|
265 |
|
/// A class to calculate or store the bounding box of plain vectors.
|
266 |
|
///
|
|
264 |
/// A class to calculate or store the bounding box of plain vectors
|
|
265 |
/// (\ref Point points).
|
267 |
266 |
template<typename T>
|
268 |
|
class BoundingBox {
|
|
267 |
class Box {
|
269 |
268 |
Point<T> _bottom_left, _top_right;
|
... |
... |
@@ -272,7 +271,7 @@
|
272 |
271 |
|
273 |
|
///Default constructor: creates an empty bounding box
|
274 |
|
BoundingBox() { _empty = true; }
|
|
272 |
///Default constructor: creates an empty box
|
|
273 |
Box() { _empty = true; }
|
275 |
274 |
|
276 |
|
///Construct an instance from one point
|
277 |
|
BoundingBox(Point<T> a) {
|
|
275 |
///Construct a box from one point
|
|
276 |
Box(Point<T> a) {
|
278 |
277 |
_bottom_left = _top_right = a;
|
... |
... |
@@ -281,5 +280,5 @@
|
281 |
280 |
|
282 |
|
///Construct an instance from two points
|
|
281 |
///Construct a box from two points
|
283 |
282 |
|
284 |
|
///Construct an instance from two points.
|
|
283 |
///Construct a box from two points.
|
285 |
284 |
///\param a The bottom left corner.
|
... |
... |
@@ -288,3 +287,3 @@
|
288 |
287 |
///than those of the top right one.
|
289 |
|
BoundingBox(Point<T> a,Point<T> b)
|
|
288 |
Box(Point<T> a,Point<T> b)
|
290 |
289 |
{
|
... |
... |
@@ -295,5 +294,5 @@
|
295 |
294 |
|
296 |
|
///Construct an instance from four numbers
|
|
295 |
///Construct a box from four numbers
|
297 |
296 |
|
298 |
|
///Construct an instance from four numbers.
|
|
297 |
///Construct a box from four numbers.
|
299 |
298 |
///\param l The left side of the box.
|
... |
... |
@@ -304,3 +303,3 @@
|
304 |
303 |
///bottom must be no more than the top.
|
305 |
|
BoundingBox(T l,T b,T r,T t)
|
|
304 |
Box(T l,T b,T r,T t)
|
306 |
305 |
{
|
... |
... |
@@ -311,5 +310,5 @@
|
311 |
310 |
|
312 |
|
///Return \c true if the bounding box is empty.
|
|
311 |
///Return \c true if the box is empty.
|
313 |
312 |
|
314 |
|
///Return \c true if the bounding box is empty (i.e. return \c false
|
|
313 |
///Return \c true if the box is empty (i.e. return \c false
|
315 |
314 |
///if at least one point was added to the box or the coordinates of
|
... |
... |
@@ -317,3 +316,3 @@
|
317 |
316 |
///
|
318 |
|
///The coordinates of an empty bounding box are not defined.
|
|
317 |
///The coordinates of an empty box are not defined.
|
319 |
318 |
bool empty() const {
|
... |
... |
@@ -322,3 +321,3 @@
|
322 |
321 |
|
323 |
|
///Make the BoundingBox empty
|
|
322 |
///Make the box empty
|
324 |
323 |
void clear() {
|
... |
... |
@@ -330,3 +329,3 @@
|
330 |
329 |
///Give back the bottom left corner of the box.
|
331 |
|
///If the bounding box is empty, then the return value is not defined.
|
|
330 |
///If the box is empty, then the return value is not defined.
|
332 |
331 |
Point<T> bottomLeft() const {
|
... |
... |
@@ -346,3 +345,3 @@
|
346 |
345 |
///Give back the top right corner of the box.
|
347 |
|
///If the bounding box is empty, then the return value is not defined.
|
|
346 |
///If the box is empty, then the return value is not defined.
|
348 |
347 |
Point<T> topRight() const {
|
... |
... |
@@ -362,3 +361,3 @@
|
362 |
361 |
///Give back the bottom right corner of the box.
|
363 |
|
///If the bounding box is empty, then the return value is not defined.
|
|
362 |
///If the box is empty, then the return value is not defined.
|
364 |
363 |
Point<T> bottomRight() const {
|
... |
... |
@@ -379,3 +378,3 @@
|
379 |
378 |
///Give back the top left corner of the box.
|
380 |
|
///If the bounding box is empty, then the return value is not defined.
|
|
379 |
///If the box is empty, then the return value is not defined.
|
381 |
380 |
Point<T> topLeft() const {
|
... |
... |
@@ -396,3 +395,3 @@
|
396 |
395 |
///Give back the bottom of the box.
|
397 |
|
///If the bounding box is empty, then the return value is not defined.
|
|
396 |
///If the box is empty, then the return value is not defined.
|
398 |
397 |
T bottom() const {
|
... |
... |
@@ -412,3 +411,3 @@
|
412 |
411 |
///Give back the top of the box.
|
413 |
|
///If the bounding box is empty, then the return value is not defined.
|
|
412 |
///If the box is empty, then the return value is not defined.
|
414 |
413 |
T top() const {
|
... |
... |
@@ -428,3 +427,3 @@
|
428 |
427 |
///Give back the left side of the box.
|
429 |
|
///If the bounding box is empty, then the return value is not defined.
|
|
428 |
///If the box is empty, then the return value is not defined.
|
430 |
429 |
T left() const {
|
... |
... |
@@ -444,3 +443,3 @@
|
444 |
443 |
/// Give back the right side of the box.
|
445 |
|
///If the bounding box is empty, then the return value is not defined.
|
|
444 |
///If the box is empty, then the return value is not defined.
|
446 |
445 |
T right() const {
|
... |
... |
@@ -460,3 +459,3 @@
|
460 |
459 |
///Give back the height of the box.
|
461 |
|
///If the bounding box is empty, then the return value is not defined.
|
|
460 |
///If the box is empty, then the return value is not defined.
|
462 |
461 |
T height() const {
|
... |
... |
@@ -468,3 +467,3 @@
|
468 |
467 |
///Give back the width of the box.
|
469 |
|
///If the bounding box is empty, then the return value is not defined.
|
|
468 |
///If the box is empty, then the return value is not defined.
|
470 |
469 |
T width() const {
|
... |
... |
@@ -473,3 +472,3 @@
|
473 |
472 |
|
474 |
|
///Checks whether a point is inside a bounding box
|
|
473 |
///Checks whether a point is inside the box
|
475 |
474 |
bool inside(const Point<T>& u) const {
|
... |
... |
@@ -483,7 +482,7 @@
|
483 |
482 |
|
484 |
|
///Increments a bounding box with a point
|
|
483 |
///Increments the box with a point
|
485 |
484 |
|
486 |
|
///Increments a bounding box with a point.
|
|
485 |
///Increments the box with a point.
|
487 |
486 |
///
|
488 |
|
BoundingBox& add(const Point<T>& u){
|
|
487 |
Box& add(const Point<T>& u){
|
489 |
488 |
if (_empty) {
|
... |
... |
@@ -501,7 +500,7 @@
|
501 |
500 |
|
502 |
|
///Increments a bounding box to contain another bounding box
|
|
501 |
///Increments the box to contain another box
|
503 |
502 |
|
504 |
|
///Increments a bounding box to contain another bounding box.
|
|
503 |
///Increments the box to contain another box.
|
505 |
504 |
///
|
506 |
|
BoundingBox& add(const BoundingBox &u){
|
|
505 |
Box& add(const Box &u){
|
507 |
506 |
if ( !u.empty() ){
|
... |
... |
@@ -513,8 +512,8 @@
|
513 |
512 |
|
514 |
|
///Intersection of two bounding boxes
|
|
513 |
///Intersection of two boxes
|
515 |
514 |
|
516 |
|
///Intersection of two bounding boxes.
|
|
515 |
///Intersection of two boxes.
|
517 |
516 |
///
|
518 |
|
BoundingBox operator&(const BoundingBox& u) const {
|
519 |
|
BoundingBox b;
|
|
517 |
Box operator&(const Box& u) const {
|
|
518 |
Box b;
|
520 |
519 |
if (_empty || u._empty) {
|
... |
... |
@@ -532,11 +531,11 @@
|
532 |
531 |
|
533 |
|
};//class Boundingbox
|
|
532 |
};//class Box
|
534 |
533 |
|
535 |
534 |
|
536 |
|
///Read a bounding box from a stream
|
|
535 |
///Read a box from a stream
|
537 |
536 |
|
538 |
|
///Read a bounding box from a stream.
|
539 |
|
///\relates BoundingBox
|
|
537 |
///Read a box from a stream.
|
|
538 |
///\relates Box
|
540 |
539 |
template<typename T>
|
541 |
|
inline std::istream& operator>>(std::istream &is, BoundingBox<T>& b) {
|
|
540 |
inline std::istream& operator>>(std::istream &is, Box<T>& b) {
|
542 |
541 |
char c;
|
... |
... |
@@ -565,8 +564,8 @@
|
565 |
564 |
|
566 |
|
///Write a bounding box to a stream
|
|
565 |
///Write a box to a stream
|
567 |
566 |
|
568 |
|
///Write a bounding box to a stream.
|
569 |
|
///\relates BoundingBox
|
|
567 |
///Write a box to a stream.
|
|
568 |
///\relates Box
|
570 |
569 |
template<typename T>
|
571 |
|
inline std::ostream& operator<<(std::ostream &os, const BoundingBox<T>& b)
|
|
570 |
inline std::ostream& operator<<(std::ostream &os, const Box<T>& b)
|
572 |
571 |
{
|