SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NamedRTree.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A RT-tree for efficient storing of SUMO's Named objects
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2014 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 NamedRTree_h
21 #define NamedRTree_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 
38 // specialized implementation for speedup and avoiding warnings
39 #define NAMED_RTREE_QUAL RTree<Named*, Named, float, 2, Named::StoringVisitor, float, 8, 4>
40 
41 template<>
42 inline float NAMED_RTREE_QUAL::RectSphericalVolume(Rect* a_rect) {
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 template<>
50 inline NAMED_RTREE_QUAL::Rect NAMED_RTREE_QUAL::CombineRect(Rect* a_rectA, Rect* a_rectB) {
51  ASSERT(a_rectA && a_rectB);
52  Rect newRect;
53  newRect.m_min[0] = rtree_min(a_rectA->m_min[0], a_rectB->m_min[0]);
54  newRect.m_max[0] = rtree_max(a_rectA->m_max[0], a_rectB->m_max[0]);
55  newRect.m_min[1] = rtree_min(a_rectA->m_min[1], a_rectB->m_min[1]);
56  newRect.m_max[1] = rtree_max(a_rectA->m_max[1], a_rectB->m_max[1]);
57  return newRect;
58 }
59 
60 // ===========================================================================
61 // class definitions
62 // ===========================================================================
70 class NamedRTree : private RTree<Named*, Named, float, 2, Named::StoringVisitor > {
71 public:
74  : RTree<Named*, Named, float, 2, Named::StoringVisitor, float>(&Named::addTo) {
75  }
76 
77 
80  }
81 
82 
89  void Insert(const float a_min[2], const float a_max[2], Named* a_data) {
91  }
92 
93 
100  void Remove(const float a_min[2], const float a_max[2], Named* a_data) {
102  }
103 
104 
108  void RemoveAll() {
110  }
111 
112 
122  int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor& c) const {
124  }
125 
126 
127 };
128 
129 
130 #endif
131 
132 /****************************************************************************/
133 
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:100
void Insert(const float a_min[2], const float a_max[2], Named *a_data)
Insert entry.
Definition: NamedRTree.h:89
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:73
A RT-tree for efficient storing of SUMO's Named objects.
Definition: NamedRTree.h:70
void RemoveAll()
Remove all enrties.
Definition: NamedRTree.h:108
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:122
~NamedRTree()
Destructor.
Definition: NamedRTree.h:79