vtkSelectvisiblePoints selects unvisible points

I am using vtkSelectVisiblePoints to get the number of visible points on my 3d volume, which is generated through vtkVolume and represented in a rendered scene.

If I threshold the volume and want to know the number of visible points, the visiblePoints->GetOutput()->GetNumberOfPoints() returns also the points, which are actually not visible.


I guess, it counts also the areas (marked with blue lines) as visible points, which are actually not there.


How could I prevent that false counting?

Thank you!

Is your data set type a vtkImageData or is it something else?

Yes it is exactly vtkImageData

It looks like this filter doesn’t take ghost information into account. The empty voxels that you see in your first rendering are blanked using a ghost array.

A way you could achieve what you want as of today would be by first calling vtkDataSetSurfaceFilter on your data. This filter will correctly filter ghosts out. Then you can run vtkSelectVisiblePoints. It’s not optimal, but it should work.

vtkSelectVisiblePoints uses the depth buffer (Z buffer) for determining what is visible, therefore semi-transparent surfaces and volumes rendered using raycast mappers are ignored.

I’m not sure if it is possible to make the volume renderer to update the depth buffer. When polygonal geometry is mixed with volume rendering then occlusion is managed properly; and the volume raycast mapper can provide a depth image; so there is a chance that you could somehow enable the volume renderer to inform vtkSelectVisiblePoints about what points the volume occludes.

As a workaround, you can create an opaque isosurface with vtkFlyingEdges3D. If you choose the isovalue correctly then the surface will not be visible for the user because it will be inside the volume. This surface will make vtkSelectVisiblePoints correctly detect points inside and behind the volume as occluded.