COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/dim2.h

    r15 r8  
    3535/// the rectangular bounding box of a set of
    3636/// \ref lemon::dim2::Point "dim2::Point"'s.
     37///
     38///\author Attila Bernath
     39
    3740
    3841namespace lemon {
     
    6063      typedef T Value;
    6164
    62       ///First coordinate
     65      ///First co-ordinate
    6366      T x;
    64       ///Second coordinate
     67      ///Second co-ordinate
    6568      T y;     
    6669     
     
    7376      ///The dimension of the vector.
    7477
    75       ///The dimension of the vector.
    76       ///This function always returns 2.
     78      ///This class give back always 2.
     79      ///
    7780      int size() const { return 2; }
    7881
     
    136139      }
    137140
    138       ///Return the negative of the vector
     141      ///Return the neg of the vectors
    139142      Point<T> operator-() const {
    140143        Point<T> b=*this;
     
    173176    };
    174177
    175   ///Return a Point
    176 
    177   ///Return a Point.
     178  ///Return an Point
     179
     180  ///Return an Point
    178181  ///\relates Point
    179182  template <typename T>
     
    184187  ///Return a vector multiplied by a scalar
    185188
    186   ///Return a vector multiplied by a scalar.
     189  ///Return a vector multiplied by a scalar
    187190  ///\relates Point
    188191  template<typename T> Point<T> operator*(const T &u,const Point<T> &x) {
     
    192195  ///Read a plainvector from a stream
    193196
    194   ///Read a plainvector from a stream.
     197  ///Read a plainvector from a stream
    195198  ///\relates Point
    196199  ///
     
    220223  ///Write a plainvector to a stream
    221224
    222   ///Write a plainvector to a stream.
     225  ///Write a plainvector to a stream
    223226  ///\relates Point
    224227  ///
     
    232235  ///Rotate by 90 degrees
    233236
    234   ///Returns the parameter rotated by 90 degrees in positive direction.
     237  ///Returns its parameter rotated by 90 degrees in positive direction.
    235238  ///\relates Point
    236239  ///
     
    243246  ///Rotate by 180 degrees
    244247
    245   ///Returns the parameter rotated by 180 degrees.
     248  ///Returns its parameter rotated by 180 degrees.
    246249  ///\relates Point
    247250  ///
     
    254257  ///Rotate by 270 degrees
    255258
    256   ///Returns the parameter rotated by 90 degrees in negative direction.
     259  ///Returns its parameter rotated by 90 degrees in negative direction.
    257260  ///\relates Point
    258261  ///
     
    269272  /// A class to calculate or store the bounding box of plainvectors.
    270273  ///
     274  ///\author Attila Bernath
    271275    template<typename T>
    272276    class BoundingBox {
     
    283287      ///Construct an instance from two points
    284288     
    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
    290292      BoundingBox(Point<T> a,Point<T> b)
    291293      {
     
    297299      ///Construct an instance from four numbers
    298300
    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
    306304      BoundingBox(T l,T b,T r,T t)
    307305      {
     
    311309      }
    312310     
    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?
    319312      bool empty() const {
    320313        return _empty;
     
    337330
    338331      ///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.
    340333      void bottomLeft(Point<T> p) {
    341334        bottom_left = p;
     
    353346
    354347      ///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.
    356349      void topRight(Point<T> p) {
    357350        top_right = p;
     
    369362
    370363      ///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.
    372365      void bottomRight(Point<T> p) {
    373366        top_right.x = p.x;
     
    386379
    387380      ///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.
    389382      void topLeft(Point<T> p) {
    390383        top_right.y = p.y;
     
    403396
    404397      ///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.
    406399      void bottom(T t) {
    407400        bottom_left.y = t;
     
    419412
    420413      ///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.
    422415      void top(T t) {
    423416        top_right.y = t;
     
    435428
    436429      ///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
    438431      void left(T t) {
    439432        bottom_left.x = t;
     
    451444
    452445      ///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
    454447      void right(T t) {
    455448        top_right.x = t;
     
    473466
    474467      ///Checks whether a point is inside a bounding box
    475       bool inside(const Point<T>& u) const {
     468      bool inside(const Point<T>& u){
    476469        if (_empty)
    477470          return false;
     
    483476 
    484477      ///Increments a bounding box with a point
    485 
    486       ///Increments a bounding box with a point.
    487       ///
    488478      BoundingBox& add(const Point<T>& u){
    489479        if (_empty){
     
    500490      }
    501491   
    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
    506493      BoundingBox& add(const BoundingBox &u){
    507494        if ( !u.empty() ){
     
    513500 
    514501      ///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){
    519503        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;
    530510        return b;
    531511      }
     
    534514
    535515
    536   ///Map of x-coordinates of a \ref Point "Point"-map
    537 
    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
    540520  ///
    541521  template<class M>
     
    591571  ///Returns a \ref ConstXMap class
    592572
    593   ///This function just returns a \ref ConstXMap class.
     573  ///This function just returns an \ref ConstXMap class.
    594574  ///
    595575  ///\ingroup maps
     
    601581  }
    602582
    603   ///Map of y-coordinates of a \ref Point "Point"-map
     583  ///Map of y-coordinates of a dim2::Point<>-map
    604584   
    605585  ///\ingroup maps
    606   ///Map of y-coordinates of a \ref Point "Point"-map.
     586  ///Map of y-coordinates of a dim2::Point<>-map
    607587  ///
    608588  template<class M>
     
    620600  };
    621601
    622   ///Returns a \ref YMap class
    623 
    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.
    625605  ///
    626606  ///\ingroup maps
     
    658638  ///Returns a \ref ConstYMap class
    659639
    660   ///This function just returns a \ref ConstYMap class.
     640  ///This function just returns an \ref ConstYMap class.
    661641  ///
    662642  ///\ingroup maps
     
    670650
    671651    ///\brief Map of the \ref Point::normSquare() "normSquare()"
    672     ///of a \ref Point "Point"-map
     652    ///of an \ref Point "Point"-map
    673653    ///
    674654    ///Map of the \ref Point::normSquare() "normSquare()"
    675     ///of a \ref Point "Point"-map.
     655    ///of an \ref Point "Point"-map
    676656    ///\ingroup maps
    677657    ///
     
    691671  ///Returns a \ref NormSquareMap class
    692672
    693   ///This function just returns a \ref NormSquareMap class.
     673  ///This function just returns an \ref NormSquareMap class.
    694674  ///
    695675  ///\ingroup maps
Note: See TracChangeset for help on using the changeset viewer.