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;
171 EdgeVector::const_iterator pfrom = find(
myAll.begin(),
myAll.end(), from);
172 while (*pfrom != to) {
175 EdgeVector::const_iterator pto = find(
myAll.begin(),
myAll.end(), to);
176 while (*pto != from) {
189 EdgeVector::const_iterator pfrom = find(
myAll.begin(),
myAll.end(), from);
190 while (*pfrom != to) {
193 EdgeVector::const_iterator pto = find(
myAll.begin(),
myAll.end(), to);
194 while (*pto != from) {
210 if (to1 == 0 || to2 == 0) {
216 if (idx1 < 0 || idx2 < 0) {
225 myDone[idx1][idx2] =
true;
226 myDone[idx2][idx1] =
true;
244 if (from1p > from2p) {
249 if (from2p > from1p) {
277 EdgeVector::const_iterator c1 = find(
myAll.begin(),
myAll.end(), from1);
280 while (*c1 != from1 && *c1 != from2) {
290 NBContHelper::nextCW(
myAll, c1);
293 EdgeVector::const_iterator c2 = find(
myAll.begin(),
myAll.end(), from2);
294 NBContHelper::nextCW(
myAll, c2);
296 while (*c2 != from2 && *c2 != from1) {
306 NBContHelper::nextCW(
myAll, c2);
313 EdgeVector::const_iterator p = find(
myAll.begin(),
myAll.end(), from);
317 if (p ==
myAll.begin()) {
331 EdgeVector::const_iterator i;
333 unsigned int noLanes = (*i)->getNumLanes();
334 for (
unsigned int k = 0; k < noLanes; k++) {
345 unsigned int noLanesEdge1 = (*i11)->getNumLanes();
346 for (
unsigned int j1 = 0; j1 < noLanesEdge1; j1++) {
347 std::vector<NBEdge::Connection> el1 = (*i11)->getConnectionsFromLane(j1);
348 for (std::vector<NBEdge::Connection>::iterator i12 = el1.begin(); i12 != el1.end(); ++i12) {
349 int idx1 =
getIndex((*i11), (*i12).toEdge);
355 unsigned int noLanesEdge2 = (*i21)->getNumLanes();
356 for (
unsigned int j2 = 0; j2 < noLanesEdge2; j2++) {
357 std::vector<NBEdge::Connection> el2 = (*i21)->getConnectionsFromLane(j2);
358 for (std::vector<NBEdge::Connection>::iterator i22 = el2.begin(); i22 != el2.end(); i22++) {
359 int idx2 =
getIndex((*i21), (*i22).toEdge);
365 if ((*i11) == (*i21)) {
372 if (((*i12).tlID ==
"" && (*i22).tlID ==
"")
374 ((*i12).tlID !=
"" && (*i22).tlID !=
"")) {
380 if (!
foes(*i11, (*i12).toEdge, *i21, (*i22).toEdge)) {
385 if ((*i12).tlID !=
"") {
401 std::pair<unsigned int, unsigned int>
403 unsigned int noLanes = 0;
404 unsigned int noLinks = 0;
405 for (EdgeVector::const_iterator i =
myIncoming.begin();
407 unsigned int noLanesEdge = (*i)->getNumLanes();
408 for (
unsigned int j = 0; j < noLanesEdge; j++) {
409 unsigned int numConnections = (
unsigned int)(*i)->getConnectionsFromLane(j).size();
410 noLinks += numConnections;
411 if (numConnections > 0) {
416 return std::make_pair(noLanes, noLinks);
422 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
424 if (to1 == 0 || to2 == 0) {
430 if (idx1 < 0 || idx2 < 0) {
441 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo,
442 bool regardNonSignalisedLowerPriority)
const {
444 if (possProhibitorTo == 0 || possProhibitedTo == 0) {
448 int possProhibitorIdx =
getIndex(possProhibitorFrom, possProhibitorTo);
449 int possProhibitedIdx =
getIndex(possProhibitedFrom, possProhibitedTo);
450 if (possProhibitorIdx < 0 || possProhibitedIdx < 0) {
456 if (!regardNonSignalisedLowerPriority) {
457 return myForbids[possProhibitorIdx][possProhibitedIdx];
460 if (!
myForbids[possProhibitorIdx][possProhibitedIdx]) {
473 int fromLane,
int pos)
const {
475 for (std::vector<NBEdge::Connection>::iterator j = connected.begin(); j != connected.end(); j++) {
495 int fromLane,
bool mayDefinitelyPass)
const {
503 unsigned int noLanes = (*i)->getNumLanes();
504 for (
int j = noLanes; j-- > 0;) {
505 std::vector<NBEdge::Connection> connected = (*i)->getConnectionsFromLane(j);
506 int size = (
int) connected.size();
507 for (
int k = size; k-- > 0;) {
508 if (mayDefinitelyPass) {
510 }
else if (to == 0) {
513 }
else if ((*i) == from && fromLane == j) {
517 assert(k < (
int) connected.size());
521 if (connected[k].toEdge != 0 &&
myForbids[
getIndex(*i, connected[k].toEdge)][idx]) {
545 for (EdgeVector::const_reverse_iterator i =
myIncoming.rbegin();
548 unsigned int noLanes = (*i)->getNumLanes();
549 for (
unsigned int j = noLanes; j-- > 0;) {
550 std::vector<NBEdge::Connection> connected = (*i)->getConnectionsFromLane(j);
551 int size = (
int) connected.size();
552 for (
int k = size; k-- > 0;) {
557 if (
foes(from, to, (*i), connected[k].toEdge)) {
585 for (
size_t i = 0; i < variations; i++) {
587 for (
size_t j = 0; j < variations; j++) {
627 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo)
const {
629 int idx1 =
getIndex(possProhibitorFrom, possProhibitorTo);
630 int idx2 =
getIndex(possProhibitedFrom, possProhibitedTo);