I noticed that the clean function in the Surface Toolbox does not handle duplicate edges ie 0 area faces.
Therefore it does not completely fix non manifold meshes.
Here you can see a mesh that I cleaned with the surface toolbox and checked in Blender. The highlighted edges are duplicated:
Would there be a way of adding a fix for this?
Previously I have done a lot of semiautomatic mesh cleaning for FE meshes and 3D printing in Blender but would like to migrate everything to Slicer.
Also, I noticed a possible typo in the logic, should line 575 in SurfaceToolbox.py be
If you change to developer mode you can use the edit and reload options to change the settings and see what works. If you find settings that should be exposed they can be added to the module’s gui.
No, I think the code is correct. The code above what you referenced creates a new polydata if needed and the successive steps in the toolbox operate on that outputModel.
However, this does not fix the non manifold issues, since it only covers some, not all, mesh issues.
Would it be possible to incorporate the mesh cleaning functionality from the 3D print add-on in Blender? It is written in Python and would enhance the Surface Toolbox cleaning function.
Here is the mesh that was giving me issues. I generated it by upsampling and remeshing and smoothing, all in Slicer. However, the non manifoldness remains (6 vertices, 2 edges, 2 faces): O45_003_SlicerClean_updatedNormals.stl - Google Drive
There are other mesh cleanup options in vtk (see links below - I’m sure there are more if you search). They would be easy to add to the Surface Toolbox or as a separate module if there are lots of options.
But if the blender code works well you should also be able wrap and call a blender-python script as a subprocess. I looked a the code you linked and yes it’s in python, but it relies on the blender libraries to do the work. There is a bpy package, but it didn’t install for me in slicer.
Maybe it’s possible to compile blender and bpy expose its python libraries in slicer’s python, and that could open interesting possibilities, but it would be easier as a start to just run blender in a separate process with its own python and pass meshes as files.