[vtkusers] Displaying a 2D image as a volume

J.S.Wijnhout at lumc.nl J.S.Wijnhout at lumc.nl
Wed Feb 27 03:31:05 EST 2008


Hi,

 

I'm trying to display a 2D image (that has a certain thickness) as a 3D
volume, visualizing the thickness of the image as well. However I seem
to be unable to get anything displayed. I've tried the following (note
that this code does work with data sets that have
image->GetDimensions()[2] > 1):

 

    vtkImageData *image = ...;

 

    vtkPiecewiseFunction *opacityTransferFunction =
vtkPiecewiseFunction::New ();

    opacityTransferFunction->AddPoint ( 0, 1.0 );

    opacityTransferFunction->AddPoint ( 255, 1.0 );

    vtkColorTransferFunction *colorTransferFunction =
vtkColorTransferFunction::New ();

    colorTransferFunction->AddRGBPoint ( 0, 0.0, 0.0, 0.0 );

    colorTransferFunction->AddRGBPoint ( 255, 1.0, 1.0, 1.0 );

 

    vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New ();

    volumeProperty->SetColor ( colorTransferFunction );

    volumeProperty->SetScalarOpacity ( opacityTransferFunction );

 

    vtkVolumeRayCastCompositeFunction *rayCastFunction =
vtkVolumeRayCastCompositeFunction::New ();

 

    vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New
();

    volumeMapper->SetInput ( image );

    volumeMapper->SetVolumeRayCastFunction ( rayCastFunction );

 

    vtkVolume *volume = vtkVolume::New ();

    volume->SetProperty ( volumeProperty );

    volume->SetMapper ( volumeMapper );

 

It seems like a very basic problem, so hopefully someone can point out
my error.

 

best,

Jeroen

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080227/cb9bef99/attachment.htm>


More information about the vtkusers mailing list