
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
when I was creating Nurbs Curves from the Alias API I came across a wrong function signature:
statusCode AlCurve::create( int deg, curveFormType form, int numKnots, const double knotVector[], int numControlPts, const double controlPoint[][4], const int multiplicity[])
The problem here is the signature for the controlPoints, it is defined as as two dimensional double array. But when you create the array in a C++ correct way:
double **alControlPoints = (new double*[numControlPts]);
for (int i = 0; i < numControlPts; i++)
{
alControlPoints[i] = new double[4];
alControlPoints[i][0] = controlPoints[i][0];
alControlPoints[i][1] = controlPoints[i][1];
alControlPoints[i][2] = controlPoints[i][2];
alControlPoints[i][3] = controlPoints[i][3];
}
And then pass alControlPoints the the create function, the function will not succeed but return a wrong argument error.
The actual correct way to create the control points buffer is:
double *alControlPoints = (new double[numControlPts * 4]);
unsigned long long vertexIndex = 0;
for (int i = 0; i < numControlPts; i++)
{
alControlPoints[vertexIndex++] = controlPoints[i][0];
alControlPoints[vertexIndex++] = controlPoints[i][1];
alControlPoints[vertexIndex++] = controlPoints[i][2];
alControlPoints[vertexIndex++] = controlPoints[i][3];
}
When you pass this to the create function, then it will work, but you need to make an ugly cast:
(double(*)[4]) alControlPoints
Therefore the signature for the create function should be
double controlPoints[]
If you compare it with the create function for the AlSurface, it already uses the correct signature.
Best regards,
Timo
Solved! Go to Solution.