Mon, 10/21/2024 - 17:31
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
Mon, 10/21/2024 - 20:27
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 intoTopoDS_Compound
, and the display them viaAIS_Shape
.Ideally, you may create a dedicated
AIS_InteractiveObject
for your circles and lines to avoid creatingTopoDS_Shape
, but this approach would allow reusingAIS_Shape
and estimate performance difference.Nowadays, to utilize immediate redrawing you will need putting animated or interactively transformed object into
Graphic3d_ZLayerId_Top
(e.g. usingAIS_InteractiveContext::SetZLayer()
method) and then callingV3d_View::RedrawImmediate()
instead ofV3d_View::Redraw()
within your animation callback (if you are usingAIS_ViewController
- then you should call something likeV3d_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.