Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions vapory/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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)
Expand Down
16 changes: 13 additions & 3 deletions vapory/vapory.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -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:
Expand Down