MCPcopy Create free account
hub / github.com/OpenMeshLab/MeshXL / write_ply

Function write_ply

utils/ply_helper.py:27–50  ·  view source on GitHub ↗
(verts, colors, indices, output_file)

Source from the content-addressed store, hash-verified

25
26
27def write_ply(verts, colors, indices, output_file):
28 if colors is None:
29 colors = np.zeros_like(verts)
30 if indices is None:
31 indices = []
32
33 file = open(output_file, 'w')
34 file.write('ply\n')
35 file.write('format ascii 1.0\n')
36 file.write('element vertex {:d}\n'.format(len(verts)))
37 file.write('property float x\n')
38 file.write('property float y\n')
39 file.write('property float z\n')
40 file.write('property uchar red\n')
41 file.write('property uchar green\n')
42 file.write('property uchar blue\n')
43 file.write('element face {:d}\n'.format(len(indices)))
44 file.write('property list uchar uint vertex_indices\n')
45 file.write('end_header\n')
46 for vert, color in zip(verts, colors):
47 file.write("{:f} {:f} {:f} {:d} {:d} {:d}\n".format(vert[0], vert[1], vert[2] , int(color[0]*255), int(color[1]*255), int(color[2]*255)))
48 for ind in indices:
49 file.write('3 {:d} {:d} {:d}\n'.format(ind[0], ind[1], ind[2]))
50 file.close()
51
52
53def create_cylinder_mesh(radius, p0, p1, stacks=10, slices=10):

Callers 5

post_process_meshFunction · 0.90
process_meshFunction · 0.90
post_process_meshFunction · 0.90
write_bboxFunction · 0.85
write_pathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected