Beispiel #1
0
def benchmark():
    # store current canvas size and camera settings
    prevDim = voreen.getPropertyValue(canvas, "canvasSize")
    prevCam = voreen.getPropertyValue(processor, cameraProp)

    # resize canvas and initialize camera
    voreen.setPropertyValue(canvas, "canvasSize", canvasDim)
    voreen.setPropertyValue(processor, cameraProp, initCam)
    voreen.repaint()

    # make sure all Qt events have been processed before starting
    voreenqt.processEvents()

    # start loop for animation
    counter = 0
    angleIncr = 2 * math.pi / frames  # do a full rotation
    start = time.time()
    while (counter < frames):
        counter = counter + 1

        # update camera for current frame
        voreen.rotateCamera(processor, cameraProp, angleIncr, rotAxis)

        # render network state
        voreen.repaint()
    end = time.time()

    # restore canvas and camera
    voreen.setPropertyValue(canvas, "canvasSize", prevDim)
    voreen.setPropertyValue(processor, cameraProp, prevCam)
    voreen.repaint()

    # evaluate results
    runtime = (end - start)
    if runtime > 0:
        fps = frames / runtime
    else:
        fps = -1

    message = 'frames: %i\n' % (frames)
    message += 'total runtime: %f\n' % (runtime)
    message += 'fps: %f' % (fps)
    print message
    voreenqt.messageBox("Finished!\n" + message)
Beispiel #2
0
def benchmark():
    # store current canvas size and camera settings
    prevDim = voreen.getPropertyValue(canvas, "canvasSize")
    prevCam = voreen.getPropertyValue(processor, cameraProp)

    # resize canvas and initialize camera
    voreen.setPropertyValue(canvas, "canvasSize", canvasDim)
    voreen.setPropertyValue(processor, cameraProp, initCam)
    voreen.repaint()

    # make sure all Qt events have been processed before starting
    voreenqt.processEvents()  

    # start loop for animation
    counter = 0
    angleIncr = 2*math.pi / frames  # do a full rotation
    start = time.time()
    while (counter < frames):
        counter = counter + 1

        # update camera for current frame
        voreen.rotateCamera(processor, cameraProp, angleIncr, rotAxis)

        # render network state
        voreen.repaint()
    end = time.time()

    # restore canvas and camera
    voreen.setPropertyValue(canvas, "canvasSize", prevDim)
    voreen.setPropertyValue(processor, cameraProp, prevCam)
    voreen.repaint()

    # evaluate results
    runtime = (end - start)
    if runtime > 0:
        fps = frames / runtime
    else:
        fps = -1

    message =  'frames: %i\n' % (frames)
    message += 'total runtime: %f\n' % (runtime)
    message += 'fps: %f' %(fps)
    print message
    voreenqt.messageBox("Finished!\n" + message)
Beispiel #3
0
# Consecutively loads the ten time steps of the golf ball data set
# (http://www.voreen.org/files/volumedynamics.zip), 
# and takes a snapshot of each frame.

import voreen
import voreenqt

golfBallPath = voreen.getBasePath() + "/data/volumes/golfball"
snapshotPath = voreen.getBasePath() + "/data/screenshots"

for i in range(0, 10):
    # usage: voreen.loadVolume(filepath, [VolumeSource processor]) 
    voreen.loadVolume(golfBallPath + "/golfball0_%d-512x256x256.dat" % (i))
    
    # alternative: use VolumeSeriesSource as data supplier
    #voreen.setPropertyValue("VolumeSeriesSource", "step", i) 

    voreen.repaint()
    voreenqt.processEvents() # to see each frame on screen
    voreen.snapshot(snapshotPath + "/golfball0_%d.png" % (i))

voreenqt.messageBox("Wrote ten frames to %s/golfball0_*.png" % snapshotPath)