Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

advoptimizedraycaster.cpp 5.24 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-2015, all rights reserved,
6
7
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
8
9
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// 
// 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.
// 
// ================================================================================================

#include "advoptimizedraycaster.h"

#include "core/tools/quadrenderer.h"
#include "core/datastructures/renderdata.h"
#include "core/pipeline/processordecoratorgradient.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/lightsourcedata.h"
#include "core/datastructures/geometrydatafactory.h"

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

    AdvOptimizedRaycaster::AdvOptimizedRaycaster(IVec2Property* viewportSizeProp)
        : RaycastingProcessor(viewportSizeProp, "modules/vis/glsl/advoptimizedraycaster.frag", true, "400")
        , p_enableShading("EnableShading", "Enable Shading", true)
        , p_lightId("LightId", "Input Light Source", "lightsource", DataNameProperty::READ)
        , _vhm(nullptr)
    {
        addDecorator(new ProcessorDecoratorGradient());

        addProperty(p_enableShading, INVALID_RESULT | INVALID_PROPERTIES | INVALID_SHADER);
        addProperty(p_lightId);

        setPropertyInvalidationLevel(p_transferFunction, INVALID_BBV | INVALID_RESULT);
49
        setPropertyInvalidationLevel(p_sourceImageID, INVALID_BBV | INVALID_PROPERTIES | INVALID_RESULT);
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

        decoratePropertyCollection(this);
    }

    AdvOptimizedRaycaster::~AdvOptimizedRaycaster() {
    }

    void AdvOptimizedRaycaster::init() {
        RaycastingProcessor::init();

        _vhm = new VoxelHierarchyMapper();
        invalidate(INVALID_BBV);
    }

    void AdvOptimizedRaycaster::deinit() {
        delete _vhm;
        RaycastingProcessor::deinit();
    }

    void AdvOptimizedRaycaster::processImpl(DataContainer& data, ImageRepresentationGL::ScopedRepresentation& image) {
70
        _shader->deactivate();
71
72
73
74
75
76

        if (getInvalidationLevel() & INVALID_BBV){
            _vhm->createHierarchy(image, p_transferFunction.getTF());
            validate(INVALID_BBV);
        }
        
77
        if (_vhm->getHierarchyTexture() == nullptr) {
78
79
80
81
82
83
84
85
86
            LERROR("Could not retreive voxel hierarchy lookup structure.");
            return;
        }

        ScopedTypedData<LightSourceData> light(data, p_lightId.getValue());

        if (p_enableShading.getValue() == false || light != nullptr) {
            _shader->activate();

87
88
89
90
91
            cgt::TextureUnit xorUnit, bbvUnit;
            xorUnit.activate();
            _vhm->getXorBitmaskTexture()->bind();
            _shader->setUniform("_xorBitmask", xorUnit.getUnitNumber());

92
            bbvUnit.activate();
93
            _vhm->getHierarchyTexture()->bind();
94
            {
95
                cgt::Shader::IgnoreUniformLocationErrorGuard guard(_shader);
96
97
                _shader->setUniform("_voxelHierarchy", bbvUnit.getUnitNumber());
                _shader->setUniform("_vhMaxMipMapLevel", static_cast<int>(_vhm->getMaxMipmapLevel()));
98
99
100
101
102
103
104
105
106
107
108
109
110
            }

            if (p_enableShading.getValue() && light != nullptr) {
                light->bind(_shader, "_lightSource");
            }

            FramebufferActivationGuard fag(this);
            createAndAttachTexture(GL_RGBA8);
            createAndAttachTexture(GL_RGBA32F);
            createAndAttachTexture(GL_RGBA32F);
            createAndAttachDepthTexture();


111
            static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 , GL_COLOR_ATTACHMENT2 };
112
            glDrawBuffers(4, buffers);
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

            glEnable(GL_DEPTH_TEST);
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

            QuadRdr.renderQuad();

            glDisable(GL_DEPTH_TEST);
            LGL_ERROR;

            glDrawBuffers(1, buffers);

            data.addData(p_targetImageID.getValue(), new RenderData(_fbo)); 
        }
    }

    std::string AdvOptimizedRaycaster::generateHeader() const {
        std::string toReturn = RaycastingProcessor::generateHeader();
        if (p_enableShading.getValue())
            toReturn += "#define ENABLE_SHADING\n";
        return toReturn;
    }

135
136
    void AdvOptimizedRaycaster::updateProperties(DataContainer& dataContainer) {
        RaycastingProcessor::updateProperties(dataContainer);
137
138
139
140
        validate(AbstractProcessor::INVALID_PROPERTIES);
    }

}