summaryrefslogtreecommitdiff
path: root/chroma-cam
diff options
context:
space:
mode:
authorAnthony LaTorre <tlatorre9@gmail.com>2011-09-09 09:53:42 -0400
committerAnthony LaTorre <tlatorre9@gmail.com>2011-09-09 09:53:42 -0400
commit8f39536a7a5a15afeba52b1492f1d84fed95054f (patch)
treefdd78495d9fb3bfae47e182b386308a808420a1f /chroma-cam
parent25de37ef26b8356d8fa012c709cd68c1fb327227 (diff)
downloadchroma-8f39536a7a5a15afeba52b1492f1d84fed95054f.tar.gz
chroma-8f39536a7a5a15afeba52b1492f1d84fed95054f.tar.bz2
chroma-8f39536a7a5a15afeba52b1492f1d84fed95054f.zip
chroma-cam script now used to view geometries.
Diffstat (limited to 'chroma-cam')
-rwxr-xr-xchroma-cam43
1 files changed, 43 insertions, 0 deletions
diff --git a/chroma-cam b/chroma-cam
new file mode 100755
index 0000000..8465aaa
--- /dev/null
+++ b/chroma-cam
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+#--*-python-*-
+
+if __name__ == '__main__':
+ import optparse
+ import sys
+ import imp
+ import os
+
+ from chroma import view, build, EventViewer
+ from chroma import mesh_from_stl
+
+ parser = optparse.OptionParser('%prog')
+ parser.add_option('-r', '--resolution', dest='resolution',
+ help='specify window resolution', default='1024,576')
+ parser.add_option('-i', dest='io_file', default=None)
+ options, args = parser.parse_args()
+
+ if len(args) < 1:
+ sys.exit(parser.format_help())
+
+ size = [int(s) for s in options.resolution.split(',')]
+
+ if os.path.exists(args[0]) and args[0].lower().endswith(('.stl', '.bz2')):
+ obj = mesh_from_stl(args[0])
+ else:
+ name, attr = args[0].split('.')
+
+ try:
+ file, path, description = imp.find_module(name)
+ except ImportError:
+ raise
+
+ module = imp.load_module(name, file, path, description)
+
+ obj = getattr(module, attr)
+
+ if options.io_file is None:
+ view(obj, size)
+ else:
+ geometry = build(obj)
+ viewer = EventViewer(geometry, options.io_file, size=size)
+ viewer.start()