# vtkSelectvisiblePoints selects unvisible points

**URL:** https://discourse.vtk.org/t/vtkselectvisiblepoints-selects-unvisible-points/8120
**Category:** Support
**Created:** [March 23, 2022, 12:43pm UTC](https://discourse.vtk.org/t/vtkselectvisiblepoints-selects-unvisible-points/8120 "2022-03-23T12:43:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![csad6517](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/49beb7/32.png) [@csad6517](https://discourse.vtk.org/u/csad6517)
#### Post date: [March 23, 2022, 12:43pm UTC](https://discourse.vtk.org/t/vtkselectvisiblepoints-selects-unvisible-points/8120/1 "2022-03-23T12:43:40Z")

</div>

Hello,  
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.

![image](https://discourse.vtk.org/uploads/default/original/2X/e/e8d070c4990d25b787ba20ad062b2108254403f3.png)

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

![image](https://discourse.vtk.org/uploads/default/original/2X/5/5a0bd921affda32de39bf0eaadbcd7e4e5adca88.jpeg)

How could I prevent that false counting?

Thank you!

---

<div class="post-metadata">

### Author: ![Yohann\_Bearzi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yohann_bearzi/32/671_2.png) [@Yohann\_Bearzi](https://discourse.vtk.org/u/Yohann_Bearzi)
#### Post date: [March 23, 2022, 1:21pm UTC](https://discourse.vtk.org/t/vtkselectvisiblepoints-selects-unvisible-points/8120/2 "2022-03-23T13:21:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![csad6517](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/49beb7/32.png) [@csad6517](https://discourse.vtk.org/u/csad6517)
#### Post date: [March 23, 2022, 1:23pm UTC](https://discourse.vtk.org/t/vtkselectvisiblepoints-selects-unvisible-points/8120/3 "2022-03-23T13:23:41Z")

</div>

Yes it is exactly `vtkImageData`

---

<div class="post-metadata">

### Author: ![Yohann\_Bearzi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yohann_bearzi/32/671_2.png) [@Yohann\_Bearzi](https://discourse.vtk.org/u/Yohann_Bearzi)
#### Post date: [March 23, 2022, 1:25pm UTC](https://discourse.vtk.org/t/vtkselectvisiblepoints-selects-unvisible-points/8120/4 "2022-03-23T13:25:37Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [March 23, 2022, 6:34pm UTC](https://discourse.vtk.org/t/vtkselectvisiblepoints-selects-unvisible-points/8120/5 "2022-03-23T18:34:10Z")

</div>

`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](https://vtk.org/doc/nightly/html/classvtkGPUVolumeRayCastMapper.html#a0070776aef22cec5afedefeddbc9efe4); 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.
