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