LibreOffice Module basegfx (master) 1
b3drange.hxx
Go to the documentation of this file.
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
27
28namespace basegfx
29{
30 class B3DHomMatrix;
31
33 {
34 typedef ::basegfx::BasicRange< double, DoubleTraits > MyBasicRange;
35
39
40 public:
42
43 explicit B3DRange(const B3DTuple& rTuple)
44 : maRangeX(rTuple.getX()),
45 maRangeY(rTuple.getY()),
46 maRangeZ(rTuple.getZ())
47 {
48 }
49
50 B3DRange(double x1,
51 double y1,
52 double z1,
53 double x2,
54 double y2,
55 double z2)
56 : maRangeX(x1),
57 maRangeY(y1),
58 maRangeZ(z1)
59 {
60 maRangeX.expand(x2);
61 maRangeY.expand(y2);
62 maRangeZ.expand(z2);
63 }
64
65 B3DRange(const B3DTuple& rTuple1,
66 const B3DTuple& rTuple2)
67 : maRangeX(rTuple1.getX()),
68 maRangeY(rTuple1.getY()),
69 maRangeZ(rTuple1.getZ())
70 {
71 expand(rTuple2);
72 }
73
74 bool isEmpty() const
75 {
76 return (
77 maRangeX.isEmpty()
78 || maRangeY.isEmpty()
79 || maRangeZ.isEmpty()
80 );
81 }
82
83 void reset()
84 {
85 maRangeX.reset();
86 maRangeY.reset();
87 maRangeZ.reset();
88 }
89
90 bool operator==( const B3DRange& rRange ) const
91 {
92 return (maRangeX == rRange.maRangeX
93 && maRangeY == rRange.maRangeY
94 && maRangeZ == rRange.maRangeZ);
95 }
96
97 bool operator!=( const B3DRange& rRange ) const
98 {
99 return (maRangeX != rRange.maRangeX
100 || maRangeY != rRange.maRangeY
101 || maRangeZ != rRange.maRangeZ);
102 }
103
104 double getMinX() const
105 {
106 return maRangeX.getMinimum();
107 }
108
109 double getMinY() const
110 {
111 return maRangeY.getMinimum();
112 }
113
114 double getMinZ() const
115 {
116 return maRangeZ.getMinimum();
117 }
118
119 double getMaxX() const
120 {
121 return maRangeX.getMaximum();
122 }
123
124 double getMaxY() const
125 {
126 return maRangeY.getMaximum();
127 }
128
129 double getMaxZ() const
130 {
131 return maRangeZ.getMaximum();
132 }
133
134 double getWidth() const
135 {
136 return maRangeX.getRange();
137 }
138
139 double getHeight() const
140 {
141 return maRangeY.getRange();
142 }
143
144 double getDepth() const
145 {
146 return maRangeZ.getRange();
147 }
148
150 {
151 return B3DVector(
152 maRangeX.getRange(),
153 maRangeY.getRange(),
154 maRangeZ.getRange()
155 );
156 }
157
159 {
160 return B3DPoint(
161 maRangeX.getCenter(),
162 maRangeY.getCenter(),
163 maRangeZ.getCenter()
164 );
165 }
166
167 bool overlaps(const B3DRange& rRange) const
168 {
169 return (
170 maRangeX.overlaps(rRange.maRangeX)
171 && maRangeY.overlaps(rRange.maRangeY)
172 && maRangeZ.overlaps(rRange.maRangeZ)
173 );
174 }
175
176 void expand(const B3DTuple& rTuple)
177 {
178 maRangeX.expand(rTuple.getX());
179 maRangeY.expand(rTuple.getY());
180 maRangeZ.expand(rTuple.getZ());
181 }
182
183 void expand(const B3DRange& rRange)
184 {
185 maRangeX.expand(rRange.maRangeX);
186 maRangeY.expand(rRange.maRangeY);
187 maRangeZ.expand(rRange.maRangeZ);
188 }
189
190 void grow(double fValue)
191 {
192 maRangeX.grow(fValue);
193 maRangeY.grow(fValue);
194 maRangeZ.grow(fValue);
195 }
196
198 B3DTuple clamp(const B3DTuple& rTuple) const
199 {
200 return B3DTuple(
201 maRangeX.clamp(rTuple.getX()),
202 maRangeY.clamp(rTuple.getY()),
203 maRangeZ.clamp(rTuple.getZ()));
204 }
205
206 BASEGFX_DLLPUBLIC void transform(const B3DHomMatrix& rMatrix);
207
215 B3DRange& operator*=( const ::basegfx::B3DHomMatrix& rMat );
216
218 static const B3DRange& getUnitB3DRange();
219 };
220
223 B3DRange operator*( const B3DHomMatrix& rMat, const B3DRange& rB2DRange );
224
225} // end of namespace basegfx
226
227/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define BASEGFX_DLLPUBLIC
Definition: basegfxdllapi.h:35
Base Point class with three double values.
Definition: b3dpoint.hxx:38
double getMinZ() const
Definition: b3drange.hxx:114
bool operator!=(const B3DRange &rRange) const
Definition: b3drange.hxx:97
bool overlaps(const B3DRange &rRange) const
Definition: b3drange.hxx:167
B3DVector getRange() const
Definition: b3drange.hxx:149
B3DRange(double x1, double y1, double z1, double x2, double y2, double z2)
Definition: b3drange.hxx:50
double getHeight() const
Definition: b3drange.hxx:139
void grow(double fValue)
Definition: b3drange.hxx:190
B3DRange(const B3DTuple &rTuple)
Definition: b3drange.hxx:43
bool operator==(const B3DRange &rRange) const
Definition: b3drange.hxx:90
double getMaxZ() const
Definition: b3drange.hxx:129
double getMinX() const
Definition: b3drange.hxx:104
B3DRange(const B3DTuple &rTuple1, const B3DTuple &rTuple2)
Definition: b3drange.hxx:65
void expand(const B3DRange &rRange)
Definition: b3drange.hxx:183
bool isEmpty() const
Definition: b3drange.hxx:74
::basegfx::BasicRange< double, DoubleTraits > MyBasicRange
Definition: b3drange.hxx:34
B3DTuple clamp(const B3DTuple &rTuple) const
clamp value on range
Definition: b3drange.hxx:198
MyBasicRange maRangeX
Definition: b3drange.hxx:36
void expand(const B3DTuple &rTuple)
Definition: b3drange.hxx:176
double getDepth() const
Definition: b3drange.hxx:144
MyBasicRange maRangeY
Definition: b3drange.hxx:37
double getWidth() const
Definition: b3drange.hxx:134
MyBasicRange maRangeZ
Definition: b3drange.hxx:38
double getMinY() const
Definition: b3drange.hxx:109
double getMaxX() const
Definition: b3drange.hxx:119
B3DPoint getCenter() const
Definition: b3drange.hxx:158
double getMaxY() const
Definition: b3drange.hxx:124
Base class for all Points/Vectors with three double values.
Definition: b3dtuple.hxx:40
Base Point class with three double values.
Definition: b3dvector.hxx:38
bool overlaps(const BasicRange &rRange) const
Definition: basicrange.hxx:108
T clamp(T nValue) const
Definition: basicrange.hxx:250
bool isEmpty() const
Definition: basicrange.hxx:57
double getCenter() const
Definition: basicrange.hxx:65
T getMaximum() const
Definition: basicrange.hxx:63
T getMinimum() const
Definition: basicrange.hxx:62
void grow(T nValue)
Definition: basicrange.hxx:226
void expand(T nValue)
Definition: basicrange.hxx:152
Traits::DifferenceType getRange() const
Definition: basicrange.hxx:276
TYPE getX() const
Get X-Coordinate of 3D Tuple.
Definition: Tuple3D.hxx:57
TYPE getZ() const
Get Z-Coordinate of 3D Tuple.
Definition: Tuple3D.hxx:63
TYPE getY() const
Get Y-Coordinate of 3D Tuple.
Definition: Tuple3D.hxx:60
B2DPoint operator*(const ::basegfx::B2DHomMatrix &rMat, const B2DPoint &rPoint)
Definition: b2dpoint.cxx:43
#define SAL_WARN_UNUSED
SmFace & operator*=(SmFace &rFace, const Fraction &rFrac)