SUMO - Simulation of Urban MObility
NamedRTree.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A RT-tree for efficient storing of SUMO's Named objects
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2008-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef NamedRTree_h
23 #define NamedRTree_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <set>
36 #include <foreign/rtree/RTree.h>
37 #include <utils/common/Named.h>
38 
39 
40 // specialized implementation for speedup and avoiding warnings
41 #define NAMED_RTREE_QUAL RTree<Named*, Named, float, 2, Named::StoringVisitor, float, 8, 4>
42 
43 template<>
44 inline float NAMED_RTREE_QUAL::RectSphericalVolume(Rect* a_rect) {
45  ASSERT(a_rect);
46  const float extent0 = a_rect->m_max[0] - a_rect->m_min[0];
47  const float extent1 = a_rect->m_max[1] - a_rect->m_min[1];
48  return .78539816f * (extent0 * extent0 + extent1 * extent1);
49 }
50 
51 template<>
52 inline NAMED_RTREE_QUAL::Rect NAMED_RTREE_QUAL::CombineRect(Rect* a_rectA, Rect* a_rectB) {
53  ASSERT(a_rectA && a_rectB);
54  Rect newRect;
55  newRect.m_min[0] = rtree_min(a_rectA->m_min[0], a_rectB->m_min[0]);
56  newRect.m_max[0] = rtree_max(a_rectA->m_max[0], a_rectB->m_max[0]);
57  newRect.m_min[1] = rtree_min(a_rectA->m_min[1], a_rectB->m_min[1]);
58  newRect.m_max[1] = rtree_max(a_rectA->m_max[1], a_rectB->m_max[1]);
59  return newRect;
60 }
61 
62 // ===========================================================================
63 // class definitions
64 // ===========================================================================
72 class NamedRTree : private RTree<Named*, Named, float, 2, Named::StoringVisitor > {
73 public:
76  : RTree<Named*, Named, float, 2, Named::StoringVisitor, float>(&Named::addTo) {
77  }
78 
79 
82  }
83 
84 
91  void Insert(const float a_min[2], const float a_max[2], Named* a_data) {
93  }
94 
95 
102  void Remove(const float a_min[2], const float a_max[2], Named* a_data) {
104  }
105 
106 
110  void RemoveAll() {
112  }
113 
114 
124  int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor& c) const {
126  }
127 
128 
129 };
130 
131 
132 #endif
133 
134 /****************************************************************************/
135 
virtual void Insert(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_data)
Remove entry.
Definition: NamedRTree.h:102
void Insert(const float a_min[2], const float a_max[2], Named *a_data)
Insert entry.
Definition: NamedRTree.h:91
virtual int Search(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], const CONTEXT &c) const
DK 15.10.2008 - begin.
NamedRTree()
Constructor.
Definition: NamedRTree.h:75
A RT-tree for efficient storing of SUMO's Named objects.
Definition: NamedRTree.h:72
void RemoveAll()
Remove all enrties.
Definition: NamedRTree.h:110
virtual void Remove(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], const DATATYPE &a_dataId)
void RemoveAll()
DK 15.10.2008 - end.
#define ASSERT
Definition: RTree.h:12
#define rtree_min(a, b)
Definition: RTree.h:20
Definition: RTree.h:61
#define rtree_max(a, b)
Definition: RTree.h:21
Base class for objects which have an id.
Definition: Named.h:45
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition: Named.h:92
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
Definition: NamedRTree.h:124
~NamedRTree()
Destructor.
Definition: NamedRTree.h:81