Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2002-2024 German Aerospace Center (DLR) and others. 4 : // This program and the accompanying materials are made available under the 5 : // terms of the Eclipse Public License 2.0 which is available at 6 : // https://www.eclipse.org/legal/epl-2.0/ 7 : // This Source Code may also be made available under the following Secondary 8 : // Licenses when the conditions for such availability set forth in the Eclipse 9 : // Public License 2.0 are satisfied: GNU General Public License, version 2 10 : // or later which is available at 11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html 12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later 13 : /****************************************************************************/ 14 : /// @file NIVissimNodeDef.cpp 15 : /// @author Daniel Krajzewicz 16 : /// @author Michael Behrisch 17 : /// @date Sept 2002 18 : /// 19 : // ------------------- 20 : /****************************************************************************/ 21 : #include <config.h> 22 : 23 : 24 : #include <iostream> // !!! debug 25 : #include <cassert> 26 : #include "NIVissimNodeDef.h" 27 : #include "NIVissimConnection.h" 28 : #include "NIVissimDisturbance.h" 29 : #include "NIVissimTL.h" 30 : 31 : 32 : // =========================================================================== 33 : // static member variables 34 : // =========================================================================== 35 : NIVissimNodeDef::DictType NIVissimNodeDef::myDict; 36 : int NIVissimNodeDef::myMaxID = 0; 37 : 38 : 39 : // =========================================================================== 40 : // method definitions 41 : // =========================================================================== 42 105 : NIVissimNodeDef::NIVissimNodeDef(int id, const std::string& name) 43 105 : : myID(id), myName(name) {} 44 : 45 : 46 105 : NIVissimNodeDef::~NIVissimNodeDef() {} 47 : 48 : 49 : bool 50 105 : NIVissimNodeDef::dictionary(int id, NIVissimNodeDef* o) { 51 : DictType::iterator i = myDict.find(id); 52 105 : if (i == myDict.end()) { 53 105 : myDict[id] = o; 54 105 : myMaxID = myMaxID > id 55 : ? myMaxID 56 : : id; 57 : // o->computeBounding(); 58 105 : return true; 59 : } 60 : return false; 61 : } 62 : 63 : 64 : NIVissimNodeDef* 65 0 : NIVissimNodeDef::dictionary(int id) { 66 : DictType::iterator i = myDict.find(id); 67 0 : if (i == myDict.end()) { 68 : return nullptr; 69 : } 70 0 : return (*i).second; 71 : } 72 : 73 : /* 74 : void 75 : NIVissimNodeDef::buildNodeClusters() 76 : { 77 : for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) { 78 : int cluster = (*i).second->buildNodeCluster(); 79 : } 80 : } 81 : */ 82 : 83 : 84 : /* 85 : 86 : std::vector<int> 87 : NIVissimNodeDef::getWithin(const AbstractPoly &p, double off) 88 : { 89 : std::vector<int> ret; 90 : for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) { 91 : NIVissimNodeDef *d = (*i).second; 92 : if(d->partialWithin(p, off)) { 93 : ret.push_back((*i).first); 94 : } 95 : } 96 : return ret; 97 : } 98 : 99 : bool 100 : NIVissimNodeDef::partialWithin(const AbstractPoly &p, double off) const 101 : { 102 : assert(myBoundary!=0&&myBoundary->xmax()>=myBoundary->xmin()); 103 : return myBoundary->partialWithin(p, off); 104 : } 105 : 106 : 107 : void 108 : NIVissimNodeDef::dict_assignConnectionsToNodes() { 109 : for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) { 110 : (*i).second->searchAndSetConnections(); 111 : } 112 : } 113 : */ 114 : 115 : 116 : void 117 9 : NIVissimNodeDef::clearDict() { 118 114 : for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) { 119 105 : delete (*i).second; 120 : } 121 : myDict.clear(); 122 9 : } 123 : 124 : 125 : int 126 9 : NIVissimNodeDef::getMaxID() { 127 9 : return myMaxID; 128 : } 129 : 130 : 131 : /****************************************************************************/