advancedusvis.cpp 5.87 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
//      Technische Universitt Mnchen
//      Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// 
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
// 
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// 
// ================================================================================================

#include "advancedusvis.h"

#include "tgt/event/keyevent.h"
33

34
35
36
37
38
39
40
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"

namespace campvis {

    AdvancedUsVis::AdvancedUsVis()
        : VisualizationPipeline()
41
42
        , _usReader()
        , _confidenceReader()
43
44
        , _gvg()
        , _lhh()
45
        , _usFusion(_effectiveRenderTargetSize)
schultezub's avatar
schultezub committed
46
        , _usFilter()
47
48
        , _wheelHandler(&_usFusion.p_sliceNumber)
        , _tfWindowingHandler(&_usFusion.p_transferFunction)
49
    {
50
51
52
        addProcessor(&_usReader);
        addProcessor(&_confidenceReader);
        addProcessor(&_gvg);
53
54
        //addProcessor(&_lhh);
        addProcessor(&_usFusion);
schultezub's avatar
schultezub committed
55
        addProcessor(&_usFilter);
56
57
58
59
60
61
62
63
64
65
        addEventHandler(&_wheelHandler);
        addEventHandler(&_tfWindowingHandler);
    }

    AdvancedUsVis::~AdvancedUsVis() {
    }

    void AdvancedUsVis::init() {
        VisualizationPipeline::init();

66
67
        _usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\01\\BMode_01.mhd");
        _usReader.p_targetImageID.setValue("us.image");
68
        _usReader.p_targetImageID.connect(&_usFusion.p_usImageId);
69
70
        _usReader.p_targetImageID.connect(&_gvg.p_sourceImageID);
        _usReader.p_targetImageID.connect(&_lhh.p_intensitiesId);
schultezub's avatar
schultezub committed
71
        _usReader.p_targetImageID.connect(&_usFilter.p_sourceImageID);
72

73
74
        _confidenceReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\01\\Confidence_01.mhd");
        _confidenceReader.p_targetImageID.setValue("confidence.image");
75
        _confidenceReader.p_targetImageID.connect(&_usFusion.p_confidenceImageID);
76

77
        _gvg.p_targetImageID.connect(&_lhh.p_gradientsId);
78
        _gvg.p_targetImageID.connect(&_usFusion.p_gradientImageID);
79

80
81
        _usFusion.p_targetImageID.setValue("us.fused");
        _usFusion.p_sliceNumber.setValue(0);
82
        _usFusion.p_view.setValue(0);
83

schultezub's avatar
schultezub committed
84
        _usFilter.p_targetImageID.setValue("us.filtered");
85
        _usFilter.p_targetImageID.connect(&_usFusion.p_blurredImageId);
schultezub's avatar
schultezub committed
86
        _usFilter.p_filterMode.selectById("gauss");
87
        _usFilter.p_sigma.setValue(4.f);
schultezub's avatar
schultezub committed
88

89
        // TODO: replace this hardcoded domain by automatically determined from image min/max values
90
        Geometry1DTransferFunction* tf = new Geometry1DTransferFunction(128, tgt::vec2(0.f, 1.f));
91
        tf->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 0), tgt::col4(255, 255, 255, 255)));
92
        _usFusion.p_transferFunction.replaceTF(tf);
93

94
        _usFusion.p_targetImageID.addSharedProperty(&(_renderTargetID));
95
96
97
98
99
100
101
102
103
    }

    void AdvancedUsVis::execute() {
        {
            tbb::spin_mutex::scoped_lock lock(_localMutex);
            _invalidationLevel.setValid();
            // TODO:    think whether we want to lock all processors already here.
        }

104
105
106
        for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) {
            if (! (*it)->getInvalidationLevel().isValid())
                lockGLContextAndExecuteProcessor(*it);
107
        }
108
109
110
//         if (! _usReader.getInvalidationLevel().isValid()) {
//             executeProcessor(&_usReader);
//         }
111
112
113
114
115
116
//         if (! _gvg.getInvalidationLevel().isValid()) {
//             executeProcessor(&_gvg);
//         }
//         if (! _lhh.getInvalidationLevel().isValid()) {
//             lockGLContextAndExecuteProcessor(&_lhh);
//         }
117
118
//         if (! _usFusion.getInvalidationLevel().isValid()) {
//             lockGLContextAndExecuteProcessor(&_usFusion);
119
//         }
120
121
122
123
124
125
    }

    void AdvancedUsVis::keyEvent(tgt::KeyEvent* e) {
        if (e->pressed()) {
            switch (e->keyCode()) {
                case tgt::KeyEvent::K_UP:
126
                    _usFusion.p_sliceNumber.increment();
127
128
                    break;
                case tgt::KeyEvent::K_DOWN:
129
                    _usFusion.p_sliceNumber.decrement();
130
131
132
133
134
135
136
137
138
139
                    break;
            }
        }
    }

    const std::string AdvancedUsVis::getName() const {
        return "AdvancedUsVis";
    }

}