script.lua 1.76 KB
Newer Older
1
require("tgt")
2
require("cvio")
3
require("vis")
4
require("preprocessing")
5

6
pipeline = campvis.newPipeline()
7

8
9
function pipeline:ctor()
    print("I'm being constructed!")
10
    self.image_reader = cvio.MhdImageReader()
11
    self.addProcessor(instance, self.image_reader)
12

13
14
    self.ve = vis.VolumeExplorer(self.getCanvasSizeProperty(instance))
    self.resampler = preprocessing.GlImageResampler(self.getCanvasSizeProperty(instance))
15

16
17
    self.addProcessor(instance, self.resampler)
    self.addProcessor(instance, self.ve)
18
19

    self.addEventListenerToBack(instance, self.ve)
20
end
21
22
23

function pipeline:init()
    print("I'm being inited!")
24
25

    self.ve.p_outputImage:setValue("result")
26
    self.getRenderTargetIDProperty(instance):setValue("result")
27

28
    self.image_reader.p_url:setValue(campvis.SOURCE_DIR .. "/modules/vis/sampledata/smallHeart.mhd")
29
30
31
32
33
34
    self.image_reader.p_targetImageID:setValue("reader.output")
    self.image_reader.p_targetImageID:addSharedProperty(self.resampler.p_inputImage)

    self.resampler.p_outputImage:setValue("resampled")
    self.resampler.p_outputImage:addSharedProperty(self.ve.p_inputVolume)

35
36
37
38
    local geometry1 = campvis.TFGeometry1D_createQuad(tgt.vec2(0.1, 0.125), tgt.col4(255, 0, 0, 32),
                                                      tgt.vec4(255, 0, 0, 32))
    local geometry2 = campvis.TFGeometry1D_createQuad(tgt.vec2(.4, .5), tgt.col4(0, 255, 0, 128),
                                                      tgt.vec4(0, 255, 0, 128))
39

40
    local dvrTF = campvis.Geometry1DTransferFunction(128, tgt.vec2(0, 0.05))
41
42
43
44
    dvrTF:addGeometry(geometry1)
    dvrTF:addGeometry(geometry2)

    self.ve:getProperty("TransferFunction"):replaceTF(dvrTF)
45
46

    self.resampler.p_resampleScale:setValue(1.25)
47
48
49
50
51
end

function pipeline:deinit()
    print("I'm being deinited!")
end