[vtk-developers] SafeDownCast returns NULL for derived data type

Pelt, R.F.P. van R.F.P.v.Pelt at tue.nl
Thu Sep 27 05:29:05 EDT 2012


Dear all,

Recently, I'm working on a reader derived from vtkMedicalImageReader2.
I've also declared my own data type:

#include "vtkImageData.h"

class qfeVTIImageData : public vtkImageData
{
public:
  static qfeVTIImageData *New();

  vtkTypeMacro(qfeVTIImageData,vtkImageData);

  vtkSetMacro(PhaseCount, int);
  vtkGetMacro(PhaseCount, int);

  ...

When I attempt a SafeDownCast to vtkImageData, the macro returns NULL.
It seems like the IsTypeOf does not traverse up the hierarchy to vtkObjectBase.
Anyone know what could be the issue here?

When using a static_cast, I can get the data object.
However, the added variables in the derived data type  (e.g., phasecount in the example above),
give an error upon assignment. I guess this memory is not allocated.
What am I doing wrong here?

Thanks.

Roy


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20120927/a2da6148/attachment.html>


More information about the vtk-developers mailing list