MCPcopy Create free account
hub / github.com/SimVascular/SimVascular / Math_curve_length

Function Math_curve_length

Code/Source/PythonAPI/Math_PyModule.cxx:372–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370");
371
372static PyObject *
373Math_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

Callers

nothing calls this directly

Calls 5

GetPointsFromListFunction · 0.85
argsErrorMethod · 0.80
errorMethod · 0.80
curveLengthMethod · 0.45
deleteArrayMethod · 0.45

Tested by

no test coverage detected