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.

Denis Nikolaev's picture

Thank you for your answer.
I tried to use both ways.
Results: without any optimization i got ~4FPS with OCCT counters. After applying ZLayer I got ~20FPS on Immediate drawings.
After creating one AIS_Shape from compound TopoDS i got ~20FPS on V3DView::Redraws.
There are two things i need to solve:
1.Arcs created with BRepBuilderAPI_MakeEdge(gp_Circ,Angle1,Angle2) look like polylines, not arcs while zooming. how can I avoid this effect
2.after getting one AIS_InteractiveObject I can highlight by mouse only the whole curve, i cant select a proper line or arc

gkv311 n's picture

1.Arcs created with BRepBuilderAPI_MakeEdge(gp_Circ,Angle1,Angle2) look like polylines, not arcs while zooming. how can I avoid this effect

The tessellation quality is managed by Prs3d_Drawer::SetDeviationAngle(), SetDeviationCoefficent(), SetMaximalChordialDeviation() and SetTypeOfDeflection() parameters, which you may adjust to achieve desired quality.

2.after getting one AIS_InteractiveObject I can highlight by mouse only the whole curve, i cant select a proper line or arc

In this case you need activating in AIS_Shape local selection mode for picking edges, e.g. AIS_Shape::SelectionMode(TopAbs_EDGE).