def main():
    global window, ts, width, height
    (width, height) = (1024, 1024)

    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH )
    glutInitWindowSize(width, height)
    glutInitWindowPosition(0, 0)
    window = glutCreateWindow("Stereo Volume Rendering")


    glutDisplayFunc(display)
    glutIdleFunc(idle)
    glutReshapeFunc(resize)
    glutMouseFunc( mouseButton )
    glutMotionFunc( mouseMotion )
    glutKeyboardFunc(keyPressed)
    init_gl(width, height)

    # create texture for blitting to screen
    create_texture(width, height)

    import pycuda.gl.autoinit
    import pycuda.gl
    cuda_gl = pycuda.gl

    create_PBO(width, height)
    # ----- Load and Set Volume Data -----

    density_grid = np.load("/home/bogert/dd150_log_densities.npy")

    mi, ma= 21.5, 24.5
    bins = 5000
    tf = ColorTransferFunction( (mi, ma), bins)
    tf.map_to_colormap(mi, ma, colormap="algae", scale_func = scale_func)

    ts = TheiaScene(volume = density_grid, raycaster = FrontToBackRaycaster(size = (width, height), tf = tf))

    ts.get_raycaster().set_sample_size(0.01)
    ts.get_raycaster().set_max_samples(5000)
    ts.update()

    glutMainLoop()
Example #2
0
def main():
    global window, ts, width, height
    (width, height) = (1920, 1080)

    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH | GLUT_STEREO)
    glutInitWindowSize(*initial_size)
    glutInitWindowPosition(0, 0)
    window = glutCreateWindow("Stereo Volume Rendering")


    glutDisplayFunc(display)
    glutIdleFunc(idle)
    glutReshapeFunc(resize)
    glutMouseFunc( mouseButton )
    glutMotionFunc( mouseMotion )
    glutKeyboardFunc(keyPressed)
    init_gl(width, height)

    # create texture for blitting to screen
    create_texture(width, height)

    import pycuda.gl.autoinit
    import pycuda.gl
    cuda_gl = pycuda.gl

    create_PBO(width, height)
    # ----- Load and Set Volume Data -----

    density_grid = np.load("/home/bogert/dd150_log_densities.npy")

    mi, ma= 21.5, 24.5
    bins = 5000
    tf = ColorTransferFunction( (mi, ma), bins)
    tf.map_to_colormap(mi, ma, colormap="algae", scale_func = scale_func)

    ts = TheiaScene(volume = density_grid, raycaster = FrontToBackRaycaster(size = (width, height), tf = tf))

    ts.get_raycaster().set_sample_size(0.01)
    ts.get_raycaster().set_max_samples(5000)

    glutMainLoop()
#Of course we need numpy for math magic
import numpy as np


#Opacity scaling function
def scale_func(v, mi, ma):
    return np.minimum(1.0, (v - mi) / (ma - mi) + 0.0)


#load the uniform grid from a numpy array file
bolshoi = "/home/bogert/log_densities_1024.npy"
density_grid = np.load(bolshoi)

#Set the TheiaScene to use the density_grid and
#setup the raycaster for a resulting 1080p image
ts = TheiaScene(volume=density_grid,
                raycaster=FrontToBackRaycaster(size=(1920, 1080)))

#the min and max values in the data to color
mi, ma = 0.0, 3.6

#setup colortransferfunction
bins = 5000
tf = ColorTransferFunction((mi, ma), bins)
tf.map_to_colormap(0.5, ma, colormap="spring", scale_func=scale_func)

#pass the transfer function to the ray caster
ts.source.raycaster.set_transfer(tf)

#Initial configuration for start of video
#set initial opacity and brightness values
#then zoom into the center of the data 30%
import subprocess as sp

#Of course we need numpy for math magic
import numpy as np

#Opacity scaling function
def scale_func(v, mi, ma):
      return  np.minimum(1.0, (v-mi)/(ma-mi) + 0.0)

#load the uniform grid from a numpy array file
bolshoi = "/home/bogert/log_densities_1024.npy"
density_grid = np.load(bolshoi)

#Set the TheiaScene to use the density_grid and 
#setup the raycaster for a resulting 1080p image
ts = TheiaScene(volume = density_grid, raycaster = FrontToBackRaycaster(size = (1920,1080) ))

#the min and max values in the data to color
mi, ma = 0.0, 3.6

#setup colortransferfunction
bins = 5000
tf = ColorTransferFunction( (mi, ma), bins)
tf.map_to_colormap(0.5, ma, colormap="spring", scale_func = scale_func)

#pass the transfer function to the ray caster
ts.source.raycaster.set_transfer(tf)

#Initial configuration for start of video
#set initial opacity and brightness values
#then zoom into the center of the data 30%