[vtkusers] Incremental mesh rendering question

John Shalf jshalf at lbl.gov
Wed Dec 20 16:43:17 EST 2000


This came up once before in the VTK list.  I think the key is to be able to tell the renderer
(or well actually the vtkOpenGLRenderer->Clear() is called by vtkOpenGLCamera->Render()) to
*not* execute glClear() on a new frame so that you accumulate things into the image buffer.
Unfortunately VTK 3.1 does not expose this in the standard renderer (perhaps someone will say
something about VTK 3.2 having a method for this?)

Anyways, we can easily inherit from the vtkOpenGLRenderer and override the
vtkOpenGLRenderer->Clear() method to only glClear() if a particular flag is set (ie. some
vtkSetMacro(ClearFrame)).

But there is going to be more to it than that I guess because we would want it to avoid
calling the "Render" method for each of the mesh actors.  I guess if you are busy inheriting
the renderer to override the Clear() method, that you could also create a companion array for
the list of actors that need to be rendered which flags which actors have already been
rendered since the last clear and ignores them.

-john

Shannon Whitmore wrote:

> Greetings,
>
> I am in the beginning stages of modifying an existing mesh visualization
> code for my research.  I'm trying to change the code so that meshes are
> incrementally loaded and displayed when the system is idle.
>
> My problem is that the mesh rendering code is becoming a performance
> issue because it rerenders all meshes displayed to the window every time
> the Render method is called (which occurs every time I load a new grid
> and display it).   If 1000 meshes have already been rendered
> and 5 new ones have been loaded, I would like to only render the 5 new
> ones.  Is it possible to do this?
>
> The code for the Render method is shown below:
>
> void vtkSMGPolyDataMapper::Render(vtkRenderer *ren, vtkActor *a)
> {
>    vtkSMGPolyData *input=(vtkSMGPolyData *)(this->GetInput());
>    this->Update();
>    realmapper->ShallowCopy((vtkMapper *)this);
>    for (int ii=0;ii<input->GetNumberOfEntries();ii++)
>    {
>       if (input->GetPolyData(ii)!=NULL){
>          realmapper->SetInput(input->GetPolyData(ii));
>          realmapper->Render(ren, a);
>       }
>       realmapper->SetInput(NULL);
>    }
> }
>
> I was hoping to call realmapper->Render for each mesh only once, but
> so far I have been unable to make this work.  Does anyone have any ideas on
> what I need to do to render only the newest meshes? I'm rather new to the VTK
> world and have searched the VTK documentation and email list for ideas but
> I'm not finding anything.  Any tips, hints, or tricks would be much
> appreciated.  :-)
>
> Thanks in advance,
> Shannon Whitmore
> Pablo Research Group
> Department of Computer Science
> University of Illinois
> swhitmor at cs.uiuc.edu
>
> _______________________________________________
> 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://public.kitware.com/mailman/listinfo/vtkusers





More information about the vtkusers mailing list