[vtkusers] scalar type

Jawbin seafloat11 at 163.com
Wed Jul 14 04:48:19 EDT 2004


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




More information about the vtkusers mailing list