auto intersectionPoints = vsp<vtkPoints>::New();
// cell
auto intersectioncells = vsp<vtkIdList>::New();
double tol = 1e-8;
auto obbTree = vsp<vtkOBBTree>::New();
obbTree->SetTolerance(tol);
obbTree->SetDataSet(normfilter->GetOutput());
obbTree->SetMaxLevel(10);
obbTree->SetNumberOfCellsPerNode(1);
obbTree->BuildLocator();
obbTree->IntersectWithLine(virtualStartpoint,virtualEndpoint,
intersectionPoints,intersectioncells);
obbTree->Update();
vtkOBBTree utilizes the following parent class parameters:
- Tolerance (default 0.01) 容差
- Level (default 4)
- MaxLevel (default 12) 最大递归深度次数
- NumberOfCellsPerNode (default 32) 最小包围盒里cell数量
- RetainCellLists (default true)
- UseExistingSearchStructure (default false)
包围盒精细程度由递归深度 MaxLevel以及预先设置的NumberOfCellsPerNode决定,进而影响求交精度。
官方例程参考:官方example
以下是笔者绘制球并使用直线与其相交。
Tips:shift+w(显示模型网格) shift+s(显示模型),模型精度不同,需要考虑设置合适的包围盒精度。