# Why VTK filters behave strangely when I feed my dataset to them?

**URL:** https://discourse.vtk.org/t/why-vtk-filters-behave-strangely-when-i-feed-my-dataset-to-them/2795
**Category:** Support
**Created:** [March 10, 2020, 6:26pm UTC](https://discourse.vtk.org/t/why-vtk-filters-behave-strangely-when-i-feed-my-dataset-to-them/2795 "2020-03-10T18:26:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![myousefi2016](https://discourse.vtk.org/user_avatar/discourse.vtk.org/myousefi2016/32/921_2.png) [@myousefi2016](https://discourse.vtk.org/u/myousefi2016)
#### Post date: [March 10, 2020, 6:26pm UTC](https://discourse.vtk.org/t/why-vtk-filters-behave-strangely-when-i-feed-my-dataset-to-them/2795/1 "2020-03-10T18:26:29Z")

</div>

I have `vtkUnstructuredGrid` that has a vector array in it. All the cell types in this `vtkUnstructuredGrid` are `VTK_VOXEL` and my vector array is attributed to the cells (i.e. cell data). Now I want to extract the cell centers of these voxels by using `vtkCellCenters` and then resample this point cloud to a `vtkImage` by using `vtkResampleToImage`. This is my code:

```auto
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(filenameUG)
reader.Update()

ug = reader.GetOutput()

cleaner = vtk.vtkCleanUnstructuredGrid()
cleaner.SetInputData(ug)
cleaner.Update()

ugCleaned = cleaner.GetOutput()

cellCenters = vtk.vtkCellCenters()
cellCenters.SetInputData(ugCleaned)
cellCenters.VertexCellsOn()
cellCenters.Update()
    
ugCellCenters = cellCenters.GetOutput()
    
bounds = ugCellCenters.GetBounds()

rangeX = int((bounds[1] - bounds[0]) / deltaX)
rangeY = int((bounds[3] - bounds[2]) / deltaX)
rangeZ = int((bounds[5] - bounds[4]) / deltaX)

resampleFilter = vtk.vtkResampleToImage()
resampleFilter.SetInputDataObject(ugCellCenters)
resampleFilter.SetSamplingDimensions(rangeX, rangeY, rangeZ)
resampleFilter.UseInputBoundsOn()
resampleFilter.Update()

sg = resampleFilter.GetOutput()

print np.unique(vtk_to_numpy(sg.GetPointData().GetArray('vtkValidPointMask')))

```

Unfortunately, I can’t provide the file to test and reproduce the thing that I’m seeing due to its large size. But basically, at the end the thing that I print is the mask for the points inside my `vtkUnstructuredGrid` and outside my `vtkUnstructuredGrid`, so I expect to get: `[0,1]`, but I’m getting `[0]`, which means the filter thinks all the points are outside of my `vtkUnstructuredGrid`. Long story short: I don’t think it’s a problem specifically related to `vtkResampleToImage`. The interesting thing is that If I apply a `vtkClipDataSet` before sending my `vtkUnstructuredGrid` to resampler, everything works fine, but I don’t want to clip my dataset, when I don’t need it, and for some reason I want to just work with my original data. The other interesting thing is that some other filters for example to create streamline shows same behavior and it doesn’t produce any result at all, but for example glyph filter just works fine. I have this problem with this only dataset that contains voxels and not any other dataset that I worked until now. Any idea what’s going on here? Does VTK has any problem with an unstructured grid composed of only voxels?
