SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TraCIRTree.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A RT-tree for efficient storing of SUMO's GL-objects
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef TraCIRTree_h
21 #define TraCIRTree_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <set>
34 #include <foreign/rtree/RTree.h>
35 #include <utils/common/Named.h>
36 
37 //#include "RTree.h"
38 
39 
40 // specialized implementation for speedup and avoiding warnings
41 template<>
43  ASSERT(a_rect);
44  const float extent0 = a_rect->m_max[0] - a_rect->m_min[0];
45  const float extent1 = a_rect->m_max[1] - a_rect->m_min[1];
46  return .78539816f * (extent0 * extent0 + extent1 * extent1);
47 }
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
59 class TraCIRTree : private RTree<Named*, Named, float, 2, Named::StoringVisitor >, public Boundary {
60 public:
63  : RTree<Named*, Named, float, 2, Named::StoringVisitor, float>(&Named::addTo) {
64  }
65 
66 
69  }
70 
71 
78  void Insert(const float a_min[2], const float a_max[2], Named* a_dataId) {
79  //AbstractMutex::ScopedLocker locker(myLock);
81  }
82 
83 
90  void Remove(const float a_min[2], const float a_max[2], Named* a_dataId) {
91  //AbstractMutex::ScopedLocker locker(myLock);
93  }
94 
95 
105  int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor& c) {
106  //AbstractMutex::ScopedLocker locker(myLock);
108  }
109 
110 
115  void addObject(Named* o, Boundary& b) {
116  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
117  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
118  Insert(cmin, cmax, o);
119  }
120 
121 
126  void addObject(Named* o, Position& p) {
127  Boundary b;
128  b.add(p);
129  addObject(o, b);
130  }
131 
132 
137  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
138  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
139  Remove(cmin, cmax, o);
140  }
141 
142 
143 protected:
145  //MFXMutex myLock;
146 
147 };
148 
149 
150 #endif
151 
152 /****************************************************************************/
153 
virtual void Insert(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], const DATATYPE &a_dataId)
ELEMTYPEREAL RectSphericalVolume(Rect *a_rect)
void removeAdditionalGLObject(Named *o, Boundary &b)
Removes an additional object (detector/shape/trigger) from being visualised.
Definition: TraCIRTree.h:136
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
TraCIRTree()
Constructor.
Definition: TraCIRTree.h:62
void Insert(const float a_min[2], const float a_max[2], Named *a_dataId)
Insert entry.
Definition: TraCIRTree.h:78
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:112
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:118
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
ELEMTYPE m_min[NUMDIMS]
Min dimensions of bounding box.
Definition: RTree.h:270
virtual void Remove(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], const DATATYPE &a_dataId)
void Remove(const float a_min[2], const float a_max[2], Named *a_dataId)
Remove entry.
Definition: TraCIRTree.h:90
ELEMTYPE m_max[NUMDIMS]
Max dimensions of bounding box.
Definition: RTree.h:271
#define ASSERT
Definition: RTree.h:12
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
Definition: RTree.h:61
void addObject(Named *o, Boundary &b)
Adds an additional object (detector/shape/trigger) for visualisation.
Definition: TraCIRTree.h:115
Base class for objects which have an id.
Definition: Named.h:45
~TraCIRTree()
Destructor.
Definition: TraCIRTree.h:68
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: TraCIRTree.h:59
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition: Named.h:85
virtual int Search(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], const CONTEXT &c)
DK 15.10.2008 - begin.
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
void addObject(Named *o, Position &p)
Adds an additional object (detector/shape/trigger) for visualisation.
Definition: TraCIRTree.h:126
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
Minimal bounding rectangle (n-dimensional)
Definition: RTree.h:268
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c)
Find all within search rectangle.
Definition: TraCIRTree.h:105