# vtkConnectedPointsFilter does not support vtkPointSet

**URL:** <https://discourse.vtk.org/t/vtkconnectedpointsfilter-does-not-support-vtkpointset/9348>\
**Category:** Development\
**Created:** [September 14, 2022, 6:05pm UTC](https://discourse.vtk.org/t/vtkconnectedpointsfilter-does-not-support-vtkpointset/9348 "2022-09-14T18:05:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbene](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gbene/32/5746_2.png) [@gbene](https://discourse.vtk.org/u/gbene)\
**Post date:** [September 14, 2022, 6:05pm UTC](https://discourse.vtk.org/t/vtkconnectedpointsfilter-does-not-support-vtkpointset/9348/1 "2022-09-14T18:05:25Z")

</div>

Hi!

I was trying the newly concretized vtkPointSet class for dense pointcloud analysis and visualization. I wanted to calculate the connectivity of my point cloud using vtkConnectedPointsFilter() but it raises the following error

> ERROR:root:Input dataset is not a polydata!

and the RegionId output is empty.  
If I use a vtkPolyData the filter runs fine (without defining cell data). Is this behaviour intended, am I doing something wrong or it’s a bug? Why is PolyData needed if this filter does not need the presence of cells?

Steps to reproduce the behaviour:

```python
import vtk 

plotter = pv.Plotter()

pc = some_VTK_FLOAT_data

points = vtk.vtkPoints()

points.SetData(pc)

vtk_ps = vtk.vtkPointSet()
vtk_ps.SetPoints(points)
vtk_ps.Modified()

connectivity_filter = vtk.vtkConnectedPointsFilter()
connectivity_filter.SetInputData(vtk_ps)
connectivity_filter.SetRadius(200)
connectivity_filter.SetExtractionModeToAllRegions()
connectivity_filter.Update()

```

This throws the error.

But when doing

```python
import vtk 

plotter = pv.Plotter()

pc = some_VTK_FLOAT_data

points = vtk.vtkPoints()

points.SetData(pc)

vtk_pd= vtk.vtkPolyData()
vtk_pd.SetPoints(points)
vtk_pd.Modified()

connectivity_filter = vtk.vtkConnectedPointsFilter()
connectivity_filter.SetInputData(vtk_pd)
connectivity_filter.SetRadius(200)
connectivity_filter.SetExtractionModeToAllRegions()
connectivity_filter.Update()

```

it works as intended.

Thanks!

---

<div class="post-metadata">

**Author:** ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)\
**Post date:** [September 14, 2022, 6:47pm UTC](https://discourse.vtk.org/t/vtkconnectedpointsfilter-does-not-support-vtkpointset/9348/2 "2022-09-14T18:47:37Z")

</div>

I haven’t looked at this in a while, but I think the problem is that the filter has options to extract just a _subset_ of the input points. This means that potentially the definition of any cells would be corrupted. My understanding is that you just want to label points with region ids so the cells would remain valid - I get it, but the filter is more general etc. which limits your workflow.

Short of writing a new filter, there are workarounds. Basically you can create a vtkPointSet with just the points added, run the connectivity filter to generate the point region ids, and then reassemble a vtkPolyData with the original points and cells and other attribute data, plus the addition of the region ids. This could be done manually, or if you wanted to get fancier some sort of programmable filter. HTH

---

<div class="post-metadata">

**Author:** ![gbene](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gbene/32/5746_2.png) [@gbene](https://discourse.vtk.org/u/gbene)\
**Post date:** [September 15, 2022, 10:13am UTC](https://discourse.vtk.org/t/vtkconnectedpointsfilter-does-not-support-vtkpointset/9348/3 "2022-09-15T10:13:30Z")

</div>

Yes I thought of doing it like that but in reverse since I want my main object to remain as PointSet. I was hoping for a more direct approach. Thanks!
