Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

volumerenderer.cpp 7.15 KB
Newer Older
1
2
3
4
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
6
7
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
8
9
//      Technische Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, Germany
10
// 
11
12
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// 
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
27
28
29
30
31
32
33
34
35
36
37
// 
// ================================================================================================

#include "volumerenderer.h"
#include "tgt/logmanager.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"

#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagerepresentationgl.h"

#include "core/classification/simpletransferfunction.h"

namespace campvis {
    const std::string VolumeRenderer::loggerCat_ = "CAMPVis.modules.vis.VolumeRenderer";

38
    VolumeRenderer::VolumeRenderer(IVec2Property* viewportSizeProp, RaycastingProcessor* raycaster)
39
        : VisualizationProcessor(viewportSizeProp)
40
41
        , p_inputVolume("InputVolume", "Input Volume", "", DataNameProperty::READ, AbstractProcessor::VALID)
        , p_camera("Camera", "Camera", tgt::Camera(), AbstractProcessor::VALID)
42
        , p_outputImage("OutputImage", "Output Image", "vr.output", DataNameProperty::WRITE, AbstractProcessor::VALID)
43
44
        , p_pgProps("PGGProps", "Proxy Geometry Generator", AbstractProcessor::VALID)
        , p_eepProps("EEPProps", "Entry/Exit Points Generator", AbstractProcessor::VALID)
45
        , p_raycasterProps("RaycasterProps", "Raycaster", AbstractProcessor::VALID)
46
        , _pgGenerator()
47
        , _eepGenerator(viewportSizeProp)
48
        , _raycaster(raycaster)
49
    {
50
51
        _raycaster->setViewportSizeProperty(viewportSizeProp);

52
        addProperty(&p_inputVolume);
53
        addProperty(&_raycaster->p_transferFunction);
54
        addProperty(&p_outputImage);
55

56
57
58
59
60
61
62
63
64
65
66
67
68
        p_pgProps.addPropertyCollection(_pgGenerator);
        _pgGenerator.p_sourceImageID.setVisible(false);
        _pgGenerator.p_geometryID.setVisible(false);
        addProperty(&p_pgProps);

        p_eepProps.addPropertyCollection(_eepGenerator);
        _eepGenerator.p_lqMode.setVisible(false);
        _eepGenerator.p_camera.setVisible(false);
        _eepGenerator.p_sourceImageID.setVisible(false);
        _eepGenerator.p_geometryID.setVisible(false);
        _eepGenerator.p_entryImageID.setVisible(false);
        _eepGenerator.p_exitImageID.setVisible(false);
        addProperty(&p_eepProps);
69

70
71
72
73
74
75
76
        p_raycasterProps.addPropertyCollection(*_raycaster);
        _raycaster->p_lqMode.setVisible(false);
        _raycaster->p_camera.setVisible(false);
        _raycaster->p_sourceImageID.setVisible(false);
        _raycaster->p_entryImageID.setVisible(false);
        _raycaster->p_exitImageID.setVisible(false);
        _raycaster->p_targetImageID.setVisible(false);
77
78
        addProperty(&p_raycasterProps);

79
80
81
        // setup shared properties
        p_inputVolume.addSharedProperty(&_pgGenerator.p_sourceImageID);
        p_inputVolume.addSharedProperty(&_eepGenerator.p_sourceImageID);
82
        p_inputVolume.addSharedProperty(&_raycaster->p_sourceImageID);
83
84

        p_camera.addSharedProperty(&_eepGenerator.p_camera);
85
        p_camera.addSharedProperty(&_raycaster->p_camera);
86

87
        p_outputImage.addSharedProperty(&_raycaster->p_targetImageID);
88

89
        p_inputVolume.s_changed.connect(this, &VolumeRenderer::onPropertyChanged);
90
91
92
93
94
95
96
97
98
99
    }

    VolumeRenderer::~VolumeRenderer() {

    }

    void VolumeRenderer::init() {
        VisualizationProcessor::init();
        _pgGenerator.init();
        _eepGenerator.init();
100
        _raycaster->init();
101

102
        p_lqMode.addSharedProperty(&_raycaster->p_lqMode);
103

104
105
        _pgGenerator.s_invalidated.connect(this, &VolumeRenderer::onProcessorInvalidated);
        _eepGenerator.s_invalidated.connect(this, &VolumeRenderer::onProcessorInvalidated);
106
        _raycaster->s_invalidated.connect(this, &VolumeRenderer::onProcessorInvalidated);
107
108
109
    }

    void VolumeRenderer::deinit() {
110
111
        _pgGenerator.s_invalidated.disconnect(this);
        _eepGenerator.s_invalidated.disconnect(this);
112
        _raycaster->s_invalidated.disconnect(this);
113

114
115
        _pgGenerator.deinit();
        _eepGenerator.deinit();
116
        _raycaster->deinit();
117

118
119
120
        VisualizationProcessor::deinit();
    }

121
    void VolumeRenderer::updateResult(DataContainer& data) {
122
123
124
        if (getInvalidationLevel() & PG_INVALID) {
            _pgGenerator.process(data);
        }
125
        if (getInvalidationLevel() & EEP_INVALID) {
126
127
            _eepGenerator.process(data);
        }
128
        if (getInvalidationLevel() & RAYCASTER_INVALID) {
129
            _raycaster->process(data);
130
131
132
133
134
135
136
        }

        validate(INVALID_RESULT | PG_INVALID | EEP_INVALID | RAYCASTER_INVALID);
    }

    void VolumeRenderer::onProcessorInvalidated(AbstractProcessor* processor) {
        if (processor == &_pgGenerator) {
137
            invalidate(PG_INVALID | EEP_INVALID | RAYCASTER_INVALID);
138
139
        }
        else if (processor == &_eepGenerator) {
140
            invalidate(EEP_INVALID | RAYCASTER_INVALID);
141
        }
142
        else if (processor == _raycaster) {
143
144
145
146
147
148
149
150
151
            invalidate(RAYCASTER_INVALID);
        }

        invalidate(AbstractProcessor::INVALID_RESULT);
    }

    void VolumeRenderer::onPropertyChanged(const AbstractProperty* prop) {
        if (prop == &p_outputImage) {
            _pgGenerator.p_geometryID.setValue(p_outputImage.getValue() + ".geometry");
152
153
            _eepGenerator.p_geometryID.setValue(p_outputImage.getValue() + ".geometry");

154
            _eepGenerator.p_entryImageID.setValue(p_outputImage.getValue() + ".entrypoints");
155
            _raycaster->p_entryImageID.setValue(p_outputImage.getValue() + ".entrypoints");
156

157
            _eepGenerator.p_exitImageID.setValue(p_outputImage.getValue() + ".exitpoints");
158
            _raycaster->p_exitImageID.setValue(p_outputImage.getValue() + ".exitpoints");
159
160
161
162
        }
        VisualizationProcessor::onPropertyChanged(prop);
    }

163
164
    void VolumeRenderer::setViewportSizeProperty(IVec2Property* viewportSizeProp) {
        _eepGenerator.setViewportSizeProperty(viewportSizeProp);
165
        _raycaster->setViewportSizeProperty(viewportSizeProp);
166
167
168
169

        VisualizationProcessor::setViewportSizeProperty(viewportSizeProp);
    }

170
171
172
173
    void VolumeRenderer::updateProperties(DataContainer& dataContainer) {
        // nothing to do here
    }

174
175
}