The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated 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.cpp 4.61 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, 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 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".
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// 
// 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.
// 
// ================================================================================================

#include "geometrydata.h"
31
32
#include "tgt/buffer.h"
#include "tgt/vertexarrayobject.h"
33
#include "tgt/glcontextmanager.h"
34

35
36
#include "core/tools/opengljobprocessor.h"

schultezub's avatar
schultezub committed
37
namespace campvis {
38
39
40

    GeometryData::GeometryData() 
        : AbstractData()
41
42
43
44
45
        , _buffersInitialized(false)
        , _verticesBuffer(0)
        , _texCoordsBuffer(0)
        , _colorsBuffer(0)
        , _normalsBuffer(0)
46
        , _context(0)
47
48
49
    {
    }

50
51
52
53
54
55
56
57
58
59
60
    GeometryData::GeometryData(const GeometryData& rhs)
        : AbstractData(rhs)
        , _buffersInitialized(false)
        , _verticesBuffer(0)
        , _texCoordsBuffer(0)
        , _colorsBuffer(0)
        , _normalsBuffer(0)
    {

    }

61
    GeometryData::~GeometryData() {
62
        if (_buffersInitialized) {
63
64
65
66
            delete _verticesBuffer;
            delete _texCoordsBuffer;
            delete _colorsBuffer;
            delete _normalsBuffer;
67
        }
68
69
70
71
72
73
74
75
76
    }

    GeometryData& GeometryData::operator=(const GeometryData& rhs) {
        if (this == &rhs)
            return *this;

        AbstractData::operator=(rhs);

        // delete old VBOs and null pointers
77
        if (_buffersInitialized) {
78
79
80
81
            delete _verticesBuffer;
            delete _texCoordsBuffer;
            delete _colorsBuffer;
            delete _normalsBuffer;
82
        }
83

84
        _verticesBuffer = 0;
85
86
87
88
        _texCoordsBuffer = 0;
        _colorsBuffer = 0;
        _normalsBuffer = 0;
        _buffersInitialized = false;
89

90
91
92
        return *this;
    }

93
94
95
96
97
    void GeometryData::deleteBuffers(std::vector<tgt::BufferObject*> buffers) {
        for (std::vector<tgt::BufferObject*>::iterator it = buffers.begin(); it != buffers.end(); ++it)
            delete *it;
    }

98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
    size_t GeometryData::getVideoMemoryFootprint() const {
        size_t sum = 0;

        if (_verticesBuffer != 0)
            sum += _verticesBuffer->getBufferSize();
        if (_texCoordsBuffer != 0)
            sum += _texCoordsBuffer->getBufferSize();
        if (_colorsBuffer != 0)
            sum += _colorsBuffer->getBufferSize();
        if (_normalsBuffer != 0)
            sum += _normalsBuffer->getBufferSize();

        return sum;
    }

113
114
    void GeometryData::createGLBuffers() const {
        if (! _buffersInitialized) 
115
            _context = tgt::GlContextManager::getRef().getCurrentContext();
116
117
    }

118
119
120
121
122
123
124
125
126
127
128
129
130
131
    const tgt::BufferObject* GeometryData::getVerticesBuffer() const {
        return _verticesBuffer;
    }

    const tgt::BufferObject* GeometryData::getTextureCoordinatesBuffer() const {
        return _texCoordsBuffer;
    }

    const tgt::BufferObject* GeometryData::getColorsBuffer() const {
        return _colorsBuffer;
    }

    const tgt::BufferObject* GeometryData::getNormalsBuffer() const {
        return _normalsBuffer;
132
133
134
    }

}