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-2017 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(double x1, double y1, double x2, double y2);
56 
57  Boundary(double x1, double y1, double z1, double x2, double y2, double z2);
58 
60  ~Boundary();
61 
63  void reset();
64 
66  void add(double x, double y, double z = 0);
67 
69  void add(const Position& p);
70 
72  void add(const Boundary& p);
73 
75  Position getCenter() const;
76 
78  double xmin() const;
79 
81  double xmax() const;
82 
84  double ymin() const;
85 
87  double ymax() const;
88 
90  double zmin() const;
91 
93  double zmax() const;
94 
96  double getWidth() const;
97 
99  double getHeight() const;
100 
102  double getZRange() const;
103 
105  bool around(const Position& p, double offset = 0) const;
106 
108  bool overlapsWith(const AbstractPoly& poly, double offset = 0) const;
109 
111  bool partialWithin(const AbstractPoly& poly, double offset = 0) const;
112 
114  bool crosses(const Position& p1, const Position& p2) const;
115 
117  double distanceTo2D(const Position& p) const;
118 
120  double distanceTo2D(const Boundary& b) const;
121 
122 
126  Boundary& grow(double by);
127 
129  void growWidth(double by);
130 
132  void growHeight(double by);
133 
135  void flipY();
136 
138  void set(double xmin, double ymin, double xmax, double ymax);
139 
141  void moveby(double x, double y, double z = 0);
142 
144  friend std::ostream& operator<<(std::ostream& os, const Boundary& b);
145 
146 private:
149 
152 
153 };
154 
155 
156 #endif
157 
158 /****************************************************************************/
159 
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:132
double zmax() const
Returns maximum z-coordinate.
Definition: Boundary.cpp:156
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:120
bool partialWithin(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary is partially within the given polygon.
Definition: Boundary.cpp:292
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:144
void moveby(double x, double y, double z=0)
Moves the boundary by the given amount.
Definition: Boundary.cpp:351
double myXmax
Definition: Boundary.h:148
~Boundary()
Destructor.
Definition: Boundary.cpp:70
double myZmax
Definition: Boundary.h:148
double myYmin
Definition: Boundary.h:148
double myYmax
Definition: Boundary.h:148
friend std::ostream & operator<<(std::ostream &os, const Boundary &b)
Output operator.
Definition: Boundary.cpp:335
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
double myXmin
The boundaries.
Definition: Boundary.h:148
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:162
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:168
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
Definition: Boundary.cpp:189
double myZmin
Definition: Boundary.h:148
bool myWasInitialised
Information whether the boundary was initialised.
Definition: Boundary.h:151
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:302
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:318
bool around(const Position &p, double offset=0) const
Returns whether the boundary contains the given coordinate.
Definition: Boundary.cpp:180
void reset()
Resets the boundary.
Definition: Boundary.cpp:74
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
Definition: Boundary.cpp:224
void flipY()
flips ymin and ymax
Definition: Boundary.cpp:324
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:126
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:311
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:138
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:86
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
Definition: Boundary.cpp:210
double getZRange() const
Returns the elevation range of the boundary (z-axis)
Definition: Boundary.cpp:174
Boundary()
Constructor - the boundary is unset.
Definition: Boundary.cpp:43
double zmin() const
Returns minimum z-coordinate.
Definition: Boundary.cpp:150