Exemplo n.º 1
0
def create_random_lf_cameras(num_to_create,
                             look_from_radii,
                             max_look_to_origin=1.0,
                             interspatial_distance=1.0,
                             spatial_rows=8,
                             spatial_cols=8,
                             look_up=vec3(0, 1, 0)):
    """Create a list of randomnly positioned lf cameras

    Keyword arguments:
    num_to_create -- the number of lf cameras to create
    look_from_radii -- min, max distance from the origin to camera look from
    max_look_to_origin -- max distance from the origin to camera look to    
    interspatial_distance -- distance between cameras in array (default 1.0)
    spatial_rows, spatial_cols -- dimensions of camera array (default 8 x 8)
    """
    lf_cameras = []
    d = max_look_to_origin
    for _ in range(num_to_create):
        look_from = rand_vec_between_spheres(*look_from_radii)
        look_to = vec3(random_float(), random_float(), random_float()) * d
        lf_cam = LightFieldCamera(look_from, look_to, look_up,
                                  interspatial_distance, spatial_rows,
                                  spatial_cols)
        lf_cameras.append(lf_cam)
    return lf_cameras
Exemplo n.º 2
0
    def __init__(self, id, name):
        ivw.Processor.__init__(self, id, name)

        self.current = ivw.properties.OptionPropertyInt(
            "current", "Current", [
                ivw.properties.IntOption("left_left", "left_left", 0),
                ivw.properties.IntOption("left_right", "left_right", 1),
                ivw.properties.IntOption("left_top", "left_top", 2),
                ivw.properties.IntOption("left_bottom", "left_bottom", 3),
                ivw.properties.IntOption("right_left", "right_left", 4),
                ivw.properties.IntOption("right_right", "right_right", 5),
                ivw.properties.IntOption("right_top", "right_top", 6),
                ivw.properties.IntOption("right_bottom", "right_bottom", 7),
            ], 0)
        self.addProperty(self.current)

        self.separation = ivw.properties.FloatProperty("offset",
                                                       "Eye Separation", 0.01,
                                                       0.0, 0.1)
        self.addProperty(self.separation, owner=False)

        self.tilt = ivw.properties.FloatProperty("tilt", "View Tilt", 27, -90,
                                                 90)
        self.addProperty(self.tilt, owner=False)

        self.master = ivw.properties.CameraProperty("master", "master")
        self.addProperty(self.master, owner=False)

        self.camera = ivw.properties.CameraProperty("camera", "camera")
        self.addProperty(self.camera, owner=False)

        self.master.onChange(self.updateCamera)
        self.current.onChange(self.updateCamera)
        self.separation.onChange(self.updateCamera)
        self.tilt.onChange(self.updateCamera)

        self.camera.properties.cameraType.value = "SkewedPerspectiveCamera"
        self.camera.properties.lookFrom.minValue = glm.vec3(-10000.0)
        self.camera.properties.lookFrom.maxValue = glm.vec3(+10000.0)
        self.camera.properties.lookTo.minValue = glm.vec3(-10000.0)
        self.camera.properties.lookTo.maxValue = glm.vec3(+10000.0)
        self.camera.properties.offset.minValue = glm.vec2(-10000.0)
        self.camera.properties.offset.maxValue = glm.vec2(+10000.0)
        self.camera.properties.fov.value = 90

        self.camera.properties.lookFrom.semantics = ivw.properties.PropertySemantics.SpinBox
        self.camera.properties.lookTo.semantics = ivw.properties.PropertySemantics.SpinBox
        self.camera.properties.lookUp.semantics = ivw.properties.PropertySemantics.SpinBox
        self.camera.properties.fov.semantics = ivw.properties.PropertySemantics.SpinBox
        self.camera.properties.offset.semantics = ivw.properties.PropertySemantics.SpinBox
        self.camera.readOnly = True
Exemplo n.º 3
0
def create_random_lf_cameras(num_to_create,
                             look_from_radii,
                             max_look_to_origin=1.0,
                             interspatial_distance=1.0,
                             spatial_rows=8,
                             spatial_cols=8,
                             look_up=vec3(0.0, 1.0, 0.0)):
    """Create a list of randomnly positioned lf cameras

    Keyword arguments:
    num_to_create -- the number of lf cameras to create
    look_from_radii -- min, max distance from the origin to camera look from
    max_look_to_origin -- max distance from the origin to camera look to    
    interspatial_distance -- distance between cameras in array (default 1.0)
    spatial_rows, spatial_cols -- dimensions of camera array (default 8 x 8)
    """
    lf_cameras = []
    for _ in range(num_to_create):
        look_from, look_to, look_up = create_random_camera(
            look_from_radii, max_look_to_origin, look_up, False)

        # Centre the light field on the centre image
        view_direction = look_to - look_from
        right_vec = normalize(cross_product(view_direction, look_up))
        correction_x = -ceil(spatial_cols / 2) * interspatial_distance
        correction_y = ceil(spatial_rows / 2) * interspatial_distance
        correction = (normalize(look_up) * correction_y +
                      right_vec * correction_x)
        look_from = look_from + correction
        look_to = look_to + correction
        lf_cam = LightFieldCamera(look_from, look_to, look_up,
                                  interspatial_distance, spatial_rows,
                                  spatial_cols)
        lf_cameras.append(lf_cam)
    return lf_cameras
def main(pixel_dim, clip, num_random, plane):
    #Setup
    app = inviwopy.app
    network = app.network
    cam = network.EntryExitPoints.camera
    cam.nearPlane = 6.0
    cam.farPlane = 1000.0
    canvases = inviwopy.app.network.canvases
    for canvas in canvases:
        canvas.inputSize.dimensions.value = ivec2(pixel_dim, pixel_dim)
    inviwo_utils.update()

    random_lfs = create_random_lf_cameras(
                     num_random,
                     (180, 35), 1,
                     interspatial_distance=0.5,
                     look_up = vec3(0, 1, 0))

    time_accumulator = (0.0, 0.0, 0.0)
    for lf in random_lfs:
        if clip:
            _, clip_type = random_clip_lf(network, lf)
        elif plane:
            random_plane_clip(network, lf)
        time_taken = lf.view_array(cam, save=False, should_time=True)
        time_accumulator = welford.update(
            time_accumulator, time_taken)
        if clip:
            restore_clip(network, clip_type)
    mean, variance, _ = welford.finalize(time_accumulator)
    print("Time taken per grid, average {:4f}, std_dev {:4f}".format(
        mean, math.sqrt(variance)))
Exemplo n.º 5
0
def main(save_main_dir, pixel_dim, clip, num_random, plane):
    #Setup
    app = inviwopy.app
    network = app.network
    cam = network.EntryExitPoints.camera
    cam.nearPlane = 6.0
    cam.farPlane = 1000.0
    canvases = inviwopy.app.network.canvases
    for canvas in canvases:
        canvas.inputSize.dimensions.value = ivec2(pixel_dim, pixel_dim)
    inviwo_utils.update()
    if not os.path.isdir(save_main_dir):
        pathlib.Path(save_main_dir).mkdir(parents=True, exist_ok=True)

    #Save a number of random light fields
    random_lfs = create_random_lf_cameras(num_random, (180, 35),
                                          1,
                                          interspatial_distance=0.5,
                                          look_up=vec3(0, 1, 0))

    for lf in random_lfs:
        if clip:
            _, clip_type = random_clip_lf(network, lf)
        elif plane:
            random_plane_clip(network, lf)
        save_lf(lf, save_main_dir)
        if clip:
            restore_clip(network, clip_type)
def set_light_position(network):
    random_float = lambda : (random() - 0.5) * 2
    point = network.Pointlightsource
    light = point.properties.lightPosition
    light.referenceFrame.value = 1
    pos = light.position
    pos.value = vec3(random_float(), random_float(), 5)
    light.referenceFrame.value = 0
Exemplo n.º 7
0
def create_random_camera(look_from_radii,
                        max_look_to_origin=1.0,
                        look_up=vec3(0, 1, 0),
                        fix_look_up=False,
                        random_look_up=False):
    """Create a randomly positioned camera"""
    d = max_look_to_origin
    look_from = rand_vec_between_spheres(*look_from_radii)
    look_to = vec3(random_float(), random_float(), random_float()) * d
    reverse_direction = normalize(look_from - look_to)
    if random_look_up:
        look_up = normalize(
            vec3(random_float(), random_float(), random_float()))
    if fix_look_up:
        right = normalize(cross_product(look_up, reverse_direction))
        look_up = cross_product(reverse_direction, right)
    return (look_from, look_to, look_up)
