1.1 --- a/src/lemon/concept/graph.h Mon May 16 21:49:35 2005 +0000
1.2 +++ b/src/lemon/concept/graph.h Wed May 18 09:39:06 2005 +0000
1.3 @@ -36,61 +36,61 @@
1.4 /**************** The full-featured graph concepts ****************/
1.5
1.6
1.7 - /// \brief Modular builded static graph class.
1.8 + /// \brief Modular static graph class.
1.9 ///
1.10 /// It should be the same as the \c StaticGraph class.
1.11 class _StaticGraph
1.12 : virtual public BaseGraphComponent,
1.13 - public IterableGraphComponent, public MappableGraphComponent {
1.14 + public IterableGraphComponent, public MappableGraphComponent {
1.15 public:
1.16 typedef BaseGraphComponent::Node Node;
1.17 typedef BaseGraphComponent::Edge Edge;
1.18
1.19 template <typename _Graph>
1.20 struct Constraints {
1.21 - void constraints() {
1.22 - checkConcept<IterableGraphComponent, _Graph>();
1.23 - checkConcept<MappableGraphComponent, _Graph>();
1.24 - }
1.25 + void constraints() {
1.26 + checkConcept<IterableGraphComponent, _Graph>();
1.27 + checkConcept<MappableGraphComponent, _Graph>();
1.28 + }
1.29 };
1.30 };
1.31
1.32 - /// \brief Modular builded extendable graph class.
1.33 + /// \brief Modular extendable graph class.
1.34 ///
1.35 /// It should be the same as the \c ExtendableGraph class.
1.36 class _ExtendableGraph
1.37 : virtual public BaseGraphComponent, public _StaticGraph,
1.38 - public ExtendableGraphComponent, public ClearableGraphComponent {
1.39 + public ExtendableGraphComponent, public ClearableGraphComponent {
1.40 public:
1.41 typedef BaseGraphComponent::Node Node;
1.42 typedef BaseGraphComponent::Edge Edge;
1.43
1.44 template <typename _Graph>
1.45 struct Constraints {
1.46 - void constraints() {
1.47 - checkConcept<_StaticGraph, _Graph >();
1.48 - checkConcept<ExtendableGraphComponent, _Graph >();
1.49 - checkConcept<ClearableGraphComponent, _Graph >();
1.50 - }
1.51 + void constraints() {
1.52 + checkConcept<_StaticGraph, _Graph >();
1.53 + checkConcept<ExtendableGraphComponent, _Graph >();
1.54 + checkConcept<ClearableGraphComponent, _Graph >();
1.55 + }
1.56 };
1.57 };
1.58
1.59 - /// \brief Modular builded erasable graph class.
1.60 + /// \brief Modular erasable graph class.
1.61 ///
1.62 /// It should be the same as the \c ErasableGraph class.
1.63 class _ErasableGraph
1.64 : virtual public BaseGraphComponent, public _ExtendableGraph,
1.65 - public ErasableGraphComponent {
1.66 + public ErasableGraphComponent {
1.67 public:
1.68 typedef BaseGraphComponent::Node Node;
1.69 typedef BaseGraphComponent::Edge Edge;
1.70
1.71 template <typename _Graph>
1.72 struct Constraints {
1.73 - void constraints() {
1.74 - checkConcept<_ExtendableGraph, _Graph >();
1.75 - checkConcept<ErasableGraphComponent, _Graph >();
1.76 - }
1.77 + void constraints() {
1.78 + checkConcept<_ExtendableGraph, _Graph >();
1.79 + checkConcept<ErasableGraphComponent, _Graph >();
1.80 + }
1.81 };
1.82 };
1.83
1.84 @@ -135,33 +135,33 @@
1.85 /// from the trivial node iterator.
1.86 class Node {
1.87 public:
1.88 - /// Default constructor
1.89 + /// Default constructor
1.90
1.91 - /// @warning The default constructor sets the iterator
1.92 - /// to an undefined value.
1.93 - Node() { }
1.94 - /// Copy constructor.
1.95 + /// @warning The default constructor sets the iterator
1.96 + /// to an undefined value.
1.97 + Node() { }
1.98 + /// Copy constructor.
1.99
1.100 - /// Copy constructor.
1.101 - ///
1.102 - Node(const Node&) { }
1.103 + /// Copy constructor.
1.104 + ///
1.105 + Node(const Node&) { }
1.106
1.107 - /// Invalid constructor \& conversion.
1.108 + /// Invalid constructor \& conversion.
1.109
1.110 - /// This constructor initializes the iterator to be invalid.
1.111 - /// \sa Invalid for more details.
1.112 - Node(Invalid) { }
1.113 - /// Equality operator
1.114 + /// This constructor initializes the iterator to be invalid.
1.115 + /// \sa Invalid for more details.
1.116 + Node(Invalid) { }
1.117 + /// Equality operator
1.118
1.119 - /// Two iterators are equal if and only if they point to the
1.120 - /// same object or both are invalid.
1.121 - bool operator==(Node) const { return true; }
1.122 + /// Two iterators are equal if and only if they point to the
1.123 + /// same object or both are invalid.
1.124 + bool operator==(Node) const { return true; }
1.125
1.126 - /// Inequality operator
1.127 -
1.128 - /// \sa operator==(Node n)
1.129 - ///
1.130 - bool operator!=(Node) const { return true; }
1.131 + /// Inequality operator
1.132 +
1.133 + /// \sa operator==(Node n)
1.134 + ///
1.135 + bool operator!=(Node) const { return true; }
1.136
1.137 };
1.138
1.139 @@ -172,42 +172,42 @@
1.140 /// of nodes in graph \c g of type \c Graph like this:
1.141 /// \code
1.142 /// int count=0;
1.143 - /// for (Graph::NodeIt n(g); n!=INVALID ++n) ++count;
1.144 + /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
1.145 /// \endcode
1.146 class NodeIt : public Node {
1.147 public:
1.148 - /// Default constructor
1.149 + /// Default constructor
1.150
1.151 - /// @warning The default constructor sets the iterator
1.152 - /// to an undefined value.
1.153 - NodeIt() { }
1.154 - /// Copy constructor.
1.155 -
1.156 - /// Copy constructor.
1.157 - ///
1.158 - NodeIt(const NodeIt& n) : Node(n) { }
1.159 - /// Invalid constructor \& conversion.
1.160 + /// @warning The default constructor sets the iterator
1.161 + /// to an undefined value.
1.162 + NodeIt() { }
1.163 + /// Copy constructor.
1.164 +
1.165 + /// Copy constructor.
1.166 + ///
1.167 + NodeIt(const NodeIt& n) : Node(n) { }
1.168 + /// Invalid constructor \& conversion.
1.169
1.170 - /// Initialize the iterator to be invalid.
1.171 - /// \sa Invalid for more details.
1.172 - NodeIt(Invalid) { }
1.173 - /// Sets the iterator to the first node.
1.174 + /// Initialize the iterator to be invalid.
1.175 + /// \sa Invalid for more details.
1.176 + NodeIt(Invalid) { }
1.177 + /// Sets the iterator to the first node.
1.178
1.179 - /// Sets the iterator to the first node of \c g.
1.180 - ///
1.181 - NodeIt(const StaticGraph&) { }
1.182 - /// Node -> NodeIt conversion.
1.183 + /// Sets the iterator to the first node of \c g.
1.184 + ///
1.185 + NodeIt(const StaticGraph&) { }
1.186 + /// Node -> NodeIt conversion.
1.187
1.188 - /// Sets the iterator to the node of \c g pointed by the trivial
1.189 - /// iterator n.
1.190 - /// This feature necessitates that each time we
1.191 - /// iterate the edge-set, the iteration order is the same.
1.192 - NodeIt(const StaticGraph& g, const Node& n) { }
1.193 - /// Next node.
1.194 + /// Sets the iterator to the node of \c g pointed by the trivial
1.195 + /// iterator n.
1.196 + /// This feature necessitates that each time we
1.197 + /// iterate the edge-set, the iteration order is the same.
1.198 + NodeIt(const StaticGraph& g, const Node& n) { }
1.199 + /// Next node.
1.200
1.201 - /// Assign the iterator to the next node.
1.202 - ///
1.203 - NodeIt& operator++() { return *this; }
1.204 + /// Assign the iterator to the next node.
1.205 + ///
1.206 + NodeIt& operator++() { return *this; }
1.207 };
1.208
1.209
1.210 @@ -217,31 +217,31 @@
1.211 ///
1.212 class Edge {
1.213 public:
1.214 - /// Default constructor
1.215 + /// Default constructor
1.216
1.217 - /// @warning The default constructor sets the iterator
1.218 - /// to an undefined value.
1.219 - Edge() { }
1.220 - /// Copy constructor.
1.221 + /// @warning The default constructor sets the iterator
1.222 + /// to an undefined value.
1.223 + Edge() { }
1.224 + /// Copy constructor.
1.225
1.226 - /// Copy constructor.
1.227 - ///
1.228 - Edge(const Edge&) { }
1.229 - /// Initialize the iterator to be invalid.
1.230 + /// Copy constructor.
1.231 + ///
1.232 + Edge(const Edge&) { }
1.233 + /// Initialize the iterator to be invalid.
1.234
1.235 - /// Initialize the iterator to be invalid.
1.236 - ///
1.237 - Edge(Invalid) { }
1.238 - /// Equality operator
1.239 + /// Initialize the iterator to be invalid.
1.240 + ///
1.241 + Edge(Invalid) { }
1.242 + /// Equality operator
1.243
1.244 - /// Two iterators are equal if and only if they point to the
1.245 - /// same object or both are invalid.
1.246 - bool operator==(Edge) const { return true; }
1.247 - /// Inequality operator
1.248 + /// Two iterators are equal if and only if they point to the
1.249 + /// same object or both are invalid.
1.250 + bool operator==(Edge) const { return true; }
1.251 + /// Inequality operator
1.252
1.253 - /// \sa operator==(Node n)
1.254 - ///
1.255 - bool operator!=(Edge) const { return true; }
1.256 + /// \sa operator==(Node n)
1.257 + ///
1.258 + bool operator!=(Edge) const { return true; }
1.259 };
1.260
1.261 /// This iterator goes trough the outgoing edges of a node.
1.262 @@ -258,39 +258,39 @@
1.263
1.264 class OutEdgeIt : public Edge {
1.265 public:
1.266 - /// Default constructor
1.267 + /// Default constructor
1.268
1.269 - /// @warning The default constructor sets the iterator
1.270 - /// to an undefined value.
1.271 - OutEdgeIt() { }
1.272 - /// Copy constructor.
1.273 + /// @warning The default constructor sets the iterator
1.274 + /// to an undefined value.
1.275 + OutEdgeIt() { }
1.276 + /// Copy constructor.
1.277
1.278 - /// Copy constructor.
1.279 - ///
1.280 - OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
1.281 - /// Initialize the iterator to be invalid.
1.282 + /// Copy constructor.
1.283 + ///
1.284 + OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
1.285 + /// Initialize the iterator to be invalid.
1.286
1.287 - /// Initialize the iterator to be invalid.
1.288 - ///
1.289 - OutEdgeIt(Invalid) { }
1.290 - /// This constructor sets the iterator to first outgoing edge.
1.291 + /// Initialize the iterator to be invalid.
1.292 + ///
1.293 + OutEdgeIt(Invalid) { }
1.294 + /// This constructor sets the iterator to the first outgoing edge.
1.295
1.296 - /// This constructor set the iterator to the first outgoing edge of
1.297 - /// node
1.298 - ///@param n the node
1.299 - ///@param g the graph
1.300 - OutEdgeIt(const StaticGraph&, const Node&) { }
1.301 - /// Edge -> OutEdgeIt conversion
1.302 + /// This constructor sets the iterator to the first outgoing edge of
1.303 + /// the node.
1.304 + ///@param n the node
1.305 + ///@param g the graph
1.306 + OutEdgeIt(const StaticGraph&, const Node&) { }
1.307 + /// Edge -> OutEdgeIt conversion
1.308
1.309 - /// Sets the iterator to the value of the trivial iterator \c e.
1.310 - /// This feature necessitates that each time we
1.311 - /// iterate the edge-set, the iteration order is the same.
1.312 - OutEdgeIt(const StaticGraph& g, const Edge& e) { }
1.313 - ///Next outgoing edge
1.314 -
1.315 - /// Assign the iterator to the next
1.316 - /// outgoing edge of the corresponding node.
1.317 - OutEdgeIt& operator++() { return *this; }
1.318 + /// Sets the iterator to the value of the trivial iterator \c e.
1.319 + /// This feature necessitates that each time we
1.320 + /// iterate the edge-set, the iteration order is the same.
1.321 + OutEdgeIt(const StaticGraph& g, const Edge& e) { }
1.322 + ///Next outgoing edge
1.323 +
1.324 + /// Assign the iterator to the next
1.325 + /// outgoing edge of the corresponding node.
1.326 + OutEdgeIt& operator++() { return *this; }
1.327 };
1.328
1.329 /// This iterator goes trough the incoming edges of a node.
1.330 @@ -307,39 +307,39 @@
1.331
1.332 class InEdgeIt : public Edge {
1.333 public:
1.334 - /// Default constructor
1.335 + /// Default constructor
1.336
1.337 - /// @warning The default constructor sets the iterator
1.338 - /// to an undefined value.
1.339 - InEdgeIt() { }
1.340 - /// Copy constructor.
1.341 + /// @warning The default constructor sets the iterator
1.342 + /// to an undefined value.
1.343 + InEdgeIt() { }
1.344 + /// Copy constructor.
1.345
1.346 - /// Copy constructor.
1.347 - ///
1.348 - InEdgeIt(const InEdgeIt& e) : Edge(e) { }
1.349 - /// Initialize the iterator to be invalid.
1.350 + /// Copy constructor.
1.351 + ///
1.352 + InEdgeIt(const InEdgeIt& e) : Edge(e) { }
1.353 + /// Initialize the iterator to be invalid.
1.354
1.355 - /// Initialize the iterator to be invalid.
1.356 - ///
1.357 - InEdgeIt(Invalid) { }
1.358 - /// This constructor sets the iterator to first incoming edge.
1.359 + /// Initialize the iterator to be invalid.
1.360 + ///
1.361 + InEdgeIt(Invalid) { }
1.362 + /// This constructor sets the iterator to first incoming edge.
1.363
1.364 - /// This constructor set the iterator to the first incoming edge of
1.365 - /// node
1.366 - ///@param n the node
1.367 - ///@param g the graph
1.368 - InEdgeIt(const StaticGraph&, const Node&) { }
1.369 - /// Edge -> InEdgeIt conversion
1.370 + /// This constructor set the iterator to the first incoming edge of
1.371 + /// the node.
1.372 + ///@param n the node
1.373 + ///@param g the graph
1.374 + InEdgeIt(const StaticGraph&, const Node&) { }
1.375 + /// Edge -> InEdgeIt conversion
1.376
1.377 - /// Sets the iterator to the value of the trivial iterator \c e.
1.378 - /// This feature necessitates that each time we
1.379 - /// iterate the edge-set, the iteration order is the same.
1.380 - InEdgeIt(const StaticGraph&, const Edge&) { }
1.381 - /// Next incoming edge
1.382 + /// Sets the iterator to the value of the trivial iterator \c e.
1.383 + /// This feature necessitates that each time we
1.384 + /// iterate the edge-set, the iteration order is the same.
1.385 + InEdgeIt(const StaticGraph&, const Edge&) { }
1.386 + /// Next incoming edge
1.387
1.388 - /// Assign the iterator to the next inedge of the corresponding node.
1.389 - ///
1.390 - InEdgeIt& operator++() { return *this; }
1.391 + /// Assign the iterator to the next inedge of the corresponding node.
1.392 + ///
1.393 + InEdgeIt& operator++() { return *this; }
1.394 };
1.395 /// This iterator goes through each edge.
1.396
1.397 @@ -352,38 +352,36 @@
1.398 /// \endcode
1.399 class EdgeIt : public Edge {
1.400 public:
1.401 - /// Default constructor
1.402 + /// Default constructor
1.403
1.404 - /// @warning The default constructor sets the iterator
1.405 - /// to an undefined value.
1.406 - EdgeIt() { }
1.407 - /// Copy constructor.
1.408 + /// @warning The default constructor sets the iterator
1.409 + /// to an undefined value.
1.410 + EdgeIt() { }
1.411 + /// Copy constructor.
1.412
1.413 - /// Copy constructor.
1.414 - ///
1.415 - EdgeIt(const EdgeIt& e) : Edge(e) { }
1.416 - /// Initialize the iterator to be invalid.
1.417 + /// Copy constructor.
1.418 + ///
1.419 + EdgeIt(const EdgeIt& e) : Edge(e) { }
1.420 + /// Initialize the iterator to be invalid.
1.421
1.422 - /// Initialize the iterator to be invalid.
1.423 - ///
1.424 - EdgeIt(Invalid) { }
1.425 - /// This constructor sets the iterator to first edge.
1.426 + /// Initialize the iterator to be invalid.
1.427 + ///
1.428 + EdgeIt(Invalid) { }
1.429 + /// This constructor sets the iterator to the first edge.
1.430
1.431 - /// This constructor set the iterator to the first edge of
1.432 - /// node
1.433 - ///@param g the graph
1.434 - EdgeIt(const StaticGraph&) { }
1.435 - /// Edge -> EdgeIt conversion
1.436 + /// This constructor sets the iterator to the first edge of \c g.
1.437 + ///@param g the graph
1.438 + EdgeIt(const StaticGraph&) { }
1.439 + /// Edge -> EdgeIt conversion
1.440
1.441 - /// Sets the iterator to the value of the trivial iterator \c e.
1.442 - /// This feature necessitates that each time we
1.443 - /// iterate the edge-set, the iteration order is the same.
1.444 - EdgeIt(const StaticGraph&, const Edge&) { }
1.445 - ///Next edge
1.446 -
1.447 - /// Assign the iterator to the next
1.448 - /// edge of the corresponding node.
1.449 - EdgeIt& operator++() { return *this; }
1.450 + /// Sets the iterator to the value of the trivial iterator \c e.
1.451 + /// This feature necessitates that each time we
1.452 + /// iterate the edge-set, the iteration order is the same.
1.453 + EdgeIt(const StaticGraph&, const Edge&) { }
1.454 + ///Next edge
1.455 +
1.456 + /// Assign the iterator to the next edge.
1.457 + EdgeIt& operator++() { return *this; }
1.458 };
1.459 ///Gives back the target node of an edge.
1.460
1.461 @@ -407,16 +405,16 @@
1.462 {
1.463 public:
1.464
1.465 - ///\e
1.466 - NodeMap(const StaticGraph&) { }
1.467 - ///\e
1.468 - NodeMap(const StaticGraph&, T) { }
1.469 + ///\e
1.470 + NodeMap(const StaticGraph&) { }
1.471 + ///\e
1.472 + NodeMap(const StaticGraph&, T) { }
1.473
1.474 - ///Copy constructor
1.475 - NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
1.476 - ///Assignment operator
1.477 - NodeMap& operator=(const NodeMap&) { return *this; }
1.478 - // \todo fix this concept
1.479 + ///Copy constructor
1.480 + NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
1.481 + ///Assignment operator
1.482 + NodeMap& operator=(const NodeMap&) { return *this; }
1.483 + // \todo fix this concept
1.484 };
1.485
1.486 /// Read write map of the edges to type \c T.
1.487 @@ -431,15 +429,15 @@
1.488 {
1.489 public:
1.490
1.491 - ///\e
1.492 - EdgeMap(const StaticGraph&) { }
1.493 - ///\e
1.494 - EdgeMap(const StaticGraph&, T) { }
1.495 - ///Copy constructor
1.496 - EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
1.497 - ///Assignment operator
1.498 - EdgeMap& operator=(const EdgeMap&) { return *this; }
1.499 - // \todo fix this concept
1.500 + ///\e
1.501 + EdgeMap(const StaticGraph&) { }
1.502 + ///\e
1.503 + EdgeMap(const StaticGraph&, T) { }
1.504 + ///Copy constructor
1.505 + EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
1.506 + ///Assignment operator
1.507 + EdgeMap& operator=(const EdgeMap&) { return *this; }
1.508 + // \todo fix this concept
1.509 };
1.510
1.511 template <typename _Graph>
1.512 @@ -449,9 +447,8 @@
1.513
1.514 /// An empty non-static graph class.
1.515
1.516 - /// This class provides everything that \ref StaticGraph
1.517 - /// with additional functionality which enables to build a
1.518 - /// graph from scratch.
1.519 + /// This class provides everything that \ref StaticGraph does.
1.520 + /// Additionally it enables building graphs from scratch.
1.521 class ExtendableGraph : public StaticGraph
1.522 {
1.523 public:
1.524 @@ -486,7 +483,7 @@
1.525
1.526 /// An empty erasable graph class.
1.527
1.528 - /// This class is an extension of \ref ExtendableGraph. It also makes it
1.529 + /// This class is an extension of \ref ExtendableGraph. It makes it
1.530 /// possible to erase edges or nodes.
1.531 class ErasableGraph : public ExtendableGraph
1.532 {
2.1 --- a/src/lemon/xy.h Mon May 16 21:49:35 2005 +0000
2.2 +++ b/src/lemon/xy.h Wed May 18 09:39:06 2005 +0000
2.3 @@ -29,7 +29,7 @@
2.4 /// operations.
2.5 ///
2.6 /// The class \ref lemon::BoundingBox "BoundingBox" can be used to determine
2.7 -/// the rectangular bounding box a set of \ref lemon::xy "xy"'s.
2.8 +/// the rectangular bounding box of a set of \ref lemon::xy "xy"'s.
2.9 ///
2.10 ///\author Attila Bernath
2.11
2.12 @@ -67,81 +67,81 @@
2.13
2.14 ///Gives back the square of the norm of the vector
2.15 T normSquare() const {
2.16 - return x*x+y*y;
2.17 + return x*x+y*y;
2.18 }
2.19
2.20 ///Increments the left hand side by u
2.21 xy<T>& operator +=(const xy<T>& u) {
2.22 - x += u.x;
2.23 - y += u.y;
2.24 - return *this;
2.25 + x += u.x;
2.26 + y += u.y;
2.27 + return *this;
2.28 }
2.29
2.30 ///Decrements the left hand side by u
2.31 xy<T>& operator -=(const xy<T>& u) {
2.32 - x -= u.x;
2.33 - y -= u.y;
2.34 - return *this;
2.35 + x -= u.x;
2.36 + y -= u.y;
2.37 + return *this;
2.38 }
2.39
2.40 ///Multiplying the left hand side with a scalar
2.41 xy<T>& operator *=(const T &u) {
2.42 - x *= u;
2.43 - y *= u;
2.44 - return *this;
2.45 + x *= u;
2.46 + y *= u;
2.47 + return *this;
2.48 }
2.49
2.50 ///Dividing the left hand side by a scalar
2.51 xy<T>& operator /=(const T &u) {
2.52 - x /= u;
2.53 - y /= u;
2.54 - return *this;
2.55 + x /= u;
2.56 + y /= u;
2.57 + return *this;
2.58 }
2.59
2.60 ///Returns the scalar product of two vectors
2.61 T operator *(const xy<T>& u) const {
2.62 - return x*u.x+y*u.y;
2.63 + return x*u.x+y*u.y;
2.64 }
2.65
2.66 ///Returns the sum of two vectors
2.67 xy<T> operator+(const xy<T> &u) const {
2.68 - xy<T> b=*this;
2.69 - return b+=u;
2.70 + xy<T> b=*this;
2.71 + return b+=u;
2.72 }
2.73
2.74 ///Returns the neg of the vectors
2.75 xy<T> operator-() const {
2.76 - xy<T> b=*this;
2.77 - b.x=-b.x; b.y=-b.y;
2.78 - return b;
2.79 + xy<T> b=*this;
2.80 + b.x=-b.x; b.y=-b.y;
2.81 + return b;
2.82 }
2.83
2.84 ///Returns the difference of two vectors
2.85 xy<T> operator-(const xy<T> &u) const {
2.86 - xy<T> b=*this;
2.87 - return b-=u;
2.88 + xy<T> b=*this;
2.89 + return b-=u;
2.90 }
2.91
2.92 ///Returns a vector multiplied by a scalar
2.93 xy<T> operator*(const T &u) const {
2.94 - xy<T> b=*this;
2.95 - return b*=u;
2.96 + xy<T> b=*this;
2.97 + return b*=u;
2.98 }
2.99
2.100 ///Returns a vector divided by a scalar
2.101 xy<T> operator/(const T &u) const {
2.102 - xy<T> b=*this;
2.103 - return b/=u;
2.104 + xy<T> b=*this;
2.105 + return b/=u;
2.106 }
2.107
2.108 ///Testing equality
2.109 bool operator==(const xy<T> &u) const {
2.110 - return (x==u.x) && (y==u.y);
2.111 + return (x==u.x) && (y==u.y);
2.112 }
2.113
2.114 ///Testing inequality
2.115 bool operator!=(xy u) const {
2.116 - return (x!=u.x) || (y!=u.y);
2.117 + return (x!=u.x) || (y!=u.y);
2.118 }
2.119
2.120 };
2.121 @@ -229,116 +229,116 @@
2.122 bool _empty;
2.123 public:
2.124
2.125 - ///Default constructor: an empty bounding box
2.126 + ///Default constructor: creates an empty bounding box
2.127 BoundingBox() { _empty = true; }
2.128
2.129 ///Constructing the instance from one point
2.130 BoundingBox(xy<T> a) { bottom_left=top_right=a; _empty = false; }
2.131
2.132 - ///Is there any point added
2.133 + ///Were any points added?
2.134 bool empty() const {
2.135 - return _empty;
2.136 + return _empty;
2.137 }
2.138
2.139 ///Makes the BoundingBox empty
2.140 void clear() {
2.141 - _empty=1;
2.142 + _empty=1;
2.143 }
2.144
2.145 ///Gives back the bottom left corner (if the bounding box is empty, then the return value is not defined)
2.146 xy<T> bottomLeft() const {
2.147 - return bottom_left;
2.148 + return bottom_left;
2.149 }
2.150
2.151 ///Gives back the top right corner (if the bounding box is empty, then the return value is not defined)
2.152 xy<T> topRight() const {
2.153 - return top_right;
2.154 + return top_right;
2.155 }
2.156
2.157 ///Gives back the bottom right corner (if the bounding box is empty, then the return value is not defined)
2.158 xy<T> bottomRight() const {
2.159 - return xy<T>(top_right.x,bottom_left.y);
2.160 + return xy<T>(top_right.x,bottom_left.y);
2.161 }
2.162
2.163 ///Gives back the top left corner (if the bounding box is empty, then the return value is not defined)
2.164 xy<T> topLeft() const {
2.165 - return xy<T>(bottom_left.x,top_right.y);
2.166 + return xy<T>(bottom_left.x,top_right.y);
2.167 }
2.168
2.169 ///Gives back the bottom of the box (if the bounding box is empty, then the return value is not defined)
2.170 T bottom() const {
2.171 - return bottom_left.y;
2.172 + return bottom_left.y;
2.173 }
2.174
2.175 ///Gives back the top of the box (if the bounding box is empty, then the return value is not defined)
2.176 T top() const {
2.177 - return top_right.y;
2.178 + return top_right.y;
2.179 }
2.180
2.181 ///Gives back the left side of the box (if the bounding box is empty, then the return value is not defined)
2.182 T left() const {
2.183 - return bottom_left.x;
2.184 + return bottom_left.x;
2.185 }
2.186
2.187 ///Gives back the right side of the box (if the bounding box is empty, then the return value is not defined)
2.188 T right() const {
2.189 - return top_right.x;
2.190 + return top_right.x;
2.191 }
2.192
2.193 ///Gives back the height of the box (if the bounding box is empty, then the return value is not defined)
2.194 T height() const {
2.195 - return top_right.y-bottom_left.y;
2.196 + return top_right.y-bottom_left.y;
2.197 }
2.198
2.199 ///Gives back the width of the box (if the bounding box is empty, then the return value is not defined)
2.200 T width() const {
2.201 - return top_right.x-bottom_left.x;
2.202 + return top_right.x-bottom_left.x;
2.203 }
2.204
2.205 ///Checks whether a point is inside a bounding box
2.206 bool inside(const xy<T>& u){
2.207 - if (_empty)
2.208 - return false;
2.209 - else{
2.210 - return ((u.x-bottom_left.x)*(top_right.x-u.x) >= 0 &&
2.211 - (u.y-bottom_left.y)*(top_right.y-u.y) >= 0 );
2.212 - }
2.213 + if (_empty)
2.214 + return false;
2.215 + else{
2.216 + return ((u.x-bottom_left.x)*(top_right.x-u.x) >= 0 &&
2.217 + (u.y-bottom_left.y)*(top_right.y-u.y) >= 0 );
2.218 + }
2.219 }
2.220
2.221 ///Increments a bounding box with a point
2.222 BoundingBox& operator +=(const xy<T>& u){
2.223 - if (_empty){
2.224 - bottom_left=top_right=u;
2.225 - _empty = false;
2.226 - }
2.227 - else{
2.228 - if (bottom_left.x > u.x) bottom_left.x = u.x;
2.229 - if (bottom_left.y > u.y) bottom_left.y = u.y;
2.230 - if (top_right.x < u.x) top_right.x = u.x;
2.231 - if (top_right.y < u.y) top_right.y = u.y;
2.232 - }
2.233 - return *this;
2.234 + if (_empty){
2.235 + bottom_left=top_right=u;
2.236 + _empty = false;
2.237 + }
2.238 + else{
2.239 + if (bottom_left.x > u.x) bottom_left.x = u.x;
2.240 + if (bottom_left.y > u.y) bottom_left.y = u.y;
2.241 + if (top_right.x < u.x) top_right.x = u.x;
2.242 + if (top_right.y < u.y) top_right.y = u.y;
2.243 + }
2.244 + return *this;
2.245 }
2.246
2.247 ///Sums a bounding box and a point
2.248 BoundingBox operator +(const xy<T>& u){
2.249 - BoundingBox b = *this;
2.250 - return b += u;
2.251 + BoundingBox b = *this;
2.252 + return b += u;
2.253 }
2.254
2.255 ///Increments a bounding box with an other bounding box
2.256 BoundingBox& operator +=(const BoundingBox &u){
2.257 - if ( !u.empty() ){
2.258 - *this += u.bottomLeft();
2.259 - *this += u.topRight();
2.260 - }
2.261 - return *this;
2.262 + if ( !u.empty() ){
2.263 + *this += u.bottomLeft();
2.264 + *this += u.topRight();
2.265 + }
2.266 + return *this;
2.267 }
2.268
2.269 ///Sums two bounding boxes
2.270 BoundingBox operator +(const BoundingBox& u){
2.271 - BoundingBox b = *this;
2.272 - return b += u;
2.273 + BoundingBox b = *this;
2.274 + return b += u;
2.275 }
2.276
2.277 };//class Boundingbox