[vtkusers] vtkOBBTree::IntersectWithLine (version which returns all cell ids) question/problem
Alex Malyushytskyy
alexmalvtk at gmail.com
Wed Aug 17 19:23:59 EDT 2011
I need to get all cell ids in arbitraty poly data which are
intersected by line segment.
At the first glance example I found in VTK wiki which used
int vtkOBBTree IntersectWithLine(const double a0[3], const double a1[3],
vtkPoints *points, vtkIdList *cellIds);
should solve the problem.
Especially because of the comment "tkOBBTree returns ALL intersections
with a line and the dataset".
Unfortunately this function does not work for arbitrary data (at least
in vtk 5.6.1 ).
Example is polydata which consists of 2 disconnected triangles ( from
debug output):
Number of cells =2
cellId =0
pnt0 id = 0 x,y,z = { 18944,2166,340.981 }
pnt1 id = 1 x,y,z = { 18985.1,2242,340.981 }
pnt2 id = 2 x,y,z = { 18912.4,2188,340.981 }
center x,y,z = { 18947.2,2198.67,340.981 }
cellId =1
pnt0 id = 3 x,y,z = { 18944,2166,330.981 }
pnt1 id = 4 x,y,z = { 18985.1,2242,330.981 }
pnt2 id = 5 x,y,z = { 18912.4,2188,330.981 }
center x,y,z = { 18947.2,2198.67,330.981 }
(line intersecting centers of triangles:)
line begin x,y,z = { 18947.2,2198.67,329.981 }
line end x,y,z = { 18947.2,2198.67,341.981 }
vtkOBBTree IntersectWithLine wil return only single id:
intersecting 1 cells.
where cellIdList(0) cell_id = 1
Second triangle will not pass "sense" check at line 840 vtkOBBTree:.
// only use point if it moves us forward,
// or it moves us backward by less than tol
if (distance > lastDistance - ptol && sense != lastSense)
I am not sure if it is a bug or comes from "closed surface" assumption,
but I am sure this prevents me from getting intersections I need.
As a quick fix I am thinking to subclass vtkOBBTree and create a
function which will not be using such check,
but I guess it would makes more sense either to add parameter to vtkOBBTree
original function which would allow to skip such check , or add class
member which will control such behavior.
Anybody could comment on this?
Regards,
Alex
More information about the vtkusers
mailing list