SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
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
33
#include <
utils/gui/globjects/GUIGlObject.h
>
34
#include <
utils/gui/settings/GUIVisualizationSettings.h
>
35
#include <
utils/geom/Boundary.h
>
36
#include <
utils/foxtools/MFXMutex.h
>
37
38
#include "
RTree.h
"
39
40
41
// specialized implementation for speedup and avoiding warnings
42
template
<>
43
inline
float
RTree<GUIGlObject*, GUIGlObject, float, 2, GUIVisualizationSettings, float, 8, 4>::RectSphericalVolume
(
Rect
* a_rect)
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
:
65
SUMORTree
()
66
:
RTree
<
GUIGlObject
*,
GUIGlObject
,
float
, 2,
GUIVisualizationSettings
,
float
>(&
GUIGlObject
::drawGL){
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) {
82
AbstractMutex::ScopedLocker
locker(
myLock
);
83
RTree<GUIGlObject*, GUIGlObject, float, 2, GUIVisualizationSettings, float>::Insert
(a_min, a_max, a_dataId);
84
}
85
86
93
virtual
void
Remove
(
const
float
a_min[2],
const
float
a_max[2],
GUIGlObject
* a_dataId) {
94
AbstractMutex::ScopedLocker
locker(
myLock
);
95
RTree<GUIGlObject*, GUIGlObject, float, 2, GUIVisualizationSettings, float>::Remove
(a_min, a_max, a_dataId);
96
}
97
98
108
virtual
int
Search
(
const
float
a_min[2],
const
float
a_max[2],
const
GUIVisualizationSettings
& c)
const
{
109
AbstractMutex::ScopedLocker
locker(
myLock
);
110
return
RTree<GUIGlObject*, GUIGlObject, float, 2, GUIVisualizationSettings, float>::Search
(a_min, a_max, c);
111
}
112
113
117
void
addAdditionalGLObject
(
GUIGlObject
*o) {
118
AbstractMutex::ScopedLocker
locker(
myLock
);
119
Boundary
b = o->
getCenteringBoundary
();
120
const
float
cmin[2] = {(
float
) b.
xmin
(), (
float
) b.
ymin
()};
121
const
float
cmax[2] = {(
float
) b.
xmax
(), (
float
) b.
ymax
()};
122
Insert
(cmin, cmax, o);
123
}
124
125
129
void
removeAdditionalGLObject
(
GUIGlObject
*o) {
130
AbstractMutex::ScopedLocker
locker(
myLock
);
131
Boundary
b = o->
getCenteringBoundary
();
132
const
float
cmin[2] = {(
float
) b.
xmin
(), (
float
) b.
ymin
()};
133
const
float
cmax[2] = {(
float
) b.
xmax
(), (
float
) b.
ymax
()};
134
Remove
(cmin, cmax, o);
135
}
136
137
138
protected
:
140
mutable
MFXMutex
myLock
;
141
142
};
143
144
145
#endif
146
147
/****************************************************************************/
148
home
delphi
sumo
src
foreign
rtree
SUMORTree.h
Generated by
1.8.2