[vtkusers] How to use the method "vtkCellLocator::IntersectWithLine()" ?

Obada Mahdi omahdi at gmx.de
Wed Nov 22 11:32:01 EST 2006


Hello Che,

On 11/22/06, Chavdar Papazov <chenkaz at yahoo.com> wrote:
> But the problem is, that there is not just one intersection between a line
> and a vtkPolyData object. For example if we have a poly-sphere and a line,
> there could be two intersection points between the sphere and the line. And
> this method gives me only one point. It saves its coordinates in the "pline"
> argument (see below).
> But how should I get all the intersection points?

this question has been asked several times on the list, but there does
not seem to be any direct solution (someone please correct me if that
is not true).  The IntersectWithLine() interface exposed by
vtkCellLocator only returns the "best match", if any.

There is, however, an additional method in vtkOBBTree

http://www.vtk.org/doc/nightly/html/classvtkOBBTree.html

that is capable of returning multiple intersection points for certain
inputs, its signature is

int vtkOBBTree::IntersectWithLine(
  const double a0[3], const double a1[3],
  vtkPoints *points, vtkIdList *cellIds)

According to the description, "this method assumes that the data set
is a vtkPolyData that describes a closed surface"; I have no idea what
would happen for input data sets that do not meet these criteria.  It
seems that this method was introduced for convenience by David Gobbi
some years ago:

http://public.kitware.com/pipermail/vtk-developers/2001-June/000550.html

Of course, you could also take a look at
"Filtering/vtkCellLocator.cxx" and write a modified version of
IntersectWithLine() with similar capabilities, i.e. remembering and
returning all intersection points instead of the best match only
:-)


Regards

Obada



More information about the vtkusers mailing list