-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbbox.py
26 lines (20 loc) · 802 Bytes
/
bbox.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
import numpy as np
import sys
def bbox(obj):
xmin, ymin, xmax, ymax, zmax, zmin = 0, 0, 0, 0, 0, 0
with open(obj) as o:
for i, line in enumerate(o.readlines()):
if line.startswith('v') or 'clone' in line:
v = np.asarray(line.split()[1:4], dtype=float)
if v[0] < xmin: xmin = v[0]
if v[0] > xmax: xmax = v[0]
if v[1] < ymin: ymin = v[1]
if v[1] > ymax: ymax = v[1]
if v[2] < zmin: zmin = v[2]
if v[2] > zmax: zmax = v[2]
return xmin, xmax, ymin, ymax, zmin, zmax
if __name__ == '__main__':
obj = sys.argv[1]
for D, V in zip(['xmin', 'xmax', 'ymin', 'ymax', 'zmin', 'zmax'],
bbox(obj)):
print '{}:{:.2f}'.format(D, V)