Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/basegfx/range/b3drange.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#pragma once
21
22
#include <basegfx/vector/b3dvector.hxx>
23
#include <basegfx/point/b3dpoint.hxx>
24
#include <basegfx/tuple/b3dtuple.hxx>
25
#include <basegfx/range/basicrange.hxx>
26
#include <basegfx/basegfxdllapi.h>
27
28
namespace basegfx
29
{
30
    class B3DHomMatrix;
31
32
    class SAL_WARN_UNUSED B3DRange
33
    {
34
        typedef ::basegfx::BasicRange< double, DoubleTraits >   MyBasicRange;
35
36
        MyBasicRange            maRangeX;
37
        MyBasicRange            maRangeY;
38
        MyBasicRange            maRangeZ;
39
40
    public:
41
10.8k
        B3DRange() {}
42
43
        explicit B3DRange(const B3DTuple& rTuple)
44
        :   maRangeX(rTuple.getX()),
45
            maRangeY(rTuple.getY()),
46
            maRangeZ(rTuple.getZ())
47
0
        {
48
0
        }
49
50
        B3DRange(double x1,
51
                 double y1,
52
                 double z1,
53
                 double x2,
54
                 double y2,
55
                 double z2)
56
0
        :   maRangeX(x1),
57
0
            maRangeY(y1),
58
0
            maRangeZ(z1)
59
0
        {
60
0
            maRangeX.expand(x2);
61
0
            maRangeY.expand(y2);
62
0
            maRangeZ.expand(z2);
63
0
        }
64
65
        B3DRange(const B3DTuple& rTuple1,
66
                 const B3DTuple& rTuple2)
67
        :   maRangeX(rTuple1.getX()),
68
            maRangeY(rTuple1.getY()),
69
            maRangeZ(rTuple1.getZ())
70
0
        {
71
0
            expand(rTuple2);
72
0
        }
73
74
        bool isEmpty() const
75
0
        {
76
0
            return (
77
0
                maRangeX.isEmpty()
78
0
                || maRangeY.isEmpty()
79
0
                || maRangeZ.isEmpty()
80
0
                );
81
0
        }
82
83
        void reset()
84
47.3k
        {
85
47.3k
            maRangeX.reset();
86
47.3k
            maRangeY.reset();
87
47.3k
            maRangeZ.reset();
88
47.3k
        }
89
90
        bool operator==( const B3DRange& rRange ) const
91
0
        {
92
0
            return (maRangeX == rRange.maRangeX
93
0
                && maRangeY == rRange.maRangeY
94
0
                && maRangeZ == rRange.maRangeZ);
95
0
        }
96
97
        bool operator!=( const B3DRange& rRange ) const
98
0
        {
99
0
            return (maRangeX != rRange.maRangeX
100
0
                || maRangeY != rRange.maRangeY
101
0
                || maRangeZ != rRange.maRangeZ);
102
0
        }
103
104
        double getMinX() const
105
0
        {
106
0
            return maRangeX.getMinimum();
107
0
        }
108
109
        double getMinY() const
110
0
        {
111
0
            return maRangeY.getMinimum();
112
0
        }
113
114
        double getMinZ() const
115
0
        {
116
0
            return maRangeZ.getMinimum();
117
0
        }
118
119
        double getMaxX() const
120
0
        {
121
0
            return maRangeX.getMaximum();
122
0
        }
123
124
        double getMaxY() const
125
0
        {
126
0
            return maRangeY.getMaximum();
127
0
        }
128
129
        double getMaxZ() const
130
0
        {
131
0
            return maRangeZ.getMaximum();
132
0
        }
133
134
        double getWidth() const
135
0
        {
136
0
            return maRangeX.getRange();
137
0
        }
138
139
        double getHeight() const
140
0
        {
141
0
            return maRangeY.getRange();
142
0
        }
143
144
        double getDepth() const
145
0
        {
146
0
            return maRangeZ.getRange();
147
0
        }
148
149
        B3DVector getRange() const
150
0
        {
151
0
            return B3DVector(
152
0
                maRangeX.getRange(),
153
0
                maRangeY.getRange(),
154
0
                maRangeZ.getRange()
155
0
                );
156
0
        }
157
158
        B3DPoint getCenter() const
159
0
        {
160
0
            return B3DPoint(
161
0
                maRangeX.getCenter(),
162
0
                maRangeY.getCenter(),
163
0
                maRangeZ.getCenter()
164
0
                );
165
0
        }
166
167
        bool overlaps(const B3DRange& rRange) const
168
0
        {
169
0
            return (
170
0
                maRangeX.overlaps(rRange.maRangeX)
171
0
                && maRangeY.overlaps(rRange.maRangeY)
172
0
                && maRangeZ.overlaps(rRange.maRangeZ)
173
0
                );
174
0
        }
175
176
        void expand(const B3DTuple& rTuple)
177
0
        {
178
0
            maRangeX.expand(rTuple.getX());
179
0
            maRangeY.expand(rTuple.getY());
180
0
            maRangeZ.expand(rTuple.getZ());
181
0
        }
182
183
        void expand(const B3DRange& rRange)
184
0
        {
185
0
            maRangeX.expand(rRange.maRangeX);
186
0
            maRangeY.expand(rRange.maRangeY);
187
0
            maRangeZ.expand(rRange.maRangeZ);
188
0
        }
189
190
        void grow(double fValue)
191
0
        {
192
0
            maRangeX.grow(fValue);
193
0
            maRangeY.grow(fValue);
194
0
            maRangeZ.grow(fValue);
195
0
        }
196
197
        /// clamp value on range
198
        B3DTuple clamp(const B3DTuple& rTuple) const
199
0
        {
200
0
            return B3DTuple(
201
0
                maRangeX.clamp(rTuple.getX()),
202
0
                maRangeY.clamp(rTuple.getY()),
203
0
                maRangeZ.clamp(rTuple.getZ()));
204
0
        }
205
206
         BASEGFX_DLLPUBLIC void transform(const B3DHomMatrix& rMatrix);
207
208
        /** Transform Range by given transformation matrix.
209
210
            This operation transforms the Range by transforming all eight possible
211
            extrema points (corners) of the given range and building a new one.
212
            This means that the range will grow evtl. when a shear and/or rotation
213
            is part of the transformation.
214
        */
215
        B3DRange& operator*=( const ::basegfx::B3DHomMatrix& rMat );
216
217
        /** Get a range filled with (0.0, 0.0, 0.0, 1.0, 1.0, 1.0) */
218
        static const B3DRange& getUnitB3DRange();
219
    };
220
221
    /** Transform B3DRange by given transformation matrix (see operator*=())
222
    */
223
    B3DRange operator*( const B3DHomMatrix& rMat, const B3DRange& rB2DRange );
224
225
} // end of namespace basegfx
226
227
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */