[vtkusers] a error appear in volume rendering using vtkVolumnRayCastMapper

bo wang bowang at iastate.edu
Mon May 28 23:14:17 EDT 2001


Use vtkImageCast to cast your data type in *.vtk to unsigned short.


-----Original Message-----
From: 鞠颖 <fifojuying at 263.net>
To: vtk <vtkusers at public.kitware.com>
Date: Monday, May 28, 2001 9:58 PM
Subject: [vtkusers] a error appear in volume rendering using
vtkVolumnRayCastMapper


>Hi!
> I am a fresh man for vtk. I write a .vtk by myself, and I want to view it.
It is a 3D structured_points data
>
># vtk DataFile Version 2.0
>?£?a??2?êy?Y
>ASCII
>DATASET STRUCTURED_POINTS
>DIMENSIONS 256 256 19
>ASPECT_RATIO 1 1 1
>ORIGIN 0 0 0
>POINT_DATA 1245184
>SCALARS volume_scalars unsigned_char 1
>LOOKUP_TABLE mytable
>........
>........
>........
>LOOKUP_TABLE mytable 4
>1.0 1.0 1.0 0.0
>1.0 0.0 0.0 0.5
>0.0 1.0 0.0 0.5
>0.0 0.0 1.0 0.5
>
>there are only 0,1,2,3 in the point datas
>my render program is very simple
>
> vtkStructuredPointsReader *reader;
> reader = vtkStructuredPointsReader::New();
>    reader->SetFileName("test.vtk");
>    reader->Update();
>
> vtkPiecewiseFunction *opacityTransferFunction;
> opacityTransferFunction = vtkPiecewiseFunction::New();
> opacityTransferFunction->AddPoint(0 , 0.0);
> opacityTransferFunction->AddPoint(3 , 0.8);
>
> vtkColorTransferFunction *colorTransferFunction;
> colorTransferFunction = vtkColorTransferFunction::New();
> colorTransferFunction->AddRGBPoint(0 , 0.0 , 0.0 , 0.0);
> colorTransferFunction->AddRGBPoint(1 , 1.0 , 0.0 , 0.0);
> colorTransferFunction->AddRGBPoint(2 , 0.0 , 1.0 , 0.0);
> colorTransferFunction->AddRGBPoint(3 , 0.0 , 0.0 , 1.0);
>
> vtkVolumeProperty *volumeProperty;
> volumeProperty = vtkVolumeProperty::New();
> volumeProperty->SetColor(colorTransferFunction);
> volumeProperty->SetScalarOpacity(opacityTransferFunction);
>
> file://ray cast function
> vtkVolumeRayCastCompositeFunction  *compositeFunction;
> compositeFunction = vtkVolumeRayCastCompositeFunction::New();
>
> file://mappers
> vtkVolumeRayCastMapper *volumeMapper;
> volumeMapper = vtkVolumeRayCastMapper::New();
> volumeMapper->SetInput(reader->GetOutput());
> volumeMapper->SetVolumeRayCastFunction(compositeFunction);
>
> file://prop (volume actors)
> vtkVolume *volume;
> volume = vtkVolume::New();
> volume->SetMapper(volumeMapper);
> volume->SetProperty(volumeProperty);
>
> file://renderer
> vtkRenderer *ren1;
> ren1 = vtkRenderer::New();
> file://ren1->AddActor(outlineActor);
> ren1->AddVolume(volume);
> ren1->SetBackground(0.2  ,0.2 , 0.2);
>
> file://renderwindow
> vtkRenderWindow *renWin;
> renWin = vtkRenderWindow::New();
> renWin->AddRenderer(ren1);
> renWin->SetSize(256 , 256);
>
> file://renderwindowinteractor
> vtkRenderWindowInteractor *iren;
> iren = vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
> iren->Initialize();
>
> renWin->Render();
>
>but when I run the program, I got the error
>
>ERROR: In
F:\KitwareShared\vtk3.2\vtk-src-windows\graphics\vtkVolumeRayCastMapper.cxx,
line 921
>vtkVolumeRayCastMapper (0x00832010): The scalar data type: 2 is not
supported when volume rendering. Please convert the  data to unsigned char
or unsigned short.
>
>I don't know where is the error from, can you help me? Thank a lot!
>            ju ying
>            fifojuying at 263.net
> fifojuying at sina.com.cn
> fifojuying at soim.com
> fifojuying at hotmail.com
>
>
>_______________________________________________
>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://public.kitware.com/mailman/listinfo/vtkusers
>





More information about the vtkusers mailing list