[vtkusers] How to know if a point is inside a PolyData?

Will Schroeder will.schroeder at kitware.com
Mon Sep 10 07:31:23 EDT 2001


Hi Carlos-


>I have a PolyData that is a closed surface. I would know how to get points
>inside this closed surface randomly. I don't know if there is an easy
>method in VTK.


The simple answer is that you can cast rays from the point in a "random" 
direction. Count the intersections. An odd number of intersections means 
the point is inside, even means the point is outside.

This approach works most of the time. However, due to Murphy's law the rays 
will periodically hit an "edge" or "vertex" of the polydata, in which case 
the counting scheme fails. One approach is to shoot more than one ray in 
different directions and to make sure they both agree, a statistical-based 
approach.

Look at vtkPolygon::PointInPolygon. It does something similar to what I am 
describing, only in 2D.

Will

William J. Schroeder, Ph.D
Kitware, Inc.
469 Clifton Corporate Parkway
Clifton Park, NY 12065
will.schroeder at kitware.com
1-518-371-3971 x102
1-518-371-3971 (fax)




More information about the vtkusers mailing list