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

Function Math_smooth_curve

Code/Source/PythonAPI/Math_PyModule.cxx:565–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

563");
564
565static PyObject *
566Math_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////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected