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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A class that stores a 2D geometrical boundary
20 /****************************************************************************/
21 #ifndef Boundary_h
22 #define Boundary_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <iostream>
35 #include <utility>
36 #include "AbstractPoly.h"
37 #include "Position.h"
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
47 class Boundary
48  : public AbstractPoly {
49 public:
51  Boundary();
52 
54  Boundary(double x1, double y1, double x2, double y2);
55 
56  Boundary(double x1, double y1, double z1, double x2, double y2, double z2);
57 
59  ~Boundary();
60 
62  void reset();
63 
65  void add(double x, double y, double z = 0);
66 
68  void add(const Position& p);
69 
71  void add(const Boundary& p);
72 
74  Position getCenter() const;
75 
77  double xmin() const;
78 
80  double xmax() const;
81 
83  double ymin() const;
84 
86  double ymax() const;
87 
89  double zmin() const;
90 
92  double zmax() const;
93 
95  double getWidth() const;
96 
98  double getHeight() const;
99 
101  double getZRange() const;
102 
104  bool around(const Position& p, double offset = 0) const;
105 
107  bool overlapsWith(const AbstractPoly& poly, double offset = 0) const;
108 
110  bool partialWithin(const AbstractPoly& poly, double offset = 0) const;
111 
113  bool crosses(const Position& p1, const Position& p2) const;
114 
116  double distanceTo2D(const Position& p) const;
117 
119  double distanceTo2D(const Boundary& b) const;
120 
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 
145 private:
148 
151 
152 };
153 
154 
155 #endif
156 
157 /****************************************************************************/
158 
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
Definition: Boundary.cpp:223
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:137
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:131
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
Definition: Boundary.cpp:209
void moveby(double x, double y, double z=0)
Moves the boundary by the given amount.
Definition: Boundary.cpp:350
double myXmax
Definition: Boundary.h:147
~Boundary()
Destructor.
Definition: Boundary.cpp:69
double zmax() const
Returns maximum z-coordinate.
Definition: Boundary.cpp:155
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:161
double myZmax
Definition: Boundary.h:147
double myYmin
Definition: Boundary.h:147
double myYmax
Definition: Boundary.h:147
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
Definition: Boundary.cpp:188
friend std::ostream & operator<<(std::ostream &os, const Boundary &b)
Output operator.
Definition: Boundary.cpp:334
double zmin() const
Returns minimum z-coordinate.
Definition: Boundary.cpp:149
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
double myXmin
The boundaries.
Definition: Boundary.h:147
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
double myZmin
Definition: Boundary.h:147
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:125
bool myWasInitialised
Information whether the boundary was initialised.
Definition: Boundary.h:150
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:317
void reset()
Resets the boundary.
Definition: Boundary.cpp:73
bool partialWithin(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary is partially within the given polygon.
Definition: Boundary.cpp:291
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:167
void flipY()
flips ymin and ymax
Definition: Boundary.cpp:323
bool around(const Position &p, double offset=0) const
Returns whether the boundary contains the given coordinate.
Definition: Boundary.cpp:179
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:310
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:119
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:85
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:143
double getZRange() const
Returns the elevation range of the boundary (z-axis)
Definition: Boundary.cpp:173
Boundary()
Constructor - the boundary is unset.
Definition: Boundary.cpp:42