Mesh: fixes #12798: Macro not recording mesh decimation
This commit is contained in:
@@ -1,86 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="GeoFeaturePy"
|
||||
Name="MeshFeaturePy"
|
||||
Twin="Feature"
|
||||
TwinPointer="Feature"
|
||||
Include="Mod/Mesh/App/MeshFeature.h"
|
||||
Namespace="Mesh"
|
||||
FatherInclude="App/GeoFeaturePy.h"
|
||||
FatherNamespace="App">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
|
||||
<UserDocu>The Mesh::Feature class handles meshes.
|
||||
<PythonExport
|
||||
Father="GeoFeaturePy"
|
||||
Name="MeshFeaturePy"
|
||||
Twin="Feature"
|
||||
TwinPointer="Feature"
|
||||
Include="Mod/Mesh/App/MeshFeature.h"
|
||||
Namespace="Mesh"
|
||||
FatherInclude="App/GeoFeaturePy.h"
|
||||
FatherNamespace="App">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
|
||||
<UserDocu>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").
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="countPoints">
|
||||
<Documentation>
|
||||
<UserDocu>Return the number of vertices of the mesh object</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="countFacets">
|
||||
<Documentation>
|
||||
<UserDocu>Return the number of facets of the mesh object</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="harmonizeNormals">
|
||||
<Documentation>
|
||||
<UserDocu>Adjust wrong oriented facets</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="smooth">
|
||||
<Documentation>
|
||||
<UserDocu>Smooth the mesh data</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeNonManifolds">
|
||||
<Documentation>
|
||||
<UserDocu>Remove non-manifolds</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeNonManifoldPoints">
|
||||
<Documentation>
|
||||
<UserDocu>Remove non-manifold points</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixIndices">
|
||||
<Documentation>
|
||||
<UserDocu>Repair any invalid indices</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixDegenerations">
|
||||
<Documentation>
|
||||
<UserDocu>Remove degenerated facets</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeDuplicatedFacets">
|
||||
<Documentation>
|
||||
<UserDocu>Remove duplicated facets</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeDuplicatedPoints">
|
||||
<Documentation>
|
||||
<UserDocu>Remove duplicated points</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixSelfIntersections">
|
||||
<Documentation>
|
||||
<UserDocu>Repair self-intersections</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeFoldsOnSurface">
|
||||
<Documentation>
|
||||
<UserDocu>Remove folds on surfaces</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeInvalidPoints">
|
||||
<Documentation>
|
||||
<UserDocu>Remove points with invalid coordinates (NaN)</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="countPoints">
|
||||
<Documentation>
|
||||
<UserDocu>Return the number of vertices of the mesh object</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="countFacets">
|
||||
<Documentation>
|
||||
<UserDocu>Return the number of facets of the mesh object</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="harmonizeNormals">
|
||||
<Documentation>
|
||||
<UserDocu>Adjust wrong oriented facets</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="smooth">
|
||||
<Documentation>
|
||||
<UserDocu>Smooth the mesh data</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="decimate">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
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)
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeNonManifolds">
|
||||
<Documentation>
|
||||
<UserDocu>Remove non-manifolds</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeNonManifoldPoints">
|
||||
<Documentation>
|
||||
<UserDocu>Remove non-manifold points</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixIndices">
|
||||
<Documentation>
|
||||
<UserDocu>Repair any invalid indices</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixDegenerations">
|
||||
<Documentation>
|
||||
<UserDocu>Remove degenerated facets</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeDuplicatedFacets">
|
||||
<Documentation>
|
||||
<UserDocu>Remove duplicated facets</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeDuplicatedPoints">
|
||||
<Documentation>
|
||||
<UserDocu>Remove duplicated points</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixSelfIntersections">
|
||||
<Documentation>
|
||||
<UserDocu>Repair self-intersections</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeFoldsOnSurface">
|
||||
<Documentation>
|
||||
<UserDocu>Remove folds on surfaces</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeInvalidPoints">
|
||||
<Documentation>
|
||||
<UserDocu>Remove points with invalid coordinates (NaN)</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -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, "")) {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
#include <Mod/Mesh/App/MeshFeature.h>
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user