本文整理汇总了C++中NBConnection::check方法的典型用法代码示例。如果您正苦于以下问题:C++ NBConnection::check方法的具体用法?C++ NBConnection::check怎么用?C++ NBConnection::check使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBConnection
的用法示例。
在下文中一共展示了NBConnection::check方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: myJunction
// ===========================================================================
// method definitions
// ===========================================================================
NBRequest::NBRequest(const NBEdgeCont& ec,
NBNode* junction,
const EdgeVector& all,
const EdgeVector& incoming,
const EdgeVector& outgoing,
const NBConnectionProhibits& loadedProhibits)
: myJunction(junction),
myAll(all), myIncoming(incoming), myOutgoing(outgoing) {
size_t variations = myIncoming.size() * myOutgoing.size();
// build maps with information which forbidding connection were
// computed and what's in there
myForbids.reserve(variations);
myDone.reserve(variations);
for (size_t i = 0; i < variations; i++) {
myForbids.push_back(LinkInfoCont(variations, false));
myDone.push_back(LinkInfoCont(variations, false));
}
// insert loaded prohibits
for (NBConnectionProhibits::const_iterator j = loadedProhibits.begin(); j != loadedProhibits.end(); j++) {
NBConnection prohibited = (*j).first;
bool ok1 = prohibited.check(ec);
if (find(myIncoming.begin(), myIncoming.end(), prohibited.getFrom()) == myIncoming.end()) {
ok1 = false;
}
if (find(myOutgoing.begin(), myOutgoing.end(), prohibited.getTo()) == myOutgoing.end()) {
ok1 = false;
}
int idx1 = 0;
if (ok1) {
idx1 = getIndex(prohibited.getFrom(), prohibited.getTo());
if (idx1 < 0) {
ok1 = false;
}
}
const NBConnectionVector& prohibiting = (*j).second;
for (NBConnectionVector::const_iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
NBConnection sprohibiting = *k;
bool ok2 = sprohibiting.check(ec);
if (find(myIncoming.begin(), myIncoming.end(), sprohibiting.getFrom()) == myIncoming.end()) {
ok2 = false;
}
if (find(myOutgoing.begin(), myOutgoing.end(), sprohibiting.getTo()) == myOutgoing.end()) {
ok2 = false;
}
if (ok1 && ok2) {
int idx2 = getIndex(sprohibiting.getFrom(), sprohibiting.getTo());
if (idx2 < 0) {
ok2 = false;
} else {
myForbids[idx2][idx1] = true;
myDone[idx2][idx1] = true;
myDone[idx1][idx2] = true;
myGoodBuilds++;
}
} else {
std::string pfID = prohibited.getFrom() != 0 ? prohibited.getFrom()->getID() : "UNKNOWN";
std::string ptID = prohibited.getTo() != 0 ? prohibited.getTo()->getID() : "UNKNOWN";
std::string bfID = sprohibiting.getFrom() != 0 ? sprohibiting.getFrom()->getID() : "UNKNOWN";
std::string btID = sprohibiting.getTo() != 0 ? sprohibiting.getTo()->getID() : "UNKNOWN";
WRITE_WARNING("could not prohibit " + pfID + "->" + ptID + " by " + bfID + "->" + btID);
myNotBuild++;
}
}
}
// ok, check whether someone has prohibited two links vice versa
// (this happens also in some Vissim-networks, when edges are joined)
size_t no = myIncoming.size() * myOutgoing.size();
for (size_t s1 = 0; s1 < no; s1++) {
for (size_t s2 = s1 + 1; s2 < no; s2++) {
// not set, yet
if (!myDone[s1][s2]) {
continue;
}
// check whether both prohibit vice versa
if (myForbids[s1][s2] && myForbids[s2][s1]) {
// mark unset - let our algorithm fix it later
myDone[s1][s2] = false;
myDone[s2][s1] = false;
}
}
}
}