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 /****************************************************************************/
17 // A class that stores a 2D geometrical boundary
18 /****************************************************************************/
19 #ifndef Boundary_h
20 #define Boundary_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <iostream>
29 #include <utility>
30 
31 #include "AbstractPoly.h"
32 #include "Position.h"
33 
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
42 class Boundary : public AbstractPoly {
43 public:
45  Boundary();
46 
48  Boundary(double x1, double y1, double x2, double y2);
49 
51  Boundary(double x1, double y1, double z1, double x2, double y2, double z2);
52 
54  ~Boundary();
55 
57  void reset();
58 
60  void add(double x, double y, double z = 0);
61 
63  void add(const Position& p);
64 
66  void add(const Boundary& p);
67 
69  Position getCenter() const;
70 
72  double xmin() const;
73 
75  double xmax() const;
76 
78  double ymin() const;
79 
81  double ymax() const;
82 
84  double zmin() const;
85 
87  double zmax() const;
88 
90  double getWidth() const;
91 
93  double getHeight() const;
94 
96  double getZRange() const;
97 
101  bool around(const Position& p, double offset = 0) const;
102 
104  bool overlapsWith(const AbstractPoly& poly, double offset = 0) const;
105 
107  bool partialWithin(const AbstractPoly& poly, double offset = 0) const;
108 
110  bool crosses(const Position& p1, const Position& p2) const;
112 
114  bool isInitialised() const;
115 
117  double distanceTo2D(const Position& p) const;
118 
120  double distanceTo2D(const Boundary& b) const;
121 
125  Boundary& grow(double by);
126 
128  void growWidth(double by);
129 
131  void growHeight(double by);
132 
134  void flipY();
135 
137  void set(double xmin, double ymin, double xmax, double ymax);
138 
140  void moveby(double x, double y, double z = 0);
141 
143  friend std::ostream& operator<<(std::ostream& os, const Boundary& b);
144 
146  bool operator==(const Boundary& b) const;
147 
149  bool operator!=(const Boundary& b) const;
150 
151 private:
154 
157 };
158 
159 
160 #endif
161 
162 /****************************************************************************/
163 
AbstractPoly
Definition: AbstractPoly.h:36
Boundary::moveby
void moveby(double x, double y, double z=0)
Moves the boundary by the given amount.
Definition: Boundary.cpp:369
Boundary::getZRange
double getZRange() const
Returns the elevation range of the boundary (z-axis)
Definition: Boundary.cpp:167
Boundary::myXmax
double myXmax
Definition: Boundary.h:153
Boundary::zmax
double zmax() const
Returns maximum z-coordinate.
Definition: Boundary.cpp:149
Boundary::ymin
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:131
Boundary::distanceTo2D
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
Definition: Boundary.cpp:223
Boundary::myYmin
double myYmin
Definition: Boundary.h:153
Boundary::myYmax
double myYmax
Definition: Boundary.h:153
Boundary::myZmax
double myZmax
Definition: Boundary.h:153
Boundary::xmax
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:125
Boundary::partialWithin
bool partialWithin(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary is partially within the given polygon.
Definition: Boundary.cpp:291
Boundary::getHeight
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:161
Boundary::around
bool around(const Position &p, double offset=0) const
Returns whether the AbstractPoly the given coordinate.
Definition: Boundary.cpp:173
Boundary::myZmin
double myZmin
Definition: Boundary.h:153
Boundary::reset
void reset()
Resets the boundary.
Definition: Boundary.cpp:67
Boundary::set
void set(double xmin, double ymin, double xmax, double ymax)
Sets the boundary to the given values.
Definition: Boundary.cpp:360
Boundary::xmin
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:119
AbstractPoly.h
Boundary::operator<<
friend std::ostream & operator<<(std::ostream &os, const Boundary &b)
Output operator.
Definition: Boundary.cpp:334
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
Boundary::getWidth
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:155
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
Boundary::add
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:79
Boundary::crosses
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
Definition: Boundary.cpp:203
Boundary::growWidth
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:310
Boundary::myXmin
double myXmin
The boundaries.
Definition: Boundary.h:153
Position.h
Boundary::myWasInitialised
bool myWasInitialised
Information whether the boundary was initialised.
Definition: Boundary.h:156
Boundary::operator!=
bool operator!=(const Boundary &b) const
Comparison operator not equal.
Definition: Boundary.cpp:354
Boundary::getCenter
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:113
Boundary::operator==
bool operator==(const Boundary &b) const
Comparison operator equal.
Definition: Boundary.cpp:341
config.h
Boundary::isInitialised
bool isInitialised() const
check if Boundary is Initialised
Definition: Boundary.cpp:217
Boundary::grow
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
Boundary::Boundary
Boundary()
Constructor - the boundary is unset.
Definition: Boundary.cpp:36
Boundary::~Boundary
~Boundary()
Destructor.
Definition: Boundary.cpp:63
Boundary::flipY
void flipY()
flips ymin and ymax
Definition: Boundary.cpp:323
Boundary::zmin
double zmin() const
Returns minimum z-coordinate.
Definition: Boundary.cpp:143
Boundary::growHeight
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:317
Boundary::ymax
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:137
Boundary::overlapsWith
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
Definition: Boundary.cpp:182