Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

luapipelinedemo.lua 3.45 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- first load all the CAMPVis Lua modules we need
require("cgt")
require("base")
require("cvio")
require("vis")
require("application")
 
-- All created CAMPVis objects have to be kept alive and must not be garbage-collected by Lua.
-- In order to keep them alive after this LuaDemo has finished, they have to reside in the global
-- Lua table. At the same time however, we do not want to spam that table. Thus, we create a
-- global table for this script, where everything resides in.
LuaDemo = {}

-- create DataContainer and Pipeline
LuaDemo.dc = application:createAndAddDataContainer("This DataContainer was created by Lua.")
16
LuaDemo.pipeline = campvis.AutoEvaluationPipeline(LuaDemo.dc, "A pipeline created by Lua")
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local pipeline = LuaDemo.pipeline;

-- create the processors we need
local canvas_size = pipeline:getProperty("CanvasSize")
LuaDemo.lsp = base.LightSourceProvider()
LuaDemo.tcp = base.TrackballCameraProvider(canvas_size)
LuaDemo.image_reader = cvio.MhdImageReader()
LuaDemo.vr = vis.VolumeRenderer(canvas_size)

-- register the processors with the pipeline
pipeline:addProcessor(LuaDemo.lsp)
pipeline:addProcessor(LuaDemo.tcp)
pipeline:addProcessor(LuaDemo.image_reader)
pipeline:addProcessor(LuaDemo.vr)

-- setup event listener and register it with the pipeline
LuaDemo.tcp:addLqModeProcessor(LuaDemo.vr)
pipeline:addEventListenerToBack(LuaDemo.tcp)

-- create an init callback function, so that the following code gets called when the pipeline gets 
-- initialized by CAMPVis. 
-- Actually CAMPVis provides the Lua VM with an OpenGL context as well, so this code could also be 
-- here directly. However, this way we nicely can demonstrate how to use CAMPVis signals from Lua.
local initCallback = function()
    -- set up the processors' properties
    LuaDemo.vr.p_outputImage:setValue("combine")
    pipeline:getProperty("renderTargetID"):setValue("combine")

    LuaDemo.image_reader.p_url:setValue(campvis.SOURCE_DIR .. "/modules/vis/sampledata/smallHeart.mhd")
    LuaDemo.image_reader.p_targetImageID:setValue("reader.output")
    LuaDemo.image_reader.p_targetImageID:addSharedProperty(LuaDemo.vr.p_inputVolume)
    
    -- alternative 1 to automatically adjust the camera to the data
    LuaDemo.image_reader.p_targetImageID:addSharedProperty(LuaDemo.tcp.p_image)

    -- alternative 2 to automatically adjust the camera to the data
    local callback = function(arg)
54
        local data_container = pipeline:getDataContainer()
55
56
57
58
59
60
61
        local img_data = data_container:getData(LuaDemo.image_reader.p_targetImageID:getValue()):getData()
        LuaDemo.tcp:reinitializeCamera(img_data:getWorldBounds())
    end
    LuaDemo.image_reader.s_validated:connect(callback)

    -- let us create a fancy transfer function
    local dvrTF = campvis.Geometry1DTransferFunction(128, cgt.vec2(0, 0.05))
62
63
64
    dvrTF:addGeometry(campvis.TFGeometry1D_createQuad(cgt.vec2(0.12, 0.15), cgt.col4(85, 0, 0, 128), cgt.col4(255, 0, 0, 128)))
    dvrTF:addGeometry(campvis.TFGeometry1D_createQuad(cgt.vec2(.19, .28), cgt.col4(89, 89, 89, 155), cgt.col4(89, 89, 89, 155)))
    dvrTF:addGeometry(campvis.TFGeometry1D_createQuad(cgt.vec2(.41, .51), cgt.col4(170, 170, 128, 64), cgt.col4(192, 192, 128, 64)))
65
66
67
68
69
70
71
72

    LuaDemo.vr:getNestedProperty("RaycasterProps::TransferFunction"):replaceTF(dvrTF)
end
-- register the callback with the s_init signal
pipeline.s_init:connect(initCallback)


-- so, we now finished creating our LuaDemo. All that's missing is registering it with the CAMPVis application
73
application:addPipeline(pipeline)