| 914 | "); |
| 915 | |
| 916 | static PyObject * |
| 917 | Path_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 // |
nothing calls this directly
no test coverage detected