68 #ifdef CHECK_MEMORY_LEAKS
70 #endif // CHECK_MEMORY_LEAKS
85 myApproaching(approaching), myCurrentOutgoing(currentOutgoing) {
96 assert(myApproaching->size() > src);
98 NBEdge* incomingEdge = (*myApproaching)[src];
102 std::vector<int> approachingLanes =
104 assert(approachingLanes.size() != 0);
105 std::deque<int>* approachedLanes = spread(approachingLanes, dest);
106 assert(approachedLanes->size() <= myCurrentOutgoing->getNumLanes());
108 for (
unsigned int i = 0; i < approachedLanes->size(); i++) {
109 unsigned int approached = (*approachedLanes)[i];
110 assert(approachedLanes->size() > i);
111 assert(approachingLanes.size() > i);
112 incomingEdge->setConnection((
unsigned int) approachingLanes[i], myCurrentOutgoing,
115 delete approachedLanes;
122 std::deque<int>* ret =
new std::deque<int>();
123 unsigned int noLanes = (
unsigned int) approachingLanes.size();
127 ret->push_back(dest);
131 unsigned int noOutgoingLanes = myCurrentOutgoing->getNumLanes();
133 ret->push_back(dest);
134 unsigned int noSet = 1;
137 while (noSet < noLanes) {
143 if (noOutgoingLanes == noSet) {
152 if (dest + loffset >= static_cast<int>(noOutgoingLanes)) {
155 for (
unsigned int i = 0; i < ret->size(); i++) {
156 (*ret)[i] = (*ret)[i] - 1;
161 ret->push_back(dest + loffset);
166 if (noOutgoingLanes == noSet) {
171 if (noSet < noLanes) {
174 if (dest < roffset) {
177 for (
unsigned int i = 0; i < ret->size(); i++) {
178 (*ret)[i] = (*ret)[i] + 1;
181 ret->push_front(dest - roffset);
205 myPosition(position),
206 myType(type), myDistrict(0), myRequest(0)
212 myPosition(position),
224 bool updateEdgeGeometries) {
231 if (updateEdgeGeometries) {
235 (*i)->setGeometry(geom);
240 (*i)->setGeometry(geom);
275 for (std::set<NBTrafficLightDefinition*>::const_iterator i = trafficLights.begin(); i != trafficLights.end(); ++i) {
287 if ((*i)->getID().find(
"joined") == 0) {
298 std::set<NBTrafficLightDefinition*> newDefs;
301 if (dynamic_cast<NBOwnTLDef*>(orig) != 0) {
303 newDefs.insert(orig);
305 const std::string new_id = orig->
getID() +
"_reguessed";
307 if (!tlCont.
insert(newDef)) {
313 newDefs.insert(newDef);
317 for (std::set<NBTrafficLightDefinition*>::iterator it = newDefs.begin(); it != newDefs.end(); ++it) {
318 (*it)->addNode(
this);
327 unsigned int ret = 0;
328 unsigned int pos = 0;
344 if ((*i)->isConnectedTo(dummy) && *i != dummy) {
345 incomingConnected.push_back(*i);
352 outgoingConnected.push_back(*i);
357 remapRemoved(tc, dummy, incomingConnected, outgoingConnected);
406 if (in->
getNumLanes() != (*opposite)->getNumLanes()) {
419 NBEdge* toE,
int toL,
int numPoints)
const {
426 bool noSpline =
false;
432 unsigned int noInitialPoints = 0;
446 Line cross(straightConn);
447 cross.
sub(cross.
p1().
x(), cross.
p1().
y());
449 center.
sub(cross.
p2());
454 if (angle < M_PI / 4. || angle > 7. / 4.*
M_PI) {
495 WRITE_WARNING(
"Could not use edge geometry for internal lane, node '" +
getID() +
"'.");
512 for (
int i = 0; i < (
int) init.size(); ++i) {
514 def[i * 3 + 1] = init[i].x();
516 def[i * 3 + 3] = init[i].y();
519 bezier(noInitialPoints, def, numPoints, ret_buf);
522 for (
int i = 0; i < (
int) numPoints; i++) {
523 Position current(ret_buf[i * 3 + 1], ret_buf[i * 3 + 3]);
524 if (prev != current) {
546 if (fromE == otherFromE) {
550 if (!
foes(otherFromE, otherToE, fromE, toE)) {
558 bool bothLeft = thisLeft && otherLeft;
559 if (c.
tlID !=
"" && !bothLeft) {
592 if (numConnections >= 64) {
594 WRITE_WARNING(
"Junction '" +
getID() +
"' is too complicated (#links>64); will be set to unregulated.");
598 }
else if (numConnections == 0) {
680 std::swap(inc1, inc2);
703 std::swap(out1, out2);
714 EdgeVector::reverse_iterator i;
716 NBEdge* currentOutgoing = *i;
719 if (approaching->size() != 0) {
731 (*i)->markAsInLane2LaneState();
740 EdgeVector::const_iterator i = find(
myAllEdges.begin(),
746 for (; *i != currentOutgoing;) {
748 if ((*i)->getToNode() ==
this && (*i)->getTurnDestination() != currentOutgoing) {
749 std::vector<int> connLanes = (*i)->getConnectionLanes(currentOutgoing);
750 if (connLanes.size() != 0) {
751 approaching->push_back(*i);
781 unsigned int laneOff = 0;
782 for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
784 laneOff += (*i)->getNumLanes();
813 unsigned int laneOff = 0;
814 for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
816 laneOff += (*i)->getNumLanes();
831 unsigned int whichLaneOff,
unsigned int byLaneOff) {
835 bool changed =
false;
837 if (c.
replaceFrom(which, whichLaneOff, by, byLaneOff)) {
840 if (c.
replaceTo(which, whichLaneOff, by, byLaneOff)) {
854 for (NBConnectionVector::iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
856 sprohibiting.
replaceFrom(which, whichLaneOff, by, byLaneOff);
857 sprohibiting.
replaceTo(which, whichLaneOff, by, byLaneOff);
918 if (find(edges.begin(), edges.end(), e) != edges.end()) {
919 edges.erase(find(edges.begin(), edges.end(), e));
921 if (edges.size() == 0) {
937 mayDrive.
getTo() == 0 ||
939 mustStop.
getTo() == 0) {
941 WRITE_WARNING(
"Something went wrong during the building of a connection...");
945 conn.push_back(mayDrive);
952 unsigned int size = (
unsigned int) edgeid.length();
954 std::string
id = (*i)->
getID();
955 if (
id.substr(0, size) == edgeid) {
965 unsigned int size = (
unsigned int) edgeid.length();
967 std::string
id = (*i)->
getID();
968 if (
id.substr(0, size) == edgeid) {
993 if (removeFromConnections) {
995 (*i)->removeFromConnections(edge);
1005 EdgeVector::const_iterator i;
1007 NBNode* conn = (*i)->getFromNode();
1010 toAdd.
mul((
SUMOReal) 1.0 / sqrt(toAdd.
x()*toAdd.
x() + toAdd.
y()*toAdd.
y()));
1014 NBNode* conn = (*i)->getToNode();
1017 toAdd.
mul((
SUMOReal) 1.0 / sqrt(toAdd.
x()*toAdd.
x() + toAdd.
y()*toAdd.
y()));
1021 if (pos.
x() == 0 && pos.
y() == 0) {
1033 (*i)->invalidateConnections();
1041 (*i)->invalidateConnections();
1067 if (!try1 || toLane == -1) {
1070 if (from->
getSpeed() < 70. / 3.6) {
1079 const std::vector<NBEdge::Connection>& connections = (*i)->getConnections();
1080 for (std::vector<NBEdge::Connection>::const_iterator j = connections.begin(); j != connections.end(); ++j) {
1081 if ((*j).toEdge == to && ((*j).toLane < 0 || (*j).toLane == toLane)) {
1101 std::vector<NBEdge*>::const_iterator i = std::find(
myAllEdges.begin(),
myAllEdges.end(), from);
1111 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo,
1112 bool regardNonSignalisedLowerPriority)
const {
1114 possProhibitedFrom, possProhibitedTo,
1115 regardNonSignalisedLowerPriority);
1121 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
1130 assert(find(incoming.begin(), incoming.end(), removed) == incoming.end());
1131 bool changed =
true;
1137 for (NBConnectionProhibits::iterator i = blockedConnectionsTmp.begin(); i != blockedConnectionsTmp.end(); i++) {
1142 bool blockedChanged =
false;
1144 NBConnectionVector::const_iterator j;
1145 for (j = blocked.begin(); j != blocked.end(); j++) {
1147 if (sblocked.
getFrom() == removed || sblocked.
getTo() == removed) {
1148 blockedChanged =
true;
1152 for (j = blocked.begin(); blockedChanged && j != blocked.end(); j++) {
1154 if (sblocked.
getFrom() == removed && sblocked.
getTo() == removed) {
1158 }
else if (sblocked.
getFrom() == removed) {
1159 assert(sblocked.
getTo() != removed);
1160 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1163 }
else if (sblocked.
getTo() == removed) {
1164 assert(sblocked.
getFrom() != removed);
1165 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1172 if (blockedChanged) {
1173 blockedConnectionsNew[blocker] = newBlocked;
1178 if (blocker.
getFrom() == removed && blocker.
getTo() == removed) {
1183 }
else if (blocker.
getFrom() == removed) {
1184 assert(blocker.
getTo() != removed);
1186 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1189 }
else if (blocker.
getTo() == removed) {
1190 assert(blocker.
getFrom() != removed);
1192 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1196 blockedConnectionsNew[blocker] = blocked;
1210 if (outgoing == 0) {
1221 if (
abs((
int) angle) + 1 < 45) {
1228 EdgeVector::const_iterator i =
1231 while ((*i) != incoming) {
1232 if ((*i)->getFromNode() ==
this) {
1240 EdgeVector::const_iterator i =
1243 while ((*i) != incoming) {
1255 bool mayDefinitelyPass,
const std::string& tlID)
const {
1259 if (outgoing == 0) {
1268 if ((!incoming->
isInnerEdge() &&
mustBrake(incoming, outgoing, fromlane)) && !mayDefinitelyPass) {
1282 EdgeVector::const_iterator i;
1295 std::set<NBNode*> origSet;
1297 origSet.insert((*i)->getFromNode());
1299 if (origSet.size() < 2) {
1306 NBNode* origin = (*i)->getFromNode();
1308 EdgeVector::const_iterator j =
1317 if (!(*i)->expandableBy(*j)) {
1333 std::vector<std::pair<NBEdge*, NBEdge*> >
1336 std::vector<std::pair<NBEdge*, NBEdge*> > ret;
1340 std::pair<NBEdge*, NBEdge*>(
1346 NBNode* origin = (*i)->getFromNode();
1347 EdgeVector::const_iterator j =
1351 ret.push_back(std::pair<NBEdge*, NBEdge*>(*i, *j));
1366 if ((*i)->getToNode() == n) {
1381 back_inserter(edges));
1383 back_inserter(edges));
1384 for (EdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
1395 for (EdgeVector::const_iterator k = edges2.begin(); k != edges2.end(); ++k) {
1396 if ((*k)->getFromNode()->isDistrict() || (*k)->getToNode()->isDistrict()) {
1413 unsigned int noInternalNoSplits = 0;
1415 const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
1416 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
1417 if ((*k).toEdge == 0) {
1420 noInternalNoSplits++;
1423 unsigned int lno = 0;
1424 unsigned int splitNo = 0;
1426 (*i)->buildInnerEdges(*
this, noInternalNoSplits, lno, splitNo);
1445 if (
MAX2(angle0, angle1) <= 160) {