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) {
644 std::swap(inc1, inc2);
656 EdgeVector::reverse_iterator i;
658 NBEdge* currentOutgoing = *i;
661 if (approaching->size() != 0) {
673 (*i)->markAsInLane2LaneState();
682 EdgeVector::const_iterator i = find(
myAllEdges.begin(),
688 for (; *i != currentOutgoing;) {
690 if ((*i)->getToNode() ==
this && (*i)->getTurnDestination() != currentOutgoing) {
691 std::vector<int> connLanes = (*i)->getConnectionLanes(currentOutgoing);
692 if (connLanes.size() != 0) {
693 approaching->push_back(*i);
723 unsigned int laneOff = 0;
724 for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
726 laneOff += (*i)->getNumLanes();
755 unsigned int laneOff = 0;
756 for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
758 laneOff += (*i)->getNumLanes();
773 unsigned int whichLaneOff,
unsigned int byLaneOff) {
777 bool changed =
false;
779 if (c.
replaceFrom(which, whichLaneOff, by, byLaneOff)) {
782 if (c.
replaceTo(which, whichLaneOff, by, byLaneOff)) {
796 for (NBConnectionVector::iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
798 sprohibiting.
replaceFrom(which, whichLaneOff, by, byLaneOff);
799 sprohibiting.
replaceTo(which, whichLaneOff, by, byLaneOff);
860 if (find(edges.begin(), edges.end(), e) != edges.end()) {
861 edges.erase(find(edges.begin(), edges.end(), e));
876 mayDrive.
getTo() == 0 ||
878 mustStop.
getTo() == 0) {
880 WRITE_WARNING(
"Something went wrong during the building of a connection...");
884 conn.push_back(mayDrive);
891 unsigned int size = (
unsigned int) edgeid.length();
893 std::string
id = (*i)->
getID();
894 if (
id.substr(0, size) == edgeid) {
904 unsigned int size = (
unsigned int) edgeid.length();
906 std::string
id = (*i)->
getID();
907 if (
id.substr(0, size) == edgeid) {
932 if (removeFromConnections) {
934 (*i)->removeFromConnections(edge);
944 EdgeVector::const_iterator i;
946 NBNode* conn = (*i)->getFromNode();
949 toAdd.
mul((
SUMOReal) 1.0 / sqrt(toAdd.
x()*toAdd.
x() + toAdd.
y()*toAdd.
y()));
953 NBNode* conn = (*i)->getToNode();
956 toAdd.
mul((
SUMOReal) 1.0 / sqrt(toAdd.
x()*toAdd.
x() + toAdd.
y()*toAdd.
y()));
960 if (pos.
x() == 0 && pos.
y() == 0) {
972 (*i)->invalidateConnections();
980 (*i)->invalidateConnections();
1006 if (!try1 || toLane == -1) {
1009 if (from->
getSpeed() < 70. / 3.6) {
1018 const std::vector<NBEdge::Connection> &connections = (*i)->getConnections();
1019 for (std::vector<NBEdge::Connection>::const_iterator j = connections.begin(); j != connections.end(); ++j) {
1020 if ((*j).toEdge == to && ((*j).toLane < 0 || (*j).toLane == toLane)) {
1040 std::vector<NBEdge*>::const_iterator i = std::find(
myAllEdges.begin(),
myAllEdges.end(), from);
1050 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo,
1051 bool regardNonSignalisedLowerPriority)
const {
1053 possProhibitedFrom, possProhibitedTo,
1054 regardNonSignalisedLowerPriority);
1060 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
1069 assert(find(incoming.begin(), incoming.end(), removed) == incoming.end());
1070 bool changed =
true;
1076 for (NBConnectionProhibits::iterator i = blockedConnectionsTmp.begin(); i != blockedConnectionsTmp.end(); i++) {
1081 bool blockedChanged =
false;
1083 NBConnectionVector::const_iterator j;
1084 for (j = blocked.begin(); j != blocked.end(); j++) {
1086 if (sblocked.
getFrom() == removed || sblocked.
getTo() == removed) {
1087 blockedChanged =
true;
1091 for (j = blocked.begin(); blockedChanged && j != blocked.end(); j++) {
1093 if (sblocked.
getFrom() == removed && sblocked.
getTo() == removed) {
1097 }
else if (sblocked.
getFrom() == removed) {
1098 assert(sblocked.
getTo() != removed);
1099 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1102 }
else if (sblocked.
getTo() == removed) {
1103 assert(sblocked.
getFrom() != removed);
1104 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1111 if (blockedChanged) {
1112 blockedConnectionsNew[blocker] = newBlocked;
1117 if (blocker.
getFrom() == removed && blocker.
getTo() == removed) {
1122 }
else if (blocker.
getFrom() == removed) {
1123 assert(blocker.
getTo() != removed);
1125 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1128 }
else if (blocker.
getTo() == removed) {
1129 assert(blocker.
getFrom() != removed);
1131 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1135 blockedConnectionsNew[blocker] = blocked;
1149 if (outgoing == 0) {
1160 if (
abs((
int) angle) + 1 < 45) {
1167 EdgeVector::const_iterator i =
1170 while ((*i) != incoming) {
1171 if ((*i)->getFromNode() ==
this) {
1179 EdgeVector::const_iterator i =
1182 while ((*i) != incoming) {
1194 if (outgoing == 0) {
1200 if ((!incoming->
isInnerEdge() &&
mustBrake(incoming, outgoing, fromlane)) && !mayDefinitelyPass) {
1214 EdgeVector::const_iterator i;
1227 std::set<NBNode*> origSet;
1229 origSet.insert((*i)->getFromNode());
1231 if (origSet.size() < 2) {
1238 NBNode* origin = (*i)->getFromNode();
1240 EdgeVector::const_iterator j =
1249 if (!(*i)->expandableBy(*j)) {
1265 std::vector<std::pair<NBEdge*, NBEdge*> >
1268 std::vector<std::pair<NBEdge*, NBEdge*> > ret;
1272 std::pair<NBEdge*, NBEdge*>(
1278 NBNode* origin = (*i)->getFromNode();
1279 EdgeVector::const_iterator j =
1283 ret.push_back(std::pair<NBEdge*, NBEdge*>(*i, *j));
1297 EdgeVector::const_iterator i =
myAllEdges.begin();
1302 ret = ret > (*i)->width() ? ret : (*i)->width();
1311 if ((*i)->getToNode() == n) {
1326 back_inserter(edges));
1328 back_inserter(edges));
1329 for (EdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
1340 for (EdgeVector::const_iterator k = edges2.begin(); k != edges2.end(); ++k) {
1341 if ((*k)->getFromNode()->isDistrict() || (*k)->getToNode()->isDistrict()) {
1358 unsigned int noInternalNoSplits = 0;
1360 const std::vector<NBEdge::Connection> &elv = (*i)->getConnections();
1361 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
1362 if ((*k).toEdge == 0) {
1365 noInternalNoSplits++;
1368 unsigned int lno = 0;
1369 unsigned int splitNo = 0;
1371 (*i)->buildInnerEdges(*
this, noInternalNoSplits, lno, splitNo);