# Chained inheritance from vtkDataSetAlgorithm in TTK

**URL:** https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347
**Category:** Development
**Created:** [August 1, 2019, 10:52pm UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347 "2019-08-01T22:52:36Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Jonas.Lukasczyk](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jonas.lukasczyk/32/5839_2.png) [@Jonas.Lukasczyk](https://discourse.paraview.org/u/Jonas.Lukasczyk)
#### Post date: [August 1, 2019, 10:52pm UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/1 "2019-08-01T22:52:36Z")

</div>

Hi everyone,  
I’m TTK developer and we are currently restructuring the VTK layer of TTK to simplify and standardize things. To this end, we want to create a new ‘ttkAlgorithm’ class that inherits from ‘vtkDataSetAlgorithm’ from which all VTK filters in TTK should inherit from in the future. So for an example filter called ‘ttkFilter’ we would have the following inheritance structure:

class VTKFILTERSGENERAL\_EXPORT ttkAlgorithm : public vtkDataSetAlgorithm {…}

class VTKFILTERSCORE\_EXPORT ttkFilter : public ttkAlgorithm {…}

The problem is that as soon as ‘ttkFilter’ inherits from ‘ttkAlgorithm’ the filter is no longer linked in the TTK plugin as a shared library (even if ‘ttkAlgorithm’ only inherits from ‘vtkDataSetAlgorithm’ without changing/adding anything). However, if ‘ttkFilter’ directly inherits from ‘vtkDataSetAlgorithm’ the filter is correctly linked in the plugin. Is it possible that we use the wrong export macros or what could be the issue here?

Thanks and all the best,  
Jonas Lukasczyk

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 2, 2019, 7:13am UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/2 "2019-08-02T07:13:40Z")

</div>

It does not make much sense that you use `VTKFILTERSGENERAL_EXPORT` or `VTKFILTERSCORE_EXPORT` in your plugin. You should have your own module export.

---

<div class="post-metadata">

### Author: ![Jonas.Lukasczyk](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jonas.lukasczyk/32/5839_2.png) [@Jonas.Lukasczyk](https://discourse.paraview.org/u/Jonas.Lukasczyk)
#### Post date: [August 2, 2019, 7:21am UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/3 "2019-08-02T07:21:44Z")

</div>

Thanks for your quick reply! Currently all TTK filters use the VTKFILTERSCORE\_EXPORT macro, but I was not the one who pushed that into TTK so I don’t know why we didn’t write our own macros. But are you confirming that this is the source of the problem?

Best  
Jonas

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 2, 2019, 7:23am UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/4 "2019-08-02T07:23:10Z")

</div>

That would be my best guess, but @Charles_Gueunet may know more.

---

<div class="post-metadata">

### Author: ![Jonas.Lukasczyk](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jonas.lukasczyk/32/5839_2.png) [@Jonas.Lukasczyk](https://discourse.paraview.org/u/Jonas.Lukasczyk)
#### Post date: [August 2, 2019, 7:31am UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/5 "2019-08-02T07:31:09Z")

</div>

We discussed this actually yesterday in person and we both got stuck there. It is my understanding that these macros are just needed for cross-platform support (i.e., Windows). If I delete these macros I can observe the same described behavior (as expected I guess since I’m trying this out on linux).

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 2, 2019, 7:32am UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/6 "2019-08-02T07:32:22Z")

</div>

with 5.7, these macros are not for windows only but essential for any vtk modules and paraview plugins.

---

<div class="post-metadata">

### Author: ![Jonas.Lukasczyk](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jonas.lukasczyk/32/5839_2.png) [@Jonas.Lukasczyk](https://discourse.paraview.org/u/Jonas.Lukasczyk)
#### Post date: [August 3, 2019, 12:34pm UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/7 "2019-08-03T12:34:22Z")

</div>

We are currently looking into the macros, but we also found another interesting example where this does not work:

If ‘ttkFilter’ inherits from ‘vtkTableReader’ the filter is not linked in the plugin, but if it instead inherits from ‘vtkTableAlgorithm’ it works. Maybe we need to also adjust something in the vtk.module file:

NAME  
ttkFilter  
DEPENDS  
VTK::FiltersCore  
PRIVATE\_DEPENDS  
VTK::CommonCore

@ben.boeckel do you know what could be the issue?

Best  
Jonas

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 5, 2019, 7:43am UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/8 "2019-08-05T07:43:46Z")

</div>

You need to add  
`VTK::IOLegacy` in your depends.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [August 5, 2019, 12:12pm UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/9 "2019-08-05T12:12:53Z")

</div>

You can use that macro, but because you are not `VTK::FiltersCore`, the class will not be exported. The name for the macro given your module name will be `TKKFILTER_MODULE` instead (in a `ttkFilterModule.h` header).

As for the class differences, `vtkTableReader` is indeed in `VTK::IOLegacy` which is not in your list.

---

<div class="post-metadata">

### Author: ![Jonas.Lukasczyk](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jonas.lukasczyk/32/5839_2.png) [@Jonas.Lukasczyk](https://discourse.paraview.org/u/Jonas.Lukasczyk)
#### Post date: [August 5, 2019, 12:16pm UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/10 "2019-08-05T12:16:12Z")

</div>

Awesome, thx! We will try this and let you know if it worked.

---

<div class="post-metadata">

### Author: ![Jonas.Lukasczyk](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jonas.lukasczyk/32/5839_2.png) [@Jonas.Lukasczyk](https://discourse.paraview.org/u/Jonas.Lukasczyk)
#### Post date: [August 17, 2019, 2:21pm UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/11 "2019-08-17T14:21:46Z")

</div>

I’m sorry but I’m still not able to get this to work, but I think I boiled it down to the following problem:

```
class ttkAlgorithm : public vtkUnstructuredGridAlgorithm {
    public:
        static ttkAlgorithm* New();
        vtkTypeMacro(ttkAlgorithm, vtkUnstructuredGridAlgorithm);
};

class VTKFILTERSCORE_EXPORT ttkFilter : public ttkAlgorithm {
    public:
        static ttkFilter* New();
        vtkTypeMacro(ttkFilter, ttkAlgorithm);
};

```

These two classes are defined in the same header file (I tried to see if it is indeed a linking problem) and if ttkFilter directly inherits from vtkUnstructuredGridAlgorithm then it works, with the intermediate class it fails with the following error when I execute the filter:

`vtkPVSessionCore (0x2603300): Object type: ttkFilter, could not find requested method: "SetInputConnection".`

So it seems the inheritance is screwed up somehow. Maybe I forgot to do something in regard to VTK’s strict single inheritance checks?

I also randomly tried different export macro commands in front of ttkAlgorithm but to no effect. I have actually not a clear understanding what these do, can I read this up somewhere?

Best  
Jonas

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 18, 2019, 4:44pm UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/12 "2019-08-18T16:44:13Z")

</div>

Does it get fixed if you put each class in its own file ?

---

<div class="post-metadata">

### Author: ![Jonas.Lukasczyk](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jonas.lukasczyk/32/5839_2.png) [@Jonas.Lukasczyk](https://discourse.paraview.org/u/Jonas.Lukasczyk)
#### Post date: [August 18, 2019, 9:09pm UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/13 "2019-08-18T21:09:36Z")

</div>

It does 🤔 !?! So I guess this issue is still related to the vtk.module file.

To clarify: it only works if ttkAlgorithm and ttkFilter are separate files that are referenced in the same vtk.module file. If I split them in two modules I run into the original issue.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [August 19, 2019, 12:03pm UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/14 "2019-08-19T12:03:55Z")

</div>

Each class having its own header makes sense; the wrappers (I think) really only expect a single class per header. As for them being in different modules, could you point me to full source code? This works inside VTK and ParaView.

---

<div class="post-metadata">

### Author: ![Jonas.Lukasczyk](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jonas.lukasczyk/32/5839_2.png) [@Jonas.Lukasczyk](https://discourse.paraview.org/u/Jonas.Lukasczyk)
#### Post date: [August 19, 2019, 1:25pm UTC](https://discourse.paraview.org/t/chained-inheritance-from-vtkdatasetalgorithm-in-ttk/2347/15 "2019-08-19T13:25:53Z")

</div>

Charles and I got it to work. As you suggested we now have our own export macro for each filter/module.

We will let you know when we updated the ttk repo with the new structure and it would be great if you could have a quick look if it is possible to further simplify things.

Thanks again for the great support!
