[vtkusers] How to handle vtkWindowToImageFilter

Jean M. Favre jfavre at cscs.ch
Fri Jul 25 04:41:31 EDT 2003


rchqh at polyu.edu.hk wrote:

> However, the vtkWindowToImageFilter can only capture the first scene of the
> window without other consequent images. I found that vtkWindowToImageFilter
> could not detect the modification of the renderwindow, since the

I suggest you look at the manual page: It says verbatim:

Warning: 
        To force an update of the output image, call
vtkWindowToImageFilter's Modified method after rendering to the window.

As a result, I can suggest the following code


  vtkRenderWindow *renWin = vtkRenderWindow::New();
  vtkWindowToImageFilter *wToImg = vtkWindowToImageFilter::New();
  vtkTIFFWriter *writer = vtkTIFFWriter::New();
  
  wToImg->SetInput(renWin);
  writer->SetInput(wToImg->GetOutput());
  for(i=0;i<nIndex;i++)
  {
      ........//translate or rotate the 3D actor
      renWin->Render();
      wToImg->Modified();
      // create here a new filename for each iteration
      writer->SetFileName(fname);
      writer->Write();
  }

  wToImg->Delete();
  writer->Delete();

-- 
Dr. Jean M. Favre,                            email:favre at cscs.ch
http://www.cscs.ch/people/Favre.html
CSCS, Swiss Center for Scientific Computing | Tel:  +41 (91) 610.82.40
Via Cantonale, 6928 Manno, Switzerland      | Fax:  +41 (91) 610.82.82



More information about the vtkusers mailing list