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

Not all degenerate faces removed. #12

Open
Cervidellus opened this issue May 14, 2021 · 3 comments
Open

Not all degenerate faces removed. #12

Cervidellus opened this issue May 14, 2021 · 3 comments

Comments

@Cervidellus
Copy link

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...

@schlegelp
Copy link
Collaborator

schlegelp commented May 14, 2021

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?

@Cervidellus
Copy link
Author

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.

@schlegelp
Copy link
Collaborator

schlegelp commented May 17, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants