[vtkusers] Adding multiple arrays to ImageData

Miron Sadziak miron at will.brl.ntt.co.jp
Tue Feb 12 21:18:07 EST 2008


Hi

I'm using VTK for displaying time-dependent 3d datasets. My application
works in c++.
As for now I have every timestep in a separate VTI file in form of
ImageData. Im using the code similar to that below:

vtkImageData *image;
image=vtkImageData::New();
image->SetDimensions(2,2,1);
image->SetScalarTypeToFloat();
image->AllocateScalars();
float *ptr=static_cast<float*>(image->GetScalarPointer());
for(int y=0;y<2;++y) {
for(int x=0;x<2;++x) {
*ptr++=10.0*sin(0.1*x)*sin(0.1*y);
}
}
vtkXMLImageDataWriter *writer = vtkXMLImageDataWriter::New();
writer->SetFileName("test.vti");
writer->SetInput(image);
writer->Write();

Now I want to put all the timesteps into one file so Im trying to write
many arrays into one ImageData. After looking over the examples, books,
class references and in the internet Im not able to find a solution.
I want to have one ImageData file with multiple arrays in it, each one
with its own name like "Step1", "Step2"... so the second question is how
can I change the name of the scalar data.

Thanks in advance
VTK user




More information about the vtkusers mailing list