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

clraycaster.h 6.66 KB
Newer Older
schultezub's avatar
schultezub committed
1
2
// ================================================================================================
// 
schultezub's avatar
schultezub committed
3
// This file is part of the CAMPVis Software Framework.
schultezub's avatar
schultezub committed
4
5
// 
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
schultezub's avatar
schultezub committed
6
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
schultezub's avatar
schultezub committed
7
8
9
//      Chair for Computer Aided Medical Procedures
//      Technische Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, Germany
schultezub's avatar
schultezub committed
10
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
schultezub's avatar
schultezub committed
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
// 
// 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.
// 
// ================================================================================================

#ifndef CLRAYCASTER_H__
#define CLRAYCASTER_H__

#include <string>

#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/cameraproperty.h"
schultezub's avatar
schultezub committed
37
#include "core/properties/datanameproperty.h"
schultezub's avatar
schultezub committed
38
39
40
41
42
43
44
45
46
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/transferfunctionproperty.h"

#include "kisscl/kisscl.h"

namespace kisscl {
    class Context;
    class Image;
schultezub's avatar
KissCL:    
schultezub committed
47
    class GLTexture;
schultezub's avatar
schultezub committed
48
49
50
    class Program;
}

schultezub's avatar
schultezub committed
51
namespace campvis {
schultezub's avatar
schultezub committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    /**
     * Proof of concept processor for OpenCL based Volume raycasting.
     */
    class CLRaycaster : public VisualizationProcessor {
    public:
        /**
         * Creates a CLRaycaster.
         * \note    The render target size property of this CLRaycaster will automatically 
         *          be assigned as shared property of the given \a renderTargetSize property.
         * \see     VisualizationProcessor
         * \param   renderTargetSize            Reference to the parent pipeline's render target size property.
         * \param   fragmentShaderFileName      Filename for the fragment shader being automatically loaded.
         * \param   bindEntryExitDepthTextures  Flag whether to also bind the depth textures of the entry-/exit points.
         */
66
        CLRaycaster(IVec2Property& renderTargetSize);
schultezub's avatar
schultezub committed
67
68
69
70
71
72
73
74
75
76

        /**
         * Destructor
         **/
        virtual ~CLRaycaster();

        /// \see AbstractProcessor::getName()
        virtual const std::string getName() const { return "CLRaycaster"; };
        /// \see AbstractProcessor::getDescription()
        virtual const std::string getDescription() const { return "Proof of concept processor for OpenCL based Volume raycasting."; };
77
78
79
80
        /// \see AbstractProcessor::getAuthor()
        virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
        /// \see AbstractProcessor::getProcessorState()
        virtual const ProcessorState getProcessorState() const { return AbstractProcessor::EXPERIMENTAL; };
schultezub's avatar
schultezub committed
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

        /**
         * Initalizes the Processor, loads and builds the shader.
         * \see     AbstractProcessor::init
         * \note    When overwriting this method, make sure to call the base class version first.
         */
        virtual void init();

        /**
         * Disposes the shader and deinitializes the processor.
         * \see     AbstractProcessor::deinit
         * \note    When overwriting this method, make sure to call the base class version at the end.
         */
        virtual void deinit();

        /**
         * Performs sanity checks, sets up the rendering and calls CLRaycaster::processImpl().
         * This method first reads the input image, entry and exit points from \a data and validates them. On sucess
         * the shader will be rebuild if necessary, the shader will be activated, common uniforms will be set and
         * the textures and transfer function will be bound before calling processImpl().
         *
         * \sa      CLRaycaster::processImpl()
         * \param   data    DataContainer to work on.
         */
        virtual void process(DataContainer& data);

schultezub's avatar
schultezub committed
107
108
109
110
        DataNameProperty _sourceImageID;                ///< image ID for input image
        DataNameProperty _entryImageID;                 ///< image ID for output entry points image
        DataNameProperty _exitImageID;                  ///< image ID for output exit points image
        DataNameProperty _targetImageID;                ///< image ID for output image
schultezub's avatar
schultezub committed
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

        CameraProperty _camera;                         ///< Camera used for ray casting
        TransferFunctionProperty _transferFunction;     ///< Transfer function
        FloatProperty _samplingStepSize;                ///< Ray casting step size
        BoolProperty _jitterEntryPoints;                ///< Flag whether to jitter the entry points

    protected:

        /**
         * Returns an additional header that will be linked into the fragment shader.
         * Gets calles when building \a _shader. Overwrite this method to add a processor specific header to
         * your fragment shader.
         * \note    When overwriting this method make sure to call the base class version and append its result.
         * \return  The current default implementation returns an empty string.
         */
        virtual std::string generateHeader() const;

        kisscl::Context* _clContext;
        kisscl::Program* _clProgram;

        kisscl::Image* _imgVolume;
        clock_t _volumeTimestamp;
        kisscl::Image* _imgTf;
        clock_t _tfTimestamp;
schultezub's avatar
KissCL:    
schultezub committed
135
136
137
        kisscl::GLTexture* _texEntryPointsColor;
        kisscl::GLTexture* _texExitPointsColor;
        kisscl::GLTexture* _texOutColor;
schultezub's avatar
schultezub committed
138
139
140
141
142
143
144
145
146



        static const std::string loggerCat_;
    };

}

#endif // CLRAYCASTER_H__