# vtkResampleToImage ignore hidden cells in vtkSmartVolumeMapper

**URL:** https://discourse.vtk.org/t/vtkresampletoimage-ignore-hidden-cells-in-vtksmartvolumemapper/1830
**Category:** Support
**Created:** [September 26, 2019, 12:24pm UTC](https://discourse.vtk.org/t/vtkresampletoimage-ignore-hidden-cells-in-vtksmartvolumemapper/1830 "2019-09-26T12:24:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jal/32/729_2.png) [@jal](https://discourse.vtk.org/u/jal)
#### Post date: [September 26, 2019, 12:24pm UTC](https://discourse.vtk.org/t/vtkresampletoimage-ignore-hidden-cells-in-vtksmartvolumemapper/1830/1 "2019-09-26T12:24:07Z")

</div>

Hi, is it possible to ignore cells marked as hidden when doing volume rendering of the output of vtkResampleToImage? My pipeline is roughly:  
unstructuredgrid-\>ImageResample-\>smartvolumemapper. ResampleToImage seems to mark the cells outside my dataset with the hidden bitmask

The issue i see is that for voxels outside the sampled dataset i have field values which default to zero, and my ug dataset field has negative and positive values that i want to see, so when i try to apply a scalar opacity function i see what is essentially the outside of the image, not the outer boundaries of my volume.

Is there a way to set the field values for voxels which failed the probe to VTK\_DOUBLE\_MAX or something like that? I think there is currently a pad of 0.0 applied in the ResampleToImage filter but we could add api to set a value outside the dataset range so it can be masked by the opacity function.

 ![bad](https://discourse.vtk.org/uploads/default/original/1X/93a726233d45b604f0ce1ffd3c79890f466e4e6e.png) ![good](https://discourse.vtk.org/uploads/default/original/1X/cbb777306137496cdc19cb5ba16bf4dddada49db.png)

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)
#### Post date: [September 26, 2019, 1:46pm UTC](https://discourse.vtk.org/t/vtkresampletoimage-ignore-hidden-cells-in-vtksmartvolumemapper/1830/2 "2019-09-26T13:46:57Z")

</div>

I’m surprised there isn’t API to do that already - it sounds useful. Seems simple enough to implement. If you want to try your hand at contributing that feature, I would be happy to review.

---

<div class="post-metadata">

### Author: ![jal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jal/32/729_2.png) [@jal](https://discourse.vtk.org/u/jal)
#### Post date: [September 26, 2019, 2:23pm UTC](https://discourse.vtk.org/t/vtkresampletoimage-ignore-hidden-cells-in-vtksmartvolumemapper/1830/3 "2019-09-26T14:23:45Z")

</div>

Im surprised too, tetrahedralization of the data is too expensive to do direct bunyk. I already have an idea to just add an api to ResampleToImage and change the pad value to be outside my data focus range. If it works i will add an automatic mode behavior to set the pad value to be outside the data range for each array but it might have the side effect of messing up the array ranges.

I dont see the dataarray classes respecting this hidden flag either - how do you get the range of a dataarray from a structured grid with iblanking? i see code like vtkExtractDataArraysOverTime which replace invalid cells with 0.0 which seems wrong to me. I’m surely missing something.

I think the ultimate solution would be having the volume mappers skip hidden cells.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)
#### Post date: [September 27, 2019, 10:52pm UTC](https://discourse.vtk.org/t/vtkresampletoimage-ignore-hidden-cells-in-vtksmartvolumemapper/1830/4 "2019-09-27T22:52:52Z")

</div>

> [@jal](#):
>
> it might have the side effect of messing up the array ranges.

Maybe you could set them to Inf. There is vtkDataArray API to get only the data range of finite values, so this would work well.

> [@jal](#):
>
> i see code like vtkExtractDataArraysOverTime which replace invalid cells with 0.0 which seems wrong to me. I’m surely missing something.

AFAIK, blanking is not consistently supported throughout VTK, unfortunately.

---

<div class="post-metadata">

### Author: ![jal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jal/32/729_2.png) [@jal](https://discourse.vtk.org/u/jal)
#### Post date: [October 11, 2019, 11:46pm UTC](https://discourse.vtk.org/t/vtkresampletoimage-ignore-hidden-cells-in-vtksmartvolumemapper/1830/5 "2019-10-11T23:46:14Z")

</div>

Thanks Cory,  
I was able to get the desired behavior by turning on PassPartialArrays on the internal vtkCompositeDataProbeFilter inside vtkResampleToImage. vtkSmartVolumeMapper seems to be working fine. Maybe the simplest fix is as simple as exposing this setting in vtkResampleToImage?
