[vtkusers] Line/triangle intersection

David Doria daviddoria at gmail.com
Tue Jun 2 17:45:21 EDT 2009


>
> I also tried this:
>
>     vtkOBBTree* Tree = vtkOBBTree::New();
>     Tree->SetDataSet(polydata);
>
>     //intersect the locator with the line
>     double LineP0[3] = {0.5, 0.5, 1.0};
>     double LineP1[3] = {0.5, 0.5, -1.0};
>     vtkPoints* IntersectPoints = vtkPoints::New();
>     Tree->IntersectWithLine(LineP0, LineP1, IntersectPoints, NULL);
>
>     std::cout << "NumPoints: " << IntersectPoints->GetNumberOfPoints() <<
> std::endl;
>
> and it just segfaults on the IntersectWithLine call.
>
> Dave
>

Thanks Murali Dhanakoti. (In the future, please reply to the list rather
than an individual so the knowledge is shared with all :) )

The problem was that I was not calling Tree->BuildLocator() before doing the
intersections in both examples! I've actually done this same thing with
other classes in the past - can we add some kind of check that says "Error -
you need to call BuildLocator() before doing anything" rather than just
crashing or giving bogus results? (I've been asking these kinds of questions
on the users list - are the better posed to the dev list?)

Murali also mentioned that "pcoords are the parametric coordinates of the
intersection point."  Is this somewhere in the documentation and I just
missed it? Or can the documentation be updated/improved?

I will add an example of this vtkOBBTree usage to the wiki. Is it possible
to make links to the wiki in the documentation so when you are in the
documentation you can click "click here to see an example"?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090602/90b7c8ea/attachment.htm>


More information about the vtkusers mailing list