Exemplo n.º 8
0
    def __init__(self,
                 look_from,
                 look_to,
                 look_up=vec3(0.0, 1.0, 0.0),
                 interspatial_distance=1.0,
                 spatial_rows=8,
                 spatial_cols=8):
        """Create a light field camera array.

        Keyword arguments:
        look_from, look_to, look_up -- vectors for top left cam (default up y)
        interspatial_distance -- distance between cameras in array (default 1.0)
        spatial_rows, spatial_cols -- camera array dimensions (default 8 x 8)
        """
        self.set_look(look_from, look_to, look_up)
        self.spatial_rows = spatial_rows
        self.spatial_cols = spatial_cols
        self.interspatial_distance = interspatial_distance
Exemplo n.º 9
0
    def updateFrame(self):
        currentFrame = self.frame.value
        if currentFrame < len(self.fromTrack):
            self.outCamera.properties.lookFrom.minValue = glm.vec3(-10000.0)
            self.outCamera.properties.lookFrom.maxValue = glm.vec3(+10000.0)
            self.outCamera.properties.lookTo.minValue = glm.vec3(-10000.0)
            self.outCamera.properties.lookTo.maxValue = glm.vec3(+10000.0)

            fromVec = glm.vec3(self.fromTrack[currentFrame])
            toVec = glm.vec3(self.toTrack[currentFrame])
            upVec = glm.vec3(self.upTrack[currentFrame])

            normal = toVec - fromVec
            right = glm.cross(normal, upVec)
            upVec = glm.normalize(glm.cross(right, normal))

            self.outCamera.lookFrom = fromVec
            self.outCamera.lookTo = toVec
            self.outCamera.lookUp = upVec
def main(pixel_dim):
    #Setup
    app = inviwopy.app
    network = app.network
    cam = network.EntryExitPoints.camera
    cam.lookUp = vec3(0, 1, 0)
    cam.nearPlane = 6.0
    cam.farPlane = 1000.0
    canvases = inviwopy.app.network.canvases
    for canvas in canvases:
        canvas.inputSize.dimensions.value = ivec2(pixel_dim, pixel_dim)
    inviwo_utils.update()

    # Create a light field camera at the current camera position
    lf_camera_here = LightFieldCamera(cam.lookFrom,
                                      cam.lookTo,
                                      cam.lookUp,
                                      interspatial_distance=0.5)

    #Preview the lf camera array
    lf_camera_here.view_array(cam, save=False, should_time=True)
Exemplo n.º 11
0
def color(x):
   r = x
   g = 1-x
   return vec3(r,g,0)
Exemplo n.º 12
0
    def __init__(self, id, name):
        ivw.Processor.__init__(self, id, name)

        self.outport = ivw.data.MeshOutport("outport")
        self.addOutport(self.outport, owner=False)

        self.ctrlpts = ivw.data.MeshOutport("ctrlpts")
        self.addOutport(self.ctrlpts, owner=False)

        self.frame = ivw.properties.IntProperty("frame", "frame", 0, 0, 159, 1)
        self.addProperty(self.frame, owner=False)

        self.scale = ivw.properties.FloatProperty("scale", "scale", 1.0, 0.0,
                                                  100.0, 1.0)
        self.addProperty(self.scale, owner=False)

        self.add = ivw.properties.ButtonProperty("add", "Add Point")
        self.addProperty(self.add, owner=False)

        self.camera = ivw.properties.CameraProperty("camera", "camera")
        self.addProperty(self.camera, owner=False)

        self.outCamera = ivw.properties.CameraProperty("outCamera",
                                                       "outCamera")
        self.addProperty(self.outCamera, owner=False)
        self.outCamera.properties.lookFrom.minValue = glm.vec3(-10000.0)
        self.outCamera.properties.lookFrom.maxValue = glm.vec3(+10000.0)
        self.outCamera.properties.lookTo.minValue = glm.vec3(-10000.0)
        self.outCamera.properties.lookTo.maxValue = glm.vec3(+10000.0)
        self.outCamera.properties.lookFrom.semantics = ivw.properties.PropertySemantics.SpinBox
        self.outCamera.properties.lookTo.semantics = ivw.properties.PropertySemantics.SpinBox
        self.outCamera.properties.lookUp.semantics = ivw.properties.PropertySemantics.SpinBox
        self.outCamera.properties.fov.semantics = ivw.properties.PropertySemantics.SpinBox

        points = {
            "to": [[1.0, 0.0, 0.0], [2.0, 0.0, 0.0], [3.0, 0.0, 0.0],
                   [4.0, 0.0, 0.0]],
            "from": [[-10.0, -10.0, 0.0], [10.0, -10.0, 0.0],
                     [10.0, 10.0, 0.0], [-10.0, 10.0, 0.0]],
            "up": [[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0],
                   [0.0, 0.0, 1.0]]
        }
        self.pts = ivw.properties.StringProperty(
            "ctrlPrts", "ControlPoints", json.dumps(
                points,
                indent=4,
            ))
        self.addProperty(self.pts, owner=False)
        self.pts.semantics = ivw.properties.PropertySemantics.Multiline

        self.fromPm = ivw.PickingMapper(self, 1, lambda x: self.callback(x, 1))
        self.toPm = ivw.PickingMapper(self, 1, lambda x: self.callback(x, 2))
        self.upPm = ivw.PickingMapper(self, 1, lambda x: self.callback(x, 3))

        self.fromTrack = []
        self.toTrack = []
        self.upTrack = []

        self.frame.onChange(self.updateFrame)
        self.add.onChange(self.addPoint)

        self.pts.onChange(self.doInterpolation)
