From 84f9b9dec6389c0f0f59099850ade04d1a4541b0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 3 May 2020 15:25:48 +0200 Subject: [PATCH] Mesh: [skip ci] allow to pass target number to Python function Mesh.decimate() --- src/Mod/Mesh/App/MeshPyImp.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Mod/Mesh/App/MeshPyImp.cpp b/src/Mod/Mesh/App/MeshPyImp.cpp index 08037f771d0a..166849c3eb38 100644 --- a/src/Mod/Mesh/App/MeshPyImp.cpp +++ b/src/Mod/Mesh/App/MeshPyImp.cpp @@ -1726,14 +1726,26 @@ PyObject* MeshPy::smooth(PyObject *args, PyObject *kwds) PyObject* MeshPy::decimate(PyObject *args) { float fTol, fRed; - if (!PyArg_ParseTuple(args, "ff", &fTol,&fRed)) - return NULL; + if (PyArg_ParseTuple(args, "ff", &fTol,&fRed)) { + PY_TRY { + getMeshObjectPtr()->decimate(fTol, fRed); + } PY_CATCH; - PY_TRY { - getMeshObjectPtr()->decimate(fTol, fRed); - } PY_CATCH; + Py_Return; + } - Py_Return; + PyErr_Clear(); + int targetSize; + if (PyArg_ParseTuple(args, "i", &targetSize)) { + PY_TRY { + getMeshObjectPtr()->decimate(targetSize); + } PY_CATCH; + + Py_Return; + } + + PyErr_SetString(PyExc_ValueError, "decimate(tolerance=float, reduction=float) or decimate(targetSize=int)"); + return nullptr; } PyObject* MeshPy::nearestFacetOnRay(PyObject *args)