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.44 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
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".
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 
// 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
30
#include "tfgeometry1d.h"
31
32
33
34
35
36
37

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

#include <algorithm>

schultezub's avatar
schultezub committed
38
namespace campvis {
39

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

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

    }

54
55
56
57
    TFGeometry1D* TFGeometry1D::clone() const {
        return new TFGeometry1D(_keyPoints);
    }

schultezub's avatar
schultezub committed
58
    std::vector<TFGeometry1D::KeyPoint>& TFGeometry1D::getKeyPoints() {
59
60
61
        return _keyPoints;
    }

62
63
    void TFGeometry1D::renderIntoEditor() const {
        // TODO: get rid of intermediade mode?
64
65
66
        if (_keyPoints.size() < 2)
            return;

67
68
69
70
71
72
73
74
        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);
75

76
77
78
79
            glColor4ubv(b->_color.elem);
            y = static_cast<float>(b->_color.a) / 255.f;
            glVertex2f(b->_position, y);
            glVertex2f(b->_position, 0.f);
80
        }
81
        glEnd();
82
83
    }

schultezub's avatar
schultezub committed
84
    void TFGeometry1D::render() const {
85
        // TODO: get rid of intermediade mode?
86
87
        if (_keyPoints.size() < 2)
            return;
88

89
90
91
92
93
94
        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);
95
            glVertex2f(a->_position, 1.f);
96
97

            glColor4ubv(b->_color.elem);
98
            glVertex2f(b->_position, 1.f);
99
            glVertex2f(b->_position, 0.f);
100
101
102
        }
        glEnd();
    }
schultezub's avatar
schultezub committed
103
    TFGeometry1D* TFGeometry1D::createQuad(const tgt::vec2& interval, const tgt::col4& leftColor, const tgt::vec4& rightColor) {
104
105
106
107
108
        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
109
        return new TFGeometry1D(keyPoints);
110
111
112
113
    }


}