本文整理汇总了C++中TwoDScene::getEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ TwoDScene::getEdge方法的具体用法?C++ TwoDScene::getEdge怎么用?C++ TwoDScene::getEdge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwoDScene
的用法示例。
在下文中一共展示了TwoDScene::getEdge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performCollisionDetection
void AllPairsDetector::performCollisionDetection(const TwoDScene &scene, const VectorXs &qs, const VectorXs &qe, DetectionCallback &dc)
{
for(int i=0; i<(int)scene.getNumParticles(); i++)
{
for(int j=i+1; j<(int)scene.getNumParticles(); j++)
{
dc.ParticleParticleCallback(i,j);
}
for(int e=0; e<(int)scene.getNumEdges(); e++)
{
if(scene.getEdge(e).first != i && scene.getEdge(e).second != i)
dc.ParticleEdgeCallback(i,e);
}
for(int h=0; h<(int)scene.getNumHalfplanes(); h++)
{
dc.ParticleHalfplaneCallback(i,h);
}
}
}
示例2: loadSpringForces
void TwoDSceneXMLParser::loadSpringForces( rapidxml::xml_node<>* node, TwoDScene& twodscene )
{
assert( node != NULL );
// Extract the edge the force acts across
int forcenum = 0;
for( rapidxml::xml_node<>* nd = node->first_node("springforce"); nd; nd = nd->next_sibling("springforce") )
{
int edge = -1;
if( nd->first_attribute("edge") )
{
std::string attribute(nd->first_attribute("edge")->value());
if( !stringutils::extractFromString(attribute,edge) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of edge attribute for springforce " << forcenum << ". Value must be integer. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of edge attribute for springforce " << forcenum << ". Exiting." << std::endl;
exit(1);
}
std::pair<int,int> newedge(twodscene.getEdge(edge));
// Extract the spring stiffness
scalar k = std::numeric_limits<scalar>::signaling_NaN();
if( nd->first_attribute("k") )
{
std::string attribute(nd->first_attribute("k")->value());
if( !stringutils::extractFromString(attribute,k) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of k attribute for springforce " << forcenum << ". Value must be numeric. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse k attribute for springforce " << forcenum << ". Exiting." << std::endl;
exit(1);
}
// Extract the spring rest length
scalar l0 = std::numeric_limits<scalar>::signaling_NaN();
if( nd->first_attribute("l0") )
{
std::string attribute(nd->first_attribute("l0")->value());
if( !stringutils::extractFromString(attribute,l0) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of l0 attribute for springforce " << forcenum << ". Value must be numeric. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse l0 attribute for springforce " << forcenum << ". Exiting." << std::endl;
exit(1);
}
// Extract the optional damping coefficient
scalar b = 0.0;
if( nd->first_attribute("b") )
{
std::string attribute(nd->first_attribute("b")->value());
if( !stringutils::extractFromString(attribute,b) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of b attribute for springforce " << forcenum << ". Value must be numeric. Exiting." << std::endl;
exit(1);
}
}
//std::cout << "Springforce: " << forcenum << " i: " << newedge.first << " j: " << newedge.second << " k: " << k << " l0: " << l0 << std::endl;
twodscene.insertForce(new SpringForce(newedge,k,l0,b));
++forcenum;
}
//SpringForce( const std::pair<int,int>& endpoints, const scalar& k, const scalar& l0 )
}