【定义】
这个增量式八叉树支持点的定位和插入。
【简介】这个是翻译的,可能确实是翻译的不好,见谅
不同于传统的有固定空间解析度的基于分支的搜索框架(如 vtkPointLocator ), 一个八叉树原理将一个3D数据应用为每一层为树状划分。他可以确定已知数据的空间解析度,进而加速点的定位和插入,尤其是处理在自适应网格中不平衡分布的点、不常见的数据集。相较于一个稳定的点定位器通过固定的点集建立一些搜索结构来支持单纯定位功能,而一个增量型点定位器容许点的插入,随着点的动态增加搜索结构会维持下去。
vtkIncrementalOctreePointLocator 是一个基于八叉树的加速实现增量式的点定位器。
对于点的定位,八叉树是针对 vtkDataSet 、 vtkPointSet 建立的。
对于点的插入,初始化一个空的八叉树,然后再插入点,插入方法direct check-free insertion, zero tolerance insertion, and non-zero tolerance insertion。
这个类提供一个八叉树边界的多边形表示。
【示例】包括点集的初始化、插入、查询等基本操作
#include <vtkSmartPointer.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkIdList.h>
#include <vtkIncrementalOctreePointLocator.h>
int main(int, char *[])
{
// Setup point coordinates
double x[3] = {1.0, 0.0, 0.0};
double y[3] = {0.0, 1.0, 0.0};
double z[3] = {0.0, 0.0, 1.0};
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
points->InsertNextPoint(x);
points->InsertNextPoint(y);
points->InsertNextPoint(z);
vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
polydata->SetPoints(points);
// Create the tree
vtkSmartPointer<vtkIncrementalOctreePointLocator> octree = vtkSmartPointer<vtkIncrementalOctreePointLocator>::New();
octree->SetDataSet(polydata);
octree->BuildLocator();
double testPoint[3] = {2.0, 0.0, 0.0};
{
// Find the closest points to TestPoint
// double closestPointDist;
vtkIdType iD = octree->FindClosestPoint(testPoint);
std::cout << "The closest point is point " << iD << std::endl;
// Get the coordinates of the closest point
double closestPoint[3];
octree->GetDataSet()->GetPoint(iD, closestPoint);
std::cout << "Coordinates: " << closestPoint[0] << " " << closestPoint[1] << " " << closestPoint[2] << std::endl;
}
// Insert a point
double pnew[3] = {2.1, 0, 0};
octree->InsertNextPoint(pnew);
{
// Find the closest points to TestPoint
// double closestPointDist;
vtkIdType iD = octree->FindClosestPoint(testPoint);
std::cout << "The closest point is point " << iD << std::endl;
// Get the coordinates of the closest point
double closestPoint[3];
octree->GetDataSet()->GetPoint(iD, closestPoint);
std::cout << "Coordinates: " << closestPoint[0] << " " << closestPoint[1] << " " << closestPoint[2] << std::endl;
}
return EXIT_SUCCESS;
}