[vtkusers] Problem solved - almost!

Jonas jonas.email at gmail.com
Fri Sep 15 09:33:44 EDT 2006


Ok, I've found a solution myself, by using case two with the vtkTexture.

I need to scale the plane to have the same size as the slice used for the
texture. It is a good idea to translate the plane such that the origo of the
image is the lower left corner of the plane. Finally i use the actor to set the
position of the slice in space.

So this is what i execute when a user select an image:

double sw = pixelWidth * spacingX;
double sh = pixelHeight * spacingY;
int tx = (int)round(sw / 2.);
int ty = (int)round(sh / 2.);

texture->SetInput(image);
textureTransform->Identity();

// move plane origin from center to lower left corner
textureTransform->Translate(tx, ty, 0); 

// scale plane to have the same size as the image
textureTransform->Scale(sw, sh, 1);			

// finaly move the slice into position in space
textureActor->SetPosition(x, y, z);
	
textureMapper->SetInput(textureTransformFilter->GetOutput());

I also had to add a lookup table to map the colors

textureLUT->SetNumberOfColors(1000);
textureLUT->SetTableRange(0, 1000);
textureLUT->SetSaturationRange(0, 0);
textureLUT->SetHueRange(0, 1);
textureLUT->SetValueRange(0, 1);
textureLUT->SetAlphaRange(1, 1);
textureLUT->Build();

texture->SetLookupTable(textureLUT);

- Jonas




More information about the vtkusers mailing list