[vtkusers]help: Volume Rendering problems
lpf
lpf at vico-lab.com
Tue Nov 22 07:30:59 EST 2005
Yes, you are right. I have resolved it by adopting your suggestion.
Thank you very much!
Pengfei Liu
----- Original Message -----
From: "Marc Cotran" <marc at cotran.ca>
To: "lpf" <lpf at vico-lab.com>
Sent: Monday, November 21, 2005 11:03 PM
Subject: Re: [vtkusers]help: Volume Rendering problems
> Hi,
>
> I don't believe the mapper supports float data. Try using vtkImageCast
> to cast the data to unsigned short or unsigned char.
>
> HTH
>
> Marc
>
> lpf wrote:
>> Hi, VTK users
>> Now I am rendering a volume Data, it is raw single 3D data, at first
>> I render it slice by slice, it is no problem,
>> so I think file reading is no problem , but when I render it as volume,
>> Nothing display, who can tell me what's wrong
>> My VTK is Version 4.0
>> Here is the code
>> ------------------------------------------------------
>> #include "vtkImageReader.h"
>> #include "vtkRenderer.h"
>> #include "vtkRenderWindow.h"
>> #include "vtkRenderWindowInteractor.h"
>> #include "vtkPiecewiseFunction.h"
>> #include "vtkColorTransferFunction.h"
>> #include "vtkVolumeProperty.h"
>> #include "vtkVolumeRayCastCompositeFunction.h"
>> #include "vtkVolumeRayCastMapper.h"
>> #include "vtkVolume.h"
>> int main()
>> {
>> vtkImageReader* reader = vtkImageReader::New();
>> reader->SetFileName("D:\\volume.im"); //single 3D raw data
>> reader->SetDataScalarTypeToFloat();
>> reader->SetDataByteOrderToBigEndian();
>> reader->SetFileDimensionality(3);
>> reader->SetDataExtent(0,255,0,127,0,127);
>> reader->SetDataSpacing(0.39,0.78,0.78);
>> reader->SetHeaderSize(0);
>> reader->Update();
>>
>> vtkPiecewiseFunction *opacityFun = vtkPiecewiseFunction::New();
>> opacityFun->AddPoint(0, 0.0);
>> opacityFun->AddPoint(10, 0.0);
>> opacityFun->AddPoint(500, 0.1);
>> opacityFun->AddPoint(5000, 0.4);
>>
>> vtkColorTransferFunction *colorFun = vtkColorTransferFunction::New();
>> colorFun->AddRGBPoint(0, 0.3, 0.3, 1.0);
>> colorFun->AddRGBPoint(5000,1.0, 0.0, 0.0);
>>
>> vtkVolumeProperty *volProperty = vtkVolumeProperty::New();
>> volProperty->SetScalarOpacity(opacityFun);
>> volProperty->SetColor(colorFun);
>>
>> vtkVolumeRayCastCompositeFunction *compositeFun =
>> vtkVolumeRayCastCompositeFunction::New();
>>
>> vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
>> volumeMapper->SetVolumeRayCastFunction(compositeFun);
>> volumeMapper->SetInput(reader->GetOutput());
>>
>> vtkVolume* volProp = vtkVolume::New();
>> volProp->SetMapper(volumeMapper);
>> volProp->SetProperty(volProperty);
>>
>> vtkRenderer *render = vtkRenderer::New();
>> render->AddVolume(volProp);
>> render->SetBackground(1.0,1.0,1.0);
>> vtkRenderWindow *renWin = vtkRenderWindow::New();
>> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>> renWin->AddRenderer(render);
>> renWin->SetSize(500,500);
>> renWin->SetInteractor(iren);
>>
>> renWin->Render();
>> iren->Start();
>> }
>> ------------------------------------------------------
>>
>>
>>
>> Best regards
>> PengFei Liu
>> _______________________________________________
>> This is the private VTK discussion list. Please keep messages on-topic.
>> Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list