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.
Tue, 10/22/2024 - 16:55
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
Tue, 10/22/2024 - 18:10
The tessellation quality is managed by
Prs3d_Drawer::SetDeviationAngle()
,SetDeviationCoefficent()
,SetMaximalChordialDeviation()
andSetTypeOfDeflection()
parameters, which you may adjust to achieve desired quality.In this case you need activating in
AIS_Shape
local selection mode for picking edges, e.g.AIS_Shape::SelectionMode(TopAbs_EDGE)
.