Commits

Matthew Turk committed 3ee81b7

Starting out small.

Comments (0)

Files changed (1)

+from functools import wraps
+import pyro
+
+def requires_pf(func):
+    @wraps(func)
+    def wrap(self, *args, **kwargs):
+        if self.pf is None: raise RuntimeError
+        return func(self, *args, **kwargs)
+    return wrap
+
+class VolumeRenderingHandler(object):
+    pf = None
+
+    def load(self, fn, resolution = 1024):
+        self.pf = load(fn)
+        if self.pf is None: raise IOError(fn)
+        c = (self.pf.domain_right_edge + self.pf.domain_left_edge)/2.0
+        self.cam = self.pf.camera(c, [1.0, 1.0, 1.0],
+                      1.0/pf['unitary'], resolution, None)
+
+    @requires_pf
+    def switch_view(self, normal_vector, width, center, north_vectors):
+        self.cam.switch_view(normal_vector, width, center, north_vectors)
+
+    @requires_pf
+    def render(self):
+        if self.cam.transfer_function is None:
+            raise RuntimeError
+        sn = self.cam.snapshot()
+        return sn
+
+    def isocontours(self, limits, nlayers, width):
+        self.cam.transfer_function = ColorTransferFunction(limits)
+        self.cam.transfer_function.add_layers(nlayers, w=width)
+        
+
+if __name__ == "__main__":
+    pass