gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Improved and fixed dim2.h. Improved and fixed documentation. Bug fix in BoundingBox<>::operator&. Removed \author tags.
0 1 0
default
1 file changed with 72 insertions and 52 deletions:
↑ Collapse diff ↑
Ignore white space 4 line context
... ...
@@ -35,7 +35,4 @@
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

	
40 37

	
41 38
namespace lemon {
... ...
@@ -63,7 +60,7 @@
63 60
      typedef T Value;
64 61

	
65
      ///First co-ordinate
62
      ///First coordinate
66 63
      T x;
67
      ///Second co-ordinate
64
      ///Second coordinate
68 65
      T y;     
69 66
      
... ...
@@ -76,6 +73,6 @@
76 73
      ///The dimension of the vector.
77 74

	
78
      ///This class give back always 2.
79
      ///
75
      ///The dimension of the vector.
76
      ///This function always returns 2. 
80 77
      int size() const { return 2; }
81 78

	
... ...
@@ -139,5 +136,5 @@
139 136
      }
140 137

	
141
      ///Return the neg of the vectors
138
      ///Return the negative of the vector
142 139
      Point<T> operator-() const {
143 140
        Point<T> b=*this;
... ...
@@ -176,7 +173,7 @@
176 173
    };
177 174

	
178
  ///Return an Point 
175
  ///Return a Point 
179 176

	
180
  ///Return an Point
177
  ///Return a Point.
181 178
  ///\relates Point
182 179
  template <typename T>
... ...
@@ -187,5 +184,5 @@
187 184
  ///Return a vector multiplied by a scalar
188 185

	
189
  ///Return a vector multiplied by a scalar
186
  ///Return a vector multiplied by a scalar.
190 187
  ///\relates Point
