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) {
645 std::swap(inc1, inc2);
672 std::swap(out1, out2);
683 EdgeVector::reverse_iterator i;
685 NBEdge* currentOutgoing = *i;
688 if (approaching->size() != 0) {
700 (*i)->markAsInLane2LaneState();
709 EdgeVector::const_iterator i = find(
myAllEdges.begin(),
715 for (; *i != currentOutgoing;) {
717 if ((*i)->getToNode() ==
this && (*i)->getTurnDestination() != currentOutgoing) {
718 std::vector<int> connLanes = (*i)->getConnectionLanes(currentOutgoing);
719 if (connLanes.size() != 0) {
720 approaching->push_back(*i);
750 unsigned int laneOff = 0;
751 for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
753 laneOff += (*i)->getNumLanes();
782 unsigned int laneOff = 0;
783 for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
785 laneOff += (*i)->getNumLanes();
800 unsigned int whichLaneOff,
unsigned int byLaneOff) {
804 bool changed =
false;
806 if (c.
replaceFrom(which, whichLaneOff, by, byLaneOff)) {
809 if (c.
replaceTo(which, whichLaneOff, by, byLaneOff)) {
823 for (NBConnectionVector::iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
825 sprohibiting.
replaceFrom(which, whichLaneOff, by, byLaneOff);
826 sprohibiting.
replaceTo(which, whichLaneOff, by, byLaneOff);
887 if (find(edges.begin(), edges.end(), e) != edges.end()) {
888 edges.erase(find(edges.begin(), edges.end(), e));
890 if (edges.size() == 0) {
906 mayDrive.
getTo() == 0 ||
908 mustStop.
getTo() == 0) {
910 WRITE_WARNING(
"Something went wrong during the building of a connection...");
914 conn.push_back(mayDrive);
921 unsigned int size = (
unsigned int) edgeid.length();
923 std::string
id = (*i)->
getID();
924 if (
id.substr(0, size) == edgeid) {
934 unsigned int size = (
unsigned int) edgeid.length();
936 std::string
id = (*i)->
getID();
937 if (
id.substr(0, size) == edgeid) {
962 if (removeFromConnections) {
964 (*i)->removeFromConnections(edge);
974 EdgeVector::const_iterator i;
976 NBNode* conn = (*i)->getFromNode();
979 toAdd.
mul((
SUMOReal) 1.0 / sqrt(toAdd.
x()*toAdd.
x() + toAdd.
y()*toAdd.
y()));
983 NBNode* conn = (*i)->getToNode();
986 toAdd.
mul((
SUMOReal) 1.0 / sqrt(toAdd.
x()*toAdd.
x() + toAdd.
y()*toAdd.
y()));
990 if (pos.
x() == 0 && pos.
y() == 0) {
1002 (*i)->invalidateConnections();
1010 (*i)->invalidateConnections();
1036 if (!try1 || toLane == -1) {
1039 if (from->
getSpeed() < 70. / 3.6) {
1048 const std::vector<NBEdge::Connection>& connections = (*i)->getConnections();
1049 for (std::vector<NBEdge::Connection>::const_iterator j = connections.begin(); j != connections.end(); ++j) {
1050 if ((*j).toEdge == to && ((*j).toLane < 0 || (*j).toLane == toLane)) {
1070 std::vector<NBEdge*>::const_iterator i = std::find(
myAllEdges.begin(),
myAllEdges.end(), from);
1080 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo,
1081 bool regardNonSignalisedLowerPriority)
const {
1083 possProhibitedFrom, possProhibitedTo,
1084 regardNonSignalisedLowerPriority);
1090 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
1099 assert(find(incoming.begin(), incoming.end(), removed) == incoming.end());
1100 bool changed =
true;
1106 for (NBConnectionProhibits::iterator i = blockedConnectionsTmp.begin(); i != blockedConnectionsTmp.end(); i++) {
1111 bool blockedChanged =
false;
1113 NBConnectionVector::const_iterator j;
1114 for (j = blocked.begin(); j != blocked.end(); j++) {
1116 if (sblocked.
getFrom() == removed || sblocked.
getTo() == removed) {
1117 blockedChanged =
true;
1121 for (j = blocked.begin(); blockedChanged && j != blocked.end(); j++) {
1123 if (sblocked.
getFrom() == removed && sblocked.
getTo() == removed) {
1127 }
else if (sblocked.
getFrom() == removed) {
1128 assert(sblocked.
getTo() != removed);
1129 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1132 }
else if (sblocked.
getTo() == removed) {
1133 assert(sblocked.
getFrom() != removed);
1134 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1141 if (blockedChanged) {
1142 blockedConnectionsNew[blocker] = newBlocked;
1147 if (blocker.
getFrom() == removed && blocker.
getTo() == removed) {
1152 }
else if (blocker.
getFrom() == removed) {
1153 assert(blocker.
getTo() != removed);
1155 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1158 }
else if (blocker.
getTo() == removed) {
1159 assert(blocker.
getFrom() != removed);
1161 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1165 blockedConnectionsNew[blocker] = blocked;
1179 if (outgoing == 0) {
1190 if (
abs((
int) angle) + 1 < 45) {
1197 EdgeVector::const_iterator i =
1200 while ((*i) != incoming) {
1201 if ((*i)->getFromNode() ==
this) {
1209 EdgeVector::const_iterator i =
1212 while ((*i) != incoming) {
1224 bool mayDefinitelyPass,
const std::string& tlID)
const {
1228 if (outgoing == 0) {
1234 if ((!incoming->
isInnerEdge() &&
mustBrake(incoming, outgoing, fromlane)) && !mayDefinitelyPass) {
1248 EdgeVector::const_iterator i;
1261 std::set<NBNode*> origSet;
1263 origSet.insert((*i)->getFromNode());
1265 if (origSet.size() < 2) {
1272 NBNode* origin = (*i)->getFromNode();
1274 EdgeVector::const_iterator j =
1283 if (!(*i)->expandableBy(*j)) {
1299 std::vector<std::pair<NBEdge*, NBEdge*> >
1302 std::vector<std::pair<NBEdge*, NBEdge*> > ret;
1306 std::pair<NBEdge*, NBEdge*>(
1312 NBNode* origin = (*i)->getFromNode();
1313 EdgeVector::const_iterator j =
1317 ret.push_back(std::pair<NBEdge*, NBEdge*>(*i, *j));
1331 EdgeVector::const_iterator i =
myAllEdges.begin();
1336 ret = ret > (*i)->width() ? ret : (*i)->width();
1345 if ((*i)->getToNode() == n) {
1360 back_inserter(edges));
1362 back_inserter(edges));
1363 for (EdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
1374 for (EdgeVector::const_iterator k = edges2.begin(); k != edges2.end(); ++k) {
1375 if ((*k)->getFromNode()->isDistrict() || (*k)->getToNode()->isDistrict()) {
1392 unsigned int noInternalNoSplits = 0;
1394 const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
1395 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
1396 if ((*k).toEdge == 0) {
1399 noInternalNoSplits++;
1402 unsigned int lno = 0;
1403 unsigned int splitNo = 0;
1405 (*i)->buildInnerEdges(*
this, noInternalNoSplits, lno, splitNo);