67 #ifdef CHECK_MEMORY_LEAKS
69 #endif // CHECK_MEMORY_LEAKS
84 myApproaching(approaching), myCurrentOutgoing(currentOutgoing) {
95 assert(myApproaching->size() > src);
97 NBEdge* incomingEdge = (*myApproaching)[src];
101 std::vector<int> approachingLanes =
103 assert(approachingLanes.size() != 0);
104 std::deque<int>* approachedLanes = spread(approachingLanes, dest);
105 assert(approachedLanes->size() <= myCurrentOutgoing->getNumLanes());
107 for (
unsigned int i = 0; i < approachedLanes->size(); i++) {
108 unsigned int approached = (*approachedLanes)[i];
109 assert(approachedLanes->size() > i);
110 assert(approachingLanes.size() > i);
111 incomingEdge->setConnection((
unsigned int) approachingLanes[i], myCurrentOutgoing,
114 delete approachedLanes;
121 std::deque<int>* ret =
new std::deque<int>();
122 unsigned int noLanes = (
unsigned int) approachingLanes.size();
126 ret->push_back(dest);
130 unsigned int noOutgoingLanes = myCurrentOutgoing->getNumLanes();
132 ret->push_back(dest);
133 unsigned int noSet = 1;
136 while (noSet < noLanes) {
142 if (noOutgoingLanes == noSet) {
151 if (dest + loffset >= static_cast<int>(noOutgoingLanes)) {
154 for (
unsigned int i = 0; i < ret->size(); i++) {
155 (*ret)[i] = (*ret)[i] - 1;
160 ret->push_back(dest + loffset);
165 if (noOutgoingLanes == noSet) {
170 if (noSet < noLanes) {
173 if (dest < roffset) {
176 for (
unsigned int i = 0; i < ret->size(); i++) {
177 (*ret)[i] = (*ret)[i] + 1;
180 ret->push_front(dest - roffset);
204 myPosition(position),
205 myType(type), myDistrict(0), myRequest(0)
211 myPosition(position),
223 bool updateEdgeGeometries) {
230 if (updateEdgeGeometries) {
234 (*i)->setGeometry(geom);
239 (*i)->setGeometry(geom);
272 for (std::set<NBTrafficLightDefinition*>::const_iterator i = trafficLights.begin(); i != trafficLights.end(); ++i) {
284 if ((*i)->getID().find(
"joined") == 0) {
295 unsigned int ret = 0;
296 unsigned int pos = 0;
312 if ((*i)->isConnectedTo(dummy) && *i != dummy) {
313 incomingConnected.push_back(*i);
320 outgoingConnected.push_back(*i);
325 remapRemoved(tc, dummy, incomingConnected, outgoingConnected);
374 if (in->
getNumLanes() != (*opposite)->getNumLanes()) {
387 NBEdge* toE,
int toL,
int numPoints)
const {
394 bool noSpline =
false;
400 unsigned int noInitialPoints = 0;
414 Line cross(straightConn);
415 cross.
sub(cross.
p1().
x(), cross.
p1().
y());
417 center.
sub(cross.
p2());
422 if (angle < PI / 4. || angle > 7. / 4.*
PI) {
463 WRITE_WARNING(
"Could not use edge geometry for internal lane, node '" +
getID() +
"'.");
480 for (
int i = 0; i < (
int) init.size(); ++i) {
482 def[i * 3 + 1] = init[i].x();
484 def[i * 3 + 3] = init[i].y();
487 bezier(noInitialPoints, def, numPoints, ret_buf);
490 for (
int i = 0; i < (
int) numPoints; i++) {
491 Position current(ret_buf[i * 3 + 1], ret_buf[i * 3 + 3]);
492 if (prev != current) {
514 if (fromE == otherFromE) {
518 if (!
foes(otherFromE, otherToE, fromE, toE)) {
526 bool bothLeft = thisLeft && otherLeft;
527 if (c.
tlID !=
"" && !bothLeft) {
560 if (numConnections >= 64) {
562 WRITE_WARNING(
"Junction '" +
getID() +
"' is too complicated (#links>64); will be set to unregulated.");
566 }
else if (numConnections == 0) {
648 std::swap(inc1, inc2);
675 std::swap(out1, out2);
686 EdgeVector::reverse_iterator i;
688 NBEdge* currentOutgoing = *i;
691 if (approaching->size() != 0) {
703 (*i)->markAsInLane2LaneState();
712 EdgeVector::const_iterator i = find(
myAllEdges.begin(),
718 for (; *i != currentOutgoing;) {
720 if ((*i)->getToNode() ==
this && (*i)->getTurnDestination() != currentOutgoing) {
721 std::vector<int> connLanes = (*i)->getConnectionLanes(currentOutgoing);
722 if (connLanes.size() != 0) {
723 approaching->push_back(*i);
753 unsigned int laneOff = 0;
754 for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
756 laneOff += (*i)->getNumLanes();
785 unsigned int laneOff = 0;
786 for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
788 laneOff += (*i)->getNumLanes();
803 unsigned int whichLaneOff,
unsigned int byLaneOff) {
807 bool changed =
false;
809 if (c.
replaceFrom(which, whichLaneOff, by, byLaneOff)) {
812 if (c.
replaceTo(which, whichLaneOff, by, byLaneOff)) {
826 for (NBConnectionVector::iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
828 sprohibiting.
replaceFrom(which, whichLaneOff, by, byLaneOff);
829 sprohibiting.
replaceTo(which, whichLaneOff, by, byLaneOff);
890 if (find(edges.begin(), edges.end(), e) != edges.end()) {
891 edges.erase(find(edges.begin(), edges.end(), e));
893 if (edges.size() == 0) {
909 mayDrive.
getTo() == 0 ||
911 mustStop.
getTo() == 0) {
913 WRITE_WARNING(
"Something went wrong during the building of a connection...");
917 conn.push_back(mayDrive);
924 unsigned int size = (
unsigned int) edgeid.length();
926 std::string
id = (*i)->
getID();
927 if (
id.substr(0, size) == edgeid) {
937 unsigned int size = (
unsigned int) edgeid.length();
939 std::string
id = (*i)->
getID();
940 if (
id.substr(0, size) == edgeid) {
965 if (removeFromConnections) {
967 (*i)->removeFromConnections(edge);
977 EdgeVector::const_iterator i;
979 NBNode* conn = (*i)->getFromNode();
982 toAdd.
mul((
SUMOReal) 1.0 / sqrt(toAdd.
x()*toAdd.
x() + toAdd.
y()*toAdd.
y()));
986 NBNode* conn = (*i)->getToNode();
989 toAdd.
mul((
SUMOReal) 1.0 / sqrt(toAdd.
x()*toAdd.
x() + toAdd.
y()*toAdd.
y()));
993 if (pos.
x() == 0 && pos.
y() == 0) {
1005 (*i)->invalidateConnections();
1013 (*i)->invalidateConnections();
1039 if (!try1 || toLane == -1) {
1042 if (from->
getSpeed() < 70. / 3.6) {
1051 const std::vector<NBEdge::Connection>& connections = (*i)->getConnections();
1052 for (std::vector<NBEdge::Connection>::const_iterator j = connections.begin(); j != connections.end(); ++j) {
1053 if ((*j).toEdge == to && ((*j).toLane < 0 || (*j).toLane == toLane)) {
1073 std::vector<NBEdge*>::const_iterator i = std::find(
myAllEdges.begin(),
myAllEdges.end(), from);
1083 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo,
1084 bool regardNonSignalisedLowerPriority)
const {
1086 possProhibitedFrom, possProhibitedTo,
1087 regardNonSignalisedLowerPriority);
1093 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
1102 assert(find(incoming.begin(), incoming.end(), removed) == incoming.end());
1103 bool changed =
true;
1109 for (NBConnectionProhibits::iterator i = blockedConnectionsTmp.begin(); i != blockedConnectionsTmp.end(); i++) {
1114 bool blockedChanged =
false;
1116 NBConnectionVector::const_iterator j;
1117 for (j = blocked.begin(); j != blocked.end(); j++) {
1119 if (sblocked.
getFrom() == removed || sblocked.
getTo() == removed) {
1120 blockedChanged =
true;
1124 for (j = blocked.begin(); blockedChanged && j != blocked.end(); j++) {
1126 if (sblocked.
getFrom() == removed && sblocked.
getTo() == removed) {
1130 }
else if (sblocked.
getFrom() == removed) {
1131 assert(sblocked.
getTo() != removed);
1132 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1135 }
else if (sblocked.
getTo() == removed) {
1136 assert(sblocked.
getFrom() != removed);
1137 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1144 if (blockedChanged) {
1145 blockedConnectionsNew[blocker] = newBlocked;
1150 if (blocker.
getFrom() == removed && blocker.
getTo() == removed) {
1155 }
else if (blocker.
getFrom() == removed) {
1156 assert(blocker.
getTo() != removed);
1158 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1161 }
else if (blocker.
getTo() == removed) {
1162 assert(blocker.
getFrom() != removed);
1164 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1168 blockedConnectionsNew[blocker] = blocked;
1182 if (outgoing == 0) {
1193 if (
abs((
int) angle) + 1 < 45) {
1200 EdgeVector::const_iterator i =
1203 while ((*i) != incoming) {
1204 if ((*i)->getFromNode() ==
this) {
1212 EdgeVector::const_iterator i =
1215 while ((*i) != incoming) {
1227 bool mayDefinitelyPass,
const std::string& tlID)
const {
1231 if (outgoing == 0) {
1237 if ((!incoming->
isInnerEdge() &&
mustBrake(incoming, outgoing, fromlane)) && !mayDefinitelyPass) {
1251 EdgeVector::const_iterator i;
1264 std::set<NBNode*> origSet;
1266 origSet.insert((*i)->getFromNode());
1268 if (origSet.size() < 2) {
1275 NBNode* origin = (*i)->getFromNode();
1277 EdgeVector::const_iterator j =
1286 if (!(*i)->expandableBy(*j)) {
1302 std::vector<std::pair<NBEdge*, NBEdge*> >
1305 std::vector<std::pair<NBEdge*, NBEdge*> > ret;
1309 std::pair<NBEdge*, NBEdge*>(
1315 NBNode* origin = (*i)->getFromNode();
1316 EdgeVector::const_iterator j =
1320 ret.push_back(std::pair<NBEdge*, NBEdge*>(*i, *j));
1335 if ((*i)->getToNode() == n) {
1350 back_inserter(edges));
1352 back_inserter(edges));
1353 for (EdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
1364 for (EdgeVector::const_iterator k = edges2.begin(); k != edges2.end(); ++k) {
1365 if ((*k)->getFromNode()->isDistrict() || (*k)->getToNode()->isDistrict()) {
1382 unsigned int noInternalNoSplits = 0;
1384 const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
1385 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
1386 if ((*k).toEdge == 0) {
1389 noInternalNoSplits++;
1392 unsigned int lno = 0;
1393 unsigned int splitNo = 0;
1395 (*i)->buildInnerEdges(*
this, noInternalNoSplits, lno, splitNo);
1414 if (
MAX2(angle0, angle1) <= 160) {