SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Boundary.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A class that stores a 2D geometrical boundary
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef Boundary_h
23 #define Boundary_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <iostream>
36 #include <utility>
37 #include "AbstractPoly.h"
38 #include "Position.h"
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
48 class Boundary
49  : public AbstractPoly {
50 public:
52  Boundary();
53 
55  Boundary(SUMOReal x1, SUMOReal y1, SUMOReal x2, SUMOReal y2);
56 
58  ~Boundary();
59 
61  void reset();
62 
64  void add(SUMOReal x, SUMOReal y);
65 
67  void add(const Position& p);
68 
70  void add(const Boundary& p);
71 
73  Position getCenter() const;
74 
76  SUMOReal xmin() const;
77 
79  SUMOReal xmax() const;
80 
82  SUMOReal ymin() const;
83 
85  SUMOReal ymax() const;
86 
88  SUMOReal getWidth() const;
89 
91  SUMOReal getHeight() const;
92 
94  bool around(const Position& p, SUMOReal offset = 0) const;
95 
97  bool overlapsWith(const AbstractPoly& poly, SUMOReal offset = 0) const;
98 
100  bool partialWithin(const AbstractPoly& poly, SUMOReal offset = 0) const;
101 
103  bool crosses(const Position& p1, const Position& p2) const;
104 
105 
109  Boundary& grow(SUMOReal by);
110 
111  void growWidth(SUMOReal by);
112 
113  void growHeight(SUMOReal by);
114 
116  void flipY();
117 
119  void set(SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax);
120 
122  void moveby(SUMOReal x, SUMOReal y);
123 
125  friend std::ostream& operator<<(std::ostream& os, const Boundary& b);
126 
127 private:
130 
133 
134 };
135 
136 
137 #endif
138 
139 /****************************************************************************/
140 
SUMOReal myXmin
The boundaries.
Definition: Boundary.h:129
SUMOReal getHeight() const
Returns the height of the boundary.
Definition: Boundary.cpp:142
void growWidth(SUMOReal by)
Definition: Boundary.cpp:209
SUMOReal myXmax
Definition: Boundary.h:129
SUMOReal getWidth() const
Returns the width of the boudary.
Definition: Boundary.cpp:136
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:106
bool around(const Position &p, SUMOReal offset=0) const
Returns whether the boundary contains the given coordinate.
Definition: Boundary.cpp:148
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
bool partialWithin(const AbstractPoly &poly, SUMOReal offset=0) const
Returns whether the boundary is partially within the given polygon.
Definition: Boundary.cpp:190
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:112
~Boundary()
Destructor.
Definition: Boundary.cpp:62
SUMOReal myYmin
Definition: Boundary.h:129
friend std::ostream & operator<<(std::ostream &os, const Boundary &b)
Output operator.
Definition: Boundary.cpp:233
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:118
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
SUMOReal myYmax
Definition: Boundary.h:129
void set(SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax)
Sets the boundary to the given values.
Definition: Boundary.cpp:240
bool overlapsWith(const AbstractPoly &poly, SUMOReal offset=0) const
Returns whether the boundary overlaps with the given polygon.
Definition: Boundary.cpp:156
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
bool myWasInitialised
Information whether the boundary was initialised.
Definition: Boundary.h:132
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
void reset()
Resets the boundary.
Definition: Boundary.cpp:66
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:200
void flipY()
flips ymin and ymax
Definition: Boundary.cpp:222
#define SUMOReal
Definition: config.h:215
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
void growHeight(SUMOReal by)
Definition: Boundary.cpp:216
void moveby(SUMOReal x, SUMOReal y)
Moves the boundary by the given amount.
Definition: Boundary.cpp:249
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
Definition: Boundary.cpp:177
Boundary()
Constructor - the boundary is unset.
Definition: Boundary.cpp:47