[vtkusers] DeepCopy()
Amit Tikekar
amitt at tataelxsi.co.in
Fri Jun 20 08:40:30 EDT 2003
Hi,
In an imaging application, I am trying to modify the image data. Before I
finalize my modifications, I test the results on the image through a
temporary vtkImageData Source.
After I am sure of these modifications, I copy the modified vtkImageData
onto the original data, through DeepCopy.
My code looks like this:
/////////////////////////////////////////////////
ReadData(LPCTSTR lpszPathName)
{
m_pTIFFReader->SetFileName(lpszPathName);
m_pTIFFReader->GetOutput()->Update();
//Create a copy of data that shall be the source for image rendering in the
pipeline.
m_pVtkImageData->DeepCopy(m_pTIFFReader->GetOutput());
//Create a duplicate buffer that will hold temporary modifications
m_pVtkTempImageData = vtkImageData::New();
}
//Routine Renders to screen via vtkImageViewer tied to a child window.
OnDraw()
{
if ( bDrawTempData)
m_pImageViewer->SetInput(m_pVtkTempImageData);
else
m_pImageViewer->SetInput(m_pVtkImageData);
m_pImageViewer->Render();
}
//Routine modifies permanent data after modifications are finalised.
ModifyPermanentData()
{
m_pVtkImageData->DeepCopy(m_pVtkTempImageData);
bDrawTempData = FALSE;
Invalidate();
}
/////////////////////////////////////////////////
I hope you have an idea by now what my intention is. But when I do this, the
application crashes in ModifyPermanentData::DeepCopy().
I tried using DeepCopy at all levels, vtkDataArray, vtkUnsignedCharArray
etc.
I tried to copy the image data explicitly through a routine from one Data
array to other, even then there is a crash.
Can anybody tell me, how such a situation is taken care of ? Where do I go
wrong ?
1) Why is there so much dependency of one object on the other?
2) Is it the case that once the pipeline executes, the vtkImageData object
undergoes change in terms of dataarrays & memory allocations ?
Please help...
Regards
Amit
More information about the vtkusers
mailing list