本文整理汇总了C++中KDTree::FindNearestNeighbour方法的典型用法代码示例。如果您正苦于以下问题:C++ KDTree::FindNearestNeighbour方法的具体用法?C++ KDTree::FindNearestNeighbour怎么用?C++ KDTree::FindNearestNeighbour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDTree
的用法示例。
在下文中一共展示了KDTree::FindNearestNeighbour方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindCongruentBases
//.........这里部分代码省略.........
e.x = q0->x+r1*(q1->x-q0->x);
e.y = q0->y+r1*(q1->y-q0->y);
e.z = q0->z+r1*(q1->z-q0->z);
tmpCloud1.addPoint(e);
e.x = q1->x+r1*(q0->x-q1->x);
e.y = q1->y+r1*(q0->y-q1->y);
e.z = q1->z+r1*(q0->z-q1->z);
tmpCloud1.addPoint(e);
}
count = pairs2.size();
if (!tmpCloud2.reserve(count*2)) //not enough memory
return -3;
for(i=0; i<count; i++)
{
//generate the two intermediate points from r2 in pairs2[i]
q0 = cloud->getPoint(pairs2[i].a);
q1 = cloud->getPoint(pairs2[i].b);
e.x = q0->x+r2*(q1->x-q0->x);
e.y = q0->y+r2*(q1->y-q0->y);
e.z = q0->z+r2*(q1->z-q0->z);
tmpCloud2.addPoint(e);
e.x = q1->x+r2*(q0->x-q1->x);
e.y = q1->y+r2*(q0->y-q1->y);
e.z = q1->z+r2*(q0->z-q1->z);
tmpCloud2.addPoint(e);
}
//build kdtree for nearest neighbour fast research
KDTree *intermediatesTree = new KDTree();
if (!intermediatesTree->BuildFromCloud(&tmpCloud1))
{
delete intermediatesTree;
return -4;
}
//Find matching (up to delta) intermediate points in tmpCloud1 and tmpCloud2
count = tmpCloud2.size();
match.reserve(count);
if (match.capacity() < count) //not enough memory
{
delete intermediatesTree;
return -5;
}
for(i=0; i<count; i++)
{
q0 = tmpCloud2.getPoint(i);
if(intermediatesTree->FindNearestNeighbour(q0->u, a, delta))
{
idxPair.a = i;
idxPair.b = a;
match.push_back(idxPair);
}
}
//Find bases from matching intermediate points indexes
results.clear();
count = match.size();
if(count>0)
{
results.reserve(count);
if (results.capacity() < count) //not enough memory
{
delete intermediatesTree;
return -6;
}
for(i=0; i<count; i++)
{
a = match[i].a / 2;
b = match[i].b / 2;
if((match[i].b%2) == 0)
{
quad.a = pairs1[b].a;
quad.b = pairs1[b].b;
}
else
{
quad.a = pairs1[b].b;
quad.b = pairs1[b].a;
}
if((match[i].a%2) == 0)
{
quad.c = pairs2[a].a;
quad.d = pairs2[a].b;
}
else
{
quad.c = pairs2[a].b;
quad.d = pairs2[a].a;
}
results.push_back(quad);
}
}
delete intermediatesTree;
tmpCloud1.clear();
tmpCloud2.clear();
return (int)results.size();
}