advancedusvis.cpp 5.48 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
46
47
        , _usFusion(_effectiveRenderTargetSize)
        , _wheelHandler(&_usFusion.p_sliceNumber)
        , _tfWindowingHandler(&_usFusion.p_transferFunction)
48
    {
49
50
51
        addProcessor(&_usReader);
        addProcessor(&_confidenceReader);
        addProcessor(&_gvg);
52
53
        //addProcessor(&_lhh);
        addProcessor(&_usFusion);
54
55
56
57
58
59
60
61
62
63
        addEventHandler(&_wheelHandler);
        addEventHandler(&_tfWindowingHandler);
    }

    AdvancedUsVis::~AdvancedUsVis() {
    }

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

64
65
        _usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\01\\BMode_01.mhd");
        _usReader.p_targetImageID.setValue("us.image");
66
        _usReader.p_targetImageID.connect(&_usFusion.p_usImageId);
67
68
        _usReader.p_targetImageID.connect(&_gvg.p_sourceImageID);
        _usReader.p_targetImageID.connect(&_lhh.p_intensitiesId);
69

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

74
        _gvg.p_targetImageID.connect(&_lhh.p_gradientsId);
75
        _gvg.p_targetImageID.connect(&_usFusion.p_gradientImageID);
76

77
78
        _usFusion.p_targetImageID.setValue("us.fused");
        _usFusion.p_sliceNumber.setValue(0);
79
80

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

85
        _usFusion.p_targetImageID.addSharedProperty(&(_renderTargetID));
86
87
88
89
90
91
92
93
94
    }

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

95
96
97
        for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) {
            if (! (*it)->getInvalidationLevel().isValid())
                lockGLContextAndExecuteProcessor(*it);
98
        }
99
100
101
//         if (! _usReader.getInvalidationLevel().isValid()) {
//             executeProcessor(&_usReader);
//         }
102
103
104
105
106
107
//         if (! _gvg.getInvalidationLevel().isValid()) {
//             executeProcessor(&_gvg);
//         }
//         if (! _lhh.getInvalidationLevel().isValid()) {
//             lockGLContextAndExecuteProcessor(&_lhh);
//         }
108
109
//         if (! _usFusion.getInvalidationLevel().isValid()) {
//             lockGLContextAndExecuteProcessor(&_usFusion);
110
//         }
111
112
113
114
115
116
    }

    void AdvancedUsVis::keyEvent(tgt::KeyEvent* e) {
        if (e->pressed()) {
            switch (e->keyCode()) {
                case tgt::KeyEvent::K_UP:
117
                    _usFusion.p_sliceNumber.increment();
118
119
                    break;
                case tgt::KeyEvent::K_DOWN:
120
                    _usFusion.p_sliceNumber.decrement();
121
122
123
124
125
126
127
128
129
130
                    break;
            }
        }
    }

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

}