| 563 | "); |
| 564 | |
| 565 | static PyObject * |
| 566 | Math_smooth_curve(PyObject *self, PyObject *args) |
| 567 | { |
| 568 | auto api = PyUtilApiFunction("Oiii", PyRunTimeErr, __func__); |
| 569 | int numInterpPoints = 0; |
| 570 | int closed = 0; |
| 571 | int numModes = 0; |
| 572 | |
| 573 | PyObject *pointsArg; |
| 574 | if (!PyArg_ParseTuple(args, api.format, &pointsArg, &closed, &numModes, &numInterpPoints)) { |
| 575 | return api.argsError(); |
| 576 | } |
| 577 | |
| 578 | // Get an array of points from the pointsArgs list. |
| 579 | int dim = 3; |
| 580 | auto pts = GetPointsFromList(api, pointsArg, dim, "points"); |
| 581 | if (pts == nullptr) { |
| 582 | return nullptr; |
| 583 | } |
| 584 | int nlistpts = PyList_Size(pointsArg); |
| 585 | |
| 586 | // Smooth the curve. |
| 587 | // |
| 588 | auto mathObj = cvMath(); |
| 589 | double **outPts = NULL; |
| 590 | if (mathObj.smoothCurve(pts, nlistpts, closed, numModes, numInterpPoints, &outPts) == SV_ERROR) { |
| 591 | mathObj.deleteArray(pts,nlistpts,dim); |
| 592 | api.error("Error soothing the curve."); |
| 593 | return nullptr; |
| 594 | } |
| 595 | |
| 596 | // create result string |
| 597 | char r[2048]; |
| 598 | PyObject *pylist=PyList_New(numInterpPoints); |
| 599 | for (int i = 0; i < numInterpPoints; i++) { |
| 600 | r[0] = '\0'; |
| 601 | sprintf(r,"%.6le %.6le %.6le",outPts[i][0],outPts[i][1],outPts[i][2]); |
| 602 | PyObject *rr=PyBytes_FromString(r); |
| 603 | PyList_SET_ITEM(pylist, i, rr); |
| 604 | } |
| 605 | |
| 606 | mathObj.deleteArray(pts,nlistpts,dim); |
| 607 | mathObj.deleteArray(outPts,numInterpPoints,dim); |
| 608 | |
| 609 | return pylist; |
| 610 | } |
| 611 | |
| 612 | |
| 613 | //////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected