[Paraview] CS Wrapper for plugins ignores preprocessor variable

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Thu Jan 11 08:29:26 EST 2018


Two approaches:

1. put the two is separate headers and pick the approach header based
on if _DETAILED was defined at cmake configure time.
2. change header as follows:

#ifndef __VTK_WRAP__
#ifdef __DETAILED
#define vtkAlgorithm vtkMultiBlockDataSetAlgorithm
#else
#define vtkAlgorithm vtkRectilinearGridAlgorithm
#endif
#endif

class ... MyPlugin: public vtkAlgorithm
{
   static MyPlugin* New();
   vtkTypeMacro(MyPlugin, vtkRectilinearGridAlgorithm);
#ifndef __VTK_WRAP__
#undef vtkAlgorithm
#endif

};

Here, the wrapper will not provide any API on the the real superclass
but most likely, you only care about API in vtkAlgorithm to be
wrapped. See vtkFloatArray as an example on how this is done.

Utkarsh

On Thu, Jan 11, 2018 at 7:51 AM, Alexander Straub
<Alexander.Straub at visus.uni-stuttgart.de> wrote:
> 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
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> https://paraview.org/mailman/listinfo/paraview
>


More information about the ParaView mailing list