Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / basegfx / range / b3drange.hxx
blob881dce6122979b79e6e88abf31948db7018c83c8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_BASEGFX_RANGE_B3DRANGE_HXX
21 #define INCLUDED_BASEGFX_RANGE_B3DRANGE_HXX
23 #include <basegfx/vector/b3dvector.hxx>
24 #include <basegfx/point/b3dpoint.hxx>
25 #include <basegfx/tuple/b3dtuple.hxx>
26 #include <basegfx/range/basicrange.hxx>
27 #include <basegfx/basegfxdllapi.h>
29 namespace basegfx
31 class B3DHomMatrix;
33 class SAL_WARN_UNUSED B3DRange
35 typedef ::basegfx::BasicRange< double, DoubleTraits > MyBasicRange;
37 MyBasicRange maRangeX;
38 MyBasicRange maRangeY;
39 MyBasicRange maRangeZ;
41 public:
42 B3DRange() {}
44 explicit B3DRange(const B3DTuple& rTuple)
45 : maRangeX(rTuple.getX()),
46 maRangeY(rTuple.getY()),
47 maRangeZ(rTuple.getZ())
51 B3DRange(double x1,
52 double y1,
53 double z1,
54 double x2,
55 double y2,
56 double z2)
57 : maRangeX(x1),
58 maRangeY(y1),
59 maRangeZ(z1)
61 maRangeX.expand(x2);
62 maRangeY.expand(y2);
63 maRangeZ.expand(z2);
66 B3DRange(const B3DTuple& rTuple1,
67 const B3DTuple& rTuple2)
68 : maRangeX(rTuple1.getX()),
69 maRangeY(rTuple1.getY()),
70 maRangeZ(rTuple1.getZ())
72 expand(rTuple2);
75 bool isEmpty() const
77 return (
78 maRangeX.isEmpty()
79 || maRangeY.isEmpty()
80 || maRangeZ.isEmpty()
84 void reset()
86 maRangeX.reset();
87 maRangeY.reset();
88 maRangeZ.reset();
91 bool operator==( const B3DRange& rRange ) const
93 return (maRangeX == rRange.maRangeX
94 && maRangeY == rRange.maRangeY
95 && maRangeZ == rRange.maRangeZ);
98 bool operator!=( const B3DRange& rRange ) const
100 return (maRangeX != rRange.maRangeX
101 || maRangeY != rRange.maRangeY
102 || maRangeZ != rRange.maRangeZ);
105 double getMinX() const
107 return maRangeX.getMinimum();
110 double getMinY() const
112 return maRangeY.getMinimum();
115 double getMinZ() const
117 return maRangeZ.getMinimum();
120 double getMaxX() const
122 return maRangeX.getMaximum();
125 double getMaxY() const
127 return maRangeY.getMaximum();
130 double getMaxZ() const
132 return maRangeZ.getMaximum();
135 double getWidth() const
137 return maRangeX.getRange();
140 double getHeight() const
142 return maRangeY.getRange();
145 double getDepth() const
147 return maRangeZ.getRange();
150 B3DVector getRange() const
152 return B3DVector(
153 maRangeX.getRange(),
154 maRangeY.getRange(),
155 maRangeZ.getRange()
159 B3DPoint getCenter() const
161 return B3DPoint(
162 maRangeX.getCenter(),
163 maRangeY.getCenter(),
164 maRangeZ.getCenter()
168 bool overlaps(const B3DRange& rRange) const
170 return (
171 maRangeX.overlaps(rRange.maRangeX)
172 && maRangeY.overlaps(rRange.maRangeY)
173 && maRangeZ.overlaps(rRange.maRangeZ)
177 void expand(const B3DTuple& rTuple)
179 maRangeX.expand(rTuple.getX());
180 maRangeY.expand(rTuple.getY());
181 maRangeZ.expand(rTuple.getZ());
184 void expand(const B3DRange& rRange)
186 maRangeX.expand(rRange.maRangeX);
187 maRangeY.expand(rRange.maRangeY);
188 maRangeZ.expand(rRange.maRangeZ);
191 void grow(double fValue)
193 maRangeX.grow(fValue);
194 maRangeY.grow(fValue);
195 maRangeZ.grow(fValue);
198 BASEGFX_DLLPUBLIC void transform(const B3DHomMatrix& rMatrix);
201 } // end of namespace basegfx
204 #endif // INCLUDED_BASEGFX_RANGE_B3DRANGE_HXX
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */