SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LayeredRTree Class Reference

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

#include <LayeredRTree.h>

Inheritance diagram for LayeredRTree:
SUMORTree RTree< GUIGlObject *, GUIGlObject, float, 2, GUIVisualizationSettings > Boundary AbstractPoly

Public Member Functions

void add (SUMOReal x, SUMOReal y)
 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, SUMOReal 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...
 
void flipY ()
 flips ymin and ymax More...
 
Position getCenter () const
 Returns the center of the boundary. More...
 
SUMOReal getHeight () const
 Returns the height of the boundary. More...
 
SUMOReal getWidth () const
 Returns the width of the boudary. More...
 
Boundarygrow (SUMOReal by)
 extends the boundary by the given amount More...
 
void growHeight (SUMOReal by)
 
void growWidth (SUMOReal by)
 
void Insert (const float a_min[2], const float a_max[2], GUIGlObject *a_dataId)
 Insert entry (delegate to appropriate layer) More...
 
virtual void Insert (const floata_min[NUMDIMS], const floata_max[NUMDIMS], const GUIGlObject *&a_dataId)
 
 LayeredRTree ()
 Constructor. More...
 
void moveby (SUMOReal x, SUMOReal y)
 Moves the boundary by the given amount. More...
 
bool overlapsWith (const AbstractPoly &poly, SUMOReal offset=0) const
 Returns whether the boundary overlaps with the given polygon. More...
 
bool partialWithin (const AbstractPoly &poly, SUMOReal 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 *a_dataId)
 Remove entry (delegate to appropriate layer) More...
 
virtual void Remove (const floata_min[NUMDIMS], const floata_max[NUMDIMS], const GUIGlObject *&a_dataId)
 
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)
 Find all within search rectangle (searches all layers in order) More...
 
virtual int Search (const floata_min[NUMDIMS], const floata_max[NUMDIMS], const GUIVisualizationSettings &c)
 DK 15.10.2008 - begin. More...
 
void set (SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax)
 Sets the boundary to the given values. More...
 
SUMOReal xmax () const
 Returns maximum x-coordinate. More...
 
SUMOReal xmin () const
 Returns minimum x-coordinate. More...
 
SUMOReal ymax () const
 Returns maximum y-coordinate. More...
 
SUMOReal ymin () const
 Returns minimum y-coordinate. More...
 
 ~LayeredRTree ()
 Destructor. More...
 

Protected Member Functions

bool Search (Node *a_node, Rect *a_rect, int &a_foundCount, const GUIVisualizationSettings &c)
 

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

Constructor & Destructor Documentation

LayeredRTree::LayeredRTree ( )
inline

Constructor.

Definition at line 59 of file LayeredRTree.h.

References myLayers, and SUMORTree::SUMORTree().

LayeredRTree::~LayeredRTree ( )
inline

Destructor.

Definition at line 66 of file LayeredRTree.h.

References myLayers.

Member Function Documentation

void Boundary::add ( const Position p)
inherited

Makes the boundary include the given coordinate.

Definition at line 93 of file Boundary.cpp.

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

void Boundary::add ( const Boundary p)
inherited

Makes the boundary include the given boundary.

Definition at line 99 of file Boundary.cpp.

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

void SUMORTree::addAdditionalGLObject ( GUIGlObject o)
inlineinherited
bool Boundary::around ( const Position p,
SUMOReal  offset = 0 
) const
virtualinherited

Returns whether the boundary contains the given coordinate.

Implements AbstractPoly.

Definition at line 148 of file Boundary.cpp.

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

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

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

Returns whether the boundary crosses the given line.

Implements AbstractPoly.

Definition at line 177 of file Boundary.cpp.

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

void Boundary::flipY ( )
inherited

flips ymin and ymax

Definition at line 222 of file Boundary.cpp.

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

void LayeredRTree::Insert ( const float  a_min[2],
const float  a_max[2],
GUIGlObject 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 79 of file LayeredRTree.h.

References myLayers, and selectLayer().

Referenced by GUINet::initGUIStructures().

virtual void RTree< GUIGlObject * , GUIGlObject , float , NUMDIMS, GUIVisualizationSettings , float , 8 , 8 / 2 >::Insert ( const float  a_min[NUMDIMS],
const float  a_max[NUMDIMS],
const GUIGlObject * &  a_dataId 
)
virtualinherited

Insert entry

Parameters
a_minMin of bounding rect
a_maxMax of bounding rect
a_dataIdPositive Id of data. Maybe zero, but negative numbers not allowed.
void Boundary::moveby ( SUMOReal  x,
SUMOReal  y 
)
inherited
bool Boundary::overlapsWith ( const AbstractPoly poly,
SUMOReal  offset = 0 
) const
virtualinherited
bool Boundary::partialWithin ( const AbstractPoly poly,
SUMOReal  offset = 0 
) const
virtualinherited

Returns whether the boundary is partially within the given polygon.

Implements AbstractPoly.

Definition at line 190 of file Boundary.cpp.

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

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

void LayeredRTree::Remove ( const float  a_min[2],
const float  a_max[2],
GUIGlObject 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 89 of file LayeredRTree.h.

References myLayers, and selectLayer().

virtual void RTree< GUIGlObject * , GUIGlObject , float , NUMDIMS, GUIVisualizationSettings , float , 8 , 8 / 2 >::Remove ( const float  a_min[NUMDIMS],
const float  a_max[NUMDIMS],
const GUIGlObject * &  a_dataId 
)
virtualinherited

Remove entry

Parameters
a_minMin of bounding rect
a_maxMax of bounding rect
a_dataIdPositive Id of data. Maybe zero, but negative numbers not allowed.
void SUMORTree::removeAdditionalGLObject ( GUIGlObject o)
inlineinherited

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

Parameters
[in]oThe object to remove

Definition at line 128 of file SUMORTree.h.

References GUIGlObject::getCenteringBoundary(), SUMORTree::Remove(), Boundary::xmax(), Boundary::xmin(), Boundary::ymax(), and Boundary::ymin().

Referenced by GUIShapeContainer::movePOI(), GUIShapeContainer::removePOI(), GUIShapeContainer::removePolygon(), and GUIShapeContainer::reshapePolygon().

void Boundary::reset ( )
inherited

Resets the boundary.

Definition at line 66 of file Boundary.cpp.

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

int LayeredRTree::Search ( const float  a_min[2],
const float  a_max[2],
const GUIVisualizationSettings c 
)
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 101 of file LayeredRTree.h.

References myLayers.

virtual int RTree< GUIGlObject * , GUIGlObject , float , NUMDIMS, GUIVisualizationSettings , float , 8 , 8 / 2 >::Search ( const float  a_min[NUMDIMS],
const float  a_max[NUMDIMS],
const GUIVisualizationSettings c 
)
virtualinherited

DK 15.10.2008 - begin.

Find all within search rectangle

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
bool RTree< GUIGlObject * , GUIGlObject , float , NUMDIMS, GUIVisualizationSettings , float , 8 , 8 / 2 >::Search ( Node *  a_node,
Rect *  a_rect,
int a_foundCount,
const GUIVisualizationSettings c 
)
protectedinherited
size_t LayeredRTree::selectLayer ( GUIGlObject o)
inlineprivate

select the appropriate layer for each object

Definition at line 117 of file LayeredRTree.h.

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

Referenced by Insert(), and Remove().

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

Sets the boundary to the given values.

Definition at line 240 of file Boundary.cpp.

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

Field Documentation

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

the layers for drawing

Definition at line 112 of file LayeredRTree.h.

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

MFXMutex SUMORTree::myLock
protectedinherited

A mutex avoiding parallel change and traversal of the tree.

Definition at line 138 of file SUMORTree.h.

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


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