Header-only vtk-derived class

Hi Tom,

The abstract class should not declare a ::New() method. The only reason that some of VTK’s abstract classes have ::New() is so that they can use VTK’s factory mechanism. In general, VTK abstract classes do not have ::New().

Neither is it necessary to use vtkStandardNewMacro in your concrete classes. I’d still recommend it if your classes have a .cxx implementation, but if they are header-only like your abstract class, you can use this instead:

vtkMyClass *vtkMyClass::New()
{
  vtkMyClass *obj = new vtkMyClass;
#ifdef VTK_HAS_INITIALIZE_OBJECT_BASE
  obj->InitializeObjectBase();
#endif
  return obj;
}
1 Like