# vtkGeometryFIlter does not support vtkMultiBockDataSet containing mixed polydata/unstructured grid content

**URL:** https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238
**Category:** Support
**Created:** [July 24, 2021, 8:38pm UTC](https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238 "2021-07-24T20:38:09Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [July 24, 2021, 8:38pm UTC](https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238/1 "2021-07-24T20:38:09Z")

</div>

Hello!!

I’m working with vtkMultiBlockDataSets that contain both ctkPolyData and vtkUnstructuredGrid blocks.

I find that neither vtkGeometryFilter nor vtkDataSetSurfaceFIlter support such a dataset. These filters work just fine if the vtkMultiBlockDataSet includes only polys or only ugrids - but they just donlt work at all with mixed datasets

So to extract the external faces of my data I have to write my own filter, iterate over the multi blcok data set and execute geomety filter oon the individauel datasets and reconstruct the multiblock dataset.

Is this a know limitation? Is there a better way to do this?

Doug

---

<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: [July 26, 2021, 1:22pm UTC](https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238/2 "2021-07-26T13:22:06Z")

</div>

`vtkGeometryFilter` and `vtkDataSetFilter` are not supposed to take `vtkMultiBlockDataSet` inputs. How are you using it? In plain C++?

What you should use with a multi block is `vtkCompositeDataGeometryFilter`. It iterates on the input blocks and calls `vtkDataSetSurfaceFilter` on them.

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [July 26, 2021, 4:25pm UTC](https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238/3 "2021-07-26T16:25:01Z")

</div>

@Yohann_Bearzi - Thanks for the reply. I’m using Python. The documentation for the geometfy filter classes says they take ANY vtk dataset however I just relaised that vtkMultiblockDataSet doesnlt actually inherit from vtkDataSet - so that make sense.

The problem with using vtkCompositeDataGeometryFilter is that it gives me back a single vtkPolydata which isn’t what I need. I need to keep the structure of the `vtkMultiBlockDataSet`.

My understanding of VTK was that non-composite aware filters should just iterate over the composite data structures - but that seems not to be the case.

For now, I’m just going to keep doing what Ido now - implement my own fillter that iterates over the blocks and returns a filtered vrkMultiBlockDataSet. The Python implementaion of vtkPythonAlgorithm make writing this filter really easy AND keeps my pipeline intact.

Doug

---

<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: [July 26, 2021, 5:43pm UTC](https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238/4 "2021-07-26T17:43:14Z")

</div>

`vtkCompositeDataGeometryFilter` should do exactly what you intend to do. You don’t need to write your own filter.

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [July 26, 2021, 5:57pm UTC](https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238/5 "2021-07-26T17:57:47Z")

</div>

I’m pretty sure it generates a SINGLE vtkPolyData - not a vtkMultiBlockDtatSet of vtkPolyDatas.  
But I’ll check. It’s a while since I did this and I may be wrong…

From the documentation

[vtkCompositeDataGeometryFilter](https://vtk.org/doc/nightly/html/classvtkCompositeDataGeometryFilter.html) applies [vtkGeometryFilter](https://vtk.org/doc/nightly/html/classvtkGeometryFilter.html) to all leaves in [vtkCompositeDataSet](https://vtk.org/doc/nightly/html/classvtkCompositeDataSet.html). Place this filter at the end of a pipeline before a polydata consumer such as a polydata mapper to extract geometry from all blocks and append them to **one polydata object**.

---

<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: [July 26, 2021, 7:15pm UTC](https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238/6 "2021-07-26T19:15:07Z")

</div>

Oh yes you’re correct. My bad. Yes, you need to create a custom filter. Shouldn’t be too hard.

---

<div class="post-metadata">

### Author: ![andreasbuykx](https://discourse.vtk.org/user_avatar/discourse.vtk.org/andreasbuykx/32/8137_2.png) [@andreasbuykx](https://discourse.vtk.org/u/andreasbuykx)
#### Post date: [July 27, 2021, 7:21am UTC](https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238/7 "2021-07-27T07:21:40Z")

</div>

> My understanding of VTK was that non-composite aware filters should just iterate over the composite data structures - but that seems not to be the case.

I would’ve expected vtkGeometryFilter to work as you expected it too. Can you file a bug report?

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [July 27, 2021, 5:14pm UTC](https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238/8 "2021-07-27T17:14:48Z")

</div>

@andreasbuykx - Yes - I will file a bug report.

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [July 27, 2021, 8:17pm UTC](https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238/9 "2021-07-27T20:17:39Z")

</div>

OK - Turns out this is fake news…  
I created an issue and was building a test case to demonstrate the problelm when I realised that what I was stating was wrong.

Basically I was doing this,

```auto
geometry_filter = vtk.vtkGeometryFilter()
geometry_filter.SetInputConnection(reader.GetOutputPort())
geometry_filter.Update()
geometry_filter_output = geometry_filter.GetOutput()
print('type(geometry_filter_output) : ',type(geometry_filter_output))

```

And finding the output type to be None, and seemingly confirming the problem.  
But when I change the output line to,

`geometry_filter_output = geometry_filter.GetOutputDataObject(0)`

I do in fact get a `vtkMultiBlockDataSet` returned from the different geometry filters.

I don’t really understand why I have to use `GetOutputDataObject(0)` when the input is a `vtkMultiBlockDataSet` but `GetOuput()` works just fine when the input is a `vtkPolyData or vtkUnstructuredGrid?`

---

<div class="post-metadata">

### Author: ![andreasbuykx](https://discourse.vtk.org/user_avatar/discourse.vtk.org/andreasbuykx/32/8137_2.png) [@andreasbuykx](https://discourse.vtk.org/u/andreasbuykx)
#### Post date: [July 28, 2021, 6:50am UTC](https://discourse.vtk.org/t/vtkgeometryfilter-does-not-support-vtkmultibockdataset-containing-mixed-polydata-unstructured-grid-content/6238/10 "2021-07-28T06:50:47Z")

</div>

`vtkGeometryFilter::GetOutput()` is a convenience method from the base class `vtkPolyDataAlgorithm` that returns the output cast to `vtkPolyData`, because (except when processing composite data) any `vtkPolyDataAlgorithm` returns `vtkPolyData`. This explains why it returns None on a `vtkMultiBlockDataSetInput`, and I would expect that it returns None for a `vtkUnstructuredGrid` too.

When processing composite data with a non-composite aware filter the executive creates a duplicate of the input data object which is not a `vtkPolyData`. Therefore you have to use `vtkGeometryFilter::GetOutputDataObject` which just returns the data object at the specified output port.