191 188
  template<typename T> Point<T> operator*(const T &u,const Point<T> &x) {
... ...
@@ -195,5 +192,5 @@
195 192
  ///Read a plainvector from a stream
196 193

	
197
  ///Read a plainvector from a stream
194
  ///Read a plainvector from a stream.
198 195
  ///\relates Point
199 196
  ///
... ...
@@ -223,5 +220,5 @@
223 220
  ///Write a plainvector to a stream
224 221

	
225
  ///Write a plainvector to a stream
222
  ///Write a plainvector to a stream.
226 223
  ///\relates Point
227 224
  ///
... ...
@@ -235,5 +232,5 @@
235 232
  ///Rotate by 90 degrees
236 233

	
237
  ///Returns its parameter rotated by 90 degrees in positive direction.
234
  ///Returns the parameter rotated by 90 degrees in positive direction.
238 235
  ///\relates Point
239 236
  ///
... ...
@@ -246,5 +243,5 @@
246 243
  ///Rotate by 180 degrees
247 244

	
248
  ///Returns its parameter rotated by 180 degrees.
245
  ///Returns the parameter rotated by 180 degrees.
249 246
  ///\relates Point
250 247
  ///
... ...
@@ -257,5 +254,5 @@
257 254
  ///Rotate by 270 degrees
258 255

	
259
  ///Returns its parameter rotated by 90 degrees in negative direction.
256
  ///Returns the parameter rotated by 90 degrees in negative direction.
260 257
  ///\relates Point
261 258
  ///
... ...
@@ -272,5 +269,4 @@
272 269
  /// A class to calculate or store the bounding box of plainvectors.
273 270
  ///
274
  ///\author Attila Bernath
275 271
    template<typename T>
276 272
    class BoundingBox {
... ...
@@ -287,7 +283,9 @@
287 283
      ///Construct an instance from two points
288 284
      
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
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.
292 290
      BoundingBox(Point<T> a,Point<T> b)
293 291
      {
... ...
@@ -299,7 +297,11 @@
299 297
      ///Construct an instance from four numbers
300 298

	
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
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. 
304 306
      BoundingBox(T l,T b,T r,T t)
305 307
      {
... ...
@@ -309,5 +311,10 @@
309 311
      }
310 312
      
311
      ///Were any points added?
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. 
312 319
      bool empty() const {
313 320
        return _empty;
... ...
@@ -330,5 +337,5 @@
330 337

	
331 338
      ///Set the bottom left corner.
332
      ///It should only bee used for non-empty box.
339
      ///It should only be used for non-empty box.
333 340
      void bottomLeft(Point<T> p) {
334 341
	bottom_left = p;
... ...
@@ -346,5 +353,5 @@
346 353

	
347 354
      ///Set the top right corner.
348
      ///It should only bee used for non-empty box.
355
      ///It should only be used for non-empty box.
349 356
      void topRight(Point<T> p) {
350 357
	top_right = p;
... ...
@@ -362,5 +369,5 @@
362 369

	
363 370
      ///Set the bottom right corner.
364
      ///It should only bee used for non-empty box.
371
      ///It should only be used for non-empty box.
365 372
      void bottomRight(Point<T> p) {
366 373
	top_right.x = p.x;
... ...
@@ -379,5 +386,5 @@
379 386

	
380 387
      ///Set the top left corner.
381
      ///It should only bee used for non-empty box.
388
      ///It should only be used for non-empty box.
382 389
      void topLeft(Point<T> p) {
383 390
	top_right.y = p.y;
... ...
@@ -396,5 +403,5 @@
396 403

	
397 404
      ///Set the bottom of the box.
398
      ///It should only bee used for non-empty box.
405
      ///It should only be used for non-empty box.
399 406
      void bottom(T t) {
400 407
	bottom_left.y = t;
... ...
@@ -412,5 +419,5 @@
412 419

	
413 420
      ///Set the top of the box.
414
      ///It should only bee used for non-empty box.
421
      ///It should only be used for non-empty box.
415 422
      void top(T t) {
416 423
	top_right.y = t;
... ...
@@ -428,5 +435,5 @@
428 435

	
429 436
      ///Set the left side of the box.
430
      ///It should only bee used for non-empty box
437
      ///It should only be used for non-empty box.
431 438
      void left(T t) {
432 439
	bottom_left.x = t;
... ...
@@ -444,5 +451,5 @@
444 451

	
445 452
      ///Set the right side of the box.
446
      ///It should only bee used for non-empty box
453
      ///It should only be used for non-empty box.
447 454
      void right(T t) {
448 455
	top_right.x = t;
... ...
@@ -466,5 +473,5 @@
466 473

	
467 474
      ///Checks whether a point is inside a bounding box
468
      bool inside(const Point<T>& u){
475
      bool inside(const Point<T>& u) const {
469 476
        if (_empty)
470 477
          return false;
... ...
@@ -476,4 +483,7 @@
476 483
  
477 484
      ///Increments a bounding box with a point
485

	
486
      ///Increments a bounding box with a point.
487
      ///
478 488
      BoundingBox& add(const Point<T>& u){
479 489
        if (_empty){
... ...
@@ -490,5 +500,8 @@
490 500
      }
491 501
    
492
      ///Increments a bounding to contain another bounding box
502
      ///Increments a bounding box to contain another bounding box
503
      
504
      ///Increments a bounding box to contain another bounding box.
505
      ///
493 506
      BoundingBox& add(const BoundingBox &u){
494 507
        if ( !u.empty() ){
... ...
@@ -500,12 +513,19 @@
500 513
  
501 514
      ///Intersection of two bounding boxes
502
      BoundingBox operator &(const BoundingBox& u){
515

	
516
      ///Intersection of two bounding boxes.
517
      ///
518
      BoundingBox operator&(const BoundingBox& u) const {
503 519
        BoundingBox b;
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;
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
	} 
510 530
        return b;
511 531
      }
... ...
@@ -514,8 +534,8 @@
514 534

	
515 535

	
516
  ///Map of x-coordinates of a dim2::Point<>-map
536
  ///Map of x-coordinates of a \ref Point "Point"-map
517 537

	
518 538
  ///\ingroup maps
519
  ///Map of x-coordinates of a dim2::Point<>-map
539
  ///Map of x-coordinates of a \ref Point "Point"-map.
520 540
  ///
521 541
  template<class M>
... ...
@@ -571,5 +591,5 @@
571 591
  ///Returns a \ref ConstXMap class
572 592

	
573
  ///This function just returns an \ref ConstXMap class.
593
  ///This function just returns a \ref ConstXMap class.
574 594
  ///
575 595
  ///\ingroup maps
... ...
@@ -581,8 +601,8 @@
581 601
  }
582 602

	
583
  ///Map of y-coordinates of a dim2::Point<>-map
603
  ///Map of y-coordinates of a \ref Point "Point"-map
584 604
    
585 605
  ///\ingroup maps
586
  ///Map of y-coordinates of a dim2::Point<>-map
606
  ///Map of y-coordinates of a \ref Point "Point"-map.
587 607
  ///
588 608
  template<class M>
... ...
@@ -600,7 +620,7 @@
600 620
  };
601 621

	
602
  ///Returns an \ref YMap class
622
  ///Returns a \ref YMap class
603 623

	
604
  ///This function just returns an \ref YMap class.
624
  ///This function just returns a \ref YMap class.
605 625
  ///
606 626
  ///\ingroup maps
... ...
@@ -638,5 +658,5 @@
638 658
  ///Returns a \ref ConstYMap class
639 659

	
640
  ///This function just returns an \ref ConstYMap class.
660
  ///This function just returns a \ref ConstYMap class.
641 661
  ///
642 662
  ///\ingroup maps
... ...
@@ -650,8 +670,8 @@
650 670

	
651 671
    ///\brief Map of the \ref Point::normSquare() "normSquare()"
652
    ///of an \ref Point "Point"-map
672
    ///of a \ref Point "Point"-map
653 673
    ///
654 674
    ///Map of the \ref Point::normSquare() "normSquare()"
655
    ///of an \ref Point "Point"-map
675
    ///of a \ref Point "Point"-map.
656 676
    ///\ingroup maps
657 677
    ///
... ...
@@ -671,5 +691,5 @@
671 691
  ///Returns a \ref NormSquareMap class
672 692

	
673
  ///This function just returns an \ref NormSquareMap class.
693
  ///This function just returns a \ref NormSquareMap class.
674 694
  ///
675 695
  ///\ingroup maps
0 comments (0 inline)