SUMO - Simulation of Urban MObility
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.dlr.de/
12 // Copyright (C) 2001-2016 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 
60  ~Boundary();
61 
63  void reset();
64 
66  void add(SUMOReal x, SUMOReal y, SUMOReal z = 0);
67 
69  void add(const Position& p);
70 
72  void add(const Boundary& p);
73 
75  Position getCenter() const;
76 
78  SUMOReal xmin() const;
79 
81  SUMOReal xmax() const;
82 
84  SUMOReal ymin() const;
85 
87  SUMOReal ymax() const;
88 
90  SUMOReal zmin() const;
91 
93  SUMOReal zmax() const;
94 
96  SUMOReal getWidth() const;
97 
99  SUMOReal getHeight() const;
100 
102  bool around(const Position& p, SUMOReal offset = 0) const;
103 
105  bool overlapsWith(const AbstractPoly& poly, SUMOReal offset = 0) const;
106 
108  bool partialWithin(const AbstractPoly& poly, SUMOReal offset = 0) const;
109 
111  bool crosses(const Position& p1, const Position& p2) const;
112 
113 
117  Boundary& grow(SUMOReal by);
118 
120  void growWidth(SUMOReal by);
121 
123  void growHeight(SUMOReal by);
124 
126  void flipY();
127 
130 
132  void moveby(SUMOReal x, SUMOReal y, SUMOReal z = 0);
133 
135  friend std::ostream& operator<<(std::ostream& os, const Boundary& b);
136 
137 private:
140 
143 
144 };
145 
146 
147 #endif
148 
149 /****************************************************************************/
150 
SUMOReal myXmin
The boundaries.
Definition: Boundary.h:139
void growWidth(SUMOReal by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:241
SUMOReal myXmax
Definition: Boundary.h:139
SUMOReal getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:172
bool overlapsWith(const AbstractPoly &poly, SUMOReal offset=0) const
Returns whether the boundary overlaps with the given polygon.
Definition: Boundary.cpp:187
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
Definition: Boundary.cpp:208
~Boundary()
Destructor.
Definition: Boundary.cpp:74
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:142
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:148
SUMOReal getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:166
SUMOReal myYmin
Definition: Boundary.h:139
friend std::ostream & operator<<(std::ostream &os, const Boundary &b)
Output operator.
Definition: Boundary.cpp:265
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:130
SUMOReal myYmax
Definition: Boundary.h:139
SUMOReal zmax() const
Returns maximum z-coordinate.
Definition: Boundary.cpp:160
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
SUMOReal myZmin
Definition: Boundary.h:139
bool myWasInitialised
Information whether the boundary was initialised.
Definition: Boundary.h:142
void reset()
Resets the boundary.
Definition: Boundary.cpp:78
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:232
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:136
void add(SUMOReal x, SUMOReal y, SUMOReal z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:90
void flipY()
flips ymin and ymax
Definition: Boundary.cpp:254
bool partialWithin(const AbstractPoly &poly, SUMOReal offset=0) const
Returns whether the boundary is partially within the given polygon.
Definition: Boundary.cpp:222
SUMOReal myZmax
Definition: Boundary.h:139
bool around(const Position &p, SUMOReal offset=0) const
Returns whether the boundary contains the given coordinate.
Definition: Boundary.cpp:178
SUMOReal zmin() const
Returns minimum z-coordinate.
Definition: Boundary.cpp:154
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:124
#define SUMOReal
Definition: config.h:213
void growHeight(SUMOReal by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:248
void moveby(SUMOReal x, SUMOReal y, SUMOReal z=0)
Moves the boundary by the given amount.
Definition: Boundary.cpp:281
Boundary()
Constructor - the boundary is unset.
Definition: Boundary.cpp:47