[vtkusers] How to save the updated render window

Xiaofeng Z xf10036 at hotmail.com
Thu May 14 15:31:12 EDT 2009


I'm writing a short program to store a series of scences from an offscreen render window.  The following is the code snippet that writes the (offscreen) render window in a series of files as the position of an object moves.

 

for (int i=0; i<36; ++i)

{

  cone->SetCenter(3.0-i*1.0/100.0, -1.0, 0.0);

  mRenWin->Render();

 

  std::stringstream s;

  s << "C:\\OffScreenTest\\scence" << i << ".png";

  vtkWindowToImageFilter* w2if = vtkWindowToImageFilter::New();

  w2if->SetInput(mRenWin);

  vtkPNGWriter* wr = vtkPNGWriter::New();

  wr->SetInputConnection(w2if->GetOutputPort());

  wr->SetFileName(s.str().c_str());

  wr->Write();

}


You can see I have to create new vtkWindowToImageFilter and vtkPNGWriter objects for each iteration inside the loop to save the updated render window.  Otherwise, only the screen of the first scene is saved.

 

What did I do wrong?

 

Thanks!


Xiaofeng Zhao




_________________________________________________________________
Insert movie times and more without leaving Hotmail®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd1_052009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090514/9df8fd2d/attachment.htm>


More information about the vtkusers mailing list