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