[vtkusers] How to know a coordinate inside or outside a vtkPolyData?
Mike.Taverne at bristol.ac.uk
Wed Oct 8 06:30:44 EDT 2014
You can do it using the vtkImplicitPolyDataDistance class (available
from VTK 6.1.0):
implicit_function = vtk.vtkImplicitPolyDataDistance()
if implicit_function.FunctionValue([x,y,z]) <= 0:
There might be cases where it does not work, since in reality what it
does is calculate the distance to the closest point of the polydata
projected onto the surface normal at that point.
One case where I had problems was with two solids joined a one vertex,
leading to a normal vector at that point close to the null vector and
therefore incorrect inside/outside determinations.
But otherwise it tends to generally work, even with non-closed solids
like a simple plane, in which case it will consider one side of the
plane to be inside and the other outside.
I'm currently using it in a set of python scripts to create files in the
HDF5 format from geometries defined in .stl files for use with the MIT
MPB and MEEP simulation tools.
Another option, used in OpenEMS for instance, is to use the CGAL library
and count the number of intersections of a ray going from the point
towards the outside.
Code from 3D printing/slicing tools might also be worth looking into,
but I'm happy with my current vtkImplicitPolyDataDistance system.
On 08/10/14 02:29, Simon wrote:
> Hi, I have read a *.stl to a vtkPolyData, and I checked it is Not Surface
> Closed, is it possible to know a coordinate like (x:1.232323, y:2.232323, z:
> 3.1232323) is inside or outside this vtkPolyData?
> View this message in context: http://vtk.1045678.n5.nabble.com/How-to-know-a-coordinate-inside-or-outside-a-vtkPolyData-tp5729019.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> Powered by www.kitware.com
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: OpenPGP digital signature
More information about the vtkusers