dvrvis.cpp 6.08 KB
Newer Older
1
2
// ================================================================================================
// 
schultezub's avatar
schultezub committed
3
// This file is part of the CAMPVis Software Framework.
4
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
schultezub's avatar
schultezub committed
6
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
7
//      Chair for Computer Aided Medical Procedures
8
9
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
10
// 
schultezub's avatar
schultezub committed
11
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
12
// 
13
14
15
16
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
// except in compliance with the License. You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
17
// 
18
19
20
21
// Unless required by applicable law or agreed to in writing, software distributed under the 
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific language governing permissions 
// and limitations under the License.
22
23
24
// 
// ================================================================================================

25
26
#include "dvrvis.h"

27
#include "cgt/event/keyevent.h"
28
#include "core/datastructures/imagedata.h"
29

schultezub's avatar
schultezub committed
30
31
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
32

schultezub's avatar
schultezub committed
33
namespace campvis {
34

35
36
    DVRVis::DVRVis(DataContainer* dc)
        : AutoEvaluationPipeline(dc)
37
        , _tcp(&_canvasSize)
38
        , _lsp()
39
        , _imageReader()
40
        , _pgGenerator()
schultezub's avatar
schultezub committed
41
        , _vmgGenerator()
42
43
44
45
46
47
48
        , _vmRenderer(&_canvasSize)
        , _eepGenerator(&_canvasSize)
        , _vmEepGenerator(&_canvasSize)
        , _dvrNormal(&_canvasSize)
        , _dvrVM(&_canvasSize)
        , _depthDarkening(&_canvasSize)
        , _combine(&_canvasSize)
49
    {
50
51
52
53
        _tcp.addLqModeProcessor(&_dvrNormal);
        _tcp.addLqModeProcessor(&_dvrVM);
        _tcp.addLqModeProcessor(&_depthDarkening);
        addEventListenerToBack(&_tcp);
54

55
        addProcessor(&_tcp);
56
        addProcessor(&_lsp);
57
58
59
60
61
62
63
64
65
66
        addProcessor(&_imageReader);
        addProcessor(&_pgGenerator);
        addProcessor(&_vmgGenerator);
        addProcessor(&_vmRenderer);
        addProcessor(&_eepGenerator);
        addProcessor(&_vmEepGenerator);
        addProcessor(&_dvrNormal);
        addProcessor(&_dvrVM);
        addProcessor(&_depthDarkening);
        addProcessor(&_combine);
67
68
69
70
71
72
    }

    DVRVis::~DVRVis() {
    }

    void DVRVis::init() {
73
        AutoEvaluationPipeline::init();
74

75
        _imageReader.p_url.setValue(ShdrMgr.completePath("/modules/vis/sampledata/smallHeart.mhd"));
76
        _imageReader.p_targetImageID.setValue("reader.output");
77
78
79
80
81
        _imageReader.p_targetImageID.addSharedProperty(&_eepGenerator.p_sourceImageID);
        _imageReader.p_targetImageID.addSharedProperty(&_vmEepGenerator.p_sourceImageID);
        _imageReader.p_targetImageID.addSharedProperty(&_dvrVM.p_sourceImageID);
        _imageReader.p_targetImageID.addSharedProperty(&_dvrNormal.p_sourceImageID);
        _imageReader.p_targetImageID.addSharedProperty(&_pgGenerator.p_sourceImageID);
82
        _imageReader.p_targetImageID.addSharedProperty(&_tcp.p_image);
83

84
        _dvrNormal.p_targetImageID.setValue("drr.output");
85
        _dvrVM.p_targetImageID.setValue("dvr.output");
schultezub's avatar
schultezub committed
86

87
88
89
90
        Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, cgt::vec2(0.f, .05f));
        dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.12f, .15f), cgt::col4(85, 0, 0, 128), cgt::col4(255, 0, 0, 128)));
        dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.19f, .28f), cgt::col4(89, 89, 89, 155), cgt::col4(89, 89, 89, 155)));
        dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.41f, .51f), cgt::col4(170, 170, 128, 64), cgt::col4(192, 192, 128, 64)));
91
        _dvrNormal.p_transferFunction.replaceTF(dvrTF);
92

93
94
        Geometry1DTransferFunction* vmTF = new Geometry1DTransferFunction(128, cgt::vec2(0.f, .05f));
        vmTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.41f, .51f), cgt::col4(170, 170, 128, 64), cgt::col4(192, 192, 128, 64)));
95
        _dvrVM.p_transferFunction.replaceTF(vmTF);
96

97
        _vmRenderer.p_renderTargetID.addSharedProperty(&_combine.p_mirrorRenderID);
98
99
100
        _vmEepGenerator.p_entryImageID.setValue("vm.eep.entry");
        _vmEepGenerator.p_exitImageID.setValue("vm.eep.exit");
        _vmEepGenerator.p_enableMirror.setValue(true);
101

102
103
104
        // not the most beautiful way... *g*
        // this will all get better with scripting support.
        static_cast<BoolProperty*>(_vmEepGenerator.getProperty("applyMask"))->setValue(true);
105
        _vmRenderer.p_renderTargetID.addSharedProperty(static_cast<DataNameProperty*>(_vmEepGenerator.getProperty("maskID")));
106
        _vmRenderer.p_renderMode.selectByOption(GL_TRIANGLE_FAN);
107

108
        _renderTargetID.setValue("combine");
109

110
111
112
113
        _pgGenerator.p_geometryID.addSharedProperty(&_vmEepGenerator.p_geometryID);
        _pgGenerator.p_geometryID.addSharedProperty(&_eepGenerator.p_geometryID);
        _vmgGenerator.p_mirrorID.addSharedProperty(&_vmEepGenerator.p_mirrorID);
        _vmgGenerator.p_mirrorID.addSharedProperty(&_vmRenderer.p_geometryID);
114
115
        _vmgGenerator.p_mirrorCenter.setValue(cgt::vec3(0.f, 0.f, -20.f));
        _vmgGenerator.p_poi.setValue(cgt::vec3(50.f, 80.f, 15.f));
116
        _vmgGenerator.p_size.setValue(128.f);
schultezub's avatar
schultezub committed
117

118
119
        _eepGenerator.p_entryImageID.addSharedProperty(&_dvrNormal.p_entryImageID);
        _vmEepGenerator.p_entryImageID.addSharedProperty(&_dvrVM.p_entryImageID);
schultezub's avatar
schultezub committed
120

121
122
        _eepGenerator.p_exitImageID.addSharedProperty(&_dvrNormal.p_exitImageID);
        _vmEepGenerator.p_exitImageID.addSharedProperty(&_dvrVM.p_exitImageID);
schultezub's avatar
schultezub committed
123

124
        _dvrVM.p_targetImageID.addSharedProperty(&_combine.p_mirrorImageID);
125
        _combine.p_targetImageID.setValue("combine");
126

127
128
        _dvrNormal.p_targetImageID.addSharedProperty(&_depthDarkening.p_inputImage);
        _depthDarkening.p_outputImage.addSharedProperty(&_combine.p_normalImageID);
129
130
131
    }

}