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

bounds.cpp 4.51 KB
Newer Older
schultezub's avatar
schultezub committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**********************************************************************
 *                                                                    *
 * tgt - Tiny Graphics Toolbox                                        *
 *                                                                    *
 * Copyright (C) 2006-2011 Visualization and Computer Graphics Group, *
 * Department of Computer Science, University of Muenster, Germany.   *
 * <http://viscg.uni-muenster.de>                                     *
 *                                                                    *
 * This file is part of the tgt library. This library is free         *
 * software; you can redistribute it and/or modify it under the terms *
 * of the GNU Lesser General Public License version 2.1 as published  *
 * by the Free Software Foundation.                                   *
 *                                                                    *
 * This library is distributed in the hope that it will be useful,    *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the       *
 * GNU Lesser General Public License for more details.                *
 *                                                                    *
 * You should have received a copy of the GNU Lesser General Public   *
 * License in the file "LICENSE.txt" along with this library.         *
 * If not, see <http://www.gnu.org/licenses/>.                        *
 *                                                                    *
 **********************************************************************/

25
#include "cgt/bounds.h"
schultezub's avatar
schultezub committed
26
27
28

#include <algorithm>

29
#include "cgt/assert.h"
schultezub's avatar
schultezub committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

namespace tgt {

using std::min;
using std::max;

void Bounds::addPoint(const Vector& v) {
    if (points_ < 2) {
        ++points_;
        if (points_ == 1) {
            llf_ = v; urb_ = v;
            return;
        }
    }

    llf_ = min(llf_, v);
    urb_ = max(urb_, v);
}

bool Bounds::insideXZ(const Bounds& bounds) const {
    tgtAssert(       isDefined(), "This Box ist not defined.");
    tgtAssert(bounds.isDefined(), "Box b ist not defined.");

    vec3 llfb = bounds.getLLF();
    vec3 urbb = bounds.getURB();

    float r0x = min(llf_[0], urb_[0]);
    float r1x = max(llf_[0], urb_[0]);
    float r0y = min(llf_[2], urb_[2]);
    float r1y = max(llf_[2], urb_[2]);
    float r2x = min(llfb[0], urbb[0]);
    float r3x = max(llfb[0], urbb[0]);
    float r2y = min(llfb[2], urbb[2]);
    float r3y = max(llfb[2], urbb[2]);

    return (r0x >= r2x) && (r0y >= r2y)
        && (r1x <= r3x) && (r1y <= r3y);
}

bool Bounds::insideXZ(const vec3& v) const {
    tgtAssert(  isDefined(), "This Box ist not defined.");

    return (llf_[0] <= v[0]) && (v[0] <= urb_[0])
        && (llf_[2] <= v[2]) && (v[2] <= urb_[2]);
}

bool Bounds::inside(const Bounds& bounds) const {
    tgtAssert(       isDefined(), "This Box ist not defined.");
    tgtAssert(bounds.isDefined(), "Box b ist not defined.");

    vec3 llfb = bounds.getLLF();
    vec3 urbb = bounds.getURB();

    float r0x = min(llf_[0], urb_[0]);
    float r1x = max(llf_[0], urb_[0]);
    float r0y = min(llf_[1], urb_[1]);
    float r1y = max(llf_[1], urb_[1]);
    float r0z = min(llf_[2], urb_[2]);
    float r1z = max(llf_[2], urb_[2]);

    float r2x = min(llfb[0], urbb[0]);
    float r3x = max(llfb[0], urbb[0]);
    float r2y = min(llfb[1], urbb[1]);
    float r3y = max(llfb[1], urbb[1]);
    float r2z = min(llfb[2], urbb[2]);
    float r3z = max(llfb[2], urbb[2]);

    return (r0x >= r2x) && (r1x <= r3x)
        && (r0y >= r2y) && (r1y <= r3y)
        && (r0z >= r2z) && (r1z <= r3z);
}

bool Bounds::inside(const vec3& v) const {
    tgtAssert(  isDefined(), "This Box ist not defined.");

    return (llf_[0] <= v[0]) && (v[0] <= urb_[0])
        && (llf_[1] <= v[1]) && (v[1] <= urb_[1])
        && (llf_[2] <= v[2]) && (v[2] <= urb_[2]);
}

Bounds Bounds::transform(const mat4& m) const {
    Bounds b;
    b.addPoint(m * vec3(llf_.x, llf_.y, llf_.z));
    b.addPoint(m * vec3(urb_.x, llf_.y, llf_.z));
    b.addPoint(m * vec3(llf_.x, urb_.y, llf_.z));
    b.addPoint(m * vec3(llf_.x, llf_.y, urb_.z));
    b.addPoint(m * vec3(urb_.x, urb_.y, llf_.z));
    b.addPoint(m * vec3(llf_.x, urb_.y, urb_.z));
    b.addPoint(m * vec3(urb_.x, llf_.y, urb_.z));
    b.addPoint(m * vec3(urb_.x, urb_.y, urb_.z));
    return b;
}

/// ostream-operator
std::ostream& operator<< (std::ostream& o, const Bounds& b) {
    return (o << "(llf: " << b.getLLF() << " urb: " << b.getURB() << ")");
}

} // namespace