1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
32 class SAL_WARN_UNUSED B3DRange
34 typedef ::basegfx::BasicRange
< double, DoubleTraits
> MyBasicRange
;
36 MyBasicRange maRangeX
;
37 MyBasicRange maRangeY
;
38 MyBasicRange maRangeZ
;
43 explicit B3DRange(const B3DTuple
& rTuple
)
44 : maRangeX(rTuple
.getX()),
45 maRangeY(rTuple
.getY()),
46 maRangeZ(rTuple
.getZ())
65 B3DRange(const B3DTuple
& rTuple1
,
66 const B3DTuple
& rTuple2
)
67 : maRangeX(rTuple1
.getX()),
68 maRangeY(rTuple1
.getY()),
69 maRangeZ(rTuple1
.getZ())
90 bool operator==( const B3DRange
& rRange
) const
92 return (maRangeX
== rRange
.maRangeX
93 && maRangeY
== rRange
.maRangeY
94 && maRangeZ
== rRange
.maRangeZ
);
97 bool operator!=( const B3DRange
& rRange
) const
99 return (maRangeX
!= rRange
.maRangeX
100 || maRangeY
!= rRange
.maRangeY
101 || maRangeZ
!= rRange
.maRangeZ
);
104 double getMinX() const
106 return maRangeX
.getMinimum();
109 double getMinY() const
111 return maRangeY
.getMinimum();
114 double getMinZ() const
116 return maRangeZ
.getMinimum();
119 double getMaxX() const
121 return maRangeX
.getMaximum();
124 double getMaxY() const
126 return maRangeY
.getMaximum();
129 double getMaxZ() const
131 return maRangeZ
.getMaximum();
134 double getWidth() const
136 return maRangeX
.getRange();
139 double getHeight() const
141 return maRangeY
.getRange();
144 double getDepth() const
146 return maRangeZ
.getRange();
149 B3DVector
getRange() const
158 B3DPoint
getCenter() const
161 maRangeX
.getCenter(),
162 maRangeY
.getCenter(),
167 bool overlaps(const B3DRange
& rRange
) const
170 maRangeX
.overlaps(rRange
.maRangeX
)
171 && maRangeY
.overlaps(rRange
.maRangeY
)
172 && maRangeZ
.overlaps(rRange
.maRangeZ
)
176 void expand(const B3DTuple
& rTuple
)
178 maRangeX
.expand(rTuple
.getX());
179 maRangeY
.expand(rTuple
.getY());
180 maRangeZ
.expand(rTuple
.getZ());
183 void expand(const B3DRange
& rRange
)
185 maRangeX
.expand(rRange
.maRangeX
);
186 maRangeY
.expand(rRange
.maRangeY
);
187 maRangeZ
.expand(rRange
.maRangeZ
);
190 void grow(double fValue
)
192 maRangeX
.grow(fValue
);
193 maRangeY
.grow(fValue
);
194 maRangeZ
.grow(fValue
);
197 /// clamp value on range
198 B3DTuple
clamp(const B3DTuple
& rTuple
) const
201 maRangeX
.clamp(rTuple
.getX()),
202 maRangeY
.clamp(rTuple
.getY()),
203 maRangeZ
.clamp(rTuple
.getZ()));
206 BASEGFX_DLLPUBLIC
void transform(const B3DHomMatrix
& rMatrix
);
208 /** Transform Range by given transformation matrix.
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.
215 B3DRange
& operator*=( const ::basegfx::B3DHomMatrix
& rMat
);
217 /** Get a range filled with (0.0, 0.0, 0.0, 1.0, 1.0, 1.0) */
218 static const B3DRange
& getUnitB3DRange();
221 /** Transform B3DRange by given transformation matrix (see operator*=())
223 B3DRange
operator*( const B3DHomMatrix
& rMat
, const B3DRange
& rB2DRange
);
225 } // end of namespace basegfx
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */