33 #define GUI_RTREE_QUAL RTree<GUIGlObject*, GUIGlObject, float, 2, GUIVisualizationSettings>
38 inline float GUI_RTREE_QUAL::RectSphericalVolume(Rect* a_rect) {
40 const float extent0 = a_rect->m_max[0] - a_rect->m_min[0];
41 const float extent1 = a_rect->m_max[1] - a_rect->m_min[1];
42 return .78539816f * (extent0 * extent0 + extent1 * extent1);
46 inline GUI_RTREE_QUAL::Rect GUI_RTREE_QUAL::CombineRect(Rect* a_rectA, Rect* a_rectB) {
47 ASSERT(a_rectA && a_rectB);
49 newRect.m_min[0] =
rtree_min(a_rectA->m_min[0], a_rectB->m_min[0]);
50 newRect.m_max[0] =
rtree_max(a_rectA->m_max[0], a_rectB->m_max[0]);
51 newRect.m_min[1] =
rtree_min(a_rectA->m_min[1], a_rectB->m_min[1]);
52 newRect.m_max[1] =
rtree_max(a_rectA->m_max[1], a_rectB->m_max[1]);
79 WRITE_ERROR(
"Mutex of SUMORTree is locked during call of the destructor");
91 virtual void Insert(
const float a_min[2],
const float a_max[2],
GUIGlObject*
const & a_dataId) {
92 FXMutexLock locker(
myLock);
93 GUI_RTREE_QUAL::Insert(a_min, a_max, a_dataId);
102 virtual void Remove(
const float a_min[2],
const float a_max[2],
GUIGlObject*
const & a_dataId) {
103 FXMutexLock locker(
myLock);
104 GUI_RTREE_QUAL::Remove(a_min, a_max, a_dataId);
117 FXMutexLock locker(
myLock);
118 return GUI_RTREE_QUAL::Search(a_min, a_max, c);
127 throw ProcessError(
"Mutex of SUMORTree is locked before object insertion");
130 FXMutexLock locker(
myLock);
134 if (exaggeration > 1) {
135 b.
scale(exaggeration);
150 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
151 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
161 throw ProcessError(
"Mutex of SUMORTree is locked before object remove");
164 FXMutexLock locker(
myLock);
168 if (exaggeration > 1) {
169 b.
scale(exaggeration);
187 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
188 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
#define WRITE_GLDEBUG(msg)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
double getHeight() const
Returns the height of the boundary (y-axis)
double getWidth() const
Returns the width of the boudary (x-axis)
Boundary & scale(double by)
scale the boundary by the given amount
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
virtual Boundary getCenteringBoundary() const =0
const std::string & getFullName() const
Stores the information about how to visualize structures.
static bool writeDebugGLMessages()
check whether to enable/disable gl-debug messages
A RT-tree for efficient storing of SUMO's GL-objects.
void addAdditionalGLObject(GUIGlObject *o, const double exaggeration=1)
Adds an additional object (detector/shape/trigger) for visualisation.
virtual void Remove(const float a_min[2], const float a_max[2], GUIGlObject *const &a_dataId)
Remove entry.
std::map< GUIGlObject *, Boundary > myTreeDebug
Map only used for check that SUMORTree works as expected, only is used if option "gui-testing-debug-g...
virtual void Insert(const float a_min[2], const float a_max[2], GUIGlObject *const &a_dataId)
Insert entry.
void removeAdditionalGLObject(GUIGlObject *o, const double exaggeration=1)
Removes an additional object (detector/shape/trigger) from being visualised.
virtual int Search(const float a_min[2], const float a_max[2], const GUIVisualizationSettings &c) const
Find all within search rectangle.
FXMutex myLock
A mutex avoiding parallel change and traversal of the tree.
virtual ~SUMORTree()
Destructor.