Let’s Talk Mesh Repair
Today I saw a post about Emendo, a program for mesh repair, and became a little miffed. It costs roughly $50, which I think is pretty steep for something you could do in a few lines of code in Python with the Blender API. Even if you’re not a programmer, there are $0 solutions like netfabb Basic and free software like MeshLab and Blender. I can’t attest to the quality of Emendo, but it has to be amazing to be worth that price.
So, let’s talk mesh repair: what is it, why it’s hard, and why I would or wouldn’t spend $50 on it.
Mesh repair is essentially fixing up a 3D model so it can satisfy 3D printing constraints. I became interested in mesh repair when I was modeling a small figurine. When designing, I cared more about aesthetics of the model than the printability of the model. I figured there would be tools to magically and automatically correct my model to be printable.
There is such a tool. It’s called netfabb.
Netfabb is a software that’s pretty good at fixing all sorts of problems. It’s also popular among 3D printing enthusiasts and is leveraged by businesses and 3D printer manufacturers (like Shapeways, Formlabs, and Figulo).
Unfortunately, my model turned out to be disastrously hard to repair. Netfabb failed, and I ended up concocting a solution out of both netfabb Basic and MeshLab after days of struggle.
Turning a model of any shape into a printable model is a hard problem. For example, suppose you have holes in your model that makes it unprintable. The mesh repair software will try to patch those holes. These holes are big gaps of missing information and the software has to guess what should go in them based on the topology of each hole’s surroundings. While some solutions can be easily guessed, other guesses can create more problems and can even conflict with one another. Here are wonderful visualizations of capping a hole in three different and valid ways, illustrating the underconstrained nature of the hole problem. Holes are just one of the many problems a 3D model could have.
There are many algorithms for mesh repair, but none of them are perfect. Here is an excellent introduction to various algorithms and the tradeoffs between them. Here is a more recent and more in-depth look at different algorithms and their features.
I use my figurine model to test the “robustness” of different mesh repair software. It may not be a fair test, since my model may be a very hard edge case, but I’m testing mostly to satisfy my curiosity. Here are some results:
netfabb Basic 4.9: failed
Netfabb flags something as unprintable with a big red caution sign. Even after repairs, the caution sign remained. Netfabb Cloud also failed. I believe the most recent version of netfabb Basic will successfully repair the model. Since netfabb is such a staple tool, I determine the success or failure of other mesh repair programs by importing the fixed models into netfabb and recording whether netfabb determines if they are printable or not.
Autodesk Meshmixer version 10.3.44: failed
Autodesk 3D Print Utility 1.1.1: succeeded
The 3D print utility actually succeeded in the mesh repair. However, it took about 3 hours for the repair to complete on my laptop, and the resulting mesh had a tremendous loss of resolution.
Photoshop CC: failed
I don’t know what version of Photoshop CC I used, but it was a 30-day trial from this past January. The repaired model still had issues, but could subsequently be repaired by netfabb. Photoshop actually emailed me asking for the figurine model, so I suspect they might’ve upgraded their algorithm.
GitHub: failed
Custom Blender Script: succeeded
Over the summer, when I was working on 3D printing glasses from 2D designs, I realized I need to repair the glasses models. I started to write a mesh repair script and decided to design it to repair the figurine. My script does indeed fix the model, but it takes about five minutes to run on the figurine model. The script produces better resolution in less time than Autodesk’s 3D Print Utility, but it’s not the fastest since I’m looping multiple times. I’ve decided to release it as a Blender Add-On, in the 3D Print Toolbox, available now in Blender 2.72b. Hope it’s helpful!
The script’s algorithm works better on simple models or models with dense polygons. If patching holes result in non-manifold geometry, the script will try to delete vertices around the holes and then patch them again. If the polygons are dense, removing a few shouldn’t affect the overall aesthetics.
It probably won’t work for all models, though.
$50 for a mesh repair software that repairs all models is absolutely worth it, for all the time invested spent in manual repairs. However, given the diversity of models and the diversity of problems (some of which could be caused by printer-dependent constraints), I doubt there’s such a silver bullet right now.
Between the Blender Add-On and netfabb, you have a pretty good chance that your model will get repaired. However, should you need to, I advocate using Blender’s Python API to build your own repair tool. It will allow you to create something catered to your specific modeling needs. It might not be as fast as pressing a button, but you’ll have unparalleled customization ability. I hear the paid upgraded versions of netfabb give you a lot of customization choices in mesh repair, but I doubt it would be as thorough as interacting with the models directly. The Blender API already provides some nice helper functions like bpy.ops.mesh.fill to fill in faces and bpy.ops.mesh.select_non_manifold to select non-manifold vertices. You could even update the Add-On and release it back to the Blender community.
Thanks for the link to your script. I am downloading now and can’t wait to give it a try. I agree with your consensus on the various repair options. I think there is no turnkey solution at this point but I’m sure it will be coming down the pike soon. I would also add that repairing models for at home printing using a desktop 3d printer is even more challenging that preparing a model for printing by shapeways or similar services. The slicing software and printers they are using are (obviously) top notch and can print models successfully that I could never print on my flashforge desktop printer. The model has to be darn near perfect for me to get a solid print. And even then there is much clean up that will need to be done to make it really look good. Also I love all your posts on Dota models- that’s actually how I found your site. Planning on doing some more reading too. 🙂
The script works better on high polygon models, but you can change it to fix your needs. Good luck on your 3D printing!
This was written some time ago. As I write, Jan, 2017.
Some other considerations:
Blender now has, built in, the 3D Print Toolbox addon which incorporates quite a few
fixes:
https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Modeling/PrintToolbox
Netfabb is now owned by Autodesk. Netfabb Basic has disappeared. If you already
have a copy, hold on to it.
Meshlab also has some render and filter functions I’ve had good luck with.
In Meshlab:
Import Mesh, If it wants to “Unify Duplicated Vertices” on load, then check “ok”.
After that, look under Render for:
Show non-manifold edges
and
Show non-manifold vertices
If there are non-manifold edges, use Filter, Cleaning and Repairing:
“Remove Faces from non-manifold edges”
thiw will almost always result in non-manifold vertices.
Fix those with Filter, Cleaning and Repairing:
“Split Vertexes incident on non-manifold Faces”
repeat until non-manifold vertices is “0”.
When non-manifold edges and vertices are both “0”
Export.
If you still have issues, something else you can try is, the Solidify Modifier (or, in Edit Mode, select All and apply using
Alt-S)
If you use the Solidify modifier, try:
Checking “Even Thickness”
Setting “Offset” to “0”
and
Applying a negative thickness. Negative (inward), Positive (outward).
Adjust to taste, apply, export, look at it again in Meshlab to ensure that it’s manifold. Adjust again, if need be,
and upload it. Good luck.
Wrote this before having seen this:
https://caretdashcaret.com/2013/08/09/how-to-fix-your-mesh-for-3d-printing-part-2/
my bad.