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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // A class that stores a 2D geometrical boundary
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <iostream>
26 #include <utility>
27 
28 #include "AbstractPoly.h"
29 #include "Position.h"
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
39 class Boundary : public AbstractPoly {
40 public:
42  Boundary();
43 
45  Boundary(double x1, double y1, double x2, double y2);
46 
48  Boundary(double x1, double y1, double z1, double x2, double y2, double z2);
49 
51  ~Boundary();
52 
54  void reset();
55 
57  void add(double x, double y, double z = 0);
58 
60  void add(const Position& p);
61 
63  void add(const Boundary& p);
64 
66  Position getCenter() const;
67 
69  double xmin() const;
70 
72  double xmax() const;
73 
75  double ymin() const;
76 
78  double ymax() const;
79 
81  double zmin() const;
82 
84  double zmax() const;
85 
87  double getWidth() const;
88 
90  double getHeight() const;
91 
93  double getZRange() const;
94 
98  bool around(const Position& p, double offset = 0) const;
99 
101  bool overlapsWith(const AbstractPoly& poly, double offset = 0) const;
102 
104  bool partialWithin(const AbstractPoly& poly, double offset = 0) const;
105 
107  bool crosses(const Position& p1, const Position& p2) const;
109 
111  bool isInitialised() const;
112 
114  double distanceTo2D(const Position& p) const;
115 
117  double distanceTo2D(const Boundary& b) const;
118 
122  Boundary& grow(double by);
123 
125  void growWidth(double by);
126 
128  void growHeight(double by);
129 
131  void flipY();
132 
134  void set(double xmin, double ymin, double xmax, double ymax);
135 
137  void moveby(double x, double y, double z = 0);
138 
140  friend std::ostream& operator<<(std::ostream& os, const Boundary& b);
141 
143  bool operator==(const Boundary& b) const;
144 
146  bool operator!=(const Boundary& b) const;
147 
148 private:
151 
154 };
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:111
bool partialWithin(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary is partially within the given polygon.
Definition: Boundary.cpp:289
double myZmin
Definition: Boundary.h:150
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:77
void moveby(double x, double y, double z=0)
Moves the boundary by the given amount.
Definition: Boundary.cpp:367
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:315
bool isInitialised() const
check if Boundary is Initialised
Definition: Boundary.cpp:215
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:129
double myZmax
Definition: Boundary.h:150
void reset()
Resets the boundary.
Definition: Boundary.cpp:65
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:117
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:299
void flipY()
flips ymin and ymax
Definition: Boundary.cpp:321
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
Definition: Boundary.cpp:221
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:159
bool myWasInitialised
Information whether the boundary was initialised.
Definition: Boundary.h:153
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
Definition: Boundary.cpp:180
Boundary()
Constructor - the boundary is unset.
Definition: Boundary.cpp:34
~Boundary()
Destructor.
Definition: Boundary.cpp:61
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:153
bool operator!=(const Boundary &b) const
Comparison operator not equal.
Definition: Boundary.cpp:352
double myYmin
Definition: Boundary.h:150
void set(double xmin, double ymin, double xmax, double ymax)
Sets the boundary to the given values.
Definition: Boundary.cpp:358
double zmin() const
Returns minimum z-coordinate.
Definition: Boundary.cpp:141
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:308
double myYmax
Definition: Boundary.h:150
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
Definition: Boundary.cpp:201
bool around(const Position &p, double offset=0) const
Returns whether the AbstractPoly the given coordinate.
Definition: Boundary.cpp:171
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:135
double myXmin
The boundaries.
Definition: Boundary.h:150
double myXmax
Definition: Boundary.h:150
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:123
double zmax() const
Returns maximum z-coordinate.
Definition: Boundary.cpp:147
friend std::ostream & operator<<(std::ostream &os, const Boundary &b)
Output operator.
Definition: Boundary.cpp:332
double getZRange() const
Returns the elevation range of the boundary (z-axis)
Definition: Boundary.cpp:165
bool operator==(const Boundary &b) const
Comparison operator equal.
Definition: Boundary.cpp:339
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36