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

tfgeometry1d.cpp 4.26 KB
Newer Older
1
2
// ================================================================================================
// 
schultezub's avatar
schultezub committed
3
// This file is part of the CAMPVis Visualization Framework.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// 
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
//      Christian Schulte zu Berge (christian.szb@in.tum.de)
//      Chair for Computer Aided Medical Procedures
//      Technische Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, Germany
// 
// 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.
// 
// ================================================================================================

schultezub's avatar
schultezub committed
29
#include "tfgeometry1d.h"
30
31
32
33
34
35
36

#include "tgt/assert.h"
#include "tgt/texture.h"
#include "tgt/tgt_math.h"

#include <algorithm>

schultezub's avatar
schultezub committed
37
namespace campvis {
38

schultezub's avatar
schultezub committed
39
    bool operator< (const TFGeometry1D::KeyPoint& left, const TFGeometry1D::KeyPoint& right) {
40
41
42
        return left._position < right._position;
    }
    
schultezub's avatar
schultezub committed
43
    TFGeometry1D::TFGeometry1D(const std::vector<KeyPoint>& keyPoints)
44
45
46
47
48
        : _keyPoints(keyPoints)
    {
        std::sort(_keyPoints.begin(), _keyPoints.end());
    }

schultezub's avatar
schultezub committed
49
    TFGeometry1D::~TFGeometry1D() {
50
51
52

    }

schultezub's avatar
schultezub committed
53
    std::vector<TFGeometry1D::KeyPoint>& TFGeometry1D::getKeyPoints() {
54
55
56
        return _keyPoints;
    }

57
58
    void TFGeometry1D::renderIntoEditor() const {
        // TODO: get rid of intermediade mode?
59
60
61
        if (_keyPoints.size() < 2)
            return;

62
63
64
65
66
67
68
69
        glBegin(GL_QUADS);
        std::vector<KeyPoint>::const_iterator a = _keyPoints.begin();
        std::vector<KeyPoint>::const_iterator b = _keyPoints.begin()+1;
        for (/* already inited */; b != _keyPoints.end(); ++a, ++b) {
            glColor4ubv(a->_color.elem);
            float y = static_cast<float>(a->_color.a) / 255.f;
            glVertex2f(a->_position, 0.f);
            glVertex2f(a->_position, y);
70

71
72
73
74
            glColor4ubv(b->_color.elem);
            y = static_cast<float>(b->_color.a) / 255.f;
            glVertex2f(b->_position, y);
            glVertex2f(b->_position, 0.f);
75
        }
76
        glEnd();
77
78
    }

schultezub's avatar
schultezub committed
79
    void TFGeometry1D::render() const {
80
        // TODO: get rid of intermediade mode?
81
82
        if (_keyPoints.size() < 2)
            return;
83

84
85
86
87
88
89
        glBegin(GL_QUADS);
        std::vector<KeyPoint>::const_iterator a = _keyPoints.begin();
        std::vector<KeyPoint>::const_iterator b = _keyPoints.begin()+1;
        for (/* already inited */; b != _keyPoints.end(); ++a, ++b) {
            glColor4ubv(a->_color.elem);
            glVertex2f(a->_position, 0.f);
90
            glVertex2f(a->_position, 1.f);
91
92

            glColor4ubv(b->_color.elem);
93
            glVertex2f(b->_position, 1.f);
94
            glVertex2f(b->_position, 0.f);
95
96
97
        }
        glEnd();
    }
schultezub's avatar
schultezub committed
98
    TFGeometry1D* TFGeometry1D::createQuad(const tgt::vec2& interval, const tgt::col4& leftColor, const tgt::vec4& rightColor) {
99
100
101
102
103
        tgtAssert(interval.x >= 0.f && interval.y <= 1.f, "Interval out of bounds");

        std::vector<KeyPoint> keyPoints;
        keyPoints.push_back(KeyPoint(interval.x, leftColor));
        keyPoints.push_back(KeyPoint(interval.y, rightColor));
schultezub's avatar
schultezub committed
104
        return new TFGeometry1D(keyPoints);
105
106
107
108
    }


}