Mesh Decimation python script

Need help, or want to share a macro? Post here!
Post Reply
pi-a
Posts: 2
Joined: Thu Apr 22, 2021 12:35 pm

Mesh Decimation python script

Post by pi-a »

Hi,

because I am a beginner in using FreeCAD, I wasn't able to find any script that does the "Mesh Decimating" with a given number of faces.
(Also, I don't know if it's ok to ask my separate, yet to some extent related, questions all in one post?)

Short version:
- I want to write a script that applies the mesh decimation on the resulting mesh, with a fixed number of faces.
- what is the best way to guarantee a manifold mesh, watertight, as a result of the solver.

Long version (for context):
I would like to apply a force on a mesh, and apply another force on the resulting mesh. To do so, after the first time that solver is done I create a mesh from femmesh, and then use that as the mesh, i.e. I go again through the steps of creating a shape from mesh and ...
But the resulting mesh after each time increases in size (the number of faces), and the more dense the mesh the slower is the process of "FEM Mesh from shape", and also the solver.
So, I thought why not use mesh decimation on the resulting mesh of the solver. But I couldn't find a script for that, only a button (my first question).
Now, when I do a mesh decimation using a different library, e.g. open3d, and create a shape from that and follow the steps for defining force to deform it, in most cases the "volume mesh (Netgen)" has issues and doesn't have a volume. So, I used the other methods in open3d such as "remove_degenerate_triangles" or "remove_non_manifold_edges", but it didn't help. And once I import the decimated mesh from open3d and run the "evaluate and repair mesh" on them in FreeCAD I see there are folds on surface, and if I repair it, it no longer is a watertight mesh.
What is the best way to first reduce the size of the resulting mesh after creating a Mesh from FEM Mesh, and then do a mesh refinement and repair on this new and smaller (less dense) mesh.

Sorry in advance if it is long and maybe too wordy. Please let me know if anything is not clear.
Thank you for your help.
Post Reply