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