2012-05-29 16:33:15 -07:00
|
|
|
import argparse
|
|
|
|
import json
|
|
|
|
|
|
|
|
from surf.geometry import PolygonMesh
|
|
|
|
from surf.subd import cc
|
|
|
|
from surf.subd import butterfly
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2012-07-13 07:18:34 -07:00
|
|
|
parser = argparse.ArgumentParser(description='Manually subdivide mesh '
|
|
|
|
'(first argument) and dump json to stdout')
|
2012-05-29 16:33:15 -07:00
|
|
|
parser.add_argument('type', choices=('cc', 'butterfly'))
|
|
|
|
parser.add_argument('mesh')
|
2012-07-13 14:33:24 -07:00
|
|
|
parser.add_argument('refines', type=int)
|
2012-05-29 16:33:15 -07:00
|
|
|
opt = parser.parse_args()
|
|
|
|
|
|
|
|
cube = json.load(open(opt.mesh, 'r'))
|
|
|
|
p = PolygonMesh(**cube)
|
|
|
|
|
|
|
|
if opt.type == 'cc':
|
|
|
|
refine = cc.refine
|
|
|
|
else:
|
|
|
|
refine = butterfly.refine
|
|
|
|
|
2012-07-13 14:33:24 -07:00
|
|
|
for i in range(opt.refines):
|
|
|
|
p = refine(p)
|
|
|
|
print(p)
|