Connect points with a spline curve

Hello everyone. I would like to ask you a question to see if someone is able to answer me.

Let's suppose that I have 4 points whose coordinates could be the following:

    gp_Pnt P1(-1,5,0);
    gp_Pnt P2(10,10,0);
    gp_Pnt P3(8,-10,0);
    gp_Pnt P4(-4,0,0);

What I need is to obtain a TopoDS_wire so that the mentioned points are part of the spline and, in addition, it is a closed spline.

I have tried with methods such as BezierSpline and the interpolate function but both generate closed curves in which the points P1, P2, P3 and P4 are not part of.

Thanks

Dmitrii Pasukhin's picture

Hello, in OCCT create TopoDS_Vertex for each knot of spline is not possible.

TopoDS_Vertex is a start and end of edge.

I think, BRepBuilderAPI_MakePolygon can help you. You be able to create from 3,4 points via constructor and then usd Add to insert new point.

Best regards,  Dmitrii.

alefdezsuarez's picture

Yes, as you say with the polygon option I could do it. But the goal was to do it with a spline between the points.
Similar to what you can do with SolidWorks or other programs where you can define the position of the points and make a spline pass through them.

Thank you so much

Dmitrii Pasukhin's picture

What about my next message about GeomAPI_PointsToBSpline? It can help you? I need more information about final result.

GeomAPI_PointsToBSpline help with the next scenarion:

Curve by GeomAPI_PointsToBSpline -> TopoDS_Edge by BRepBuilderAPI_MakeEdge -> TopoDS_Wire by BRepBuilderAPI_MakeWire. In this case you will have 1-2 TopoDS_Vertex.

Best regards, Dmitrii.

Dmitrii Pasukhin's picture

If you would like to create just a Edge and then Wire from this Edge(you will have only 2 or 1 TopoDS_Vertex in this case). So, for creating BSpline you can use GeomAPI_PointsToBSpline.

Best regards, Dmitrii

Mikhail Sazonov's picture

I propose to use the class GeomAPI_Interpolate. The draw command to create the curve with your points:

tanginterpol c p 4 -1 5 0 10 10 0 8 -10 0 -4 0 0

The result is on the picture.

Attachments: