import numpy as np


def testOFFReader():
    path = '../sample-data/chair.off'
    raw_data = tuple(open(path, 'r'))
    header = raw_data.strip(' ')[:-1]
    n_vertices, n_faces = header[0], header[1]
        

if __name__ == '__main__':
    a = testOFFReader()
    print a

@@ -4,273 +4,1845 @@
 ort 
-numpy as np%0A%0A%0Adef testOFFReader():%0A    path = '../sample-data/chair.off'%0A    raw_data = tuple(open(path, 'r'))%0A    header = raw_data.strip(' ')%5B:-1%5D%0A    n_vertices, n_fac
+trimesh%0Aimport sys%0A%0Aimport scipy.ndimage as nd%0Aimport numpy as np%0Aimport matplotlib.pyplot as plt%0A%0Afrom stl import mesh%0Afrom mpl_toolkits import mplot3d%0A%0A%0Adef getVerticesFaces(path):%0A    raw_data = tuple(open(path, 'r'))%0A    header = raw_data%5B1%5D.split()%0A    n_vertices = int(header%5B0%5D)%0A    n_faces = int(header%5B1%5D)%0A    %0A    vertices = np.asarray(%5Bmap(float,raw_data%5Bi+2%5D.split()) for i in range(n_vertices)%5D)%0A    faces = np.asarray(%5Bmap(int,raw_data%5Bi+2+n_vertices%5D.split()) for i in range(n_faces)%5D) %0A    return vertices, faces%0A%0Adef plot(vertices, faces):%0A    input_vec = mesh.Mesh(np.zeros(faces.shape%5B0%5D, dtype=mesh.Mesh.dtype))%0A    for i, f in enumerate(faces):%0A        for j in range(3):%0A            input_vec.vectors%5Bi%5D%5Bj%5D = vertices%5Bf%5Bj%5D,:%5D%0A    figure = plt.figure()%0A    axes = mplot3d.Axes3D(figure)%0A    axes.add_collection3d(mplot3d.art3d.Poly3DCollection(input_vec.vectors))%0A    scale = input_vec.points.flatten(-1)%0A    axes.auto_scale_xyz(scale, scale, scale)%0A    plt.show()%0A%0Adef binaryPlot(voxels):%0A    z,x,y = voxels.nonzero()%0A    fig = plt.figure()%0A    ax = fig.add_subplot(111, projection='3d')%0A    ax.scatter(x, y, -z, zdir='z', c= 'red')%0A    plt.show()%0A%0Adef discretePlot(vertices):%0A    figure = pyplot.figure()%0A    axes = mplot3d.Axes3D(figure)%0A    axes.scatter(vertices.T%5B0,:%5D,vertices.T%5B1,:%5D,vertices.T%5B2,:%5D)%0A    pyplot.show()%0A%0Adef getVolume(path, sideLen=32):%0A    m
 es
+h
  = 
-header%5B0%5D, header%5B1%5D%0A        %0A%0Aif __name__ == '__main__':%0A    a = testOFFReader()%0A    print a
+trimesh.load(path)%0A    volume = trimesh.voxel.Voxel(mesh, 0.5).raw%0A    (x, y, z) = map(float, volume.shape)%0A    volume = nd.zoom(volume.astype(float), %0A                     (sideLen/x, sideLen/y, sideLen/z),%0A                     order=1, %0A                     mode='nearest')%0A    volume%5Bnp.nonzero(volume)%5D = 1.0%0A    return volume.astype(np.bool)%0A%0Aif __name__ == '__main__':%0A    path = sys.argv%5B1%5D%0A    volume = getVolume(path)%0A    binaryPlot(volume)
 %0A

Add off file reader with 3d resampling