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

David E DeMarle dave.demarle at kitware.com
Thu Sep 27 10:31:22 EDT 2012


In the cxx file that accompanies this, are you using
vtkStandardNewMacro() to define the New method?

David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Thu, Sep 27, 2012 at 5:29 AM, Pelt, R.F.P. van <R.F.P.v.Pelt at tue.nl> wrote:
> 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
>
>
>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>



More information about the vtk-developers mailing list