Speed up the visualization?

I need display 1000 edges. The following is my code:
---------------------------
for(int i=0; i {
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(..);
Handle(AIS_Shape) hShape = new AIS_Shape(edge);
myAISContext->Display(hShape);
}
---------------------------
When I excute the program, it can work, but very slowly, just like an animation. Do you know how can speed up the display by using some strategy. Thanks a lot.

By the way, when I triangulize the surface into meshes, acutally there are much more than 1000 edges, but the OCC can display the meshes very smoothly and fast. Why ???

Paul Jimenez's picture

You should try the solution that has been suggested a lot of times here: add all the Edges to a Compound, then just display the Compound.

Francois Lauzon's picture

Hello Jun,
try adding all the shape in the loop without updating the display:
for(int i=0; i<1000; i++)
{
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(..);
Handle(AIS_Shape) hShape = new AIS_Shape(edge);
myAISContext->Display(hShape,Standard_False);
}

then update the display outside of the loop:
myAISContext->UpdateCurrentViewer();

This will speed up for sure. Using a compound like Paul said is another good option.

Good Luck,
Francois.