[vtkusers] scalar type
Lisa Avila
lisa.avila at kitware.com
Wed Jul 14 09:51:24 EDT 2004
The volume mappers in VTK support only unsigned char and unsigned short.
You can use vtkImageShiftScale to convert to unsigned short.
Lisa
At 04:48 AM 7/14/2004, =?gb2312?B?SmF3Ymlu?= wrote:
>Dear all:
> I want to do some volume rendering, and the data type is structured
> points. When
>
>the scalar type is unsigned char, it is ok; but when the scalar type is
>float, noting is
>
>seen. How can I do this.
> Thank you very much.
>
> vtkStructuredPointsReader *reader= vtkStructuredPointsReader::New();
> //reader->SetFileName("d:/vtkdata/Data/ironprot.vtk");
> //when the scalar type is unsigned char , it is ok.
> reader->SetFileName("d:/vtkdata/data/heart.vtk");
> //when the scalar type is float , noting to be seen.
> reader->Update();
>
> float *sr=reader->GetOutput()->GetScalarRange();
>
> vtkPiecewiseFunction *opacityTransFunc=vtkPiecewiseFunction::New();
> opacityTransFunc->AddPoint(sr[0],0.0);
> opacityTransFunc->AddPoint(sr[1],0.2);
>
> vtkColorTransferFunction
> *colorTransFunc=vtkColorTransferFunction::New();
> //blue to red
> colorTransFunc-> AddHSVPoint ( sr[0], 0.667, 1.0 ,1.0);//
> colorTransFunc ->AddHSVPoint ( sr[1] , 0 ,1.0, 1.0);//
> colorTransFunc ->SetColorSpaceToHSV();
>
> vtkVolumeProperty *volumeProperty= vtkVolumeProperty::New();
> volumeProperty->SetColor(colorTransFunc);
> volumeProperty->SetScalarOpacity(opacityTransFunc);
> volumeProperty->SetInterpolationTypeToNearest();
>
> vtkVolumeRayCastCompositeFunction *compositeFunction
> = vtkVolumeRayCastCompositeFunction::New();
>
> vtkVolumeRayCastMapper *volumeMapper=vtkVolumeRayCastMapper::New();
> volumeMapper->SetInput(vtkImageData*)(reader->GetOutput()));
> volumeMapper->SetVolumeRayCastFunction(compositeFunction);
>
> vtkVolume *volume=vtkVolume::New();
> volume->SetMapper( volumeMapper);
> volume->SetProperty (volumeProperty);
>
> ren1->AddVolume(volume);
> renWin->Render();
>========================================================
>¼ÎÄ껪ÌôÕ½¿ìÀÖ¼«ÏÞ£¬Äã¸ÒÍæÂð£¿
>http://smspop.163.com/personal/wang/17/index.htm
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at:
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list