[vtkusers] a error appear in volume rendering using vtkVolumnRayCastMapper

¾ÏÓ± fifojuying at 263.net
Mon May 28 22:56:42 EDT 2001


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
模拟断层数据
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);

	//ray cast function
	vtkVolumeRayCastCompositeFunction  *compositeFunction;
	compositeFunction = vtkVolumeRayCastCompositeFunction::New();
	
	//mappers 
	vtkVolumeRayCastMapper *volumeMapper;
	volumeMapper = vtkVolumeRayCastMapper::New();
	volumeMapper->SetInput(reader->GetOutput());
	volumeMapper->SetVolumeRayCastFunction(compositeFunction);
	
	//prop (volume actors)
	vtkVolume *volume;
	volume = vtkVolume::New();
	volume->SetMapper(volumeMapper);
	volume->SetProperty(volumeProperty);

	//renderer
	vtkRenderer *ren1;
	ren1 = vtkRenderer::New();
	//ren1->AddActor(outlineActor);
	ren1->AddVolume(volume);
	ren1->SetBackground(0.2  ,0.2 , 0.2);
	
	//renderwindow
	vtkRenderWindow *renWin;
	renWin = vtkRenderWindow::New();
	renWin->AddRenderer(ren1);
	renWin->SetSize(256 , 256);
	
	//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





More information about the vtkusers mailing list