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 /****************************************************************************/
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