[vtkusers] Render a image in a loop while it is updating

LuanKuan luankuan at hotmail.com
Tue Nov 9 21:35:26 EST 2010


Hi, vtk users

I am a beginner. 
 
I just want to render a 3d image in the same vtkRenderWindow without creating a new one.
 
I create vtkrenderer and vtkrenderwindow before the loop.
 
The 3d image is updated and rendered in the loop.
 
In the result, only the first 3d image is rendered in the vtkrenderwindow. Then, the rendered 3d image can not change while it is updating.
 
My code is as fellows, please tell me how to correct it or give me some examples.
 
thank you.

 
 vtkRenderer *aRenderer = vtkRenderer::New();
 vtkRenderWindow *renWin = vtkRenderWindow::New();
 renWin->AddRenderer(aRenderer);
 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
 iren->SetRenderWindow(renWin);
 
 vtkContourFilter *contours = vtkContourFilter::New();
 vtkPolyDataMapper *contmap = vtkPolyDataMapper::New();
 vtkActor *contact = vtkActor::New();
 
 vtkCamera *aCamera = vtkCamera::New();
 aCamera->ParallelProjectionOn();
 aRenderer->SetActiveCamera(aCamera);
 aRenderer->ResetCamera();
 aRenderer->SetBackground(0.725,0.725,1);
 renWin->SetSize(1024, 768);
 aRenderer->ResetCameraClippingRange ();
 iren ->Initialize();

// loop 
for (int i=iFirstFrame; i<iNumFrames; i++)
{
  ......
  interpolate bmpimage into volumeimage;
  ......
  volumeimage->update();
  contours->SetInput(volumeimage);
  contours->SetValue(0,gval);
  contmap->SetInput(contours->GetOutput());
  contmap->SetScalarRange(100,220);
  contact->SetMapper(contmap);
  aRenderer->AddActor(contact);
  aRenderer->Render();
  iren->Render();
}
iren->Start();
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101110/eff13046/attachment.htm>


More information about the vtkusers mailing list