[vtkusers] Updating transfer function in volume rendering

Dženan Zukić dzenanz at gmail.com
Mon Feb 7 06:03:15 EST 2011


Hi all,

I have the following menu handler:

void MainWindow::on_TF_chosen(QAction *action)
{
    if (volume) //volume is loaded and set up
    {
        volume->SetProperty( tf[action->data().toInt()] );
        vis->GetRenderWindow()->Render();
    }
}

tf is an array of vtkVolumeProperty*s, containing combinations of color and
opacity transfer functions. However, when transfer function is changed with
this procedure, the result is not what I expect: transfer functions are
either not changed, or they are changed to something I didn't specify.

Is there some call missing here, something like "UpdateTransferFunctions"?

This is the code from form constructor:

//manually create transfer functions
tf[0] = vtkVolumeProperty::New();
vtkPiecewiseFunction *opacityFun0 = vtkPiecewiseFunction::New();
tf[0]->SetScalarOpacity( opacityFun0 );
opacityFun0->AddPoint(0, 0);
opacityFun0->AddPoint(255, 0 );
tf[0]->ShadeOn();
tf[0]->SetScalarOpacityUnitDistance(0.8919);

tf[1] = vtkVolumeProperty::New();
vtkColorTransferFunction *colorFun1 = vtkColorTransferFunction::New();
vtkPiecewiseFunction *opacityFun1 = vtkPiecewiseFunction::New();
tf[1]->SetColor( colorFun1 );
tf[1]->SetScalarOpacity( opacityFun1 );
tf[1]->SetInterpolationTypeToLinear();
colorFun1->AddRGBPoint( 0, .55, .75, .85 );
colorFun1->AddRGBPoint( 80, .88, .60, .29 );
opacityFun1->AddPoint(0, 0);
opacityFun1->AddPoint(80, .5 );
tf[1]->ShadeOn();
tf[1]->SetScalarOpacityUnitDistance(0.8919);

tf[2] = vtkVolumeProperty::New();
vtkColorTransferFunction *colorFun2 = vtkColorTransferFunction::New();
vtkPiecewiseFunction *opacityFun2 = vtkPiecewiseFunction::New();
tf[2]->SetColor( colorFun2 );
tf[2]->SetScalarOpacity( opacityFun2 );
tf[2]->SetInterpolationTypeToLinear();
colorFun2->AddRGBPoint( 0, .55, .9, .5 );
colorFun2->AddRGBPoint( 160, .88, .1, .1 );
opacityFun2->AddPoint(0, 0);
opacityFun2->AddPoint(160, .6 );
tf[2]->ShadeOn();
tf[2]->SetScalarOpacityUnitDistance(0.8919);

Thanks,
Dženan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110207/05b6e578/attachment.htm>


More information about the vtkusers mailing list