skeletor icon indicating copy to clipboard operation
skeletor copied to clipboard

Not all degenerate faces removed.

Open Cervidellus opened this issue 3 years ago • 3 comments

Skeletor is relying on Trimesh 's "remove_degenerate_faces()" to deal with degenerate faces, which will only remove faces composed of two vertices, as I understand it. Our neuron meshes are generated with a rather unfortunately large number of t-vertices (3 vertices in a line with a zero area face associated with them). Possible solutions would be to switch to Blender's degenerate dissolve to deal with them, which I believe works pretty well. Meshlab's function for removing them via edge collapse also seems to work for me and is what I have been using. An additional solution may be to roll our own by finding the ones with zero or negligible area (trimesh.base.area_faces or maybe trimesh.base.face_angles ) and then dealing with them by collapsing the edge associated with the middle point? Or by deleting the middle point and then using trimesh.repair.fill_holes(mesh) to put the face back? This would save having to do a type conversion to blender or meshlab and back...

Cervidellus avatar May 14 '21 21:05 Cervidellus

Yeah, skeletor.fix_mesh() is not a magic bullet unfortunately. I'm a fan of tools doing one thing, and doing that well. skeletor already does a bit more than just skeletonising but I'm reluctant to go down the rabbit hole of mesh fixing. As you point out, there are other specialised tools and software that do that job, and to my mind it's the user's job to make sure the meshes are good enough for skeletonisation. I'm not totally opposed to adding more easy mesh fixes though. At this point I would consider (and encourage contributions for):

  • a tutorial on fixing meshes for skeletonization either for the docs or the Wiki, maybe some sort of cookbook?
  • (potentially) some sort of quality control inside skeletor that flags such issues rather than fixing them

trimesh's remove_degenerate_faces has a height parameter that, if I understand it correctly, should also catch 0 area faces. Have you tried playing around with that? If that doesn't cut it and you find another way to leverage trimesh to do what you need, you could also consider contributing to trimesh itself?

Out of curiosity: have you tried playing around with the different skeletonization methods to see if any is robust against the errors in your meshes?

schlegelp avatar May 14 '21 23:05 schlegelp

I hadn't noticed the height parameter, I'm going to play around with it and see how it works. I have played with CGAL's skeletonization https://doc.cgal.org/latest/Surface_mesh_skeletonization/index.html, which gives you some good parameters to play with for optimizing, but I have to move back and forth between python and C++(at least in the short term..). Default settings do a decent job for my needs, but I'd like to see if I could do a better job at spines.. I haven't yet compared it to Skeletor's skeletonization options, as I am still working on getting a nice workflow that reliably gives me good clean watertight meshes without my intervention. The two biggest problems are these t-vertices, and larger holes (which trimesh as far as I know cannot close.). Meshlab does great and fixing those things and more (e.g. ambient occlusion for removing internal geometries, nice control over decimation), but the python interface currently has some bugs, so that would for the short term have to be implemented in C++(they are doing a great job at making better...) As I mentioned, Blender does well but it is not as fast as meshlab and I find the GUI-first API annoying. I don't know if you have played with CGAL, but if you are interested I can get back to you once I compare them on our meshes.

Cervidellus avatar May 14 '21 23:05 Cervidellus

Yeah, let me know what you find. If you are happy sharing one of your meshes, I could have a crack and see how far I get with them. Curious to see if I can make the skeletonizations more robust against errors in meshes.

schlegelp avatar May 17 '21 08:05 schlegelp