[vtkusers] volume rendering problem!

Paul McGuinness mcguinpg at maths.tcd.ie
Tue Jul 8 06:53:32 EDT 2003


John,

In more recent versions of the visualization toolkit
vtkStructuredPointsReader has been replaced with vtkImageReader. For
example vtkVolumeRayCastMapper use to take vtkStructuredPointsData
objects as input, but in the current version of vtk vtkVolumeRayCastMapper
takes vtkImageData as the input. Using vtkImageReader instead of
vtkStructuredPointsReader is causing some problems because I cannot find a
similar example where vtkImageReader has been used for volume rendering.

Paul


On Mon, 7 Jul 2003 anast.jm at pg.com wrote:

> Paul,  vtkImageReader doesn't read VTK format data files....try using
> vtkStructurePointsReader ....john
>
>
>
> Internet Mail Message
> Received from host:     public.kitware.com [24.97.130.19]
>
>
>
> Paul McGuinness <mcguinpg at maths.tcd.ie>
> Sent by: vtkusers-admin at vtk.org
> 07/04/2003 10:10 AM
>
>
>         To:     vtkusers at vtk.org
>         cc:     (bcc: John Anast-JM/PGI)
>         Subject:        [vtkusers] volume rendering problem!
>
>
>
> Hi All,
>
> I am having a problem displaying the volume rendering of ironProt.vtk. The
> code compiles, and the display window appears but there is no rendering in
> the window, the window is just empty. Can someone please help me, I am
> reading in the file using vtkImageReader and using vtkImageCast to convert
> it to unsigned-short. Then vtkVolumeRayCastMapper sets its input to the
> vtkImageCast object's output, see below. I am using vtk4.2.2.
> Please can someone help,
> Happy 4th July,
> Paul.
>
>
> int main( int argc, char *argv[] )
>          {
> vtkRenderer *ren1 =vtkRenderer::New();
> vtkRenderWindow *renWin=vtkRenderWindow::New();
>     renWin->AddRenderer(ren1);
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>     iren->SetRenderWindow(renWin);
>
> vtkImageReader *reader =vtkImageReader::New();
> reader->SetFileName("ironProt.vtk");
>
>
> vtkImageCast *imgcas = vtkImageCast::New();
> imgcas->SetInput(reader->GetOutput());
> imgcas->SetOutputScalarTypeToUnsignedShort();
>
>
> vtkPiecewiseFunction *opacityTransferFunction =
> vtkPiecewiseFunction::New();
>     opacityTransferFunction->AddPoint(20,   0.0);
>     opacityTransferFunction->AddPoint(255,  0.2);
>
> vtkColorTransferFunction *colorTransferFunction =
> vtkColorTransferFunction::New();
>     colorTransferFunction->AddRGBPoint( 0.0, 0.0, 0.0, 0.0);
>     colorTransferFunction->AddRGBPoint(64.0, 1.0, 0.0, 0.0);
>     colorTransferFunction->AddRGBPoint(128.0, 0.0, 0.0, 1.0);
>     colorTransferFunction->AddRGBPoint(192.0, 0.0, 1.0, 0.0);
>     colorTransferFunction->AddRGBPoint(255.0, 0.0, 0.2, 0.0);
>
> vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
>     volumeProperty->SetColor(colorTransferFunction);
>     volumeProperty->SetScalarOpacity(opacityTransferFunction);
>     volumeProperty->ShadeOn();
>     volumeProperty->SetInterpolationTypeToLinear();
>
> vtkVolumeRayCastCompositeFunction  *compositeFunction=
> vtkVolumeRayCastCompositeFunction::New();
> vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
>     volumeMapper->SetVolumeRayCastFunction(compositeFunction);
>     volumeMapper->SetInput(imgcas->GetOutput());
>
> vtkVolume *volume = vtkVolume::New();
>     volume->SetMapper(volumeMapper);
>     volume->SetProperty(volumeProperty);
>
> ren1->AddVolume(volume);
> ren1->SetBackground(1, 1 ,1);
> renWin->SetSize(600, 600);
> renWin->Render();
> iren->Start();
>
> }
>
>
>
> _______________________________________________
> 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://www.vtk.org/mailman/listinfo/vtkusers
>
>
>




More information about the vtkusers mailing list