advdvrvis.cpp 3.12 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
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
//      Technische Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, Germany
// 
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// 
// 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
// 
// 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.
// 
// ================================================================================================

25
#include "advdvrvis.h"
26

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

#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"

33
#include "modules/vis/processors/advoptimizedraycaster.h"
34

35
36
37
38
namespace campvis {

    AdvDVRVis::AdvDVRVis(DataContainer* dc)
        : AutoEvaluationPipeline(dc)
39
        , _tcp(&_canvasSize)
40
        , _lsp()
41
        , _imageReader()
42
        , _vr(&_canvasSize, new AdvOptimizedRaycaster(&_canvasSize))
43
    {
44
45
        _tcp.addLqModeProcessor(&_vr);
        addEventListenerToBack(&_tcp);
46

47
        addProcessor(&_tcp);
48
        addProcessor(&_lsp);
49
        addProcessor(&_imageReader);
50
        addProcessor(&_vr);
51
52
53
    }

    AdvDVRVis::~AdvDVRVis() {
54

55
56
57
58
59
    }

    void AdvDVRVis::init() {
        AutoEvaluationPipeline::init();

60
        _vr.p_outputImage.setValue("combine");
61
62
        _renderTargetID.setValue("combine");

63
64
65
        _imageReader.p_url.setValue(ShdrMgr.completePath("/modules/vis/sampledata/smallHeart.mhd"));
        _imageReader.p_targetImageID.setValue("reader.output");
        _imageReader.p_targetImageID.addSharedProperty(&_vr.p_inputVolume);
66
        _imageReader.p_targetImageID.addSharedProperty(&_tcp.p_image);
67

68
69
70
71
        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)));
72
73
        static_cast<TransferFunctionProperty*>(_vr.getNestedProperty("RaycasterProps::TransferFunction"))->replaceTF(dvrTF);
        static_cast<FloatProperty*>(_vr.getNestedProperty("RaycasterProps::SamplingRate"))->setValue(4.f);
74
75
76
    }

}