Chained inheritance from vtkDataSetAlgorithm in TTK

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

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

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

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

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).

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

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

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

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.

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

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

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