@classmethod
def export_obj(cls, mesh, filename):
    """
        Write a mesh instance to a Wavefront OBJ (.obj) mesh file.

        :param Mesh mesh: The Raysect mesh instance to write to OBJ.
        :param str filename: Mesh file path.

        .. code-block:: pycon

            >>> bunny_mesh
            <raysect.primitive.mesh.mesh.Mesh at 0x7f2c09eac2e8>
            >>> from raysect.primitive import export_obj
            >>> export_obj(bunny_mesh, 'my_mesh.obj')        
        """
    with open(filename, 'w') as f:
        if mesh.name:
            f.write('# Generated by Raysect\n# Mesh name: {}\n'.format(mesh
                .name))
        else:
            f.write('# Exported Raysect Mesh\n')
        for vertex in mesh.data.vertices:
            f.write('v {:6e} {:6e} {:6e}\n'.format(vertex[0], vertex[1],
                vertex[2]))
        if mesh.data.vertex_normals is None:
            for triangle in mesh.data.triangles:
                triangle += 1
                f.write('f {:d} {:d} {:d}\n'.format(triangle[0], triangle[1
                    ], triangle[2]))
        else:
            for normal in mesh.data.vertex_normals:
                f.write('vn {:6e} {:6e} {:6e}\n'.format(normal[0], normal[1
                    ], normal[2]))
            for triangle in mesh.data.triangles:
                triangle += 1
                f.write('f {:d}//{:d} {:d}//{:d} {:d}//{:d}\n'.format(
                    triangle[0], triangle[3], triangle[1], triangle[4],
                    triangle[2], triangle[5]))
