[vtkusers] Read RAW datas with vtkImageData?
x0_y0_0
x0_y0_0 at 126.com
Mon Jun 29 03:29:46 EDT 2009
hi,evryone,
I want to use vtkImageData read a raw datasets 256*256*256, and I followed an example from the internet. I reconstruct the datasets,but it shows part of the 3D reconstruction. Could anyone help me? thanks.
code:
unsigned short *buf;
buf = new unsigned short[256*256*117];
unsigned short *p=buf;
FILE *fp = fopen( filePath,"r");
fread(buf,256*256,117,fp);
fclose(fp);
vtkImageData* id = vtkImageData::New();
id->SetDimensions(256, 256, 117);
// id ->GetPointData()->SetScalars(array) ;
id->SetSpacing(1.0,1.0,1.0);
id->SetOrigin(0.0,0.0,0.0);
id->SetScalarTypeToUnsignedShort();
id->SetNumberOfScalarComponents(1);
id->AllocateScalars();
unsigned short* a = (unsigned short*)(id->GetScalarPointer());
for (i = 0; i < dims[2]; i++)
{
for (j = 0; j < dims[1]; j++)
{
for (k = 0; k < dims[0]; k++)
{
*a = *p; a++; p++;
}
}
}
mexiao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090629/02e4ce41/attachment.htm>
More information about the vtkusers
mailing list