forked from young-geng/cs184_final
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
53 lines (39 loc) · 1.21 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import argparse
import numpy as np
import random
import time
from plyfile import PlyData, PlyElement
from utils import *
from ball_pivot import *
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'--seed', '-s', default=int(time.time()), type=int,
help='random seed'
)
parser.add_argument(
'--invert_normal', action='store_true', default=False,
help='invert the normals from ply file'
)
parser.add_argument(
'--radius', '-r', required=True, type=float, nargs='+',
help='radius'
)
parser.add_argument(
'--input', '-i', type=str, required=True,
help='input file'
)
parser.add_argument(
'--output', '-o', type=str, required=True,
help='output file'
)
args = parser.parse_args()
np.random.seed(args.seed)
random.seed(args.seed)
plydata = PlyData.read(args.input)
vs = build_vertex_set_ply(plydata, args.invert_normal)
mesh = pivot_ball(vs, args.radius)
if mesh is None:
print 'Cannot find seed triangle. Reconstruction failed!'
else:
write_collada(vs.vertices, vs.normals, np.array(mesh.faces.keys()), args.output)