specialize vtkCommand::UpdateShaderEvent callbacks to pass in interface instance instead of void*
I am converting code from vtk7.1 to vtk8.2 and I was getting crashes inside
class shaderAnnotationCallback : public vtkCommand
{
public:
virtual void Execute(vtkObject *, unsigned long, void*cbo)
{
vtkOpenGLHelper *cellBO = reinterpret_cast<vtkOpenGLHelper*>(cbo);
...
Turns out that in 7.X, cbo is originally a vtkOpenGLHelper and in 8.X, its a vtkShaderProgram.
IMHO, it's poor design to pass arguments as void* and then use reinterpret_cast<> to get the correct dynamic type.
It would be much better to specialize vtkCommand to be a vtkShaderCommand and then make Execute() a private override to do the cast for another virtual void method (shaderExecute()) so the interface is statically typed. I guess that the real problem is that AddObserver() is globally used instead of specializing it based on the event type. Maybe this is more of a documentation problem where each event type should specify what the data argument type is. But really, having more static interfaces would make porting easier.