[vtkusers] Error when deleting a vtkImageData object !
Dean Inglis
dean.inglis at camris.ca
Fri Jan 1 10:09:54 EST 2010
Hi JD,
you created and deleted a vtkImageData when you dont need to.
// Define vtk objects
vtkBMPReader* m_ImageReader = vtkBMPReader::New();
// vtkImageData* m_ImageData = vtkImageData::New();
Its ok to declare a pointer to a vtkImageData:
vtkImageData* m_ImageData = NULL;
// Get data from image file
and ok to assign the pointer to the output of
a vtk (image) algorithm's output:
m_ImageData = m_ImageReader->GetOutput();
m_ImageData->Update();
// Now do some cleaning
m_ImageReader->Delete();
It is NOT ok to delete the output of a filter:
m_ImageData->Delete(); // Commenting this line "solve" the error !
The vtkImageData output of the filter, in your case a reader, is maintained
by the reader itself. When you delete the reader, its output
is also (eventually) deleted when any other pipeline objects
that are using it delete themselves.
Dean.
I'm having a problem when I'm deleting a vtkImageData object.
I obtain the following error message (located in
vtkImageAlgorithm::Execute()) :
"Definition of Execute() method should be in subclass and you should
really use the ExecuteData(vtkInformation *request,...) signature instead"
Up to now, I've found no other workaround than NOT deleting the object,
which I'm obviously not really happy with.
Herebelow is a small sample code that reproduces the problem (I'm using
vtk5.0.4 under MSVC++8).
Any idea where my mistake comes from?
JD.
// Define vtk objects
vtkBMPReader* m_ImageReader = vtkBMPReader::New();
vtkImageData* m_ImageData = vtkImageData::New();
vtkTexture* m_Texture = vtkTexture::New();
// Read bmp file
m_ImageReader->SetFileName("Image.bmp");
// Get data from image file
m_ImageData = m_ImageReader->GetOutput();
m_ImageData->Update();
// Assign data to texture
m_Texture->SetInput(m_ImageData);
m_Texture->Update();
// Other stuff
// ...
// ...
// Now do some cleaning
m_ImageReader->Delete();
m_ImageData->Delete(); // Commenting this line "solve" the error !
m_Texture->Delete();
More information about the vtkusers
mailing list