SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SUMORTree.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 SUMORTree_h
21 #define SUMORTree_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 
35 #include <utils/geom/Boundary.h>
37 
38 #include "RTree.h"
39 
40 
41 // specialized implementation for speedup and avoiding warnings
42 template<>
44 {
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 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
61 class SUMORTree : private RTree<GUIGlObject*, GUIGlObject, float, 2, GUIVisualizationSettings>, public Boundary
62 {
63 public:
67  }
68 
69 
71  virtual ~SUMORTree() {
72  }
73 
74 
81  virtual void Insert(const float a_min[2], const float a_max[2], GUIGlObject* a_dataId) {
84  }
85 
86 
93  virtual void Remove(const float a_min[2], const float a_max[2], GUIGlObject* a_dataId) {
96  }
97 
98 
108  virtual int Search(const float a_min[2], const float a_max[2], const GUIVisualizationSettings& c) {
111  }
112 
113 
119  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
120  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
121  Insert(cmin, cmax, o);
122  }
123 
124 
130  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
131  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
132  Remove(cmin, cmax, o);
133  }
134 
135 
136 protected:
139 
140 };
141 
142 
143 #endif
144 
145 /****************************************************************************/
146 
MFXMutex myLock
A mutex avoiding parallel change and traversal of the tree.
Definition: SUMORTree.h:138
virtual void Insert(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], const DATATYPE &a_dataId)
ELEMTYPEREAL RectSphericalVolume(Rect *a_rect)
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
Stores the information about how to visualize structures.
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:112
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
Definition: SUMORTree.h:128
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
virtual int Search(const float a_min[2], const float a_max[2], const GUIVisualizationSettings &c)
Find all within search rectangle.
Definition: SUMORTree.h:108
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:61
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)
ELEMTYPE m_max[NUMDIMS]
Max dimensions of bounding box.
Definition: RTree.h:271
#define ASSERT
Definition: RTree.h:12
Definition: RTree.h:61
virtual void Insert(const float a_min[2], const float a_max[2], GUIGlObject *a_dataId)
Insert entry.
Definition: SUMORTree.h:81
virtual int Search(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], const CONTEXT &c)
DK 15.10.2008 - begin.
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
Definition: SUMORTree.h:117
A mutex encapsulator which locks/unlocks the given mutex on construction/destruction, respectively.
Definition: AbstractMutex.h:71
SUMORTree()
Constructor.
Definition: SUMORTree.h:65
virtual void Remove(const float a_min[2], const float a_max[2], GUIGlObject *a_dataId)
Remove entry.
Definition: SUMORTree.h:93
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
Minimal bounding rectangle (n-dimensional)
Definition: RTree.h:268
virtual ~SUMORTree()
Destructor.
Definition: SUMORTree.h:71