Exemplo n.º 13
0
def main(config):
    app = inviwopy.app
    network = app.network
    
    # Resize the canvas to improve rendering speed, only affects visual output
    if config["should_resize"]:
        ivw_helpers.set_canvas_sizes(128, 128)

    # Find the list of volumes and tfs form the corresponding directories
    volume_names = get_all_files_in_dir(
        config["volume_dir"], None, True)

    ivw_volume = get_volume(network, config)

    for volume_name in volume_names:
            if config["should_use_numpy_vol"]:
                ivw_volume.properties.location.value = volume_name
            else:
                ivw_volume.filename.value = volume_name
                ivw_volume.reload.press()
            inviwo_utils.update()
            sleep(1.2)

if __name__ == '__main__':
    home = os.path.expanduser('~')
    config = choose_cfg("head")
    lu = config['look_up']
    config['look_up'] = vec3(lu[0], lu[1], lu[2])

    main(config)
Exemplo n.º 14
0
import math 
import time

#Use for example the boron example network

app = inviwopy.app
network = app.network

cam = network.EntryExitPoints.camera

start = time.clock()

scale = 1;
d = 15
steps = 120
cam.lookTo = vec3(0,0,0)
cam.lookUp = vec3(0,1,0)
for i in range(0, steps):
    r = (2 * math.pi * i) / (steps-1)
    x = d*math.sin(r)
    z = -d*math.cos(r)
    cam.lookFrom = vec3(x*scale,3*scale,z*scale)
    inviwo_utils.update() # Needed for canvas to update


for i in range(0, steps):
   r = (2 * math.pi * i) / (steps-1)
   x = 1.0*math.sin(r)
   z = 1.0*math.cos(r)
   cam.lookUp = vec3(x*scale,z*scale,0)
   inviwo_utils.update() # Needed for canvas to update
# Inviwo Python script
import inviwopy
from inviwopy.glm import vec3
import ivw.utils as inviwo_utils
import math
import time

#works with the volumelighting_subclavia workspace

start = time.clock()

light = inviwopy.app.network.getProcessorByIdentifier(
    "Point light source").lightPosition.position

d = 70
steps = 360
rotations = 4
for i in range(0, steps):
    r = rotations * (2 * 3.14 * i) / (steps - 1)
    x = -d * math.sin(r)
    z = d * math.cos(r)
    light.value = vec3(x, 0, z)
    inviwo_utils.update()  # Needed for canvas to update

end = time.clock()
fps = steps / (end - start)

fps = round(fps, 2)

print("fps: " + str(fps))
if not "use_nifti" in self.properties:
    self.addProperty(
        BoolProperty("use_nifti", "Should load a Nifti", False,
                     InvalidationLevel.InvalidOutput,
                     PropertySemantics("PythonEditor")))

if not "use_scan_basis" in self.properties:
    self.addProperty(
        BoolProperty("use_scan_basis", "Use the scanned file basis", False,
                     InvalidationLevel.InvalidOutput,
                     PropertySemantics("PythonEditor")))

if not "basis" in self.properties:
    self.addProperty(
        FloatVec3Property("basis", "X, Y, Z basis scales", vec3(1.0),
                          vec3(0.0), vec3(1.0), vec3(0.001)))

