# How to render BSpline surface using gluNurbs?

Searching the forum did not reveal any result.
For now I just do it by the following code:
uorder = hBSpline->UDegree() + 1;
vorder = hBSpline->VDegree() + 1;
uknot_count = hBSpline->NbUKnots();
vknot_count = hBSpline->NbVKnots();
uknots = new float[uknot_count];
vknots = new float[vknot_count];
//knots in both directions
TColStd_Array1OfReal Ku(hBSpline->FirstUKnotIndex(), hBSpline->LastUKnotIndex());
TColStd_Array1OfReal Kv(hBSpline->FirstVKnotIndex(), hBSpline->LastVKnotIndex());
hBSpline->UKnotSequence(Ku);
hBSpline->VKnotSequence(Kv);

int index = 0;
//fill the knots array in u direction
for(int UKnotIndex = hBSpline->FirstUKnotIndex(); UKnotIndex LastUKnotIndex();++UKnotIndex)
{
uknots[index] = Ku.Value(UKnotIndex);
index++;
}
//fill the knots array in v direction
index = 0;
for(int VKnotIndex = hBSpline->FirstVKnotIndex(); VKnotIndex LastVKnotIndex(); ++VKnotIndex)
{
vknots[index] = Kv.Value(VKnotIndex);
index++;
}

const int nupoles = hBSpline->NbUPoles();
const int nvpoles = hBSpline->NbVPoles();

//array of control points
controlPoints = new float[nupoles * nvpoles * 3];
index = 0;
for(unsigned int i = 1; i {
for(unsigned int j = 1; j {
const gp_Pnt point = hBSpline->Pole(i,j);
controlPoints[index] = point.X();
controlPoints[index + 1] = point.Y();
controlPoints[index + 2] = point.Z();
index += 3;
}
}

ustride = nvpoles * 3;
vstride = 3;

And then render the resulting BSpline:
gluBeginSurface(nurbs);
gluNurbsSurface(nurbs, uknot_count, uknots, vknot_count, vknots, ustride, vstride, controlPoints, uorder, vorder, GL_MAP2_VERTEX_3);
gluEndSurface(nurbs);

But there seems to be very strange problems. In the best case only a part of the whole BSpline is rendered. In the worst case - no visible result at all. Sometimes it seems just like a "+-1 problem".

Please tell me maybe there is already a solution that I missed? Do you get the knots correct ? OCC stores knots in a bit odd way, it stores the knot values as single values and then has a multiplicity value attached, are you sure you get all knot values including multiplicity knots ?

Mikael Thank you. It really was a multiplicity problem.