I was recently revisiting our igl::writeOBJ
code and realized that for simple meshes, the code for writing an .obj file can be really simple:
ofstream("test.obj")<<
V.format(IOFormat(FullPrecision,0," ","\n","v ","","","\n"))<<
(F.array()+1).format(IOFormat(FullPrecision,0," ","\n","f ","","","\n"));
Update: And because why not, here's a .off writer:
ofstream("test.off")<<
"OFF\n"<<V.rows()<<" "<<F.rows()<<" 0\n"<<
V.format(IOFormat(FullPrecision,0," ","\n","","","","\n"))<<
(F.array()).format(IOFormat(FullPrecision,0," ","\n","3 ","","","\n"));