A Problem About Dynamic Add points into an Array

Hello~I'm a beginner of Opencascade.

These days I have a problem about drawing curves in 3D space.  

For example, if I want to draw a line with 50 points,  TColgp_Array1OfPnt A(1 , 50) can be used.

Then with a loop,

for(int i = 0; i < 50; i++)


           A.SetValue(i , gp_Pnt());


Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(A,1,1);

That's the situation that I know how many points there.

But if I want to add points to array dynamically, for TColgp_Array1OfPnt A(1 , X), it means that I am not sure about how much X is.

How can I solve this problem?

Do you have any good idea? Thanks a lot! Hope you all have a nice day!



dphil's picture

Instances of NCollection_Array1 (such as TColgp_Array1OfPnt) according to the documentation can not change size and must be instantiated with a known size at runtime. Off-hand I am not sure if OCCT provides a dynamic array. My suggestion would be to either wait until you do know what size you need (if possible) before creating the array, or just use a dynamic array structure like std::vector, incrementally add to that, and then create a TColgp_Array1OfPnt from its contents when you have all the points you need.

Kevin Chuang's picture


Thanks for your reply.  As your suggestion, I'm  trying to use vector to solve the problem! Hope it will work~  

qa qa's picture


OCCT provides dynamic collection. It is called "NCollection_Vector".

qa qa