diff --git a/vapory/io.py b/vapory/io.py index dd15552..77ed64d 100644 --- a/vapory/io.py +++ b/vapory/io.py @@ -54,7 +54,8 @@ def ppm_to_numpy(filename=None, buffer=None, byteorder='>'): def render_povstring(string, outfile=None, height=None, width=None, quality=None, antialiasing=None, remove_temp=True, - show_window=False, tempfile=None): + show_window=False, tempfile=None, + use_custom_povray=False): """ Renders the provided scene description with POV-Ray. @@ -94,7 +95,10 @@ def render_povstring(string, outfile=None, height=None, width=None, if display_in_ipython: outfile = '__temp_ipython__.png' - cmd = [POVRAY_BINARY, pov_file] + if use_custom_povray!=False and os.path.exists(use_custom_povray): + cmd = [use_custom_povray, pov_file] + else: + cmd = [POVRAY_BINARY, pov_file] if height is not None: cmd.append('+H%d'%height) if width is not None: cmd.append('+W%d'%width) if quality is not None: cmd.append('+Q%d'%quality) diff --git a/vapory/vapory.py b/vapory/vapory.py index 150e6d6..04eb5df 100644 --- a/vapory/vapory.py +++ b/vapory/vapory.py @@ -1,6 +1,7 @@ import webbrowser # <= to open the POVRay help from copy import deepcopy import re +import os from .io import render_povstring from .helpers import WIKIREF, vectorize, format_if_necessary @@ -54,7 +55,9 @@ def add_objects(self, objs): def render(self, outfile=None, height=None, width=None, quality=None, antialiasing=None, remove_temp=True, - auto_camera_angle=True, show_window=False, tempfile=None): + auto_camera_angle=True, show_window=False, + tempfile=None, evaluate=True, + use_custom_povray=False): """ Renders the scene to a PNG, a numpy array, or the IPython Notebook. @@ -78,8 +81,15 @@ def render(self, outfile=None, height=None, width=None, if auto_camera_angle and width is not None: self.camera = self.camera.add_args(['right', [1.0*width/height, 0,0]]) - return render_povstring(str(self), outfile, height, width, - quality, antialiasing, remove_temp, show_window, tempfile) + if evaluate: + return render_povstring(str(self), outfile, height, width, + quality, antialiasing, remove_temp, + show_window, tempfile, use_custom_povray) + else: + pov_file = os.path.splitext(outfile)[0] + '.pov' + with open(pov_file, 'w+') as f: + f.write(str(self)) + return pov_file class POVRayElement: