Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python sample for degenerations resolving #3666

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/python-examples/MeshModification.dox.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import meshlib.mrmeshpy as mrmeshpy

mesh = mrmeshpy.loadMesh("mesh.stl")
mesh = mrmeshpy.makeTorus()

relax_params = mrmeshpy.MeshRelaxParams()
relax_params.iterations = 5
Expand Down
18 changes: 18 additions & 0 deletions examples/python-examples/ResolvingMeshDegeneration.dox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import meshlib.mrmeshpy as mrmeshpy

mesh = mrmeshpy.loadMesh("mesh.ctm")

# You can set various parameters for the resolving process; see the documentation for more info
params = mrmeshpy.ResolveMeshDegenSettings()
# maximum permitted deviation
params.maxDeviation = 1e-5 * mesh.computeBoundingBox().diagonal()
# maximum length of edges to be collapsed
params.tinyEdgeLength = 1e-3

is_changed = mrmeshpy.resolveMeshDegenerations(mesh, params)

if is_changed:
print("Mesh was changed, saving")
mrmeshpy.saveMesh(mesh, "mesh_fixed.ctm")
else:
print("Mesh was not changed")
6 changes: 5 additions & 1 deletion test_regression/test_doc_samples/test_doc_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
'output_meshes': ['meshA_icp.stl']}, id="MeshICP.dox.py"),
pytest.param({'sample': "MeshLoadSave.dox.py", 'input_meshes': ['mesh.stl'],
'output_meshes': ['mesh.ply']}, id="MeshLoadSave.dox.py"),
pytest.param({'sample': "MeshModification.dox.py", 'input_meshes': ['mesh.stl'],
pytest.param({'sample': "MeshModification.dox.py", 'input_meshes': [],
'output_meshes': []}, id="MeshModification.dox.py"),
pytest.param({'sample': "MeshOffset.dox.py", 'input_meshes': ['mesh.stl'],
'output_meshes': ['offsetMesh.stl']}, id="MeshOffset.dox.py"),
Expand All @@ -43,6 +43,10 @@
'output_meshes': ['noised_mesh.stl', 'denoised_mesh.stl']},
id="NoiseDenoiseExample.dox.py",
marks=pytest.mark.bindingsV3),
pytest.param({'sample': "ResolvingMeshDegeneration.dox.py", 'input_meshes': ['mesh.ctm'],
'output_meshes': ['mesh_fixed.ctm']},
id="ResolvingMeshDegeneration.dox.py",
marks=pytest.mark.bindingsV3),
pytest.param({'sample': "Numpy.dox.py", 'input_meshes': [], 'output_meshes': []},
id="Numpy.dox.py"),
pytest.param(
Expand Down
Loading