Generating Mesh Quads. It should be only a few more lines of code to also handle triangles. Faces seam to be generated correctly.