SUMO - Simulation of Urban MObility

SUMORTree.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // An rtree for networks
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef SUMORTree_h
00020 #define SUMORTree_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <utils/gui/globjects/GUIGlObject.h>
00033 #include <utils/gui/settings/GUIVisualizationSettings.h>
00034 #include <utils/geom/Boundary.h>
00035 
00036 #include "RTree.h"
00037 
00038 
00039 // specialized implementation for speedup and avoiding warnings
00040 template<>
00041 inline float RTree<GUIGlObject*, GUIGlObject, float, 2, GUIVisualizationSettings, float, 8, 4>::RectSphericalVolume(Rect* a_rect)
00042 {
00043   ASSERT(a_rect);
00044   const float extent0 = a_rect->m_max[0] - a_rect->m_min[0];
00045   const float extent1 = a_rect->m_max[1] - a_rect->m_min[1];
00046   return .78539816f * (extent0 * extent0 + extent1 * extent1);
00047 }
00048 
00049 
00050 // ===========================================================================
00051 // class definitions
00052 // ===========================================================================
00053 class SUMORTree : public RTree<GUIGlObject*, GUIGlObject, float, 2, GUIVisualizationSettings>, public Boundary
00054 {
00055 public:
00056     SUMORTree() 
00057         : RTree<GUIGlObject*, GUIGlObject, float, 2, GUIVisualizationSettings, float>(&GUIGlObject::drawGL){
00058     }
00059 
00060     ~SUMORTree() {
00061     }
00062 
00066     void addAdditionalGLObject(GUIGlObject *o) throw() {
00067         Boundary b = o->getCenteringBoundary();
00068         const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
00069         const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
00070         Insert(cmin, cmax, o);
00071     }
00072 
00076     void removeAdditionalGLObject(GUIGlObject *o) throw() {
00077         Boundary b = o->getCenteringBoundary();
00078         const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
00079         const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
00080         Remove(cmin, cmax, o);
00081     }
00082 
00083 };
00084 
00085 
00086 #endif
00087 
00088 /****************************************************************************/
00089 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines