diff --git a/src/Mod/Mesh/App/MeshFeaturePy.xml b/src/Mod/Mesh/App/MeshFeaturePy.xml
index c90a1855d4..6a6292e202 100644
--- a/src/Mod/Mesh/App/MeshFeaturePy.xml
+++ b/src/Mod/Mesh/App/MeshFeaturePy.xml
@@ -1,86 +1,104 @@
-
-
-
- The Mesh::Feature class handles meshes.
+
+
+
+ The Mesh::Feature class handles meshes.
The Mesh.MeshFeature() function is for internal use only and cannot be used to create instances of this class.
Therefore you must have a reference to a document, e.g. 'd' then you can create an instance with
d.addObject("Mesh::Feature").
-
-
-
-
- Return the number of vertices of the mesh object
-
-
-
-
- Return the number of facets of the mesh object
-
-
-
-
- Adjust wrong oriented facets
-
-
-
-
- Smooth the mesh data
-
-
-
-
- Remove non-manifolds
-
-
-
-
- Remove non-manifold points
-
-
-
-
- Repair any invalid indices
-
-
-
-
- Remove degenerated facets
-
-
-
-
- Remove duplicated facets
-
-
-
-
- Remove duplicated points
-
-
-
-
- Repair self-intersections
-
-
-
-
- Remove folds on surfaces
-
-
-
-
- Remove points with invalid coordinates (NaN)
-
-
-
+
+
+
+
+ Return the number of vertices of the mesh object
+
+
+
+
+ Return the number of facets of the mesh object
+
+
+
+
+ Adjust wrong oriented facets
+
+
+
+
+ Smooth the mesh data
+
+
+
+
+
+ Decimate the mesh
+ decimate(tolerance(Float), reduction(Float))
+ tolerance: maximum error
+ reduction: reduction factor must be in the range [0.0,1.0]
+ Example:
+ mesh.decimate(0.5, 0.1) # reduction by up to 10 percent
+ mesh.decimate(0.5, 0.9) # reduction by up to 90 percent
+
+ or
+
+ decimate(targwt size(int))
+ mesh.decimate(mesh.CountFacets/2)
+
+
+
+
+
+ Remove non-manifolds
+
+
+
+
+ Remove non-manifold points
+
+
+
+
+ Repair any invalid indices
+
+
+
+
+ Remove degenerated facets
+
+
+
+
+ Remove duplicated facets
+
+
+
+
+ Remove duplicated points
+
+
+
+
+ Repair self-intersections
+
+
+
+
+ Remove folds on surfaces
+
+
+
+
+ Remove points with invalid coordinates (NaN)
+
+
+
diff --git a/src/Mod/Mesh/App/MeshFeaturePyImp.cpp b/src/Mod/Mesh/App/MeshFeaturePyImp.cpp
index 8f02291db2..aaaf58aff0 100644
--- a/src/Mod/Mesh/App/MeshFeaturePyImp.cpp
+++ b/src/Mod/Mesh/App/MeshFeaturePyImp.cpp
@@ -90,6 +90,43 @@ PyObject* MeshFeaturePy::smooth(PyObject* args)
Py_Return;
}
+PyObject* MeshFeaturePy::decimate(PyObject* args)
+{
+ float fTol {};
+ float fRed {};
+ if (PyArg_ParseTuple(args, "ff", &fTol, &fRed)) {
+ PY_TRY
+ {
+ Mesh::Feature* obj = getFeaturePtr();
+ MeshObject* kernel = obj->Mesh.startEditing();
+ kernel->decimate(fTol, fRed);
+ obj->Mesh.finishEditing();
+ }
+ PY_CATCH;
+
+ Py_Return;
+ }
+
+ PyErr_Clear();
+ int targetSize {};
+ if (PyArg_ParseTuple(args, "i", &targetSize)) {
+ PY_TRY
+ {
+ Mesh::Feature* obj = getFeaturePtr();
+ MeshObject* kernel = obj->Mesh.startEditing();
+ kernel->decimate(targetSize);
+ obj->Mesh.finishEditing();
+ }
+ PY_CATCH;
+
+ Py_Return;
+ }
+
+ PyErr_SetString(PyExc_ValueError,
+ "decimate(tolerance=float, reduction=float) or decimate(targetSize=int)");
+ return nullptr;
+}
+
PyObject* MeshFeaturePy::removeNonManifolds(PyObject* args)
{
if (!PyArg_ParseTuple(args, "")) {
diff --git a/src/Mod/Mesh/Gui/DlgDecimating.cpp b/src/Mod/Mesh/Gui/DlgDecimating.cpp
index ce1178500f..8d29e6d777 100644
--- a/src/Mod/Mesh/Gui/DlgDecimating.cpp
+++ b/src/Mod/Mesh/Gui/DlgDecimating.cpp
@@ -22,7 +22,7 @@
#include "PreCompiled.h"
-#include
+#include
#include
#include
#include
@@ -166,14 +166,12 @@ bool TaskDecimating::accept()
targetSize = widget->targetNumberOfTriangles();
}
for (auto mesh : meshes) {
- Mesh::MeshObject* mm = mesh->Mesh.startEditing();
if (absolute) {
- mm->decimate(targetSize);
+ Gui::cmdAppObjectArgs(mesh, "decimate(%i)", targetSize);
}
else {
- mm->decimate(tolerance, reduction);
+ Gui::cmdAppObjectArgs(mesh, "decimate(%f, %f)", tolerance, reduction);
}
- mesh->Mesh.finishEditing();
}
Gui::Command::commitCommand();