ExtractEnclosedPoints giving additional points outside the mesh

Hi, I am new to using more advanced features in VTK. I’m using PyVsta to generate a voxel grid then looking at extracting enclosed points from an STL or mesh. I’ve tried multiple geometries and had the filter return a lot of wrong point points outside the mesh. Some resolutions work okay, while others have a large error. I attached two examples of different mesh resolution. I’ve tried using the same filter in Paraview and obtain very similar results. Has anyone had this issue before or have any suggestions on what to try?

Thank you,

That’s an interesting effect. It could be a weird numerical issue, or maybe something strange with the data like “cracks/gaps” in the mesh. Can you provide access to the data and a test demonstrating this behavior so I can take a deeper look?

Hi Will,

I attached the grid, PyVista results, and the STL file below. I tried a few other different geometries, and they all seemed to work okay. I tried to flip this geometry by 180 degrees, and it seemed to mesh okay as well. It seems to only have issues on this particular design and some variations of it.


Thank you very much!

Very strange indeed! I’ve got some deliverables this week so I’ll try and look over the weekend.


Can you send me a vtk python script that demonstrates the problem. I’m not sure what the data you sent me is all about, and what exactly you are doing.

Hi Shawn,

vtkEnclosedPoints use cell locator to find whether a point is inside or outside of the surface. Here, they use a statistical approach. They will fire some random rays and check if these rays are intersecting with any surface. If more than 3 rays interact with a surface, then those points are considered inside. Since these rays are random, there are chances of getting such weird results. You can check the source code for mode clarity.

I imported the Grid.vtk and pyramid.stl file into ParaView then applied the ExstractEnclosedPoints filter. I also tried it on PyVista and have the lines of Python code below. For the project I am working on, it is important to have an accurate representation of the geometry. Is there another way I can apply a filter to increase the accuracy of the results?

import pyvista
mesh = pyvista.read(‘pyramid.stl’)
voxels = pyvista.voxelize(mesh, density=0.5)

Thank you,

Hi Jishnu,

I had completed a work around previously, but I’m trying to work on developing some new algorithms. Is there a more robust function to check the implicit distance or check if a point is inside or outside a mesh? I was hoping to possibly add more arrays to reduce the errors, but am not very familiar with VTK code to figure out how to add more rays.

Thank you,