SUMO - Simulation of Urban MObility
LayeredRTree Class Reference

A RT-tree for efficient storing of SUMO's GL-objects in layers. More...

#include <LayeredRTree.h>

Inheritance diagram for LayeredRTree:
Inheritance graph
Collaboration diagram for LayeredRTree:
Collaboration graph

Public Member Functions

void add (double x, double y, double z=0)
 Makes the boundary include the given coordinate. More...
 
void add (const Position &p)
 Makes the boundary include the given coordinate. More...
 
void add (const Boundary &p)
 Makes the boundary include the given boundary. More...
 
void addAdditionalGLObject (GUIGlObject *o)
 Adds an additional object (detector/shape/trigger) for visualisation. More...
 
bool around (const Position &p, double offset=0) const
 Returns whether the boundary contains the given coordinate. More...
 
bool crosses (const Position &p1, const Position &p2) const
 Returns whether the boundary crosses the given line. More...
 
double distanceTo2D (const Position &p) const
 returns the euclidean distance in the x-y-plane More...
 
double distanceTo2D (const Boundary &b) const
 returns the euclidean distance in the x-y-plane More...
 
void flipY ()
 flips ymin and ymax More...
 
Position getCenter () const
 Returns the center of the boundary. More...
 
double getHeight () const
 Returns the height of the boundary (y-axis) More...
 
double getWidth () const
 Returns the width of the boudary (x-axis) More...
 
double getZRange () const
 Returns the elevation range of the boundary (z-axis) More...
 
Boundarygrow (double by)
 extends the boundary by the given amount More...
 
void growHeight (double by)
 Increases the height of the boundary (y-axis) More...
 
void growWidth (double by)
 Increases the width of the boundary (x-axis) More...
 
void Insert (const float a_min[2], const float a_max[2], GUIGlObject *const &a_dataId)
 Insert entry (delegate to appropriate layer) More...
 
 LayeredRTree ()
 Constructor. More...
 
void moveby (double x, double y, double z=0)
 Moves the boundary by the given amount. More...
 
bool overlapsWith (const AbstractPoly &poly, double offset=0) const
 Returns whether the boundary overlaps with the given polygon. More...
 
bool partialWithin (const AbstractPoly &poly, double offset=0) const
 Returns whether the boundary is partially within the given polygon. More...
 
void Remove (const float a_min[2], const float a_max[2], GUIGlObject *const &a_dataId)
 Remove entry (delegate to appropriate layer) More...
 
void removeAdditionalGLObject (GUIGlObject *o)
 Removes an additional object (detector/shape/trigger) from being visualised. More...
 
void reset ()
 Resets the boundary. More...
 
int Search (const float a_min[2], const float a_max[2], const GUIVisualizationSettings &c) const
 Find all within search rectangle (searches all layers in order) More...
 
void set (double xmin, double ymin, double xmax, double ymax)
 Sets the boundary to the given values. More...
 
double xmax () const
 Returns maximum x-coordinate. More...
 
double xmin () const
 Returns minimum x-coordinate. More...
 
double ymax () const
 Returns maximum y-coordinate. More...
 
double ymin () const
 Returns minimum y-coordinate. More...
 
double zmax () const
 Returns maximum z-coordinate. More...
 
double zmin () const
 Returns minimum z-coordinate. More...
 
 ~LayeredRTree ()
 Destructor. More...
 

Protected Attributes

std::vector< SUMORTree * > myLayers
 the layers for drawing More...
 
MFXMutex myLock
 A mutex avoiding parallel change and traversal of the tree. More...
 

Private Member Functions

size_t selectLayer (GUIGlObject *o)
 select the appropriate layer for each object More...
 

Detailed Description

A RT-tree for efficient storing of SUMO's GL-objects in layers.

This class maintains SUMORTrees for each layer (only 2 at the moment) but provides the same interface as SUMORTree

Definition at line 55 of file LayeredRTree.h.

Constructor & Destructor Documentation

◆ LayeredRTree()

LayeredRTree::LayeredRTree ( )
inline

Constructor.

Definition at line 58 of file LayeredRTree.h.

References myLayers, and SUMORTree::SUMORTree().

◆ ~LayeredRTree()

LayeredRTree::~LayeredRTree ( )
inline

Destructor.

Definition at line 65 of file LayeredRTree.h.

References myLayers.

Member Function Documentation

◆ add() [1/3]

void Boundary::add ( double  x,
double  y,
double  z = 0 
)
inherited

Makes the boundary include the given coordinate.

Definition at line 85 of file Boundary.cpp.

References Boundary::myWasInitialised, Boundary::myXmax, Boundary::myXmin, Boundary::myYmax, Boundary::myYmin, Boundary::myZmax, and Boundary::myZmin.

Referenced by Boundary::add(), NIVissimConnectionCluster::NodeSubCluster::add(), NIVissimConnectionCluster::add(), ROEdge::addSuccessor(), MSEdge::addSuccessor(), Boundary::Boundary(), GUIDanielPerspectiveChanger::centerTo(), NBNetBuilder::compute(), GNENet::computeAndUpdate(), NIVissimDisturbance::computeBounding(), NIVissimConnection::computeBounding(), GUIEdge::getBoundary(), GNEEdge::getBoundary(), MSDevice_BTsender::VehicleInformation::getBoxBoundary(), PositionVector::getBoxBoundary(), GUITrafficLightLogicWrapper::getCenteringBoundary(), GUIPolygon::getCenteringBoundary(), GUIContainer::getCenteringBoundary(), GUIPerson::getCenteringBoundary(), GUIPointOfInterest::getCenteringBoundary(), GUIParkingArea::getCenteringBoundary(), GUIBaseVehicle::getCenteringBoundary(), GUILane::getCenteringBoundary(), GUISUMOAbstractView::getObjectAtPosition(), GUISUMOAbstractView::getObjectsAtPosition(), GUICalibrator::GUICalibrator(), GUILaneSpeedTrigger::GUILaneSpeedTrigger(), GUITriggeredRerouter::GUITriggeredRerouter(), GUITriggeredRerouter::GUITriggeredRerouterEdge::GUITriggeredRerouterEdge(), GUINet::initGUIStructures(), GNENet::initJunctionsAndEdges(), NBHeightMapper::loadShapeFile(), NBHeightMapper::loadTiff(), GNEViewNet::mergeJunctions(), GUITriggeredRerouter::myEndElement(), GUIMEInductLoop::MyWrapper::MyWrapper(), GUIInstantInductLoop::MyWrapper::MyWrapper(), GUIE3Collector::MyWrapper::MyWrapper(), GUIInductLoop::MyWrapper::MyWrapper(), GNEViewNet::onLeftBtnRelease(), NIVissimConnectionCluster::recomputeBoundary(), GNENet::registerEdge(), GNENet::registerJunction(), GUIDanielPerspectiveChanger::setViewport(), GNEJunction::updateGeometry(), and GeoConvHelper::x2cartesian().

◆ add() [2/3]

void Boundary::add ( const Position p)
inherited

Makes the boundary include the given coordinate.

Definition at line 106 of file Boundary.cpp.

References Boundary::add(), Position::x(), Position::y(), and Position::z().

◆ add() [3/3]

void Boundary::add ( const Boundary p)
inherited

Makes the boundary include the given boundary.

Definition at line 112 of file Boundary.cpp.

References Boundary::add(), Boundary::xmax(), Boundary::xmin(), Boundary::ymax(), Boundary::ymin(), Boundary::zmax(), and Boundary::zmin().

◆ addAdditionalGLObject()

◆ around()

bool Boundary::around ( const Position p,
double  offset = 0 
) const
virtualinherited

◆ crosses()

bool Boundary::crosses ( const Position p1,
const Position p2 
) const
virtualinherited

Returns whether the boundary crosses the given line.

Implements AbstractPoly.

Definition at line 209 of file Boundary.cpp.

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

◆ distanceTo2D() [1/2]

double Boundary::distanceTo2D ( const Position p) const
inherited

returns the euclidean distance in the x-y-plane

Definition at line 223 of file Boundary.cpp.

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

Referenced by ROEdge::getDistanceTo(), and MSEdge::getDistanceTo().

◆ distanceTo2D() [2/2]

double Boundary::distanceTo2D ( const Boundary b) const
inherited

returns the euclidean distance in the x-y-plane

Definition at line 257 of file Boundary.cpp.

References Boundary::myXmax, Boundary::myXmin, Boundary::myYmax, and Boundary::myYmin.

◆ flipY()

void Boundary::flipY ( )
inherited

flips ymin and ymax

Definition at line 323 of file Boundary.cpp.

References Boundary::myYmax, and Boundary::myYmin.

Referenced by GeoConvHelper::computeFinal().

◆ getCenter()

◆ getHeight()

◆ getWidth()

◆ getZRange()

double Boundary::getZRange ( ) const
inherited

Returns the elevation range of the boundary (z-axis)

Definition at line 173 of file Boundary.cpp.

References Boundary::myZmax, and Boundary::myZmin.

Referenced by NBNetBuilder::compute().

◆ grow()

Boundary & Boundary::grow ( double  by)
inherited

extends the boundary by the given amount

The method returns a reference to the instance for further use

Definition at line 301 of file Boundary.cpp.

References Boundary::myXmax, Boundary::myXmin, Boundary::myYmax, and Boundary::myYmin.

Referenced by GUIDanielPerspectiveChanger::centerTo(), NBEdgeCont::checkOverlap(), libsumo::Helper::collectObjectsInRange(), MSDevice_BTreceiver::BTreceiverUpdate::execute(), MSLane::fill(), GUIEdge::getBoundary(), GNEEdge::getBoundary(), GNECrossing::getCenteringBoundary(), GNEJunction::getCenteringBoundary(), GNEInternalLane::getCenteringBoundary(), GUITrafficLightLogicWrapper::getCenteringBoundary(), GUIPolygon::getCenteringBoundary(), GUIInstantInductLoop::MyWrapper::getCenteringBoundary(), GUILaneSpeedTrigger::getCenteringBoundary(), GUIContainer::getCenteringBoundary(), GNELane::getCenteringBoundary(), GUICalibrator::getCenteringBoundary(), GUIPerson::getCenteringBoundary(), GUIJunctionWrapper::getCenteringBoundary(), GUIMEInductLoop::MyWrapper::getCenteringBoundary(), GUIPointOfInterest::getCenteringBoundary(), GNEConnection::getCenteringBoundary(), GUIE3Collector::MyWrapper::getCenteringBoundary(), GUITriggeredRerouter::getCenteringBoundary(), GUIChargingStation::getCenteringBoundary(), GUIContainerStop::getCenteringBoundary(), GUIBusStop::getCenteringBoundary(), GUIParkingArea::getCenteringBoundary(), GUIEdge::getCenteringBoundary(), GNEEdge::getCenteringBoundary(), GUIE2Collector::MyWrapper::getCenteringBoundary(), GUIBaseVehicle::getCenteringBoundary(), GUIInductLoop::MyWrapper::getCenteringBoundary(), GUITriggeredRerouter::GUITriggeredRerouterEdge::getCenteringBoundary(), GUILane::getCenteringBoundary(), GNEAdditional::getCenteringBoundary(), GUISUMOAbstractView::getObjectAtPosition(), GUISUMOAbstractView::getObjectsAtPosition(), NBEdgeCont::ignoreFilterMatch(), GUINet::initGUIStructures(), and GNEViewNet::mergeJunctions().

◆ growHeight()

void Boundary::growHeight ( double  by)
inherited

Increases the height of the boundary (y-axis)

Definition at line 317 of file Boundary.cpp.

References Boundary::myYmax, and Boundary::myYmin.

Referenced by GUIPointOfInterest::getCenteringBoundary(), GUIPerspectiveChanger::patchedViewPort(), and GUIDanielPerspectiveChanger::setViewport().

◆ growWidth()

void Boundary::growWidth ( double  by)
inherited

Increases the width of the boundary (x-axis)

Definition at line 310 of file Boundary.cpp.

References Boundary::myXmax, and Boundary::myXmin.

Referenced by GUIPointOfInterest::getCenteringBoundary(), GUIPerspectiveChanger::patchedViewPort(), and GUIDanielPerspectiveChanger::setViewport().

◆ Insert()

void LayeredRTree::Insert ( const float  a_min[2],
const float  a_max[2],
GUIGlObject *const &  a_dataId 
)
inlinevirtual

Insert entry (delegate to appropriate layer)

Parameters
a_minMin of bounding rect
a_maxMax of bounding rect
a_dataIdPositive Id of data. Maybe zero, but negative numbers not allowed.

Reimplemented from SUMORTree.

Definition at line 78 of file LayeredRTree.h.

References myLayers, and selectLayer().

Referenced by GUINet::initGUIStructures().

◆ moveby()

void Boundary::moveby ( double  x,
double  y,
double  z = 0 
)
inherited

◆ overlapsWith()

bool Boundary::overlapsWith ( const AbstractPoly poly,
double  offset = 0 
) const
virtualinherited

◆ partialWithin()

bool Boundary::partialWithin ( const AbstractPoly poly,
double  offset = 0 
) const
virtualinherited

Returns whether the boundary is partially within the given polygon.

Implements AbstractPoly.

Definition at line 291 of file Boundary.cpp.

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

Referenced by PCPolyContainer::add(), and Boundary::overlapsWith().

◆ Remove()

void LayeredRTree::Remove ( const float  a_min[2],
const float  a_max[2],
GUIGlObject *const &  a_dataId 
)
inlinevirtual

Remove entry (delegate to appropriate layer)

Parameters
a_minMin of bounding rect
a_maxMax of bounding rect
a_dataIdPositive Id of data. Maybe zero, but negative numbers not allowed.

Reimplemented from SUMORTree.

Definition at line 88 of file LayeredRTree.h.

References myLayers, and selectLayer().

◆ removeAdditionalGLObject()

◆ reset()

void Boundary::reset ( )
inherited

◆ Search()

int LayeredRTree::Search ( const float  a_min[2],
const float  a_max[2],
const GUIVisualizationSettings c 
) const
inlinevirtual

Find all within search rectangle (searches all layers in order)

Parameters
a_minMin of search bounding rect
a_maxMax of search bounding rect
a_searchResultSearch result array. Caller should set grow size. Function will reset, not append to array.
a_resultCallbackCallback function to return result. Callback should return 'true' to continue searching
a_contextUser context to pass as parameter to a_resultCallback
Returns
Returns the number of entries found

Reimplemented from SUMORTree.

Definition at line 100 of file LayeredRTree.h.

References myLayers.

◆ selectLayer()

size_t LayeredRTree::selectLayer ( GUIGlObject o)
inlineprivate

select the appropriate layer for each object

Definition at line 116 of file LayeredRTree.h.

References GUIGlObject::getType(), GLO_EDGE, GLO_LANE, GLO_PERSON, GLO_POI, and GLO_VEHICLE.

Referenced by Insert(), and Remove().

◆ set()

void Boundary::set ( double  xmin,
double  ymin,
double  xmax,
double  ymax 
)
inherited

◆ xmax()

double Boundary::xmax ( ) const
inherited

Returns maximum x-coordinate.

Definition at line 131 of file Boundary.cpp.

References Boundary::myXmax.

Referenced by Boundary::add(), NIVissimConnectionCluster::add(), SUMORTree::addAdditionalGLObject(), NBHeightMapper::addTriangle(), NIVissimConnectionCluster::around(), NIVissimConnection::buildNodeClusters(), GUIDanielPerspectiveChanger::changeCanvasSizeLeft(), libsumo::Helper::collectObjectsInRange(), NBNetBuilder::compute(), NIVissimDisturbance::computeBounding(), NIVissimBoundedClusterObject::crosses(), GeomHelper::crossPoint(), GUIViewTraffic::doPaintGL(), GNEViewNet::doPaintGL(), MSDevice_BTreceiver::BTreceiverUpdate::execute(), MSLane::fill(), NBPTStopCont::findAccessEdgesForRailStops(), NIVissimConnection::getBoundingBox(), libsumo::Simulation::getNetBoundary(), NIVissimConnectionCluster::getPositionForEdge(), libsumo::Polygon::getTree(), libsumo::Junction::getTree(), NBHeightMapper::getZ(), GUINet::initGUIStructures(), main(), GUISUMOAbstractView::makeSnapshot(), NIVissimConnectionCluster::NIVissimConnectionCluster(), NIVissimConnectionCluster::overlapsWith(), NIVissimConnectionCluster::NodeSubCluster::overlapsWith(), GUISUMOAbstractView::paintGLGrid(), TraCIServerAPI_GUI::processGet(), NIVissimConnectionCluster::recheckEdges(), NIVissimConnectionCluster::recomputeBoundary(), SUMORTree::removeAdditionalGLObject(), Boundary::set(), GUIBaseVehicle::setFunctionalColor(), GNEPoly::simplifyShape(), BinaryFormatter::writeAttr(), NWWriter_OpenDrive::writeNetwork(), NWWriter_DlrNavteq::writeNodesUnsplitted(), and GUIDanielPerspectiveChanger::zoom().

◆ xmin()

double Boundary::xmin ( ) const
inherited

Returns minimum x-coordinate.

Definition at line 125 of file Boundary.cpp.

References Boundary::myXmin.

Referenced by Boundary::add(), NIVissimConnectionCluster::add(), SUMORTree::addAdditionalGLObject(), NBHeightMapper::addTriangle(), GUISUMOAbstractView::applyGLTransform(), NIVissimConnectionCluster::around(), NIVissimConnection::buildNodeClusters(), GUIDanielPerspectiveChanger::changeCanvasSizeLeft(), libsumo::Helper::collectObjectsInRange(), NBNetBuilder::compute(), NIVissimDisturbance::computeBounding(), NIVissimBoundedClusterObject::crosses(), GeomHelper::crossPoint(), GUIViewTraffic::doPaintGL(), GNEViewNet::doPaintGL(), MSDevice_BTreceiver::BTreceiverUpdate::execute(), MSLane::fill(), NBPTStopCont::findAccessEdgesForRailStops(), NIVissimConnection::getBoundingBox(), libsumo::Simulation::getNetBoundary(), NIVissimConnectionCluster::getPositionForEdge(), libsumo::Polygon::getTree(), libsumo::Junction::getTree(), NBHeightMapper::getZ(), GUINet::initGUIStructures(), main(), GUISUMOAbstractView::makeSnapshot(), NBNetBuilder::moveToOrigin(), NIVissimConnectionCluster::NIVissimConnectionCluster(), NIVissimConnectionCluster::overlapsWith(), NIVissimConnectionCluster::NodeSubCluster::overlapsWith(), GUISUMOAbstractView::paintGLGrid(), TraCIServerAPI_GUI::processGet(), NIVissimConnectionCluster::recheckEdges(), NIVissimConnectionCluster::recomputeBoundary(), SUMORTree::removeAdditionalGLObject(), GUISUMOAbstractView::screenPos2NetPos(), Boundary::set(), GUIBaseVehicle::setFunctionalColor(), GNEPoly::simplifyShape(), BinaryFormatter::writeAttr(), NWWriter_OpenDrive::writeNetwork(), NWWriter_DlrNavteq::writeNodesUnsplitted(), and GUIDanielPerspectiveChanger::zoom().

◆ ymax()

◆ ymin()

◆ zmax()

double Boundary::zmax ( ) const
inherited

Returns maximum z-coordinate.

Definition at line 155 of file Boundary.cpp.

References Boundary::myZmax.

Referenced by Boundary::add(), and libsumo::Simulation::getNetBoundary().

◆ zmin()

double Boundary::zmin ( ) const
inherited

Returns minimum z-coordinate.

Definition at line 149 of file Boundary.cpp.

References Boundary::myZmin.

Referenced by Boundary::add(), and libsumo::Simulation::getNetBoundary().

Field Documentation

◆ myLayers

std::vector<SUMORTree*> LayeredRTree::myLayers
protected

the layers for drawing

Definition at line 111 of file LayeredRTree.h.

Referenced by Insert(), LayeredRTree(), Remove(), Search(), and ~LayeredRTree().

◆ myLock

MFXMutex SUMORTree::myLock
mutableprotectedinherited

A mutex avoiding parallel change and traversal of the tree.

Definition at line 151 of file SUMORTree.h.

Referenced by SUMORTree::addAdditionalGLObject(), SUMORTree::Insert(), SUMORTree::Remove(), SUMORTree::removeAdditionalGLObject(), and SUMORTree::Search().


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