[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 10:40:03 EDT 2012


Thanks for your reply.

I am indeed using the new macro:

//----------------------------------------------------------------------------
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"

vtkStandardNewMacro(qfeVTIImageData);

qfeVTIImageData::qfeVTIImageData()
{
//----------------------------------------------------------------------------

Instead of a derived image data type to be handled in my reader,
I was trying to adopt the approach of the vtkMedicalImageDataReader.
It handles a normal vtkImageData, together with a set of vtkMedicalImageProperties.

However, now the RequestData information vector seems to provide 
a dataset with correct extent, but 0 dimensions. (data->Update() fails with an error)
I thought these properties were tightly coupled?

The extent is set in RequestInformation: outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), this->DataExtent, 6);

//----------------------------------------------------------------------------
int vtkOwnImageReader::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
{  
  // Read the REC file
  vtkImageData *data = this->AllocateOutputData(vtkImageData::GetData(outputVector)); 
  
  this->ReadData(...);

  return 1;  
}
//----------------------------------------------------------------------------

Thanks again.

Best,

Roy

-----Original Message-----
From: David E DeMarle [mailto:dave.demarle at kitware.com] 
Sent: donderdag 27 september 2012 16:31
To: Pelt, R.F.P. van
Cc: vtk-developers at vtk.org
Subject: Re: [vtk-developers] SafeDownCast returns NULL for derived data type

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