本文整理汇总了C++中NBEdge::reinitNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ NBEdge::reinitNodes方法的具体用法?C++ NBEdge::reinitNodes怎么用?C++ NBEdge::reinitNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBEdge
的用法示例。
在下文中一共展示了NBEdge::reinitNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessError
void
NBNodeCont::joinNodeClusters(NodeClusters clusters,
NBDistrictCont& dc, NBEdgeCont& ec, NBTrafficLightLogicCont& tlc) {
for (NodeClusters::iterator i = clusters.begin(); i != clusters.end(); ++i) {
std::set<NBNode*> cluster = *i;
assert(cluster.size() > 1);
Position pos;
bool setTL;
std::string id;
TrafficLightType type;
analyzeCluster(cluster, id, pos, setTL, type);
if (!insert(id, pos)) {
// should not fail
WRITE_WARNING("Could not join junctions " + id);
continue;
}
NBNode* newNode = retrieve(id);
if (setTL) {
NBTrafficLightDefinition* tlDef = new NBOwnTLDef(id, newNode, 0, type);
if (!tlc.insert(tlDef)) {
// actually, nothing should fail here
delete tlDef;
throw ProcessError("Could not allocate tls '" + id + "'.");
}
}
// collect edges
std::set<NBEdge*> allEdges;
for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); ++j) {
const EdgeVector& edges = (*j)->getEdges();
allEdges.insert(edges.begin(), edges.end());
}
// remap and remove edges which are completely within the new intersection
for (std::set<NBEdge*>::iterator j = allEdges.begin(); j != allEdges.end();) {
NBEdge* e = (*j);
NBNode* from = e->getFromNode();
NBNode* to = e->getToNode();
if (cluster.count(from) > 0 && cluster.count(to) > 0) {
for (std::set<NBEdge*>::iterator l = allEdges.begin(); l != allEdges.end(); ++l) {
if (e != *l) {
(*l)->replaceInConnections(e, e->getConnections());
}
}
ec.erase(dc, e);
allEdges.erase(j++); // erase does not invalidate the other iterators
} else {
++j;
}
}
// remap edges which are incoming / outgoing
for (std::set<NBEdge*>::iterator j = allEdges.begin(); j != allEdges.end(); ++j) {
NBEdge* e = (*j);
std::vector<NBEdge::Connection> conns = e->getConnections();
const bool outgoing = cluster.count(e->getFromNode()) > 0;
NBNode* from = outgoing ? newNode : e->getFromNode();
NBNode* to = outgoing ? e->getToNode() : newNode;
e->reinitNodes(from, to);
// re-add connections which previously existed and may still valid.
// connections to removed edges will be ignored
for (std::vector<NBEdge::Connection>::iterator k = conns.begin(); k != conns.end(); ++k) {
e->addLane2LaneConnection((*k).fromLane, (*k).toEdge, (*k).toLane, NBEdge::L2L_USER, false, (*k).mayDefinitelyPass);
}
}
// remove original nodes
registerJoinedCluster(cluster);
for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); ++j) {
erase(*j);
}
}
}