Visualization performance

Hi All,
I'am developing graphical utility which should visualize animation of 4 primitive 3D parts (i create them with BRepPrimAPI_MakeCylinder and BRepPrimAPI_MakeCone)

Also I have to visualize static lines and arcs (AIS_Line, AIS_Circle). There could be tens thousands of this primitives.

Animation's FPS slows down with lines and arcs quantity growth.

In the end of which window timer trigger, where I recalc tranformations/rotations in AIS_Animation, i use V3D_Viewer::Redraw to update the view. this call seems to lead to redraw of each shape in the context

My question is: is it possible somehow to optimize redrawings, preventing redrawing of all shapes in the view.

PS: After reading some topics here I thought about PrsMgr_PresentationManager::ImmediateRedraw. Maybe its wrong way?
i tried the following: in each timer trigger i added BeginImmediateDraw call, then each transormed AIS_Shape adds itself to immediate draw list by calling ImmediateAdd and in the end of the trigger i call EndImmediateDraw. but it fails on second iteration of timer trigger in:
void PrsMgr_PresentationManager::ClearImmediateDraw()
{
for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next())
{
anIter.Value()->Erase();//<-fails here
}

seems i use it in a wrong way(.
so Please give advice

gkv311 n's picture

Also I have to visualize static lines and arcs (AIS_Line, AIS_Circle). There could be tens thousands of this primitives.

If you have large amounts of such primitives, it is better grouping them into larger interactive object(s). You may create TopoDS_Edge from your lines and circles and put them into TopoDS_Compound, and the display them via AIS_Shape.

Ideally, you may create a dedicated AIS_InteractiveObject for your circles and lines to avoid creating TopoDS_Shape, but this approach would allow reusing AIS_Shape and estimate performance difference.

After reading some topics here I thought about PrsMgr_PresentationManager::ImmediateRedraw. Maybe its wrong way?

Nowadays, to utilize immediate redrawing you will need putting animated or interactively transformed object into Graphic3d_ZLayerId_Top (e.g. using AIS_InteractiveContext::SetZLayer() method) and then calling V3d_View::RedrawImmediate() instead of V3d_View::Redraw() within your animation callback (if you are using AIS_ViewController - then you should call something like V3d_View::InvalidateImmediate() before flushing ViewController events to show next animation frame).

Playing with immediate layer could be helpful only if the number of animated / modified objects is considerably smaller than amount of static presentations, and you know in advance which objects will be modified.