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

geometrydata.h 6.16 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
25
26
27
// 
// ================================================================================================

#ifndef GEOMETRYDATA_H__
#define GEOMETRYDATA_H__

28
#include "tgt/tgt_gl.h"
29
#include "tgt/bounds.h"
30
#include "core/datastructures/abstractdata.h"
31
#include <vector>
32

33
34
namespace tgt {
    class BufferObject;
35
    class GLCanvas;
36
37
}

schultezub's avatar
schultezub committed
38
namespace campvis {
39
    /**
40
     * Abstract base class for geometry data in CAMPVis.
41
     * 
42
43
44
45
46
47
48
49
50
51
52
     * GeometryData consists of a set of vertices (vec3) and optionally colors (vec4), texture 
     * coordinates (vec3) and/or normals (vec3) for each vertex.
     * GeometryData stores the geometry on the CPU side (local RAM) and takes care of transparently 
     * mapping it into GPU memory in order to render it using OpenGL. The mapping of vertex 
     * information to OpenGL vertex attributes is as follows:
     *  - Vertex positions: Vertex attribute 0
     *  - Vertex texture coordinates: Vertex attribute 1
     *  - Vertex colors: Vertex attribute 2
     *  - Vertex normals: Vertex attribute 3
     * 
     */    
53
    class CAMPVIS_CORE_API GeometryData : public AbstractData, public IHasWorldBounds {
54
    public:
55
56
57
58
59
        /**
         * Constructor
         * \param   vertexFeatures  List of features present for each vertex
         */
        explicit GeometryData();
60

61
62
63
64
        /**
         * Copy constructor
         * \param   rhs GeometryData to copy
         */
65
66
67
        GeometryData(const GeometryData& rhs);

        /**
68
         * Destructor, deletes VBOs/VAO if necessary.
69
         */
70
71
        virtual ~GeometryData();

72
73
74
75
76
        /**
         * Assignment operator.
         * \param   rhs GeometryData to assign to this.
         * \return  *this after assignment
         */
77
78
        GeometryData& operator=(const GeometryData& rhs);

79
        /// \see AbstractData::clone()
80
81
        virtual AbstractData* clone() const = 0;

82
83
84
85
        /**
         * Renders this GeometryData.
         * Must be called from a valid OpenGL context.
         */
86
        virtual void render(GLenum mode = GL_POLYGON) const = 0;
87
88
89
90
91
92
        
        /**
         * Returns the geometry extent in world coordinates.
         * \return  The geometry extent in world coordinates.
         */
        virtual tgt::Bounds getWorldBounds() const = 0;
93

94
95
96
97
98
99
100
101
102
103
104
105
        /**
         * Returns whether the geometry has texture coordinates.
         * \return  True if this geometry sets texture coordinates during rendering.
         */
        virtual bool hasTextureCoordinates() const = 0;

        /**
         * Applies the transformation matrix \a t to each vertex of this geometry.
         * \param   t   Transformation matrix to apply
         */
        virtual void applyTransformationToVertices(const tgt::mat4& t) = 0;

106
        /**
107
108
109
         * Returns the Pointer to the OpenGL Buffer with the vertex positions.
         * May be 0 if not yet created.
         * \return  _verticesBuffer
110
111
112
         */
        const tgt::BufferObject* getVerticesBuffer() const;

113
114
115
116
117
        /**
         * Returns the Pointer to the OpenGL Buffer with the vertex texture coordinates.
         * May be 0 if none are present or not yet created.
         * \return  _texCoordsBuffer
         */
118
119
        const tgt::BufferObject* getTextureCoordinatesBuffer() const;

120
121
122
123
124
        /**
         * Returns the Pointer to the OpenGL Buffer with the vertex colors. 
         * May be 0 if none are present or not yet created.
         * \return  _colorsBuffer
         */
125
126
        const tgt::BufferObject* getColorsBuffer() const;

127
128
129
130
131
        /**
         * Returns the Pointer to the OpenGL Buffer with the vertex normals.
         * May be 0 if none are present or not yet created.
         * \return  _normalsBuffer
         */
132
133
        const tgt::BufferObject* getNormalsBuffer() const;

134
135
136
        /// \see AbstractData::getVideoMemoryFootprint()
        virtual size_t getVideoMemoryFootprint() const;

137
    protected:
138
139
140
141
142
        /**
         * Deletes all OpenGL BufferObjects.
         */
        void deleteBuffers() const;

143
        // mutable to support const lazy initialization
144
        mutable bool _buffersDirty;             ///< Flag whether the buffers are dirty (i.e. need to be (re)initialized)
145

146
        enum { NUM_BUFFERS = 4 };               ///< Number of buffers in _buffers array
147
148
149

        union {
            struct {
150
151
152
153
                mutable tgt::BufferObject* _verticesBuffer;     ///< Pointer to the OpenGL Buffer with the vertex positions
                mutable tgt::BufferObject* _texCoordsBuffer;    ///< Pointer to the OpenGL Buffer with the vertex texture coordinates
                mutable tgt::BufferObject* _colorsBuffer;       ///< Pointer to the OpenGL Buffer with the vertex colors
                mutable tgt::BufferObject* _normalsBuffer;      ///< Pointer to the OpenGL Buffer with the vertex normals
154
155
            };

156
            mutable tgt::BufferObject* _buffers[NUM_BUFFERS];   ///< Array of all buffers
157
158
159
        };

    private:
160
161

        static const std::string loggerCat_;
162
163
164
165
166
    };

}

#endif // GEOMETRYDATA_H__