Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
Boundary.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 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 "PositionVector.h"
30
31
32// ===========================================================================
33// class definitions
34// ===========================================================================
39class Boundary : public AbstractPoly {
40public:
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
127 Boundary& scale(double by);
128
130 void growWidth(double by);
131
133 void growHeight(double by);
134
136 void flipY();
137
139 void set(double xmin, double ymin, double xmax, double ymax);
140
142 void setOffsets(double xmin, double ymin, double xmax, double ymax);
143
145 void moveby(double x, double y, double z = 0);
146
148 PositionVector getShape(const bool closeShape) const;
149
151 friend std::ostream& operator<<(std::ostream& os, const Boundary& b);
152
154 bool operator==(const Boundary& b) const;
155
157 bool operator!=(const Boundary& b) const;
158
159private:
162
165};
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
Position getCenter() const
Returns the center of the boundary.
Definition Boundary.cpp:112
bool partialWithin(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary is partially within the given polygon.
Definition Boundary.cpp:290
double myZmin
Definition Boundary.h:161
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:78
void moveby(double x, double y, double z=0)
Moves the boundary by the given amount.
Definition Boundary.cpp:393
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition Boundary.cpp:326
bool isInitialised() const
check if Boundary is Initialised
Definition Boundary.cpp:216
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:130
double myZmax
Definition Boundary.h:161
void reset()
Resets the boundary.
Definition Boundary.cpp:66
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:118
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:300
void flipY()
flips ymin and ymax
Definition Boundary.cpp:332
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
Definition Boundary.cpp:222
double getHeight() const
Returns the height of the boundary (y-axis)
Definition Boundary.cpp:160
bool myWasInitialised
Information whether the boundary was initialised.
Definition Boundary.h:164
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
Definition Boundary.cpp:181
Boundary()
Constructor - the boundary is unset.
Definition Boundary.cpp:35
~Boundary()
Destructor.
Definition Boundary.cpp:62
double getWidth() const
Returns the width of the boudary (x-axis)
Definition Boundary.cpp:154
bool operator!=(const Boundary &b) const
Comparison operator not equal.
Definition Boundary.cpp:363
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition Boundary.cpp:404
double myYmin
Definition Boundary.h:161
void set(double xmin, double ymin, double xmax, double ymax)
Sets the boundary to the given values.
Definition Boundary.cpp:369
Boundary & scale(double by)
scale the boundary by the given amount
Definition Boundary.cpp:311
double zmin() const
Returns minimum z-coordinate.
Definition Boundary.cpp:142
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition Boundary.cpp:319
double myYmax
Definition Boundary.h:161
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
Definition Boundary.cpp:202
bool around(const Position &p, double offset=0) const
Returns whether the AbstractPoly the given coordinate.
Definition Boundary.cpp:172
void setOffsets(double xmin, double ymin, double xmax, double ymax)
Sets the boundary to the given values, ignoring min < max constraints.
Definition Boundary.cpp:384
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:136
double myXmin
The boundaries.
Definition Boundary.h:161
double myXmax
Definition Boundary.h:161
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:124
friend std::ostream & operator<<(std::ostream &os, const Boundary &b)
Output operator.
Definition Boundary.cpp:343
double zmax() const
Returns maximum z-coordinate.
Definition Boundary.cpp:148
double getZRange() const
Returns the elevation range of the boundary (z-axis)
Definition Boundary.cpp:166
bool operator==(const Boundary &b) const
Comparison operator equal.
Definition Boundary.cpp:350
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.