Eclipse SUMO - Simulation of Urban MObility
Boundary.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // A class that stores a 2D geometrical boundary
17 /****************************************************************************/
18 #ifndef Boundary_h
19 #define Boundary_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <iostream>
28 #include <utility>
29 
30 #include "AbstractPoly.h"
31 #include "Position.h"
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
41 class Boundary : public AbstractPoly {
42 public:
44  Boundary();
45 
47  Boundary(double x1, double y1, double x2, double y2);
48 
50  Boundary(double x1, double y1, double z1, double x2, double y2, double z2);
51 
53  ~Boundary();
54 
56  void reset();
57 
59  void add(double x, double y, double z = 0);
60 
62  void add(const Position& p);
63 
65  void add(const Boundary& p);
66 
68  Position getCenter() const;
69 
71  double xmin() const;
72 
74  double xmax() const;
75 
77  double ymin() const;
78 
80  double ymax() const;
81 
83  double zmin() const;
84 
86  double zmax() const;
87 
89  double getWidth() const;
90 
92  double getHeight() const;
93 
95  double getZRange() const;
96 
100  bool around(const Position& p, double offset = 0) const;
101 
103  bool overlapsWith(const AbstractPoly& poly, double offset = 0) const;
104 
106  bool partialWithin(const AbstractPoly& poly, double offset = 0) const;
107 
109  bool crosses(const Position& p1, const Position& p2) const;
111 
113  bool isInitialised() const;
114 
116  double distanceTo2D(const Position& p) const;
117 
119  double distanceTo2D(const Boundary& b) const;
120 
124  Boundary& grow(double by);
125 
127  void growWidth(double by);
128 
130  void growHeight(double by);
131 
133  void flipY();
134 
136  void set(double xmin, double ymin, double xmax, double ymax);
137 
139  void moveby(double x, double y, double z = 0);
140 
142  friend std::ostream& operator<<(std::ostream& os, const Boundary& b);
143 
145  bool operator==(const Boundary& b) const;
146 
148  bool operator!=(const Boundary& b) const;
149 
150 private:
153 
156 };
157 
158 
159 #endif
160 
161 /****************************************************************************/
162 
AbstractPoly
Definition: AbstractPoly.h:35
Boundary::moveby
void moveby(double x, double y, double z=0)
Moves the boundary by the given amount.
Definition: Boundary.cpp:368
Boundary::getZRange
double getZRange() const
Returns the elevation range of the boundary (z-axis)
Definition: Boundary.cpp:166
Boundary::myXmax
double myXmax
Definition: Boundary.h:152
Boundary::zmax
double zmax() const
Returns maximum z-coordinate.
Definition: Boundary.cpp:148
Boundary::ymin
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:130
Boundary::distanceTo2D
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
Definition: Boundary.cpp:222
Boundary::myYmin
double myYmin
Definition: Boundary.h:152
Boundary::myYmax
double myYmax
Definition: Boundary.h:152
Boundary::myZmax
double myZmax
Definition: Boundary.h:152
Boundary::xmax
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:124
Boundary::partialWithin
bool partialWithin(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary is partially within the given polygon.
Definition: Boundary.cpp:290
Boundary::getHeight
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:160
Boundary::around
bool around(const Position &p, double offset=0) const
Returns whether the AbstractPoly the given coordinate.
Definition: Boundary.cpp:172
Boundary::myZmin
double myZmin
Definition: Boundary.h:152
Boundary::reset
void reset()
Resets the boundary.
Definition: Boundary.cpp:66
Boundary::set
void set(double xmin, double ymin, double xmax, double ymax)
Sets the boundary to the given values.
Definition: Boundary.cpp:359
Boundary::xmin
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:118
AbstractPoly.h
Boundary::operator<<
friend std::ostream & operator<<(std::ostream &os, const Boundary &b)
Output operator.
Definition: Boundary.cpp:333
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
Boundary::getWidth
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:154
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
Boundary::add
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:78
Boundary::crosses
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
Definition: Boundary.cpp:202
Boundary::growWidth
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:309
Boundary::myXmin
double myXmin
The boundaries.
Definition: Boundary.h:152
Position.h
Boundary::myWasInitialised
bool myWasInitialised
Information whether the boundary was initialised.
Definition: Boundary.h:155
Boundary::operator!=
bool operator!=(const Boundary &b) const
Comparison operator not equal.
Definition: Boundary.cpp:353
Boundary::getCenter
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:112
Boundary::operator==
bool operator==(const Boundary &b) const
Comparison operator equal.
Definition: Boundary.cpp:340
config.h
Boundary::isInitialised
bool isInitialised() const
check if Boundary is Initialised
Definition: Boundary.cpp:216
Boundary::grow
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
Boundary::Boundary
Boundary()
Constructor - the boundary is unset.
Definition: Boundary.cpp:35
Boundary::~Boundary
~Boundary()
Destructor.
Definition: Boundary.cpp:62
Boundary::flipY
void flipY()
flips ymin and ymax
Definition: Boundary.cpp:322
Boundary::zmin
double zmin() const
Returns minimum z-coordinate.
Definition: Boundary.cpp:142
Boundary::growHeight
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:316
Boundary::ymax
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:136
Boundary::overlapsWith
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
Definition: Boundary.cpp:181