SUMO - Simulation of Urban MObility
Boundary.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A class that stores a 2D geometrical boundary
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef Boundary_h
23 #define Boundary_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <iostream>
36 #include <utility>
37 #include "AbstractPoly.h"
38 #include "Position.h"
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
48 class Boundary
49  : public AbstractPoly {
50 public:
52  Boundary();
53 
55  Boundary(double x1, double y1, double x2, double y2);
56 
57  Boundary(double x1, double y1, double z1, double x2, double y2, double z2);
58 
60  ~Boundary();
61 
63  void reset();
64 
66  void add(double x, double y, double z = 0);
67 
69  void add(const Position& p);
70 
72  void add(const Boundary& p);
73 
75  Position getCenter() const;
76 
78  double xmin() const;
79 
81  double xmax() const;
82 
84  double ymin() const;
85 
87  double ymax() const;
88 
90  double zmin() const;
91 
93  double zmax() const;
94 
96  double getWidth() const;
97 
99  double getHeight() const;
100 
102  double getZRange() const;
103 
105  bool around(const Position& p, double offset = 0) const;
106 
108  bool overlapsWith(const AbstractPoly& poly, double offset = 0) const;
109 
111  bool partialWithin(const AbstractPoly& poly, double offset = 0) const;
112 
114  bool crosses(const Position& p1, const Position& p2) const;
115 
116 
120  Boundary& grow(double by);
121 
123  void growWidth(double by);
124 
126  void growHeight(double by);
127 
129  void flipY();
130 
132  void set(double xmin, double ymin, double xmax, double ymax);
133 
135  void moveby(double x, double y, double z = 0);
136 
138  friend std::ostream& operator<<(std::ostream& os, const Boundary& b);
139 
140 private:
143 
146 
147 };
148 
149 
150 #endif
151 
152 /****************************************************************************/
153 
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:138
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:132
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
Definition: Boundary.cpp:210
void moveby(double x, double y, double z=0)
Moves the boundary by the given amount.
Definition: Boundary.cpp:283
double myXmax
Definition: Boundary.h:142
~Boundary()
Destructor.
Definition: Boundary.cpp:70
double zmax() const
Returns maximum z-coordinate.
Definition: Boundary.cpp:156
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:162
double myZmax
Definition: Boundary.h:142
double myYmin
Definition: Boundary.h:142
double myYmax
Definition: Boundary.h:142
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
Definition: Boundary.cpp:189
friend std::ostream & operator<<(std::ostream &os, const Boundary &b)
Output operator.
Definition: Boundary.cpp:267
double zmin() const
Returns minimum z-coordinate.
Definition: Boundary.cpp:150
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
double myXmin
The boundaries.
Definition: Boundary.h:142
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
double myZmin
Definition: Boundary.h:142
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:126
bool myWasInitialised
Information whether the boundary was initialised.
Definition: Boundary.h:145
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:234
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:250
void reset()
Resets the boundary.
Definition: Boundary.cpp:74
bool partialWithin(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary is partially within the given polygon.
Definition: Boundary.cpp:224
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:168
void flipY()
flips ymin and ymax
Definition: Boundary.cpp:256
bool around(const Position &p, double offset=0) const
Returns whether the boundary contains the given coordinate.
Definition: Boundary.cpp:180
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:243
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:120
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:86
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:144
double getZRange() const
Returns the elevation range of the boundary (z-axis)
Definition: Boundary.cpp:174
Boundary()
Constructor - the boundary is unset.
Definition: Boundary.cpp:43