[vtkusers] Re: raycast questions

straw dog straw_dog at hotmail.com
Tue Aug 19 07:46:49 EDT 2003


Hi Nico,

VTK seems to only be able to render to an image file (or an image data) by 
rendering using the graphics card, and then grabbing the buffer off the 
card.  However, for most applications that is fine.  The key is to use the  
vtkWindowToImageFilter class.  You may also find vtkRenderLargeImage 
helpful.

I haven't actually tried that with Volume rendered stuff - it works on 
polydata models just fine. Let me know how it works on Vol rendered.

<code snippet>
vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);

  if(strlen(outfile)>0) {
    renWin->OffScreenRenderingOn();
    renWin->Render();
    vtkWindowToImageFilter *w2i=vtkWindowToImageFilter::New();
    w2i->SetInput(renWin);
    vtkTIFFWriter *iw=vtkTIFFWriter::New();
    iw->SetInput(w2i->GetOutput());
    iw->SetFileName(outfile);
    iw->Write();
    iw->Delete();
    w2i->Delete();
  } else {
    renWin->Render();
    iren->Start();
  }


Apparently, you can also write to a RIB(?) file and use Renderman or Blue 
Moon Ray tracer to render it.  I haven't tried that myself.

--rupert b.

>Date: Tue, 19 Aug 2003 08:35:50 +0200
>From: "Nico Vermaas" <vermaas at astron.nl>
>To: < <vtkusers at public.kitware.com>>
>Subject: [vtkusers] raycast questions
>
>hi,
>
>I am displaying my ImageData cube with a raycast function.=20
>(1) Is there a way to write the result of that raycast back to a 
>vtkImageDa=
>ta again? So that I get a new data cube with the max pixels projected on =
>the outside?
>(2) Is there a way to find out which x,y,z pixel was responsible for the =
>maximum projection on the outside?
>(3) Is there a way to 'shoot' a line through a cube and get back the =
>highest value it encounters? (I thought the picking might work in that =
>way, but it doesn't seem to work like this).
>
>...
>vtkVolumeRayCastMIPFunction *function =3D 
>vtkVolumeRayCastMIPFunction::New(=
>);
>vtkVolumeRayCastMapper *mapper =3D vtkVolumeRayCastMapper::New();
>mapper->SetVolumeRayCastFunction(function);
>mapper->SetInput(myImageData);
>actorVolume->SetMapper(mapper);
>...
>
>Nico

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail




More information about the vtkusers mailing list