本文整理汇总了C++中QuadTree::getParent方法的典型用法代码示例。如果您正苦于以下问题:C++ QuadTree::getParent方法的具体用法?C++ QuadTree::getParent怎么用?C++ QuadTree::getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuadTree
的用法示例。
在下文中一共展示了QuadTree::getParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rebuildTree
// Rebuilds a possibly incorrect tree (LAURENS: This function is not tested yet!)
void QuadTree::rebuildTree()
{
for(int n = 0; n < size; n++) {
// Check whether point is erroneous
double* point = data + index[n] * QT_NO_DIMS;
if(!boundary.containsPoint(point)) {
// Remove erroneous point
int rem_index = index[n];
for(int m = n + 1; m < size; m++) index[m - 1] = index[m];
index[size - 1] = -1;
size--;
// Update center-of-mass and counter in all parents
bool done = false;
QuadTree* node = this;
while(!done) {
for(int d = 0; d < QT_NO_DIMS; d++) {
node->center_of_mass[d] = ((double) node->cum_size * node->center_of_mass[d] - point[d]) / (double) (node->cum_size - 1);
}
node->cum_size--;
if(node->getParent() == NULL) done = true;
else node = node->getParent();
}
// Reinsert point in the root tree
node->insert(rem_index);
}
}
// Rebuild lower parts of the tree
northWest->rebuildTree();
northEast->rebuildTree();
southWest->rebuildTree();
southEast->rebuildTree();
}