Boundary Class Reference

#include <Boundary.h>

Inheritance diagram for Boundary:

AbstractPoly SUMORTree

Detailed Description

A class that stores a 2D geometrical boundary.

Definition at line 45 of file Boundary.h.


Public Member Functions

void add (const Boundary &p)
 Makes the boundary include the given boundary.
void add (const Position2D &p)
 Makes the boundary include the given coordinate.
void add (SUMOReal x, SUMOReal y)
 Makes the boundary include the given coordinate.
bool around (const Position2D &p, SUMOReal offset=0) const
 Returns whether the boundary contains the given coordinate.
 Boundary (SUMOReal x1, SUMOReal y1, SUMOReal x2, SUMOReal y2)
 Constructor - the boundary will be build using the given values.
 Boundary ()
 Constructor - the boundary is unset.
bool crosses (const Position2D &p1, const Position2D &p2) const
 Returns whether the boundary crosses the given line.
void flipY ()
 flips ymin and ymax
Position2D getCenter () const
 Returns the center of the boundary.
SUMOReal getHeight () const
 Returns the height of the boundary.
SUMOReal getWidth () const
 Returns the width of the boudary.
Boundarygrow (SUMOReal by)
 extends the boundary by the given amount
void moveby (SUMOReal x, SUMOReal y)
 Moves the boundary by the given amount.
bool overlapsWith (const AbstractPoly &poly, SUMOReal offset=0) const
 Returns whether the boundary overlaps with the given polygon.
bool partialWithin (const AbstractPoly &poly, SUMOReal offset=0) const
 Returns whether the boundary is partially within the given polygon.
void reset ()
 Resets the boundary.
void set (SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax)
 Sets the boundary to the given values.
SUMOReal xmax () const
 Returns maximum x-coordinate.
SUMOReal xmin () const
 Returns minimum x-coordinate.
SUMOReal ymax () const
 Returns maximum y-coordinate.
SUMOReal ymin () const
 Returns minimum y-coordinate.
 ~Boundary ()
 Destructor.

Private Attributes

bool myWasInitialised
 Information whether the boundary was initialised.
SUMOReal myXmax
SUMOReal myXmin
 The boundaries.
SUMOReal myYmax
SUMOReal myYmin

Friends

std::ostream & operator<< (std::ostream &os, const Boundary &b)
 Output operator.

Constructor & Destructor Documentation

Boundary::Boundary (  ) 

Constructor - the boundary is unset.

Definition at line 44 of file Boundary.cpp.

00045         : myXmin(10000000000.0), myXmax(-10000000000.0),
00046         myYmin(10000000000.0), myYmax(-10000000000.0),
00047         myWasInitialised(false) {}

Boundary::Boundary ( SUMOReal  x1,
SUMOReal  y1,
SUMOReal  x2,
SUMOReal  y2 
)

Constructor - the boundary will be build using the given values.

Definition at line 50 of file Boundary.cpp.

00051         : myXmin(10000000000.0), myXmax(-10000000000.0),
00052         myYmin(10000000000.0), myYmax(-10000000000.0),
00053         myWasInitialised(false) {
00054     add(x1, y1);
00055     add(x2, y2);
00056 }

Boundary::~Boundary (  ) 

Destructor.

Definition at line 59 of file Boundary.cpp.

00059 {}


Member Function Documentation

void Boundary::add ( const Boundary p  ) 

Makes the boundary include the given boundary.

Definition at line 96 of file Boundary.cpp.

References xmax(), xmin(), ymax(), and ymin().

00096                                {
00097     add(p.xmin(), p.ymin());
00098     add(p.xmax(), p.ymax());
00099 }

void Boundary::add ( const Position2D p  ) 

Makes the boundary include the given coordinate.

Definition at line 90 of file Boundary.cpp.

References Position2D::x(), and Position2D::y().

00090                                  {
00091     add(p.x(), p.y());
00092 }

void Boundary::add ( SUMOReal  x,
SUMOReal  y 
)

