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

Function Path_smooth

Code/Source/PythonAPI/PathPlanningPath_PyClass.cxx:916–963  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

914");
915
916static PyObject *
917Path_smooth(PyPath* self, PyObject* args, PyObject* kwargs)
918{
919 auto api = PyUtilApiFunction("ii|O!", PyRunTimeErr, __func__);
920 static char *keywords[] = {"sample_rate", "num_modes", "smooth_control_pts", NULL};
921 int sampleRate, numModes;
922 PyObject *smoothControlPtsArg = nullptr;
923
924 if (!PyArg_ParseTupleAndKeywords(args, kwargs, api.format, keywords, &sampleRate, &numModes, &PyBool_Type, &smoothControlPtsArg)) {
925 return api.argsError();
926 }
927
928 auto path = GetPathElement(api, self);
929 if (path == NULL) {
930 return nullptr;
931 }
932
933 int numPts = path->GetControlPoints().size();
934 if (numPts == 0) {
935 api.error("The path does not have control points defined for it.");
936 return nullptr;
937 }
938
939 // Set controlPointsBased parameter.
940 bool controlPointsBased = false;
941 if ((smoothControlPtsArg != nullptr) && PyObject_IsTrue(smoothControlPtsArg)) {
942 controlPointsBased = true;
943 }
944
945 if (sampleRate < 1) {
946 api.error("The 'sample_rate' argument must be > 0.");
947 return nullptr;
948 }
949
950 if (numModes < 1) {
951 api.error("The 'num_modes' argument must be > 0.");
952 return nullptr;
953 }
954
955 auto newPath = path->CreateSmoothedPathElement(sampleRate, numModes, controlPointsBased);
956
957 if (newPath == nullptr) {
958 api.error("Unable to smooth the path.");
959 return nullptr;
960 }
961
962 return CreatePyPath(newPath);
963}
964
965////////////////////////////////////////////////////////
966// C l a s s D e f i n i t i o n //

Callers

nothing calls this directly

Calls 7

GetPathElementFunction · 0.85
CreatePyPathFunction · 0.85
argsErrorMethod · 0.80
sizeMethod · 0.80
errorMethod · 0.80
GetControlPointsMethod · 0.45

Tested by

no test coverage detected