[vtkusers] volume rendering problem!

anast.jm at pg.com anast.jm at pg.com
Tue Jul 8 17:02:15 EDT 2003


Paul, you can use vtkImageReader but its definitely more work and you have 
to manually "parse" the file

vtkStructuredPointsReader reader
    reader SetFileName "$env(VTK_DATA)/data/ironProt.vtk"

or 

vtkImageReader reader1
    reader1 SetFileName "$env(VTK_DATA)/data/ironProt.vtk"
    reader1 SetFileDimensionality 3
    reader1 SetHeaderSize 210
    reader1 SetDataSpacing 1 1 1
    reader1 SetDataExtent 0 67 0 67 1 68
    reader1 SetDataScalarTypeToUnsignedChar 


----- Forwarded by John Anast-JM/PGI on 07/08/2003 04:55 PM -----


John Anast-JM



        To:     Paul McGuinness <mcguinpg at maths.tcd.ie>
        cc: 
        Subject:        Re: [vtkusers] volume rendering problem!

Paul, yes but vtkImageReader is expecting image files not VTK format 
files. I have a fairly recent CVS build of VTK4.2.x and 
vtkStructuredPointsReader has not been replaced to my knowledge, where did 
you see this?  I imagine you could use vtkImageReader if you told it the 
"header" was all the info up till the image data but then you would have 
to set all the parameters manually, while vtkStructuredPointsReader does 
it for you...why fight it?? Also ascii data would not work because 
vtkImageReader is expecting binary. When I use vtkStructuredPointsReader 
there is no deprecation warning (nor does the man page suggest this). 
vtkStructuredPointsReader can feed a vtkVolumeRayCastMapper just fine. 
Maybe the list has some insight here?? ...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/08/2003 06:53 AM

 
        To:     John Anast-JM/PGI at PGI
        cc:     vtkusers at vtk.org
        Subject:        Re: [vtkusers] volume rendering problem!



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
>
>
>

_______________________________________________
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



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


More information about the vtkusers mailing list