[vtkusers] Why two scalar volume rendering failed???

Enya Shen enya.shen2010 at gmail.com
Thu Mar 20 10:27:15 EDT 2014


Hi all,

I tried to use different scalar for color and opacity in volume rendering
as follows. But it failed to use the second scalar to get opacity. Why?
Thank you for any advice!!!

......

vtkPiecewiseFunction* opacityFn = vtkPiecewiseFunction::New();

vtkColorTransferFunction* colorFn = vtkColorTransferFunction::New();


vtkVolumeProperty* volumeProperty = vtkVolumeProperty::New();

volumeProperty->SetIndependentComponents(false);

volumeProperty->SetScalarOpacity(this->opacityFn);

volumeProperty->SetColor(this->colorFn);

volumeProperty->SetInterpolationTypeToLinear();

volumeProperty->ShadeOn();


vtkVolume* volumeActor = vtkVolume::New();

volumeActor->SetProperty(this->volumeProperty);


colorFn->AddRGBPoint(this->scalarsRange[0][0], 0.0, 0.0, 1.0);

colorFn->AddRGBPoint(0.5*(this->scalarsRange[0][0]+this->scalarsRange[0][1]),
0.0, 1.0, 0.0);

colorFn->AddRGBPoint(this->scalarsRange[0][1], 1.0, 0.0, 0.0);

opacityFn->AddPoint(this->scalarsRange[1][0], 0.0, 0.0, 0.0);

opacityFn->AddPoint(0.5*(this->scalarsRange[1][0]+this->scalarsRange[1][1]),
0.5, 0.0, 0.0);

opacityFn->AddPoint(this->scalarsRange[1][1], 1.0, 0.0, 0.0);

volumeProperty->SetIndependentComponents(true);

......


Regards,

Enya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140320/a92734c3/attachment.html>


More information about the vtkusers mailing list