Slow rotation and panning with many points


when I draw an high number of points (more than 1000) my view gets very very slow when I rotate or pan. I draw the points one by one using this code:

        gp_Pnt pnt(f_p[0], f_p[1], f_p[2]);
        TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(pnt);

        // Create the AIS_Shape
        Handle(AIS_Shape) point_shape = new AIS_Shape(V1);

        // Set the vertex shape, color, and size
        Handle_Prs3d_PointAspect myPointAspect = new Prs3d_PointAspect(Aspect_TOM_POINT, m_color, 1.2);

       my_context->Display(point_shape, FALSE);

is there a way to be able to draw thousands of points without the viewer getting freezed and very slow??

Thank you very much

Hugues Delorme's picture

Hello GIUSE,

    There are two solutions I think of :

        1) Make a TopoDS_Compound containing all your vertices(have a look at BRep_Builder::MakeCompound()) and then display that shape

        2) Use AIS_PointCloud

    The second solution may take less memory


Hello Hugues,

thank you very much for your suggestion.

I have the following problem: in my application, for debug purposes, I usually need to draw a point after another; for example, in the case of a loop which represents many points, I need to display a point at a time while going line after line of code in debug phase. So the points should appear one by one and not all at once. Is thee a way to update the point cloud with a new vertex and then redisplay?

Hugues Delorme's picture

If it's just for debugging purpose, you can try to keep somewhere eg the TopoDS_Compound object and each time you have a new vertex, then add it and call AIS_Shape::SetShape()

Maybe an additional call to AIS_Shape::Redisplay(true) will be needed.

Check if that's acceptable in term of speed ?