53 #ifdef CHECK_MEMORY_LEAKS
55 #endif // CHECK_MEMORY_LEAKS
74 : myJunction(junction),
75 myAll(all), myIncoming(incoming), myOutgoing(outgoing) {
80 myDone.reserve(variations);
81 for (
size_t i = 0; i < variations; i++) {
86 for (NBConnectionProhibits::const_iterator j = loadedProhibits.begin(); j != loadedProhibits.end(); j++) {
88 bool ok1 = prohibited.
check(ec);
103 for (NBConnectionVector::const_iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
105 bool ok2 = sprohibiting.
check(ec);
118 myDone[idx2][idx1] =
true;
119 myDone[idx1][idx2] =
true;
124 std::string ptID = prohibited.
getTo() != 0 ? prohibited.
getTo()->
getID() :
"UNKNOWN";
125 std::string bfID = sprohibiting.
getFrom() != 0 ? sprohibiting.
getFrom()->
getID() :
"UNKNOWN";
126 std::string btID = sprohibiting.
getTo() != 0 ? sprohibiting.
getTo()->
getID() :
"UNKNOWN";
127 WRITE_WARNING(
"could not prohibit " + pfID +
"->" + ptID +
" by " + bfID +
"->" + btID);
135 for (
size_t s1 = 0; s1 < no; s1++) {
136 for (
size_t s2 = s1 + 1; s2 < no; s2++) {
157 EdgeVector::const_iterator i, j;
173 EdgeVector::const_iterator pfrom = find(
myAll.begin(),
myAll.end(), from);
174 while (*pfrom != to) {
177 EdgeVector::const_iterator pto = find(
myAll.begin(),
myAll.end(), to);
178 while (*pto != from) {
191 EdgeVector::const_iterator pfrom = find(
myAll.begin(),
myAll.end(), from);
192 while (*pfrom != to) {
195 EdgeVector::const_iterator pto = find(
myAll.begin(),
myAll.end(), to);
196 while (*pto != from) {
212 if (to1 == 0 || to2 == 0) {
218 if (idx1 < 0 || idx2 < 0) {
227 myDone[idx1][idx2] =
true;
228 myDone[idx2][idx1] =
true;
246 if (from1p > from2p) {
250 if (from2p > from1p) {
278 EdgeVector::const_iterator c1 = find(
myAll.begin(),
myAll.end(), from1);
281 while (*c1 != from1 && *c1 != from2) {
291 NBContHelper::nextCW(
myAll, c1);
294 EdgeVector::const_iterator c2 = find(
myAll.begin(),
myAll.end(), from2);
295 NBContHelper::nextCW(
myAll, c2);
297 while (*c2 != from2 && *c2 != from1) {
307 NBContHelper::nextCW(
myAll, c2);
314 EdgeVector::const_iterator p = find(
myAll.begin(),
myAll.end(), from);
318 if (p ==
myAll.begin()) {
330 EdgeVector::const_iterator i;
332 unsigned int noLanes = (*i)->getNumLanes();
333 for (
unsigned int k = 0; k < noLanes; k++) {
344 unsigned int noLanesEdge1 = (*i11)->getNumLanes();
345 for (
unsigned int j1 = 0; j1 < noLanesEdge1; j1++) {
346 std::vector<NBEdge::Connection> el1 = (*i11)->getConnectionsFromLane(j1);
347 for (std::vector<NBEdge::Connection>::iterator i12 = el1.begin(); i12 != el1.end(); ++i12) {
348 int idx1 =
getIndex((*i11), (*i12).toEdge);
354 unsigned int noLanesEdge2 = (*i21)->getNumLanes();
355 for (
unsigned int j2 = 0; j2 < noLanesEdge2; j2++) {
356 std::vector<NBEdge::Connection> el2 = (*i21)->getConnectionsFromLane(j2);
357 for (std::vector<NBEdge::Connection>::iterator i22 = el2.begin(); i22 != el2.end(); i22++) {
358 int idx2 =
getIndex((*i21), (*i22).toEdge);
364 if ((*i11) == (*i21)) {
371 if (((*i12).tlID ==
"" && (*i22).tlID ==
"")
373 ((*i12).tlID !=
"" && (*i22).tlID !=
"")) {
379 if (!
foes(*i11, (*i12).toEdge, *i21, (*i22).toEdge)) {
384 if ((*i12).tlID !=
"") {
400 std::pair<unsigned int, unsigned int>
402 unsigned int noLanes = 0;
403 unsigned int noLinks = 0;
404 for (EdgeVector::const_iterator i =
myIncoming.begin();
406 unsigned int noLanesEdge = (*i)->getNumLanes();
407 for (
unsigned int j = 0; j < noLanesEdge; j++) {
408 unsigned int numConnections = (
unsigned int)(*i)->getConnectionsFromLane(j).size();
409 noLinks += numConnections;
410 if (numConnections > 0) {
415 return std::make_pair(noLanes, noLinks);
421 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
423 if (to1 == 0 || to2 == 0) {
429 if (idx1 < 0 || idx2 < 0) {
440 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo,
441 bool regardNonSignalisedLowerPriority)
const {
443 if (possProhibitorTo == 0 || possProhibitedTo == 0) {
447 int possProhibitorIdx =
getIndex(possProhibitorFrom, possProhibitorTo);
448 int possProhibitedIdx =
getIndex(possProhibitedFrom, possProhibitedTo);
449 if (possProhibitorIdx < 0 || possProhibitedIdx < 0) {
455 if (!regardNonSignalisedLowerPriority) {
456 return myForbids[possProhibitorIdx][possProhibitedIdx];
459 if (!
myForbids[possProhibitorIdx][possProhibitedIdx]) {
472 int fromLane,
int pos)
const {
474 for (std::vector<NBEdge::Connection>::iterator j = connected.begin(); j != connected.end(); j++) {
490 int fromLane,
bool mayDefinitelyPass)
const {
498 unsigned int noLanes = (*i)->getNumLanes();
499 for (
int j = noLanes; j-- > 0;) {
500 std::vector<NBEdge::Connection> connected = (*i)->getConnectionsFromLane(j);
501 int size = (
int) connected.size();
502 for (
int k = size; k-- > 0;) {
503 if (mayDefinitelyPass) {
505 }
else if (to == 0) {
508 }
else if ((*i) == from && fromLane == j) {
512 assert(k < (
int) connected.size());
516 if (connected[k].toEdge != 0 &&
myForbids[
getIndex(*i, connected[k].toEdge)][idx]) {
536 for (EdgeVector::const_reverse_iterator i =
myIncoming.rbegin();
539 unsigned int noLanes = (*i)->getNumLanes();
540 for (
unsigned int j = noLanes; j-- > 0;) {
541 std::vector<NBEdge::Connection> connected = (*i)->getConnectionsFromLane(j);
542 int size = (
int) connected.size();
543 for (
int k = size; k-- > 0;) {
548 if (
foes(from, to, (*i), connected[k].toEdge)) {
576 for (
size_t i = 0; i < variations; i++) {
578 for (
size_t j = 0; j < variations; j++) {
618 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo)
const {
620 int idx1 =
getIndex(possProhibitorFrom, possProhibitorTo);
621 int idx2 =
getIndex(possProhibitedFrom, possProhibitedTo);
638 std::map<NBEdge*, size_t> incomingCount;
640 std::map<NBEdge*, std::set<int> > approachedLanes;
642 std::map<NBEdge*, EdgeVector> incomingEdges;
644 const std::vector<NBEdge::Connection> connections = (*it_e)->getConnections();
645 for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); ++it_c) {
646 incomingCount[it_c->toEdge]++;
647 approachedLanes[it_c->toEdge].insert(it_c->toLane);
648 incomingEdges[it_c->toEdge].push_back(*it_e);
651 for (std::map<NBEdge*, size_t>::iterator it = incomingCount.begin(); it != incomingCount.end(); ++it) {
654 if (approachedLanes[to].size() >= it->second) {
657 for (EdgeVector::iterator it_e1 = incoming.begin(); it_e1 != incoming.end(); ++it_e1) {
658 for (EdgeVector::iterator it_e2 = incoming.begin(); it_e2 != incoming.end(); ++it_e2) {