00001 /****************************************************************************/ 00007 // ------------------- 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright 2001-2010 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 00020 00021 // =========================================================================== 00022 // included modules 00023 // =========================================================================== 00024 #ifdef _MSC_VER 00025 #include <windows_config.h> 00026 #else 00027 #include <config.h> 00028 #endif 00029 00030 00031 #include <iostream> // !!! debug 00032 #include <cassert> 00033 #include "NIVissimNodeDef.h" 00034 #include "NIVissimConnection.h" 00035 #include "NIVissimDisturbance.h" 00036 #include "NIVissimTL.h" 00037 00038 #ifdef CHECK_MEMORY_LEAKS 00039 #include <foreign/nvwa/debug_new.h> 00040 #endif // CHECK_MEMORY_LEAKS 00041 // =========================================================================== 00042 // used namespaces 00043 // =========================================================================== 00044 00045 using namespace std; 00046 00047 NIVissimNodeDef::DictType NIVissimNodeDef::myDict; 00048 int NIVissimNodeDef::myMaxID = 0; 00049 00050 NIVissimNodeDef::NIVissimNodeDef(int id, const std::string &name) 00051 : myID(id), myName(name) {} 00052 00053 00054 NIVissimNodeDef::~NIVissimNodeDef() {} 00055 00056 00057 bool 00058 NIVissimNodeDef::dictionary(int id, NIVissimNodeDef *o) { 00059 DictType::iterator i=myDict.find(id); 00060 if (i==myDict.end()) { 00061 myDict[id] = o; 00062 myMaxID = myMaxID > id 00063 ? myMaxID 00064 : id; 00065 // o->computeBounding(); 00066 return true; 00067 } 00068 return false; 00069 } 00070 00071 00072 NIVissimNodeDef * 00073 NIVissimNodeDef::dictionary(int id) { 00074 DictType::iterator i=myDict.find(id); 00075 if (i==myDict.end()) { 00076 return 0; 00077 } 00078 return (*i).second; 00079 } 00080 00081 /* 00082 void 00083 NIVissimNodeDef::buildNodeClusters() 00084 { 00085 for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) { 00086 int cluster = (*i).second->buildNodeCluster(); 00087 } 00088 } 00089 */ 00090 00091 00092 /* 00093 00094 IntVector 00095 NIVissimNodeDef::getWithin(const AbstractPoly &p, SUMOReal off) 00096 { 00097 IntVector ret; 00098 for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) { 00099 NIVissimNodeDef *d = (*i).second; 00100 if(d->partialWithin(p, off)) { 00101 ret.push_back((*i).first); 00102 } 00103 } 00104 return ret; 00105 } 00106 00107 bool 00108 NIVissimNodeDef::partialWithin(const AbstractPoly &p, SUMOReal off) const 00109 { 00110 assert(myBoundary!=0&&myBoundary->xmax()>=myBoundary->xmin()); 00111 return myBoundary->partialWithin(p, off); 00112 } 00113 */ 00114 00115 void 00116 NIVissimNodeDef::dict_assignConnectionsToNodes() { 00117 for (DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) { 00118 (*i).second->searchAndSetConnections(); 00119 } 00120 } 00121 00122 00123 size_t 00124 NIVissimNodeDef::dictSize() { 00125 return myDict.size(); 00126 } 00127 00128 00129 00130 void 00131 NIVissimNodeDef::clearDict() { 00132 for (DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) { 00133 delete(*i).second; 00134 } 00135 myDict.clear(); 00136 } 00137 00138 00139 int 00140 NIVissimNodeDef::getMaxID() { 00141 return myMaxID; 00142 } 00143 00144 00145 00146 /****************************************************************************/ 00147
1.5.6