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