[vtkusers] question about standalone data objects
dean.inglis at camris.ca
dean.inglis at camris.ca
Sun Feb 25 14:39:26 EST 2007
i have a 3D image processing/viewing program
that initializes the display with a vtkImageSinusoidSource,
and later the display will take image data read from
a file using vtkMetaImageReader, vtkDICOMImageReader etc.
I use a standalone vtkImageData as the data container
and delete the sources after use: eg.
some_vtksource* some_source = some_vtksource::New();
some_source->Update();
this->ImageData->DeepCopy(some_source->GetOutput());
some_source->Delete();
The problem is, if I pass the standalone image data
on to another filter or if it is used out of scope
of the source, the inherent data characteristics,
spacing and origin, change to default values
0,0,0 and 1,1,1 respectively. Use case:
1) the image data is read from file :
{ //...
some_reader* some_reader = some_reader::New();
some_reader->SetFileName("foo");
some_reader->Update();
this->ImageData->DeepCopy(some_reader->GetOutput());
some_reader->Delete();
double* spacing = this->ImageData->GetSpacing();
//spacing is correct, say 0.5, 0.5, 2
}
2) the data is queried in a separate method to update
labels in a GUI :
{ //...
double* spacing = this->ImageData->GetSpacing();
//spacing is now incorrect, 1, 1, 1
}
Can I use vtkTrivialProducer (?) or vtkInformation (?) to
resolve maintaining correct spacing?
Original motivation for doing things this way
was that the 3D image data when passed directly
from a reader to vtkImagViewer2, the viewer would
re-load from disk as slices were changed. Having
the data stored in program eliminated the problem.
Dean
More information about the vtkusers
mailing list