本文整理汇总了C++中KDTree::addItem方法的典型用法代码示例。如果您正苦于以下问题:C++ KDTree::addItem方法的具体用法?C++ KDTree::addItem怎么用?C++ KDTree::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDTree
的用法示例。
在下文中一共展示了KDTree::addItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kNearestItems
//=======================================================================//
void stitch::Vec3::relaxEquidistantVectorsII(std::vector<stitch::Vec3> &vectors, uint32_t numIterations)
{
const uint32_t numVectors = vectors.size();
for (uint32_t iterationsDone=0; iterationsDone<numIterations; ++iterationsDone)
{
float minResult=0.0f;
float maxResult=0.0f;
float sumResult=0.0f;
KDTree kdTree;
for (uint32_t acteeVectorNum=0; acteeVectorNum<numVectors; ++acteeVectorNum)
{
kdTree.addItem(new BoundingVolume(vectors[acteeVectorNum], 0.0f, acteeVectorNum));
}
std::vector<stitch::Vec3> splitAxisVec;
splitAxisVec.push_back(Vec3(1.0f, 0.0f, 0.0f));
splitAxisVec.push_back(Vec3(0.0f, 1.0f, 0.0f));
splitAxisVec.push_back(Vec3(0.0f, 0.0f, 1.0f));
kdTree.build(KDTREE_DEFAULT_CHUNK_SIZE, 0, 1000, splitAxisVec);
for (uint32_t acteeVectorNum=0; acteeVectorNum<numVectors; ++acteeVectorNum)
{
stitch::Vec3 relaxDelta;//Initialised to zero in the constructor.
float minActDistance=10.0;//Some large initial distance.
KNearestItems kNearestItems(vectors[acteeVectorNum], 1.0f, numVectors/100);
kdTree.getNearestK(&kNearestItems);
const uint32_t numNearestItems=kNearestItems.numItems_;
for (uint32_t i=0; i<numNearestItems; ++i)
{
uint32_t actingVectorNum=kNearestItems.heapArray_[i].second->userIndex_;
if (actingVectorNum!=acteeVectorNum)
{
const float actDistance=(kNearestItems.heapArray_[i].second->centre_-vectors[acteeVectorNum]).lengthSq() / kNearestItems.searchRadiusSq_;
const float actWeight=1.0f - actDistance;
stitch::Vec3 actNormal=(vectors[acteeVectorNum] - vectors[actingVectorNum]);
actNormal.normalise();
relaxDelta+=actNormal * (actWeight);
if (actDistance < minActDistance) minActDistance=actDistance;
}
}
vectors[acteeVectorNum] += relaxDelta*sqrtf(minActDistance*kNearestItems.searchRadiusSq_)*0.1;//+Vec3::randNorm()*0.005*minActDistance;
vectors[acteeVectorNum].normalise();
if (acteeVectorNum>0)
{
sumResult+=minActDistance;
if (minActDistance<minResult) minResult=minActDistance;
if (minActDistance>maxResult) maxResult=minActDistance;
} else
{
sumResult=minResult=maxResult=minActDistance;
}
}
//std::cout << "relaxActingDistance = [" << minResult << "|" << (sumResult/numVectors) << "|" << maxResult << "]\n";
//std::cout.flush();
}
}