空间八叉树---vtkCellLocator
vtk吧
全部回复
仅看楼主
level 12
rabbitbride 楼主
官方解释:
octree-based spatial(空间的) search object to quickly locate(位于) cells
vtkCellLocator is a spatial search object to quickly locate cells in 3D. vtkCellLocator uses a uniform-level octree subdivision(细分), where each octant(八分仪) (an octant is also referred to as a bucket) carries an indication(指示) of whether it is empty or not, and each leaf octant carries a list of the cells inside of it. (An octant is not empty if it has one or more cells inside of it.) Typical(典型的) operations are intersection(交叉) with a line to return candidate(候选人) cells, or intersection with another vtkCellLocator to return candidate cells.
2015年05月22日 11点05分 1
level 12
rabbitbride 楼主
关于空间点,VTK有一堆我还没弄明白的东西:vtkKdTree , vtkOBBTree ,vtkOctreePointLocator , vtkModifiedBSPTree
2015年05月22日 11点05分 2
level 12
rabbitbride 楼主
自己写了半天,发现VTK一个函数搞定的事情,悲催 [不高兴]
vtkSmartPointer<vtkPolyData> pd = point0;
//--------------------------------------------
// Create the tree
vtkSmartPointer<vtkCellLocator> cellLocator =
vtkSmartPointer<vtkCellLocator>::New();
cellLocator->SetDataSet(pd);
cellLocator->BuildLocator();
double testPoint[3] = {146,128,111};
cellLocator->FindClosestPoint(testPoint, closestPoint, cellId, subId, closestPointDist2);
std::cout << "Coordinates of closest point: " << closestPoint[0] << " " << closestPoint[1] << " " << closestPoint[2] << std::endl;
std::cout << "Squared distance to closest point: " << closestPointDist2 << std::endl;
std::cout << "CellId: " << cellId << std::endl;
2015年05月22日 11点05分 3
楼主 这个有可以执行的 程序吗 [汗] 我想试着运行看看
2017年06月09日 11点06分
@浩繁星尘 我看不太懂啊 这个程序可以运行吗@rabbitbride
2017年06月09日 13点06分
我看不太懂啊 这个程序可以运行吗@rabbitbride
2017年06月09日 13点06分
level 12
rabbitbride 楼主
double point_temp[3] = {146,128,111};
double squaredDistance = 1000;
double first_point[3];
for (vtkIdType i = 0; i< pPos->GetNumberOfPoints()-1 ; i++)
{
double point_temp2[3];
point_temp2[0] = pPos->GetPoint(i)[0];
point_temp2[1] = pPos->GetPoint(i)[1];
point_temp2[2] = pPos->GetPoint(i)[2];
double squaredDistance2 = vtkMath::Distance2BetweenPoints(point_temp, point_temp2);
if (squaredDistance > squaredDistance2)
{
squaredDistance = squaredDistance2;
first_point[0] = point_temp2[0];
first_point[1] = point_temp2[1];
first_point[2] = point_temp2[2];
}
}
std::cout << "squaredDistance:"<< squaredDistance<< std::endl;
std::cout << "first_point:"<< first_point[0]<<","<< first_point[1]<<","<< first_point[2]<< std::endl;
2015年05月22日 11点05分 4
楼主 这部分程序是不是接着上一层的程序?? 要是不是的 ,那这部分程序是什么??
2017年06月11日 05点06分
pPos 是什么?
2017年06月11日 05点06分
level 12
rabbitbride 楼主
继续~KD-Tree:搜索最近的n个点
//Create the tree
vtkSmartPointer<vtkKdTreePointLocator> pointTree =
vtkSmartPointer<vtkKdTreePointLocator>::New();
pointTree->SetDataSet(pd);
pointTree->BuildLocator();
// Find the k closest points to (0,0,0)
unsigned int k = 50;
//double testPoint[3] = {0.0, 0.0, 0.0};
vtkSmartPointer<vtkIdList> result =
vtkSmartPointer<vtkIdList>::New();
pointTree->FindClosestNPoints(k, testPoint, result);
for(vtkIdType i = 0; i < k; i++)
{
vtkIdType point_ind = result->GetId(i);
double p[3];
pd->GetPoint(point_ind, p);
std::cout << "Closest point " << i << ": Point "
<< point_ind << ": (" << p[0] << ", " << p[1] << ", " << p[2] << ")" << std::endl;
}
2015年05月22日 11点05分 5
吧主 求助啊 急求 十分感谢[委屈]
2016年12月07日 14点12分
@studyhard12389 同求啊[泪]
2017年06月11日 05点06分
level 1
吧主 你好 请问可以提供一下您上面所看的八叉树细分方面的资料/程序吗?最近一直在做,比较纠结 自己是在搞不懂了
2016年12月07日 02点12分 6
vtk源码包里有啊
2016年12月08日 04点12分
@rabbitbride 请问吧主 在哪里可以下载到这个源码包啊 我现在完成了读取系列图像,八叉树基本成型 然后就找不到细分了[啊]
2016年12月08日 06点12分
@studyhard12389 VTK官方链接~!
2016年12月08日 07点12分
@studyhard12389 同学 你的八叉树怎么弄的?[开心]
2017年06月09日 12点06分
level 7
楼主 可以再仔细讲讲这个八叉树的??
2017年06月11日 05点06分 7
level 7
这些类都是空间查询的,各个类实现方法略有不同,用过kdtree,该算法是先构建k维空间点集,然后可以快速查询到某一个位置附近的一个或者几个点
2017年06月14日 13点06分 8
你好。请问你用过基于vtk的kdtree?
2017年06月15日 01点06分
然后怎么实现呢?
2017年06月15日 01点06分
回复 浩繁星尘 :你要实现kdtree算法还是vtkkdtree的用法?
2017年06月15日 13点06分
回复 hwliu11 :vtkkdtree的用法
2017年06月15日 13点06分
1