bool Boundary::around ( const Position2D p,
SUMOReal  offset = 0 
) const [virtual]

Returns whether the boundary contains the given coordinate.

Implements AbstractPoly.

Definition at line 145 of file Boundary.cpp.

References myXmax, myXmin, myYmax, myYmin, Position2D::x(), and Position2D::y().

Referenced by NIVissimConnectionCluster::around(), PCPolyContainer::insert(), NIVissimConnectionCluster::recheckEdges(), and TEST().

00145                                                            {
00146     return
00147         (p.x()<=myXmax+offset && p.x()>=myXmin-offset) &&
00148         (p.y()<=myYmax+offset && p.y()>=myYmin-offset);
00149 }

bool Boundary::crosses ( const Position2D p1,
const Position2D p2 
) const [virtual]

Returns whether the boundary crosses the given line.

Implements AbstractPoly.

Definition at line 174 of file Boundary.cpp.

References GeomHelper::intersects(), myXmax, myXmin, myYmax, and myYmin.

Referenced by TEST().

void Boundary::flipY (  ) 

flips ymin and ymax

Definition at line 207 of file Boundary.cpp.

References myYmax, myYmin, and SUMOReal.

Referenced by TEST().

00207                 {
00208     myYmin *= -1.0;
00209     myYmax *= -1.0;
00210     SUMOReal tmp = myYmin;
00211     myYmin = myYmax;
00212     myYmax = tmp;
00213 }

Position2D Boundary::getCenter (  )  const

SUMOReal Boundary::getHeight (  )  const

Returns the height of the boundary.

Definition at line 139 of file Boundary.cpp.

References myYmax, and myYmin.

Referenced by GUISUMOAbstractView::applyChanges(), GUIDanielPerspectiveChanger::centerTo(), GUISUMOAbstractView::getGridHeight(), and TEST().

00139                           {
00140     return myYmax - myYmin;
00141 }

SUMOReal Boundary::getWidth (  )  const

Returns the width of the boudary.

Definition at line 133 of file Boundary.cpp.

References myXmax, and myXmin.

Referenced by GUISUMOAbstractView::applyChanges(), GUIDanielPerspectiveChanger::centerTo(), GUISUMOAbstractView::getGridWidth(), and TEST().

00133                          {
00134     return myXmax - myXmin;
00135 }

Boundary & Boundary::grow ( SUMOReal  by  ) 

void Boundary::moveby ( SUMOReal  x,
SUMOReal  y 
)

Moves the boundary by the given amount.

Definition at line 234 of file Boundary.cpp.

References myXmax, myXmin, myYmax, and myYmin.

Referenced by GeoConvHelper::moveConvertedBy(), and TEST().

00234                                        {
00235     myXmin += x;
00236     myYmin += y;
00237     myXmax += x;
00238     myYmax += y;
00239 }

bool Boundary::overlapsWith ( const AbstractPoly poly,
SUMOReal  offset = 0 
) const [virtual]

Returns whether the boundary overlaps with the given polygon.

Implements AbstractPoly.

Definition at line 153 of file Boundary.cpp.

References AbstractPoly::crosses(), myXmax, myXmin, myYmax, myYmin, AbstractPoly::partialWithin(), and partialWithin().

Referenced by NIVissimBoundedClusterObject::crosses(), NIVissimConnectionCluster::overlapsWith(), NIVissimConnectionCluster::NodeSubCluster::overlapsWith(), and TEST().

00153                                                                    {
00154     if (
00155         // check whether one of my points lies within the given poly
00156         partialWithin(p, offset) ||
00157         // check whether the polygon lies within me
00158         p.partialWithin(*this, offset)) {
00159         return true;
00160     }
00161     // check whether the bounderies cross
00162     return
00163         p.crosses(Position2D(myXmax+offset, myYmax+offset), Position2D(myXmin-offset, myYmax+offset))
00164         ||
00165         p.crosses(Position2D(myXmin-offset, myYmax+offset), Position2D(myXmin-offset, myYmin-offset))
00166         ||
00167         p.crosses(Position2D(myXmin-offset, myYmin-offset), Position2D(myXmax+offset, myYmin-offset))
00168         ||
00169         p.crosses(Position2D(myXmax+offset, myYmin-offset), Position2D(myXmax+offset, myYmax+offset));
00170 }

