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();
1081 std::vector<NBEdge*>::const_iterator i = std::find(
myAllEdges.begin(),
myAllEdges.end(), from);
1091 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo,
1092 bool regardNonSignalisedLowerPriority)
const {
1094 possProhibitedFrom, possProhibitedTo,
1095 regardNonSignalisedLowerPriority);
1101 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
1110 assert(find(incoming.begin(), incoming.end(), removed) == incoming.end());
1111 bool changed =
true;
1117 for (NBConnectionProhibits::iterator i = blockedConnectionsTmp.begin(); i != blockedConnectionsTmp.end(); i++) {
1122 bool blockedChanged =
false;
1124 NBConnectionVector::const_iterator j;
1125 for (j = blocked.begin(); j != blocked.end(); j++) {
1127 if (sblocked.
getFrom() == removed || sblocked.
getTo() == removed) {
1128 blockedChanged =
true;
1132 for (j = blocked.begin(); blockedChanged && j != blocked.end(); j++) {
1134 if (sblocked.
getFrom() == removed && sblocked.
getTo() == removed) {
1138 }
else if (sblocked.
getFrom() == removed) {
1139 assert(sblocked.
getTo() != removed);
1140 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1143 }
else if (sblocked.
getTo() == removed) {
1144 assert(sblocked.
getFrom() != removed);
1145 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1152 if (blockedChanged) {
1153 blockedConnectionsNew[blocker] = newBlocked;
1158 if (blocker.
getFrom() == removed && blocker.
getTo() == removed) {
1163 }
else if (blocker.
getFrom() == removed) {
1164 assert(blocker.
getTo() != removed);
1166 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1169 }
else if (blocker.
getTo() == removed) {
1170 assert(blocker.
getFrom() != removed);
1172 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1176 blockedConnectionsNew[blocker] = blocked;
1190 if (outgoing == 0) {
1201 if (
abs((
int) angle) + 1 < 45) {
1208 EdgeVector::const_iterator i =
1211 while ((*i) != incoming) {
1212 if ((*i)->getFromNode() ==
this) {
1220 EdgeVector::const_iterator i =
1223 while ((*i) != incoming) {
1235 bool mayDefinitelyPass,
const std::string& tlID)
const {
1239 if (outgoing == 0) {
1248 if ((!incoming->
isInnerEdge() &&
mustBrake(incoming, outgoing, fromlane)) && !mayDefinitelyPass) {
1262 EdgeVector::const_iterator i;
1275 std::set<NBNode*> origSet;
1277 origSet.insert((*i)->getFromNode());
1279 if (origSet.size() < 2) {
1286 NBNode* origin = (*i)->getFromNode();
1288 EdgeVector::const_iterator j =
1297 if (!(*i)->expandableBy(*j)) {
1313 std::vector<std::pair<NBEdge*, NBEdge*> >
1316 std::vector<std::pair<NBEdge*, NBEdge*> > ret;
1320 std::pair<NBEdge*, NBEdge*>(
1326 NBNode* origin = (*i)->getFromNode();
1327 EdgeVector::const_iterator j =
1331 ret.push_back(std::pair<NBEdge*, NBEdge*>(*i, *j));
1346 if ((*i)->getToNode() == n) {
1361 back_inserter(edges));
1363 back_inserter(edges));
1364 for (EdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
1375 for (EdgeVector::const_iterator k = edges2.begin(); k != edges2.end(); ++k) {
1376 if ((*k)->getFromNode()->isDistrict() || (*k)->getToNode()->isDistrict()) {
1393 unsigned int noInternalNoSplits = 0;
1395 const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
1396 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
1397 if ((*k).toEdge == 0) {
1400 noInternalNoSplits++;
1403 unsigned int lno = 0;
1404 unsigned int splitNo = 0;
1406 (*i)->buildInnerEdges(*
this, noInternalNoSplits, lno, splitNo);
1425 if (
MAX2(angle0, angle1) <= 160) {