[vtkusers] volume rendering from a stream of bytes

Ali Hashimi benkasmi at yahoo.com
Sat Mar 26 02:06:32 EST 2005


Hi everybody

I started looking into volume rendering examples in
VTK distribution, all of them deal with specific
format.

does anybody have an idea how to render some data
which is like : 128x128x64

64 images, every one of them is 128x128

the data is an unsigned char representation of the
material density.

I used vtkImage and set the internal data like this

//////////////////////////////

vtkImageData* imageData = vtkImageData::New();
imageData->SetDimensions(128, 128, 64);
imageData->SetScalarTypeToUnsignedChar();
imageData->SetNumberOfScalarComponents(1);
imageData->AllocateScalars();
	
unsigned char* ptr = (unsigned
char*)imageData->GetScalarPointer();

unsigned char c;

for(int slice = 0; slice < dim[2]; slice++)
{
	for(int row = 0; row < dim[1]; row++)
	{
		for(int col = 0; col < dim[0]; col++)
		{
			infile >> c;
			*(ptr+cell) = c;
			
		}
	}
}

...
.
.
.

vtkVolumeRayCastMapper* mapper =
vtkVolumeRayCastMapper::New();
mapper->SetInput(reader->GetOutput());
	mapper->SetVolumeRayCastFunction(raycastfunction);

..

.
.
.
//////////////////////////////////////////


it does not work 

any idea what I am doing wrong?


thanks in advance




		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more. 
http://info.mail.yahoo.com/mail_250



More information about the vtkusers mailing list