bool Boundary::partialWithin ( const AbstractPoly poly,
SUMOReal  offset = 0 
) const [virtual]

Returns whether the boundary is partially within the given polygon.

Implements AbstractPoly.

Definition at line 187 of file Boundary.cpp.

References AbstractPoly::around(), myXmax, myXmin, myYmax, and myYmin.

Referenced by PCPolyContainer::insert(), overlapsWith(), and TEST().

00187                                                                        {
00188     return
00189         poly.around(Position2D(myXmax, myYmax), offset) ||
00190         poly.around(Position2D(myXmin, myYmax), offset) ||
00191         poly.around(Position2D(myXmax, myYmin), offset) ||
00192         poly.around(Position2D(myXmin, myYmin), offset);
00193 }

void Boundary::reset (  ) 

Resets the boundary.

Definition at line 63 of file Boundary.cpp.

References myWasInitialised, myXmax, myXmin, myYmax, and myYmin.

Referenced by GeoConvHelper::init().

00063                 {
00064     myXmin = 10000000000.0;
00065     myXmax = -10000000000.0;
00066     myYmin = 10000000000.0;
00067     myYmax = -10000000000.0;
00068     myWasInitialised = false;
00069 }

void Boundary::set ( SUMOReal  xmin,
SUMOReal  ymin,
SUMOReal  xmax,
SUMOReal  ymax 
)

Sets the boundary to the given values.

Definition at line 225 of file Boundary.cpp.

References myXmax, myXmin, myYmax, and myYmin.

00225                                                                         {
00226     myXmin = xmin;
00227     myYmin = ymin;
00228     myXmax = xmax;
00229     myYmax = ymax;
00230 }

SUMOReal Boundary::xmax (  )  const

SUMOReal Boundary::xmin (  )  const

SUMOReal Boundary::ymax (  )  const

Returns maximum y-coordinate.

Definition at line 127 of file Boundary.cpp.

References myYmax.

Referenced by add(), GeomHelper::crossPoint(), GUINet::initGUIStructures(), main(), GUISUMOAbstractView::paintGLGrid(), GUIVehicle::Colorer::setFunctionalColor(), TEST(), and TEST_F().

00127                      {
00128     return myYmax;
00129 }

SUMOReal Boundary::ymin (  )  const

Returns minimum y-coordinate.

Definition at line 121 of file Boundary.cpp.

References myYmin.

Referenced by add(), NBNetBuilder::compute(), GeomHelper::crossPoint(), GUINet::initGUIStructures(), main(), GUISUMOAbstractView::paintGLGrid(), GUIVehicle::Colorer::setFunctionalColor(), TEST(), and TEST_F().

00121                      {
00122     return myYmin;
00123 }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Boundary b 
) [friend]

Output operator.

Definition at line 218 of file Boundary.cpp.

00218                                               {
00219     os << b.myXmin << "," << b.myYmin << "," << b.myXmax << "," << b.myYmax;
00220     return os;
00221 }


Field Documentation

Information whether the boundary was initialised.

Definition at line 125 of file Boundary.h.

Referenced by add(), and reset().

SUMOReal Boundary::myXmax [private]

SUMOReal Boundary::myXmin [private]

The boundaries.

Definition at line 122 of file Boundary.h.

Referenced by add(), around(), crosses(), getCenter(), getWidth(), grow(), moveby(), operator<<(), overlapsWith(), partialWithin(), reset(), set(), and xmin().

SUMOReal Boundary::myYmax [private]

SUMOReal Boundary::myYmin [private]


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:40 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6