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

tfgeometry1d.h 7.38 KB
Newer Older
1
2
// ================================================================================================
// 
schultezub's avatar
schultezub committed
3
// This file is part of the CAMPVis Software Framework.
4
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
schultezub's avatar
schultezub committed
6
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
7
//      Chair for Computer Aided Medical Procedures
8
9
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
10
// 
schultezub's avatar
schultezub committed
11
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
12
// 
13
14
15
16
// 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
17
// 
18
19
20
21
// 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.
22
23
24
// 
// ================================================================================================

schultezub's avatar
schultezub committed
25
26
#ifndef TFGEOMETRY1D_H__
#define TFGEOMETRY1D_H__
27

28
#include "sigslot/sigslot.h"
29
#include "cgt/vector.h"
30
31
#include <vector>

32
33
#include "core/coreapi.h"

34
namespace cgt {
35
36
37
    class Texture;
}

schultezub's avatar
schultezub committed
38
namespace campvis {
39
    class FaceGeometry;
40
41
42

    /**
     * Defines a single shape for the GeometryTransferFunction class.
schultezub's avatar
schultezub committed
43
     * TFGeometry1D is defined by a sorted list of KeyPoints, each having a position and a color.
44
     */
45
    class CAMPVIS_CORE_API TFGeometry1D {
46
    public:
47
        struct CAMPVIS_CORE_API KeyPoint {
48
            explicit KeyPoint(float position, const cgt::col4& color)
49
50
51
52
53
                : _position(position)
                , _color(color)
            {};

            float _position;
54
            cgt::col4 _color;
55
56
57
        };

        /**
schultezub's avatar
schultezub committed
58
         * Creates a new TFGeometry1D
59
60
         * \param   Bounds  Bounds of the position of the geometry in texture coordinates.
         */
61
        explicit TFGeometry1D(const std::vector<KeyPoint>& keyPoints);
62
63
64
65

        /**
         * Virtual destructor
         */
schultezub's avatar
schultezub committed
66
        virtual ~TFGeometry1D();
67

68
69
70
71
72
73
        /**
         * Clones this transfer function geometry.
         * \return  A clone of this transfer function geometry, caller takes ownership of the pointer.
         */
        TFGeometry1D* clone() const;

74
75
76
77
78
        /**
         * Returns the vector of KeyPoints.
         * \return 
         */
        std::vector<KeyPoint>& getKeyPoints();
79
        
80
        /**
81
82
83
84
         * Renders this transfer function geometry to the current active OpenGL context for usage in editor.
         * \note    Must be called from an active and valid OpenGL context.
         * \todo    Check, whether this method really belongs here (core) or better fits into
         *          an other class in the application (GUI) module.
85
         */
86
        void renderIntoEditor() const;
87

88
89
90
        /**
         * Renders this transfer function geometry to the current active OpenGL context.
         * \note    Must be called from an active and valid OpenGL context.
91
92
         * \todo    Check, whether this method really belongs here (core) or better fits into
         *          an other class in the application (GUI) module.
93
94
95
         */
        void render() const;

96
        /// Signal to be emitted when this TF geometry has changed.
97
        sigslot::signal0 s_changed;
98
99
100
101
102
103
104
105
106
107
108
109
110
111
        
        /**
         * Adds a new KeyPoint
         * \param   position    Position of new KeyPoint
         * \param   color       Alpha of color of new KeyPoint. Color is interpolated from neighbors
         */
        void addKeyPoint(float position, float alpha);

        /**
         * Adds a new KeyPoint
         * \param   position    Position of new KeyPoint
         * \param   alpha       Color for left KeyPoint
         */
        void addKeyPoint(float position, const cgt::col4& color);
112

113
114
115
116
117
        /**
         * Returns the intensity domain of this TFGeometry1D.
         */
        cgt::vec2 getIntensityDomain() const;

118
119
120
        /**
         * Creates a simple quad geometry for the given interval.
         * A quad geometry consists of two KeyPoints.
121
         * \param   interval    Interval the geometry resides in, must be in [0, 1].
122
123
         * \param   leftColor   Color for left KeyPoint
         * \param   rightColor  Color for right KeyPoint
schultezub's avatar
schultezub committed
124
         * \return  A TFGeometry1D modelling a quad with two KeyPoints.
125
         */
126
        static TFGeometry1D* createQuad(const cgt::vec2& interval, const cgt::col4& leftColor, const cgt::col4& rightColor);
127
128
129
130
131
132
133
134
        
        /**
         * Creates a ramp geometry for the given interval.
         * A quad geometry consists of two KeyPoints, the left one having 0 opacity, the right one with full opacity.
         * \param   interval    Interval the geometry resides in, must be in [0, 1].
         * \param   color       Color for ramp
         * \return  A TFGeometry1D modelling a ramp with two KeyPoints.
         */
135
        static TFGeometry1D* crateRamp(const cgt::vec2& interval, const cgt::col4& color);
136
137
138
139
140
141
142
143

        /**
         * Creates a diverging color map of two diverging colors blending over white.
         * \param   interval    Interval the geometry resides in, must be in [0, 1].
         * \param   leftColor   Color for left diverging color.
         * \param   rightColor  Color for right diverging color
         * \return  A TFGeometry1D modelling a diverging color map with three key points.
         */
144
        static TFGeometry1D* createDivergingColorMap(const cgt::vec2& interval, const cgt::col4& leftColor, const cgt::col4& rightColor, float bias = 0.5f);
145
146
147
148
149
150

        /**
         * Creates the cold-hot color map blending blue to red via white.
         * \param   interval    Intensity domain for color map, must be in [0, 1].
         * \return  A TFGeometry1D building the cold-hot color map for the given interval.
         */
151
        static TFGeometry1D* createColdHotColorMap(const cgt::vec2& interval = cgt::vec2(0.f, 1.f));
152
153
154
155
156
157

        /**
         * Creates the heated body color map blending black-red-yellow-white.
         * \param   interval    Intensity domain for color map, must be in [0, 1].
         * \return  A TFGeometry1D building the heated body color map for the given interval.
         */
158
        static TFGeometry1D* createHeatedBodyColorMap(const cgt::vec2& interval = cgt::vec2(0.f, 1.f));
159

160
161
162
    protected:

        std::vector<KeyPoint> _keyPoints;       ///< vector of KeyPoints, KeyPoints are sorted by x-coordinate of the position
163
164
        FaceGeometry* _tfRenderFace;            ///< FaceGeometry used to render TF into the TF texture
        FaceGeometry* _tfEditorFace;            ///< FaceGeometry used to render TF into editor window
165
166
167
168
169
170
171
172
173
174
    };

// ================================================================================================

    /**
     * Less operator for sorting KeyPoints by their position.
     * \param   left    Left KeyPoint to compare
     * \param   right   RightKeyPoint to compare
     * \return  left._position < right._position
     */
175
    CAMPVIS_CORE_API bool operator< (const TFGeometry1D::KeyPoint& left, const TFGeometry1D::KeyPoint& right);
176
177
178

}

schultezub's avatar
schultezub committed
179
#endif // TFGEOMETRY1D_H__