本文整理汇总了C++中TwoDScene::insertEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ TwoDScene::insertEdge方法的具体用法?C++ TwoDScene::insertEdge怎么用?C++ TwoDScene::insertEdge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwoDScene
的用法示例。
在下文中一共展示了TwoDScene::insertEdge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadEdges
void TwoDSceneXMLParser::loadEdges( rapidxml::xml_node<>* node, TwoDScene& twodscene )
{
assert( node != NULL );
twodscene.clearEdges();
int edge = 0;
for( rapidxml::xml_node<>* nd = node->first_node("edge"); nd; nd = nd->next_sibling("edge") )
{
std::pair<int,int> newedge;
if( nd->first_attribute("i") )
{
std::string attribute(nd->first_attribute("i")->value());
if( !stringutils::extractFromString(attribute,newedge.first) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of i attribute for edge " << edge << ". Value must be integer. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of i attribute for edge " << edge << ". Exiting." << std::endl;
exit(1);
}
if( nd->first_attribute("j") )
{
std::string attribute(nd->first_attribute("j")->value());
if( !stringutils::extractFromString(attribute,newedge.second) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of j attribute for edge " << edge << ". Value must be integer. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of j attribute for edge " << edge << ". Exiting." << std::endl;
exit(1);
}
scalar radius = 0.015;
if( nd->first_attribute("radius") )
{
std::string attribute(nd->first_attribute("radius")->value());
if( !stringutils::extractFromString(attribute,radius) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse radius attribute for edge " << edge << ". Value must be scalar. Exiting." << std::endl;
exit(1);
}
}
//std::cout << "Edge: " << edge << " i: " << newedge.first << " j: " << newedge.second << std::endl;
twodscene.insertEdge( newedge, radius );
++edge;
}
}