[Paraview] CS Wrapper for plugins ignores preprocessor variable

Alexander Straub Alexander.Straub at visus.uni-stuttgart.de
Thu Jan 11 07:51:00 EST 2018


Hello ParaView community,

while programming a ParaView filter I encountered a problem with the CS wrapping. In the following I will describe the problem. The ParaView version I am currently using is 5.3.0.

In my project I created a filter that has one of two possible outputs, depending on a preprocessor variable. The idea behind this is, that there is a define "_DETAILED" that can be set via cmake. If it is not defined, a vtkRectilinearGrid is created. It it is defined, the plugin outputs a multiblock data set with an additional polydata object.

The problem now is that the generation of the MyPluginClientServer.cxx doesn't account for the preprocessor variable and just takes the last defined algorithm. In my case, this means that in the MyPluginClientServer.cxx file the line is always written as
const char* commandName = "vtkRectilinearGridAlgorithm";
This leads to a runtime error when applying the filter because it erroneously tries to downcast the plugin to the wrong algorithm data type.

Here the error message:
ERROR: In T:\paraview\source\ParaView-v5.3.0\ParaViewCore\ServerImplementation\Core\vtkPVSessionCore.cxx, line 371
vtkPVSessionCore (000001D0D3633550): Cannot cast MyPlugin object to vtkRectilinearGridAlgorithm.  This probably means the class specifies the incorrect superclass in vtkTypeMacro.
while processing
Message 0 = Invoke
  Argument 0 = vtk_object_pointer {MyPlugin (000001D080685680)}
  Argument 1 = string_value {SetInputConnection}
  Argument 2 = vtk_object_pointer {vtkAlgorithmOutput (000001D0E3D49AB0)}

The following is how I create the plugin class:
[...]
#ifdef _DETAILED
// Create multi block data set for additional output as polydata
#include "vtkMultiBlockDataSetAlgorithm.h"

class VTK_EXPORT MyPlugin : public vtkMultiBlockDataSetAlgorithm
{
public:
       static MyPlugin* New();
       vtkTypeMacro(MyPlugin, vtkMultiBlockDataSetAlgorithm);
#else
// Create rectilinear grid
#include "vtkRectilinearGridAlgorithm.h"

class VTK_EXPORT MyPlugin : public vtkRectilinearGridAlgorithm
{
public:
       static MyPlugin* New();
       vtkTypeMacro(MyPlugin, vtkRectilinearGridAlgorithm);
#endif
[...]

The work-around so far is to manually edit the MyPluginClientServer.cxx file to use the correct algorithm base class. This however is very unpractical as the code is supposed to be distributed to others. As I don't have enough knowledge of the inner workings of ParaView, especially the wrapping that is done, I don't know where or how to fix this. I would be glad if someone was able to help me with this issue.

Kind regards,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://paraview.org/pipermail/paraview/attachments/20180111/f086b551/attachment.html>


More information about the ParaView mailing list