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

Aashish Chaudhary aashish.chaudhary at kitware.com
Thu Mar 20 10:33:00 EDT 2014


On Thu, Mar 20, 2014 at 10:27 AM, Enya Shen <enya.shen2010 at gmail.com> wrote:

> 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);
>
>

Did you get any error or its just that you don't see any opacity?  What are
the ranges? I may have to look at the VTK code
and your data to provide a solution.

- Aashish

>
> ......
>
>
> Regards,
>
> Enya
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>


-- 
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140320/d7652f01/attachment.html>


More information about the vtkusers mailing list