[vtkusers] Texture mapping problem.

John Ryan john.ryan at ucd.ie
Wed Jun 7 09:06:42 EDT 2006


Hi,

I'm having a problem displaying a vtkVolume using 
vtkVolumeTextureMapper2D read in from vtkBMPReader.

I've got a volume of one hundred 512X512 slices from bmp files, labelled 
0 to 99. I've experimented with iso-surfaces, so the volume has read in 
ok. But, when I try to display a texture volume, it looks like the pixel 
information is getting mixed up. I've tried casting to unsigned chars to 
no avail.

Has anyone encountered this problem or know how to combat it?

Some of the code is below...

John

    //READ IN
    vtkBMPReader *v = vtkBMPReader::New();
    v->SetFilePrefix("dataset/im.bmp");   
    v->SetDataSpacing (3.2, 3.2, 1.5);
    v->SetDataExtent(1,512,1,512,0,99);
    //v->SetDataExtent(0,64,0,64,0,99);
    v->Update();

    //OPACITY TF
    vtkPiecewiseFunction *opacityTF = vtkPiecewiseFunction::New();
    opacityTF->AddPoint(   200.0,  0.0 );
    opacityTF->AddPoint(   210.0,  1.0 );
    opacityTF->AddPoint(   255.0,  1.0 );

    //COLOUR TF
    vtkColorTransferFunction *colorTF = vtkColorTransferFunction::New();
    colorTF->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
    colorTF->AddRGBPoint(64.0, 1.0, 0.0, 0.0);
    colorTF->AddRGBPoint(128.0, 0.0, 0.0, 1.0);
    colorTF->AddRGBPoint(255.0, 0.0, 0.2, 0.0);

    //PROPERTIES
    vtkVolumeProperty *volprop = vtkVolumeProperty::New();
    volprop->SetColor(colorTF);
    volprop->SetScalarOpacity(opacityTF);
    volprop->ShadeOn();
    volprop->SetInterpolationTypeToLinear();
    volprop->SetSpecularPower(10.0);
    volprop->SetSpecular(.7);
    volprop->SetAmbient(.5);
    volprop->SetDiffuse(.5);

    vtkImageCast *cast = vtkImageCast::New();
    cast->SetInput(v->GetOutput());
    cast->SetOutputScalarTypeToUnsignedChar();

    vtkVolumeTextureMapper2D *volumeMapper = 
vtkVolumeTextureMapper2D::New();
    volumeMapper->SetInput( cast->GetOutput() );

    //VOLUME ACTOR
    vtkVolume *volume = vtkVolume::New();
    volume->SetMapper(volumeMapper);
    volume->SetProperty(volprop);




More information about the vtkusers mailing list