# BSpline

Hello

I have a problem with constructions of bspline curves. Here is my code to design a bspline curve. This code rans very well and I can display it, but the bspline curve passes throught all of the control points (poles).Is this wrong or not?

The answer of my second question is probably basic, but I don't know how many knots and multiplicities I need and how can I define it?

Thanks you very mauch vor your help.

/*Geom_BSplineCurve(const TColgp_Array1OfPnt& Poles,

const TColStd_Array1OfReal& Knots,

const TColStd_Array1OfInteger& Multiplicities,

const Standard_Integer Degree,

const Standard_Boolean Periodic = Standard_False);*/

gp_Pnt P1(0,1,0);

gp_Pnt P2(0.143379,1,0);

gp_Pnt P3(0.42981100,0.902348,0);

gp_Pnt P4(0.756611,0.545098,0.0);

gp_Pnt P5(0.933343, 0.145041,0);

gp_Pnt P6(0.97806,0,0);

gp_Pnt P7(1,0,0);

TColgp_Array1OfPnt array1 (1,7);

array1.SetValue(1,P1);

array1.SetValue(2,P2);

array1.SetValue(3,P3);

array1.SetValue(4,P4);

array1.SetValue(5,P5);

array1.SetValue(6,P6);

array1.SetValue(7,P7);

///////////////////////////////////////////////////////////////////////////////////

Standard_Real R1 = 2; //Knots

//////////////////////////////////////////////////////////////////////////////////

Standard_Integer I1 = 2; //Multiplicities

const Standard_Integer Degree = 3;

const Standard_Boolean Periodic = Standard_False;

Handle (Geom_BSplineCurve) bsc1 = GeomAPI_PointsToBSpline(array1).Curve();

TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(bsc1);

Handle(AIS_Shape) Edge1 = new AIS_Shape (E1);

myAISContext->Display(Edge1); Hi !

(Correct me if I am wrong here)

The PointsToBSpline method creates a spline curve that will pass through all the control points.

If you create a spline curve manually you will get the correct result.

The size of the knot vector is number of control points + degree + 1.

If you want the ends of the curve to pass through the first and last control point (normally what you want) then the first and last knot should have multiplicty set to same as degree.

Example: Spline curve with 5 control points and degree 3.

Knot vector size should be 5+3+1=9 (but with multiplicities on first and last we get 5 knots.

So knot vector should be something like: 0 1 2 3 4 And multiplicty vector should be 3 1 1 1 3

Then you should have a spline curve.

Remeber the important rules: Knot vector size is number of control points + degree + 1. First and last knot multiplicity same as degree.

I hope that helps a bit.

Mikael Hello Mikael,

If you create your BSpline manually then how do you convert it to a handle in order to create the edge?

Regards.

Jose Rojas Never mind. I just got the answer.