|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A class that stores a 2D geometrical boundary 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef Boundary_h 00020 #define Boundary_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <iostream> 00033 #include <utility> 00034 #include "AbstractPoly.h" 00035 #include "Position.h" 00036 00037 00038 // =========================================================================== 00039 // class definitions 00040 // =========================================================================== 00045 class Boundary 00046 : public AbstractPoly { 00047 public: 00049 Boundary(); 00050 00052 Boundary(SUMOReal x1, SUMOReal y1, SUMOReal x2, SUMOReal y2); 00053 00055 ~Boundary(); 00056 00058 void reset(); 00059 00061 void add(SUMOReal x, SUMOReal y); 00062 00064 void add(const Position& p); 00065 00067 void add(const Boundary& p); 00068 00070 Position getCenter() const; 00071 00073 SUMOReal xmin() const; 00074 00076 SUMOReal xmax() const; 00077 00079 SUMOReal ymin() const; 00080 00082 SUMOReal ymax() const; 00083 00085 SUMOReal getWidth() const; 00086 00088 SUMOReal getHeight() const; 00089 00091 bool around(const Position& p, SUMOReal offset=0) const; 00092 00094 bool overlapsWith(const AbstractPoly& poly, SUMOReal offset=0) const; 00095 00097 bool partialWithin(const AbstractPoly& poly, SUMOReal offset=0) const; 00098 00100 bool crosses(const Position& p1, const Position& p2) const; 00101 00102 00106 Boundary& grow(SUMOReal by); 00107 00108 void growWidth(SUMOReal by); 00109 00110 void growHeight(SUMOReal by); 00111 00113 void flipY(); 00114 00116 void set(SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax); 00117 00119 void moveby(SUMOReal x, SUMOReal y); 00120 00122 friend std::ostream& operator<<(std::ostream& os, const Boundary& b); 00123 00124 private: 00126 SUMOReal myXmin,myXmax, myYmin, myYmax; 00127 00129 bool myWasInitialised; 00130 00131 }; 00132 00133 00134 #endif 00135 00136 /****************************************************************************/ 00137