VTK-Wight 之vtkIncrementalOctreePointLocator简介

【定义】

这个增量式八叉树支持点的定位和插入。

【简介】这个是翻译的,可能确实是翻译的不好,见谅

不同于传统的有固定空间解析度的基于分支的搜索框架(如 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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值