[vtk-developers] Bug with vtkCellLocator and VTK_VERTEX cells

David Thompson david.thompson at kitware.com
Tue Aug 27 15:16:32 EDT 2013


Hi all,

I've run into some trouble in vtkCellLocator's implementation of IntersectWithLine() when running on a dataset composed almost entirely of VTK_VERTEX cells. The problem appears to be an overly-aggressive optimization. Around line 284 of vtkCellLocator.cxx, each cell in an octant of the locator has its bounds intersected with the test ray *without a tolerance* before the cell is extracted and its IntersectWithLine() method is called. This is a problem since VTK_VERTEX bounds are degenerate and very unlikely to intersect the test line.

There are several possible fixes:

1. Don't do that (call IntersectWithLine on point clouds). If we aren't supposed to use the cell locator with vertex cells, should we add an IntersectWithLine method to vtkPointLocator?

2. Avoid using vtkCell. We could use static geometric helpers for certain simple cell types like points and triangles, bypassing the whole bounding box and vtkCell::IntersectWithLine() tests.

3. Fix the optimization.

  a. We can always just tweaking the bounding boxes by the tolerance before running the intersection test. This works for me but I didn't do the same for the CacheCellBounds case which is tricky since a different tolerance might be used for successive queries and copying the bounds eliminates some benefit of caching them. 

  b. Add a method to test box-line intersection that takes a tolerance.

Any ideas on which fix is the best? Is there some better way to pick 3-D points from a 2-D rendering than firing a ray with vtkCellLocator::IntersectWithLine?

	Thanks,
	David


More information about the vtk-developers mailing list