| 370 | "); |
| 371 | |
| 372 | static PyObject * |
| 373 | Math_curve_length(PyObject *self, PyObject *args, PyObject* kwargs) |
| 374 | { |
| 375 | std::cout << "========== Math_curve_length ==========" << std::endl; |
| 376 | auto api = PyUtilApiFunction("O!|O!", PyRunTimeErr, __func__); |
| 377 | static char *keywords[] = {"points", "closed", NULL}; |
| 378 | PyObject *pointsArg; |
| 379 | PyObject *closedArg = nullptr; |
| 380 | |
| 381 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, api.format, keywords, &PyList_Type, &pointsArg, &PyBool_Type, &closedArg)) { |
| 382 | return api.argsError(); |
| 383 | } |
| 384 | |
| 385 | // Set closed parameter. |
| 386 | int closed = 0; |
| 387 | if ((closedArg != nullptr) && PyObject_IsTrue(closedArg)) { |
| 388 | closed = 1; |
| 389 | } |
| 390 | |
| 391 | // Get an array of points from the pointsArgs list. |
| 392 | int dim = 3; |
| 393 | auto pts = GetPointsFromList(api, pointsArg, dim, "points"); |
| 394 | if (pts == nullptr) { |
| 395 | return nullptr; |
| 396 | } |
| 397 | int nlistpts = PyList_Size(pointsArg); |
| 398 | |
| 399 | // Calculate the curve length. |
| 400 | // |
| 401 | auto mathObj = cvMath(); |
| 402 | double length = 0; |
| 403 | if (mathObj.curveLength(pts, nlistpts, closed, &length) == SV_ERROR) { |
| 404 | mathObj.deleteArray(pts,nlistpts,dim); |
| 405 | api.error("Error calculating the curve length."); |
| 406 | return nullptr; |
| 407 | } |
| 408 | |
| 409 | mathObj.deleteArray(pts,nlistpts,dim); |
| 410 | |
| 411 | return Py_BuildValue("d",length); |
| 412 | } |
| 413 | |
| 414 | //--------------------------------- |
| 415 | // Math_linear_interpolate_curve |
nothing calls this directly
no test coverage detected