Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
LayeredRTree Class Reference

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

#include <LayeredRTree.h>

Inheritance diagram for LayeredRTree:
[legend]
Collaboration diagram for LayeredRTree:
[legend]

Public Member Functions

void add (const Boundary &p)
 Makes the boundary include the given boundary.
void add (const Position &p)
 Makes the boundary include the given coordinate.
void add (double x, double y, double z=0)
 Makes the boundary include the given coordinate.
void addAdditionalGLObject (GUIGlObject *o, const double exaggeration=1)
 Adds an additional object (detector/shape/trigger) for visualisation.
bool contains2D (const Boundary &b) const
 return true if this boundary contains the given boundary (only X-Y)
double distanceTo2D (const Boundary &b) const
 returns the euclidean distance in the x-y-plane
double distanceTo2D (const Position &p) const
 returns the euclidean distance in the x-y-plane
void flipY ()
 flips ymin and ymax
Position getCenter () const
 Returns the center of the boundary.
double getHeight () const
 Returns the height of the boundary (y-axis).
PositionVector getShape (const bool closeShape) const
 get position vector (shape) based on this boundary
double getWidth () const
 Returns the width of the boudary (x-axis).
double getZRange () const
 Returns the elevation range of the boundary (z-axis).
Boundarygrow (double by)
 extends the boundary by the given amount
void growHeight (double by)
 Increases the height of the boundary (y-axis).
void growWidth (double by)
 Increases the width of the boundary (x-axis).
void Insert (const float a_min[2], const float a_max[2], GUIGlObject *const &a_dataId)
 Insert entry (delegate to appropriate layer).
bool isInitialised () const
 check if Boundary is Initialised
 LayeredRTree ()
 Constructor.
void moveby (double x, double y, double z=0)
 Moves the boundary by the given amount.
bool operator!= (const Boundary &b) const
 Comparison operator not equal.
bool operator== (const Boundary &b) const
 Comparison operator equal.
bool overlaps2D (const Boundary &b) const
 return true if at least one point of the given boundary is in boundary(only X-Y)
void Remove (const float a_min[2], const float a_max[2], GUIGlObject *const &a_dataId)
 Remove entry (delegate to appropriate layer).
void removeAdditionalGLObject (GUIGlObject *o, const double exaggeration=1)
 Removes an additional object (detector/shape/trigger) from being visualised.
void reset ()
 Resets the boundary.
Boundaryscale (double by)
 scale the boundary by the given amount
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).
void set (double xmin, double ymin, double xmax, double ymax)
 Sets the boundary to the given values.
void setOffsets (double xmin, double ymin, double xmax, double ymax)
 Sets the boundary to the given values, ignoring min < max constraints.
void updateBoundaries (GUIGlObjectType type)
 update boundaries
double xmax () const
 Returns maximum x-coordinate.
double xmin () const
 Returns minimum x-coordinate.
double ymax () const
 Returns maximum y-coordinate.
double ymin () const
 Returns minimum y-coordinate.
double zmax () const
 Returns maximum z-coordinate.
double zmin () const
 Returns minimum z-coordinate.
 ~LayeredRTree ()
 Destructor.
inherited from AbstractPoly
bool around (const Position &p, double offset=0) const
 Returns whether the boundary contains the given coordinate.
bool around2D (const Position &p, double offset=0) const
 Returns whether the boundary contains the given 2D coordinate (position).
bool around2D (const double x, const double y) const
 Returns whether the boundary contains the given 2D coordinate (x-y version).
bool overlapsWith (const AbstractPoly &poly, double offset=0) const
 Returns whether the boundary overlaps with the given polygon.
bool partialWithin (const AbstractPoly &poly, double offset=0) const
 Returns whether the boundary is partially within the given polygon.
bool crosses (const Position &p1, const Position &p2) const
 Returns whether the boundary crosses the given line.

Protected Attributes

std::vector< SUMORTree * > myLayers
 the layers for drawing
FXMutex myLock
 A mutex avoiding parallel change and traversal of the tree.
int myTreeSize = 0
 number of inserted elements

Private Member Functions

bool removeObjectFromTreeDebug (const GUIGlObject *obj)
 remove object from TreeDebug
size_t selectLayer (GUIGlObject *o)
 select the appropriate layer for each object

Private Attributes

std::map< GUIGlObject *, BoundarymyTreeDebug
 Map only used for check that SUMORTree works as expected, only is used if option "gui-testing-debug-gl" is enabled.
bool myWasInitialised
 Information whether the boundary was initialised.
double myXmax
double myXmin
 The boundaries.
double myYmax
double myYmin
double myZmax
double myZmin

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 46 of file LayeredRTree.h.

Constructor & Destructor Documentation

◆ LayeredRTree()

LayeredRTree::LayeredRTree ( )
inline

Constructor.

Definition at line 49 of file LayeredRTree.h.

References myLayers, and SUMORTree::SUMORTree().

◆ ~LayeredRTree()

LayeredRTree::~LayeredRTree ( )
inline

Destructor.

Definition at line 56 of file LayeredRTree.h.

References myLayers.

Member Function Documentation

◆ add() [1/3]

void Boundary::add ( const Boundary & p)
inherited

Makes the boundary include the given boundary.

Definition at line 102 of file Boundary.cpp.

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

◆ add() [2/3]

void Boundary::add ( const Position & p)
inherited

Makes the boundary include the given coordinate.

Definition at line 96 of file Boundary.cpp.

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

◆ add() [3/3]

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

◆ addAdditionalGLObject()

void SUMORTree::addAdditionalGLObject ( GUIGlObject * o,
const double exaggeration = 1 )
inlineinherited

Adds an additional object (detector/shape/trigger) for visualisation.

Parameters
[in]oThe object to add

Definition at line 122 of file SUMORTree.h.

References Boundary::Boundary(), StringUtils::format(), GUIGlObject::getCenteringBoundary(), GUIGlObject::getMicrosimID(), Insert(), myLock, myTreeDebug, myTreeSize, and MsgHandler::writeDebugGLMessages().

Referenced by GUINet::registerRenderedObject(), and updateBoundaries().

Here is the caller graph for this function:

◆ around()

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

Returns whether the boundary contains the given coordinate.

Implements AbstractPoly.

Definition at line 169 of file Boundary.cpp.

References myXmax, myXmin, myYmax, myYmin, myZmax, myZmin, Position::x(), Position::y(), and Position::z().

◆ around2D() [1/2]

bool Boundary::around2D ( const double x,
const double y ) const
inherited

Returns whether the boundary contains the given 2D coordinate (x-y version).

Definition at line 186 of file Boundary.cpp.

References myXmax, myXmin, myYmax, and myYmin.

◆ around2D() [2/2]

bool Boundary::around2D ( const Position & p,
double offset = 0 ) const
inherited

Returns whether the boundary contains the given 2D coordinate (position).

Definition at line 178 of file Boundary.cpp.

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

Referenced by NBHeightMapper::getZ(), and overlaps2D().

Here is the caller graph for this function:

◆ contains2D()

bool Boundary::contains2D ( const Boundary & b) const
inherited

return true if this boundary contains the given boundary (only X-Y)

Definition at line 229 of file Boundary.cpp.

References Boundary(), myXmax, myXmin, myYmax, and myYmin.

◆ 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 215 of file Boundary.cpp.

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

◆ distanceTo2D() [1/2]

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

returns the euclidean distance in the x-y-plane

Definition at line 296 of file Boundary.cpp.

References Boundary(), myXmax, myXmin, myYmax, and myYmin.

◆ distanceTo2D() [2/2]

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

returns the euclidean distance in the x-y-plane

Definition at line 262 of file Boundary.cpp.

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

Referenced by libsumo::Helper::convertCartesianToRoadMap(), MSEdge::getDistanceTo(), and ROEdge::getDistanceTo().

Here is the caller graph for this function:

◆ flipY()

void Boundary::flipY ( )
inherited

flips ymin and ymax

Definition at line 372 of file Boundary.cpp.

References myYmax, and myYmin.

◆ getCenter()

Position Boundary::getCenter ( ) const
inherited

Returns the center of the boundary.

Definition at line 109 of file Boundary.cpp.

References myXmax, myXmin, myYmax, myYmin, myZmax, and myZmin.

Referenced by GUISUMOAbstractView::applyGLTransform(), GUIGlObject::getCenter(), NIVissimConnectionCluster::liesOnSameEdgesEnd(), MSPModel_Striping::moveInDirection(), GUISUMOAbstractView::screenPos2NetPos(), and GUIOSGPerspectiveChanger::setViewport().

Here is the caller graph for this function:

◆ getHeight()

double Boundary::getHeight ( ) const
inherited

Returns the height of the boundary (y-axis).

Definition at line 157 of file Boundary.cpp.

References myYmax, and myYmin.

Referenced by GUISUMOAbstractView::applyGLTransform(), GUIPolygon::checkDraw(), libsumo::Helper::convertCartesianToRoadMap(), and GUISUMOAbstractView::screenPos2NetPos().

Here is the caller graph for this function:

◆ getShape()

PositionVector Boundary::getShape ( const bool closeShape) const
inherited

get position vector (shape) based on this boundary

Definition at line 444 of file Boundary.cpp.

References myXmax, myXmin, myYmax, and myYmin.

Referenced by GNEAdditionalHandler::buildTAZ(), GNEViewNetHelper::SelectingArea::processBoundarySelection(), GNEViewNetHelper::SelectingArea::processEdgeRectangleSelection(), and LIBSUMO_NAMESPACE::Simulation::storeShape().

Here is the caller graph for this function:

◆ getWidth()

double Boundary::getWidth ( ) const
inherited

Returns the width of the boudary (x-axis).

Definition at line 151 of file Boundary.cpp.

References myXmax, and myXmin.

Referenced by GUISUMOAbstractView::applyGLTransform(), GUIPolygon::checkDraw(), libsumo::Helper::convertCartesianToRoadMap(), MSPModel_Striping::moveInDirection(), and GUISUMOAbstractView::screenPos2NetPos().

Here is the caller graph for this function:

◆ getZRange()

double Boundary::getZRange ( ) const
inherited

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

Definition at line 163 of file Boundary.cpp.

References myZmax, and myZmin.

Referenced by NBNetBuilder::compute().

Here is the caller graph for this function:

◆ grow()

◆ growHeight()

void Boundary::growHeight ( double by)
inherited

Increases the height of the boundary (y-axis).

Definition at line 366 of file Boundary.cpp.

References myYmax, and myYmin.

Referenced by scale().

Here is the caller graph for this function:

◆ growWidth()

void Boundary::growWidth ( double by)
inherited

Increases the width of the boundary (x-axis).

Definition at line 359 of file Boundary.cpp.

References myXmax, and myXmin.

Referenced by MSPModel_Striping::moveInDirection(), and scale().

Here is the caller graph for this function:

◆ 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 69 of file LayeredRTree.h.

References myLayers, and selectLayer().

◆ isInitialised()

bool Boundary::isInitialised ( ) const
inherited

check if Boundary is Initialised

Definition at line 256 of file Boundary.cpp.

References myWasInitialised.

Referenced by GUIViewObjectsHandler::checkShapeObject(), GNEAdditional::getCenteringBoundary(), GNERoute::getCenteringBoundary(), and NIImporter_OpenDrive::loadNetwork().

Here is the caller graph for this function:

◆ moveby()

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

Moves the boundary by the given amount.

Definition at line 433 of file Boundary.cpp.

References myXmax, myXmin, myYmax, myYmin, myZmax, and myZmin.

◆ operator!=()

bool Boundary::operator!= ( const Boundary & b) const
inherited

Comparison operator not equal.

Definition at line 403 of file Boundary.cpp.

References Boundary().

◆ operator==()

bool Boundary::operator== ( const Boundary & b) const
inherited

Comparison operator equal.

Definition at line 390 of file Boundary.cpp.

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

◆ overlaps2D()

bool Boundary::overlaps2D ( const Boundary & b) const
inherited

return true if at least one point of the given boundary is in boundary(only X-Y)

Definition at line 240 of file Boundary.cpp.

References around2D(), and Boundary().

◆ overlapsWith()

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

Returns whether the boundary overlaps with the given polygon.

Implements AbstractPoly.

Definition at line 194 of file Boundary.cpp.

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

Referenced by NBEdgeCont::checkOverlap(), NBEdgeCont::ignoreFilterMatch(), and NIVissimConnectionCluster::overlapsWith().

Here is the caller graph for this function:

◆ 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 330 of file Boundary.cpp.

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

Referenced by overlapsWith().

Here is the caller graph for this function:

◆ 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 79 of file LayeredRTree.h.

References myLayers, and selectLayer().

◆ removeAdditionalGLObject()

void SUMORTree::removeAdditionalGLObject ( GUIGlObject * o,
const double exaggeration = 1 )
inlineinherited

Removes an additional object (detector/shape/trigger) from being visualised.

Parameters
[in]oThe object to remove

Definition at line 158 of file SUMORTree.h.

References Boundary::Boundary(), StringUtils::format(), GUIGlObject::getCenteringBoundary(), GUIGlObject::getMicrosimID(), myLock, myTreeDebug, myTreeSize, Remove(), toString(), and MsgHandler::writeDebugGLMessages().

Referenced by updateBoundaries().

Here is the caller graph for this function:

◆ removeObjectFromTreeDebug()

bool SUMORTree::removeObjectFromTreeDebug ( const GUIGlObject * obj)
inlineprivateinherited

remove object from TreeDebug

Definition at line 235 of file SUMORTree.h.

References myTreeDebug.

Referenced by updateBoundaries().

Here is the caller graph for this function:

◆ reset()

void Boundary::reset ( )
inherited

Resets the boundary.

Definition at line 63 of file Boundary.cpp.

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

◆ scale()

Boundary & Boundary::scale ( double by)
inherited

scale the boundary by the given amount

Returns
a reference to the instance for further use

Definition at line 351 of file Boundary.cpp.

References growHeight(), growWidth(), myXmax, myXmin, myYmax, and myYmin.

◆ 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 91 of file LayeredRTree.h.

References myLayers.

◆ selectLayer()

size_t LayeredRTree::selectLayer ( GUIGlObject * o)
inlineprivate

select the appropriate layer for each object

Definition at line 107 of file LayeredRTree.h.

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

Referenced by Insert(), and Remove().

Here is the caller graph for this function:

◆ set()

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

Sets the boundary to the given values.

Definition at line 409 of file Boundary.cpp.

References MAX2(), MIN2(), myXmax, myXmin, myYmax, myYmin, xmax(), xmin(), ymax(), and ymin().

◆ setOffsets()

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

Sets the boundary to the given values, ignoring min < max constraints.

Definition at line 424 of file Boundary.cpp.

References myXmax, myXmin, myYmax, myYmin, xmax(), xmin(), ymax(), and ymin().

Referenced by main().

Here is the caller graph for this function:

◆ updateBoundaries()

void SUMORTree::updateBoundaries ( GUIGlObjectType type)
inlineinherited

◆ xmax()

◆ xmin()

◆ ymax()

◆ ymin()

◆ zmax()

double Boundary::zmax ( ) const
inherited

Returns maximum z-coordinate.

Definition at line 145 of file Boundary.cpp.

References myZmax.

Referenced by add().

Here is the caller graph for this function:

◆ zmin()

double Boundary::zmin ( ) const
inherited

Returns minimum z-coordinate.

Definition at line 139 of file Boundary.cpp.

References myZmin.

Referenced by add().

Here is the caller graph for this function:

Field Documentation

◆ myLayers

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

the layers for drawing

Definition at line 102 of file LayeredRTree.h.

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

◆ myLock

FXMutex SUMORTree::myLock
mutableprotectedinherited

A mutex avoiding parallel change and traversal of the tree.

Definition at line 223 of file SUMORTree.h.

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

◆ myTreeDebug

std::map<GUIGlObject*, Boundary> SUMORTree::myTreeDebug
privateinherited

Map only used for check that SUMORTree works as expected, only is used if option "gui-testing-debug-gl" is enabled.

Note
Warning: DO NOT USE in release mode and use it in debug mode carefully, due it produces a slowdown.

Definition at line 232 of file SUMORTree.h.

Referenced by addAdditionalGLObject(), removeAdditionalGLObject(), and removeObjectFromTreeDebug().

◆ myTreeSize

int SUMORTree::myTreeSize = 0
protectedinherited

number of inserted elements

Definition at line 226 of file SUMORTree.h.

Referenced by addAdditionalGLObject(), removeAdditionalGLObject(), and updateBoundaries().

◆ myWasInitialised

bool Boundary::myWasInitialised
privateinherited

Information whether the boundary was initialised.

Definition at line 175 of file Boundary.h.

Referenced by add(), Boundary(), Boundary(), Boundary(), isInitialised(), operator==(), and reset().

◆ myXmax

◆ myXmin

◆ myYmax

◆ myYmin

◆ myZmax

double Boundary::myZmax
privateinherited

◆ myZmin

double Boundary::myZmin
privateinherited

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