if not "max" in self.properties:
    self.addProperty(IntProperty("max", "Defined data max", 600, 1, 1500))


def process(self):
    """
    The PythonScriptProcessor will call this process function whenever the processor process 
    function is called. The argument 'self' represents the PythonScriptProcessor.
    """
    if self.properties.use_nifti.value == True:
        print("Loading nii data at " + self.properties.location.value)
        img = nib.load(self.properties.location.value)
        print(img.header)
Exemplo n.º 17
0
import time

import ivw.regression
import ivw.camera

steps = 50

m = ivw.regression.Measurements()

network = inviwopy.app.network
canvas = network.CanvasGL

orgsize = canvas.size

with ivw.camera.Camera(network.EntryExitPoints.camera,
                       lookfrom=vec3(0, 4, 0),
                       lookto=vec3(0, 0, 0),
                       lookup=vec3(0, 0, 1)) as c:
    for size in [256, 512, 768, 1024]:
        canvas.size = ivec2(size, size)
        ivw.regression.saveCanvas(canvas,
                                  "CanvasGL-" + str(size) + "x" + str(size))

        start = time.clock()
        for step in c.rotate(math.pi / steps, steps, vec3(0, 1, 0)):
            inviwoqt.update()
        end = time.clock()
        frametime = (end - start) / steps
        fps = 1.0 / frametime

        m.addFrequency('FPS-' + str(size) + 'x' + str(size), fps)
Exemplo n.º 18
0
# Inviwo Python script
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import inviwopy
from inviwopy.glm import vec2, vec3

#http://matplotlib.org/examples/color/colormaps_reference.html

#Perceptually Uniform Sequential :  #['viridis', 'inferno', 'plasma', 'magma']
#Sequential  :  #['Blues', 'BuGn', 'BuPu','GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu','Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd']
#Diverging :  #['afmhot', 'autumn', 'bone', 'cool','copper', 'gist_heat', 'gray', 'hot','pink', 'spring', 'summer', 'winter']
#Qualitative :  #['BrBG', 'bwr', 'coolwarm', 'PiYG', 'PRGn', 'PuOr', 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral', 'seismic']
#Miscellaneous :  #['Accent', 'Dark2', 'Paired', 'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3']
#Sequential :  #['gist_earth', 'terrain', 'ocean', 'gist_stern','brg', 'CMRmap', 'cubehelix','gnuplot', 'gnuplot2', 'gist_ncar', 'nipy_spectral', 'jet', 'rainbow', 'gist_rainbow', 'hsv', 'flag', 'prism']

tf = inviwopy.app.network.VolumeRaycaster.transferFunction
tf.clear()

cmapName = "hot"

cmap = plt.get_cmap(cmapName)

N = 128

for i in range(0, N, 1):
    x = i / (N - 1)
    a = 1.0
    color = cmap(x)
    tf.addPoint(vec2(x, a), vec3(color[0], color[1], color[2]))
Exemplo n.º 19
0
# Inviwo Python script 
import inviwopy
from inviwopy.glm import vec3
import ivw.utils as inviwo_utils
import math 
import time

#works with the volumelighting_subclavia workspace

start = time.clock()

light = inviwopy.app.network.getProcessorByIdentifier("Point light source").lightPosition.position

d = 70
steps = 360
rotations = 4
for i in range(0, steps):
    r = rotations*(2 * 3.14 * i) / (steps-1)
    x = -d*math.sin(r)
    z = d*math.cos(r)
    light.value = vec3(x,0,z)
    inviwo_utils.update() # Needed for canvas to update

end = time.clock()
fps = steps / (end - start)

fps = round(fps,2)

print ("fps: " + str(fps))
Exemplo n.º 20
0
def cross_product(vec_1, vec_2):
    result = vec3((vec_1.y * vec_2.z) - (vec_1.z * vec_2.y),
                  (vec_1.z * vec_2.x) - (vec_1.x * vec_2.z),
                  (vec_1.x * vec_2.y) - (vec_1.y * vec_2.x))
    return result
Exemplo n.º 21
0
#Inviwo Python script
import inviwopy

from inviwopy.glm import vec3

app = inviwopy.app
network = app.network

cam = inviwopy.app.network.MeshClipping.camera
print(cam.lookFrom)
print(cam.lookUp)
print(cam.lookTo)
cam.lookFrom = vec3(20, -70, -90)
cam.lookTo = vec3(0)
cam.lookUp = vec3(0, -1, 0)
Exemplo n.º 22
0
import math 
import time

