本文整理汇总了C++中NBNode::hasIncoming方法的典型用法代码示例。如果您正苦于以下问题:C++ NBNode::hasIncoming方法的具体用法?C++ NBNode::hasIncoming怎么用?C++ NBNode::hasIncoming使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBNode
的用法示例。
在下文中一共展示了NBNode::hasIncoming方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throw
NBEdge *
NIImporter_OpenDrive::getIncomingDirectionalEdge(const NBEdgeCont &ec,
const NBNodeCont &nc,
const std::string &edgeID,
const std::string &nodeID) throw() {
NBNode *node = nc.retrieve(nodeID);
NBEdge *e = ec.retrieve(edgeID);
if (e!=0 && node->hasIncoming(e)) {
return e;
}
e = ec.retrieve("-" + edgeID);
if (e!=0 && node->hasIncoming(e)) {
return e;
}
return 0;
}
示例2: getNamedString
void
NIImporter_VISUM::parse_TurnsToSignalGroups() {
// get the id
std::string SGid = getNamedString("SGNR", "SIGNALGRUPPENNR");
std::string LSAid = getNamedString("LsaNr");
// nodes
NBNode* from = myLineParser.know("VonKnot") ? getNamedNode("VonKnot") : 0;
NBNode* via = myLineParser.know("KNOTNR")
? getNamedNode("KNOTNR")
: getNamedNode("UeberKnot", "UeberKnotNr");
NBNode* to = myLineParser.know("NachKnot") ? getNamedNode("NachKnot") : 0;
// edges
NBEdge* edg1 = 0;
NBEdge* edg2 = 0;
if (from == 0 && to == 0) {
edg1 = getNamedEdgeContinuating("VONSTRNR", via);
edg2 = getNamedEdgeContinuating("NACHSTRNR", via);
} else {
edg1 = getEdge(from, via);
edg2 = getEdge(via, to);
}
// add to the list
NIVisumTL::SignalGroup& SG = myTLS.find(LSAid)->second->getSignalGroup(SGid);
if (edg1 != 0 && edg2 != 0) {
if (!via->hasIncoming(edg1)) {
std::string sid;
if (edg1->getID()[0] == '-') {
sid = edg1->getID().substr(1);
} else {
sid = "-" + edg1->getID();
}
if (sid.find('_') != std::string::npos) {
sid = sid.substr(0, sid.find('_'));
}
edg1 = getNamedEdgeContinuating(myNetBuilder.getEdgeCont().retrieve(sid), via);
}
if (!via->hasOutgoing(edg2)) {
std::string sid;
if (edg2->getID()[0] == '-') {
sid = edg2->getID().substr(1);
} else {
sid = "-" + edg2->getID();
}
if (sid.find('_') != std::string::npos) {
sid = sid.substr(0, sid.find('_'));
}
edg2 = getNamedEdgeContinuating(myNetBuilder.getEdgeCont().retrieve(sid), via);
}
SG.connections().push_back(NBConnection(edg1, edg2));
}
}
示例3: while
// ----------- (Helper) methods for joining nodes
void
NBNodeCont::generateNodeClusters(SUMOReal maxDist, NodeClusters& into) const {
std::set<NBNode*> visited;
for (NodeCont::const_iterator i = myNodes.begin(); i != myNodes.end(); i++) {
std::vector<NBNode*> toProc;
if (visited.find((*i).second) != visited.end()) {
continue;
}
toProc.push_back((*i).second);
std::set<NBNode*> c;
while (!toProc.empty()) {
NBNode* n = toProc.back();
toProc.pop_back();
if (visited.find(n) != visited.end()) {
continue;
}
c.insert(n);
visited.insert(n);
const EdgeVector& edges = n->getEdges();
for (EdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
NBEdge* e = *j;
NBNode* s = 0;
if (n->hasIncoming(e)) {
s = e->getFromNode();
} else {
s = e->getToNode();
}
if (visited.find(s) != visited.end()) {
continue;
}
if (e->getLoadedLength() < maxDist) {
toProc.push_back(s);
}
}
}
if (c.size() < 2) {
continue;
}
into.push_back(c);
}
}
示例4: parse_LanesConnections
void NIImporter_VISUM::parse_LanesConnections() {
// get the node
NBNode* node = getNamedNode("KNOTNR", "KNOT");
if (node == 0) {
return;
}
// get the from-edge
NBEdge* fromEdge = getNamedEdgeContinuating("VONSTRNR", "VONSTR", node);
NBEdge* toEdge = getNamedEdgeContinuating("NACHSTRNR", "NACHSTR", node);
if (fromEdge == 0 || toEdge == 0) {
return;
}
int fromLaneOffset = 0;
if (!node->hasIncoming(fromEdge)) {
fromLaneOffset = fromEdge->getNumLanes();
fromEdge = getReversedContinuating(fromEdge, node);
} else {
fromEdge = getReversedContinuating(fromEdge, node);
NBEdge* tmp = myNetBuilder.getEdgeCont().retrieve(fromEdge->getID().substr(0, fromEdge->getID().find('_')));
fromLaneOffset = tmp->getNumLanes();
}
int toLaneOffset = 0;
if (!node->hasOutgoing(toEdge)) {
toLaneOffset = toEdge->getNumLanes();
toEdge = getReversedContinuating(toEdge, node);
} else {
NBEdge* tmp = myNetBuilder.getEdgeCont().retrieve(toEdge->getID().substr(0, toEdge->getID().find('_')));
toLaneOffset = tmp->getNumLanes();
}
// get the from-lane
std::string fromLaneS = NBHelpers::normalIDRepresentation(myLineParser.get("VONFSNR"));
int fromLane = -1;
try {
fromLane = TplConvert::_2int(fromLaneS.c_str());
} catch (NumberFormatException&) {
WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is not numeric (" + fromLaneS + ").");
return;
}
fromLane -= 1;
if (fromLane < 0) {
WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is not positive (" + fromLaneS + ").");
return;
}
// get the from-lane
std::string toLaneS = NBHelpers::normalIDRepresentation(myLineParser.get("NACHFSNR"));
int toLane = -1;
try {
toLane = TplConvert::_2int(toLaneS.c_str());
} catch (NumberFormatException&) {
WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is not numeric (" + toLaneS + ").");
return;
}
toLane -= 1;
if (toLane < 0) {
WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is not positive (" + toLaneS + ").");
return;
}
// !!! the next is probably a hack
if (fromLane - fromLaneOffset < 0) {
fromLaneOffset = 0;
} else {
fromLane = fromEdge->getNumLanes() - (fromLane - fromLaneOffset) - 1;
}
if (toLane - toLaneOffset < 0) {
toLaneOffset = 0;
} else {
toLane = toEdge->getNumLanes() - (toLane - toLaneOffset) - 1;
}
//
if ((int) fromEdge->getNumLanes() <= fromLane) {
WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is larger than the edge's lane number (" + fromLaneS + ").");
return;
}
if ((int) toEdge->getNumLanes() <= toLane) {
WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is larger than the edge's lane number (" + toLaneS + ").");
return;
}
//
fromEdge->addLane2LaneConnection(fromLane, toEdge, toLane, NBEdge::L2L_VALIDATED);
}
示例5: ProcessError
void
NIImporter_VISUM::parse_Lanes() {
// get the node
NBNode* node = getNamedNode("KNOTNR");
// get the edge
NBEdge* baseEdge = getNamedEdge("STRNR");
NBEdge* edge = getNamedEdgeContinuating("STRNR", node);
// check
if (node == 0 || edge == 0) {
return;
}
// get the lane
std::string laneS = myLineParser.know("FSNR")
? NBHelpers::normalIDRepresentation(myLineParser.get("FSNR"))
: NBHelpers::normalIDRepresentation(myLineParser.get("NR"));
int lane = -1;
try {
lane = TplConvert::_2int(laneS.c_str());
} catch (NumberFormatException&) {
WRITE_ERROR("A lane number for edge '" + edge->getID() + "' is not numeric (" + laneS + ").");
return;
}
lane -= 1;
if (lane < 0) {
WRITE_ERROR("A lane number for edge '" + edge->getID() + "' is not positive (" + laneS + ").");
return;
}
// get the direction
std::string dirS = NBHelpers::normalIDRepresentation(myLineParser.get("RICHTTYP"));
int prevLaneNo = baseEdge->getNumLanes();
if ((dirS == "1" && !(node->hasIncoming(edge))) || (dirS == "0" && !(node->hasOutgoing(edge)))) {
// get the last part of the turnaround direction
edge = getReversedContinuating(edge, node);
}
// get the length
std::string lengthS = NBHelpers::normalIDRepresentation(myLineParser.get("LAENGE"));
SUMOReal length = -1;
try {
length = TplConvert::_2SUMOReal(lengthS.c_str());
} catch (NumberFormatException&) {
WRITE_ERROR("A lane length for edge '" + edge->getID() + "' is not numeric (" + lengthS + ").");
return;
}
if (length < 0) {
WRITE_ERROR("A lane length for edge '" + edge->getID() + "' is not positive (" + lengthS + ").");
return;
}
//
if (dirS == "1") {
lane -= prevLaneNo;
}
//
if (length == 0) {
if ((int) edge->getNumLanes() > lane) {
// ok, we know this already...
return;
}
// increment by one
edge->incLaneNo(1);
} else {
// check whether this edge already has been created
if (edge->getID().substr(edge->getID().length() - node->getID().length() - 1) == "_" + node->getID()) {
if (edge->getID().substr(edge->getID().find('_')) == "_" + toString(length) + "_" + node->getID()) {
if ((int) edge->getNumLanes() > lane) {
// ok, we know this already...
return;
}
// increment by one
edge->incLaneNo(1);
return;
}
}
// nope, we have to split the edge...
// maybe it is not the proper edge to split - VISUM seems not to sort the splits...
bool mustRecheck = true;
SUMOReal seenLength = 0;
while (mustRecheck) {
if (edge->getID().substr(edge->getID().length() - node->getID().length() - 1) == "_" + node->getID()) {
// ok, we have a previously created edge here
std::string sub = edge->getID();
sub = sub.substr(sub.rfind('_', sub.rfind('_') - 1));
sub = sub.substr(1, sub.find('_', 1) - 1);
SUMOReal dist = TplConvert::_2SUMOReal(sub.c_str());
if (dist < length) {
seenLength += edge->getLength();
if (dirS == "1") {
// incoming -> move back
edge = edge->getFromNode()->getIncomingEdges()[0];
} else {
// outgoing -> move forward
edge = edge->getToNode()->getOutgoingEdges()[0];
}
} else {
mustRecheck = false;
}
} else {
// we have the center edge - do not continue...
mustRecheck = false;
}
}
//.........这里部分代码省略.........