本文整理汇总了C++中NBNode::discardAllCrossings方法的典型用法代码示例。如果您正苦于以下问题:C++ NBNode::discardAllCrossings方法的具体用法?C++ NBNode::discardAllCrossings怎么用?C++ NBNode::discardAllCrossings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBNode
的用法示例。
在下文中一共展示了NBNode::discardAllCrossings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
NIXMLConnectionsHandler::addCrossing(const SUMOSAXAttributes& attrs) {
bool ok = true;
NBNode* node = 0;
EdgeVector edges;
const std::string nodeID = attrs.get<std::string>(SUMO_ATTR_NODE, 0, ok);
const double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, nodeID.c_str(), ok, NBEdge::UNSPECIFIED_WIDTH, true);
const bool discard = attrs.getOpt<bool>(SUMO_ATTR_DISCARD, nodeID.c_str(), ok, false, true);
int tlIndex = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX, 0, ok, -1);
int tlIndex2 = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX2, 0, ok, -1);
std::vector<std::string> edgeIDs;
if (!attrs.hasAttribute(SUMO_ATTR_EDGES)) {
if (discard) {
node = myNodeCont.retrieve(nodeID);
if (node == 0) {
WRITE_ERROR("Node '" + nodeID + "' in crossing is not known.");
return;
}
node->discardAllCrossings(true);
return;
} else {
WRITE_ERROR("No edges specified for crossing at node '" + nodeID + "'.");
return;
}
}
SUMOSAXAttributes::parseStringVector(attrs.get<std::string>(SUMO_ATTR_EDGES, 0, ok), edgeIDs);
if (!ok) {
return;
}
for (std::vector<std::string>::const_iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
NBEdge* edge = myEdgeCont.retrieve(*it);
if (edge == 0) {
WRITE_ERROR("Edge '" + (*it) + "' for crossing at node '" + nodeID + "' is not known.");
return;
}
if (node == 0) {
if (edge->getToNode()->getID() == nodeID) {
node = edge->getToNode();
} else if (edge->getFromNode()->getID() == nodeID) {
node = edge->getFromNode();
} else {
WRITE_ERROR("Edge '" + (*it) + "' does not touch node '" + nodeID + "'.");
return;
}
} else {
if (edge->getToNode() != node && edge->getFromNode() != node) {
WRITE_ERROR("Edge '" + (*it) + "' does not touch node '" + nodeID + "'.");
return;
}
}
edges.push_back(edge);
}
bool priority = attrs.getOpt<bool>(SUMO_ATTR_PRIORITY, nodeID.c_str(), ok, node->isTLControlled(), true);
if (node->isTLControlled() && !priority) {
// traffic_light nodes should always have priority crossings
WRITE_WARNING("Crossing at controlled node '" + nodeID + "' must be prioritized");
priority = true;
}
PositionVector customShape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, 0, ok, PositionVector::EMPTY);
if (!NBNetBuilder::transformCoordinates(customShape)) {
WRITE_ERROR("Unable to project shape for crossing at node '" + node->getID() + "'.");
}
if (discard) {
node->removeCrossing(edges);
} else {
if (node->checkCrossingDuplicated(edges)) {
WRITE_ERROR("Crossing with edges '" + toString(edges) + "' already exists at node '" + node->getID() + "'.");
return;
}
node->addCrossing(edges, width, priority, tlIndex, tlIndex2, customShape);
}
}