import ivw.regression
import ivw.camera

steps = 50

m = ivw.regression.Measurements()

network = inviwopy.app.network;
canvas = network.CanvasGL;

orgsize = canvas.size;

with ivw.camera.Camera(network.EntryExitPoints.camera, lookfrom = vec3(0,4,0), lookto = vec3(0,0,0), lookup = vec3(0,0,1)) as c:
    for size in [256,512,768,1024]:
        canvas.size=ivec2(size,size)
        ivw.regression.saveCanvas(canvas, "CanvasGL-"+str(size) + "x" +str(size))

        start = time.perf_counter()
        for step in c.rotate(math.pi/steps, steps, vec3(0,1,0)):
            inviwoqt.update()
        end = time.perf_counter()
        frametime = (end - start) / steps
        fps = 1.0 / frametime
    
        m.addFrequency('FPS-'+str(size)+'x'+str(size), fps)

m.save()
canvas.size = orgsize;
Exemplo n.º 23
0
# Inviwo Python script 
import inviwopy
from inviwopy.glm import vec2,vec3

def color(x):
   r = x
   g = 1-x
   return vec3(r,g,0)

tf = inviwopy.app.network.VolumeRaycaster.transferFunction

tf.clear()
tf.addPoint(vec2(0.0,0.0),vec3(0,0,0)) 

for i in range(1,256,9):
   x = i / 256.0
   a = 0
   if i%2==1:
      a = 0.1
   tf.addPoint(vec2(x,a),color(x)) 


tf.addPoint(vec2(1.0,0.0),vec3(0,0,0)) 
Exemplo n.º 24
0
def rand_vec_in_unit_sphere():
    return vec3(random_float(), random_float(), random_float())
Exemplo n.º 25
0
def random_vec3():
    return vec3(random_f(), random_f(), random_f())
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import inviwopy
from inviwopy.glm import vec2,vec3

#http://matplotlib.org/examples/color/colormaps_reference.html

#Perceptually Uniform Sequential :  #['viridis', 'inferno', 'plasma', 'magma'] 
#Sequential  :  #['Blues', 'BuGn', 'BuPu','GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu','Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd']
#Diverging :  #['afmhot', 'autumn', 'bone', 'cool','copper', 'gist_heat', 'gray', 'hot','pink', 'spring', 'summer', 'winter']
#Qualitative :  #['BrBG', 'bwr', 'coolwarm', 'PiYG', 'PRGn', 'PuOr', 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral', 'seismic']
#Miscellaneous :  #['Accent', 'Dark2', 'Paired', 'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3']
#Sequential :  #['gist_earth', 'terrain', 'ocean', 'gist_stern','brg', 'CMRmap', 'cubehelix','gnuplot', 'gnuplot2', 'gist_ncar', 'nipy_spectral', 'jet', 'rainbow', 'gist_rainbow', 'hsv', 'flag', 'prism']


tf = inviwopy.app.network.VolumeRaycaster.transferFunction
tf.clear()

cmapName = "hot"

cmap=plt.get_cmap(cmapName)

N = 128

for i in range(0,N,1):
   x = i / (N-1)
   a = 1.0
   color = cmap(x)
   tf.addPoint(vec2(x,a), vec3(color[0],color[1],color[2])) 

Exemplo n.º 27
0
 def rotateVec(m, v):
     return glm.vec3(m * glm.vec4(v, 1.0))
Exemplo n.º 28
0
import math
import time

#Use for example the boron example network

app = inviwopy.app
network = app.network

cam = network.EntryExitPoints.camera

start = time.clock()

scale = 1
d = 15
steps = 120
cam.lookTo = vec3(0, 0, 0)
cam.lookUp = vec3(0, 1, 0)
for i in range(0, steps):
    r = (2 * math.pi * i) / (steps - 1)
    x = d * math.sin(r)
    z = -d * math.cos(r)
    cam.lookFrom = vec3(x * scale, 3 * scale, z * scale)
    inviwo_utils.update()  # Needed for canvas to update

for i in range(0, steps):
    r = (2 * math.pi * i) / (steps - 1)
    x = 1.0 * math.sin(r)
    z = 1.0 * math.cos(r)
    cam.lookUp = vec3(x * scale, z * scale, 0)
    inviwo_utils.update()  # Needed for canvas to update