本文整理汇总了C++中NBEdge::copyConnectionsFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ NBEdge::copyConnectionsFrom方法的具体用法?C++ NBEdge::copyConnectionsFrom怎么用?C++ NBEdge::copyConnectionsFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBEdge
的用法示例。
在下文中一共展示了NBEdge::copyConnectionsFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessError
bool
NBEdgeCont::splitAt(NBDistrictCont& dc,
NBEdge* edge, SUMOReal pos, NBNode* node,
const std::string& firstEdgeName,
const std::string& secondEdgeName,
unsigned int noLanesFirstEdge, unsigned int noLanesSecondEdge) {
// build the new edges' geometries
std::pair<PositionVector, PositionVector> geoms =
edge->getGeometry().splitAt(pos);
if (geoms.first[-1] != node->getPosition()) {
geoms.first.pop_back();
geoms.first.push_back(node->getPosition());
}
if (geoms.second[0] != node->getPosition()) {
geoms.second.pop_front();
geoms.second.push_front(node->getPosition());
}
// build and insert the edges
NBEdge* one = new NBEdge(firstEdgeName,
edge->myFrom, node, edge->myType, edge->mySpeed, noLanesFirstEdge,
edge->getPriority(), edge->myLaneWidth, 0, geoms.first,
edge->getStreetName(), edge->myLaneSpreadFunction, true);
for (unsigned int i = 0; i < noLanesFirstEdge && i < edge->getNumLanes(); i++) {
one->setSpeed(i, edge->getLaneSpeed(i));
}
NBEdge* two = new NBEdge(secondEdgeName,
node, edge->myTo, edge->myType, edge->mySpeed, noLanesSecondEdge,
edge->getPriority(), edge->myLaneWidth, edge->myOffset, geoms.second,
edge->getStreetName(), edge->myLaneSpreadFunction, true);
for (unsigned int i = 0; i < noLanesSecondEdge && i < edge->getNumLanes(); i++) {
two->setSpeed(i, edge->getLaneSpeed(i));
}
two->copyConnectionsFrom(edge);
// replace information about this edge within the nodes
edge->myFrom->replaceOutgoing(edge, one, 0);
edge->myTo->replaceIncoming(edge, two, 0);
// the edge is now occuring twice in both nodes...
// clean up
edge->myFrom->removeDoubleEdges();
edge->myTo->removeDoubleEdges();
// add connections from the first to the second edge
// check special case:
// one in, one out, the outgoing has one lane more
if (noLanesFirstEdge == noLanesSecondEdge - 1) {
for (unsigned int i = 0; i < one->getNumLanes(); i++) {
if (!one->addLane2LaneConnection(i, two, i + 1, NBEdge::L2L_COMPUTED)) { // !!! Bresenham, here!!!
throw ProcessError("Could not set connection!");
}
}
one->addLane2LaneConnection(0, two, 0, NBEdge::L2L_COMPUTED);
} else {
for (unsigned int i = 0; i < one->getNumLanes() && i < two->getNumLanes(); i++) {
if (!one->addLane2LaneConnection(i, two, i, NBEdge::L2L_COMPUTED)) {// !!! Bresenham, here!!!
throw ProcessError("Could not set connection!");
}
}
}
if (myRemoveEdgesAfterJoining) {
if (find(myEdges2Keep.begin(), myEdges2Keep.end(), edge->getID()) != myEdges2Keep.end()) {
myEdges2Keep.insert(one->getID());
myEdges2Keep.insert(two->getID());
}
if (find(myEdges2Remove.begin(), myEdges2Remove.end(), edge->getID()) != myEdges2Remove.end()) {
myEdges2Remove.insert(one->getID());
myEdges2Remove.insert(two->getID());
}
}
// erase the splitted edge
erase(dc, edge);
insert(one, true);
insert(two, true);
myEdgesSplit++;
return true;
}