3D printable models in openFrameworks

Hi,

I just spent an embarrassing amount of time getting an algorithm for creating a 3D model with holes that can be printed to work so I wrote a blog post about how you can do it:

https://eriknatanael.com/blog/3d-printable-models-with-openframeworks

TL;DR: Use Subdiv2D from OpenCV to triangulate, be careful to avoid triangles that are too skinny, keep track of your vertices and your normals. Blender is your friend for mesh inspection.

Code is here: https://github.com/ErikNatanael/re-quest-sonic/blob/master/src/ModelExport.h

Hope this helps someone else!

4 Likes

Wow! I’ve been always interested if some CNC operations could be done with OF, whether it be 3d print, CNC routing or any G-code stuff. OF could be really helpful as a framework to construct such app, considering some GUI could be applied as well to provide automatic functionality.
It uses OpenCV you say, but not everyone has a webcam of kinect or a way to record such a thing via camera - is it reliable to use OpenCV to calculate such a path that needs precision? Or does it render G-code for a CNC app to follow it?

Sounds like a great idea!

I guess I kind of skipped over how to actually go from a finished ofMesh to a 3D print. ofMesh has this really neat .save() method that can be used to save a .ply file with the mesh. You can then open the .ply file in Cura or convert it to an stl or whatever you want in Blender. So I’m not calculating any G-code at all, just generating a mesh that will let a slicer produce working G-code for the model.

OpenCV is only used for the Delaunay triangulation algorithm. You could implement it yourself or find a different implementation, but going between OF and OpenCV is really easy thanks to the ofxCv addon (although take care of the pitfalls I mention in the post). As for precision you can just scale all the values up to your required resolution (because integers) and then scale the mesh back down (using floating point numbers).