本文整理汇总了C++中NBTrafficLightLogicCont::replaceRemoved方法的典型用法代码示例。如果您正苦于以下问题:C++ NBTrafficLightLogicCont::replaceRemoved方法的具体用法?C++ NBTrafficLightLogicCont::replaceRemoved怎么用?C++ NBTrafficLightLogicCont::replaceRemoved使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBTrafficLightLogicCont
的用法示例。
在下文中一共展示了NBTrafficLightLogicCont::replaceRemoved方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: erase
unsigned int
NBNodeCont::removeUnwishedNodes(NBDistrictCont& dc, NBEdgeCont& ec,
NBJoinedEdgesMap& je, NBTrafficLightLogicCont& tlc,
bool removeGeometryNodes) {
unsigned int no = 0;
std::vector<NBNode*> toRemove;
for (NodeCont::iterator i = myNodes.begin(); i != myNodes.end(); i++) {
NBNode* current = (*i).second;
bool remove = false;
std::vector<std::pair<NBEdge*, NBEdge*> > toJoin;
// check for completely empty nodes
if (current->getOutgoingEdges().size() == 0 && current->getIncomingEdges().size() == 0) {
// remove if empty
remove = true;
}
// check for nodes which are only geometry nodes
if (removeGeometryNodes) {
if ((current->getOutgoingEdges().size() == 1 && current->getIncomingEdges().size() == 1)
||
(current->getOutgoingEdges().size() == 2 && current->getIncomingEdges().size() == 2)) {
// ok, one in, one out or two in, two out
// -> ask the node whether to join
remove = current->checkIsRemovable();
if (remove) {
toJoin = current->getEdgesToJoin();
}
}
}
// remove the node and join the geometries when wished
if (!remove) {
continue;
}
for (std::vector<std::pair<NBEdge*, NBEdge*> >::iterator j = toJoin.begin(); j != toJoin.end(); j++) {
NBEdge* begin = (*j).first;
NBEdge* continuation = (*j).second;
begin->append(continuation);
continuation->getToNode()->replaceIncoming(continuation, begin, 0);
tlc.replaceRemoved(continuation, -1, begin, -1);
je.appended(begin->getID(), continuation->getID());
ec.erase(dc, continuation);
}
toRemove.push_back(current);
no++;
}
// erase all
for (std::vector<NBNode*>::iterator j = toRemove.begin(); j != toRemove.end(); ++j) {
erase(*j);
}
return no;
}
示例2: sort
void
NBEdgeCont::joinSameNodeConnectingEdges(NBDistrictCont& dc,
NBTrafficLightLogicCont& tlc,
EdgeVector edges) {
// !!! Attention!
// No merging of the geometry to come is being done
// The connections are moved from one edge to another within
// the replacement where the edge is a node's incoming edge.
// count the number of lanes, the speed and the id
unsigned int nolanes = 0;
SUMOReal speed = 0;
int priority = 0;
std::string id;
sort(edges.begin(), edges.end(), NBContHelper::same_connection_edge_sorter());
// retrieve the connected nodes
NBEdge* tpledge = *(edges.begin());
NBNode* from = tpledge->getFromNode();
NBNode* to = tpledge->getToNode();
EdgeVector::const_iterator i;
for (i = edges.begin(); i != edges.end(); i++) {
// some assertions
assert((*i)->getFromNode() == from);
assert((*i)->getToNode() == to);
// ad the number of lanes the current edge has
nolanes += (*i)->getNumLanes();
// build the id
if (i != edges.begin()) {
id += "+";
}
id += (*i)->getID();
// compute the speed
speed += (*i)->getSpeed();
// build the priority
priority = MAX2(priority, (*i)->getPriority());
}
speed /= edges.size();
// build the new edge
// @bug new edge does not know about allowed vclass of old edges
// @bug both the width and the offset are not regarded
NBEdge* newEdge = new NBEdge(id, from, to, "", speed, nolanes, priority,
NBEdge::UNSPECIFIED_WIDTH, NBEdge::UNSPECIFIED_OFFSET,
tpledge->getStreetName(), tpledge->myLaneSpreadFunction);
insert(newEdge, true);
// replace old edge by current within the nodes
// and delete the old
from->replaceOutgoing(edges, newEdge);
to->replaceIncoming(edges, newEdge);
// patch connections
// add edge2edge-information
for (i = edges.begin(); i != edges.end(); i++) {
EdgeVector ev = (*i)->getConnectedEdges();
for (EdgeVector::iterator j = ev.begin(); j != ev.end(); j++) {
newEdge->addEdge2EdgeConnection(*j);
}
}
// move lane2lane-connections
unsigned int currLane = 0;
for (i = edges.begin(); i != edges.end(); i++) {
newEdge->moveOutgoingConnectionsFrom(*i, currLane);
currLane += (*i)->getNumLanes();
}
// patch tl-information
currLane = 0;
for (i = edges.begin(); i != edges.end(); i++) {
unsigned int noLanes = (*i)->getNumLanes();
for (unsigned int j = 0; j < noLanes; j++, currLane++) {
// replace in traffic lights
tlc.replaceRemoved(*i, j, newEdge, currLane);
}
}
// delete joined edges
for (i = edges.begin(); i != edges.end(); i++) {
erase(dc, *i);
}
}