summaryrefslogtreecommitdiff
path: root/basegfx/inc/basegfx/range
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx/inc/basegfx/range')
-rw-r--r--basegfx/inc/basegfx/range/b1drange.hxx54
-rw-r--r--basegfx/inc/basegfx/range/b1ibox.hxx52
-rw-r--r--basegfx/inc/basegfx/range/b1irange.hxx53
-rw-r--r--basegfx/inc/basegfx/range/b2drange.hxx62
-rw-r--r--basegfx/inc/basegfx/range/b2ibox.hxx74
-rw-r--r--basegfx/inc/basegfx/range/b2irange.hxx70
-rw-r--r--basegfx/inc/basegfx/range/b3drange.hxx26
-rw-r--r--basegfx/inc/basegfx/range/b3ibox.hxx6
-rw-r--r--basegfx/inc/basegfx/range/b3irange.hxx21
-rw-r--r--basegfx/inc/basegfx/range/basicbox.hxx7
-rw-r--r--basegfx/inc/basegfx/range/rangeexpander.hxx86
11 files changed, 283 insertions, 228 deletions
diff --git a/basegfx/inc/basegfx/range/b1drange.hxx b/basegfx/inc/basegfx/range/b1drange.hxx
index 83bca953734e..cac1efb075b6 100644
--- a/basegfx/inc/basegfx/range/b1drange.hxx
+++ b/basegfx/inc/basegfx/range/b1drange.hxx
@@ -37,38 +37,53 @@ namespace basegfx
{
class B1IRange;
- class BASEGFX_DLLPUBLIC B1DRange
+ /** A one-dimensional interval over doubles
+
+ This is a set of real numbers, bounded by a lower and an upper
+ value. All inbetween values are included in the set (see also
+ http://en.wikipedia.org/wiki/Interval_%28mathematics%29).
+
+ The set is closed, i.e. the upper and the lower bound are
+ included (if you're used to the notation - we're talking about
+ [a,b] here, compared to half-open [a,b) or open intervals
+ (a,b)).
+
+ That means, isInside(val) will return true also for values of
+ val=a or val=b.
+ */
+ class B1DRange
{
::basegfx::BasicRange< double, DoubleTraits > maRange;
public:
- B1DRange()
- {
- }
+ B1DRange() {}
+ /// Create degenerate interval consisting of a single double number
explicit B1DRange(double fStartValue)
: maRange(fStartValue)
{
}
+ /// Create proper interval between the two given double values
B1DRange(double fStartValue1, double fStartValue2)
: maRange(fStartValue1)
{
expand(fStartValue2);
}
- B1DRange(const B1DRange& rRange)
- : maRange(rRange.maRange)
- {
- }
+ BASEGFX_DLLPUBLIC explicit B1DRange( const B1IRange& rRange );
- explicit B1DRange( const B1IRange& rRange );
+ /** Check if the interval set is empty
+ @return false, if no value is in this set - having a
+ single value included will already return true.
+ */
bool isEmpty() const
{
return maRange.isEmpty();
}
+ /// reset the object to empty state again, clearing all values
void reset()
{
maRange.reset();
@@ -84,72 +99,78 @@ namespace basegfx
return (maRange != rRange.maRange);
}
- B1DRange& operator=(const B1DRange& rRange)
- {
- maRange = rRange.maRange;
- return *this;
- }
-
bool equal(const B1DRange& rRange) const
{
return (maRange.equal(rRange.maRange));
}
+ /// get lower bound of the set. returns arbitrary values for empty sets.
double getMinimum() const
{
return maRange.getMinimum();
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
double getMaximum() const
{
return maRange.getMaximum();
}
+ /// return difference between upper and lower value. returns 0 for empty sets.
double getRange() const
{
return maRange.getRange();
}
+ /// return middle of upper and lower value. returns 0 for empty sets.
double getCenter() const
{
return maRange.getCenter();
}
+ /// yields true if value is contained in set
bool isInside(double fValue) const
{
return maRange.isInside(fValue);
}
+ /// yields true if rRange is inside, or equal to set
bool isInside(const B1DRange& rRange) const
{
return maRange.isInside(rRange.maRange);
}
+ /// yields true if rRange at least partly inside set
bool overlaps(const B1DRange& rRange) const
{
return maRange.overlaps(rRange.maRange);
}
+ /// yields true if overlaps(rRange) does, and the overlap is larger than infinitesimal
bool overlapsMore(const B1DRange& rRange) const
{
return maRange.overlapsMore(rRange.maRange);
}
+ /// add fValue to the set, expanding as necessary
void expand(double fValue)
{
maRange.expand(fValue);
}
+ /// add rRange to the set, expanding as necessary
void expand(const B1DRange& rRange)
{
maRange.expand(rRange.maRange);
}
+ /// calc set intersection
void intersect(const B1DRange& rRange)
{
maRange.intersect(rRange.maRange);
}
+ /// grow set by fValue on both sides
void grow(double fValue)
{
maRange.grow(fValue);
@@ -160,7 +181,8 @@ namespace basegfx
@return the nearest integer for this range
*/
- B1IRange fround(const B1DRange& rRange);
+ BASEGFX_DLLPUBLIC B1IRange fround(const B1DRange& rRange);
+
} // end of namespace basegfx
diff --git a/basegfx/inc/basegfx/range/b1ibox.hxx b/basegfx/inc/basegfx/range/b1ibox.hxx
index f40c7637fa8f..5bfe9f7170c4 100644
--- a/basegfx/inc/basegfx/range/b1ibox.hxx
+++ b/basegfx/inc/basegfx/range/b1ibox.hxx
@@ -35,36 +35,56 @@
namespace basegfx
{
- class BASEGFX_DLLPUBLIC B1IBox
+ /** A one-dimensional interval over integers
+
+ This is most easily depicted as a set of integers, bounded by
+ a lower and an upper value - but excluding the upper
+ value. All inbetween values are included in the set (see also
+ http://en.wikipedia.org/wiki/Interval_%28mathematics%29).
+
+ The set is half-open, i.e. the lower bound is included, the
+ upper bound not (if you're used to the notation - we're
+ talking about [a,b) here, compared to closed [a,b] or fully
+ open intervals (a,b)).
+
+ If you don't need a half-open interval, check B1IRange.
+
+ That means, isInside(val) will return true also for values of
+ val=a, but not for val=b.
+
+ @see B1IRange
+ */
+ class B1IBox
{
::basegfx::BasicBox maRange;
public:
- B1IBox()
- {
- }
+ B1IBox() {}
+ /// Create degenerate interval that's still empty
explicit B1IBox(sal_Int32 nStartValue)
: maRange(nStartValue)
{
}
+ /// Create proper interval between the two given values
B1IBox(sal_Int32 nStartValue1, sal_Int32 nStartValue2)
: maRange(nStartValue1)
{
expand(nStartValue2);
}
- B1IBox(const B1IBox& rBox)
- : maRange(rBox.maRange)
- {
- }
+ /** Check if the interval set is empty
+ @return false, if no value is in this set - having a
+ single value included will still return false.
+ */
bool isEmpty() const
{
return maRange.isEmpty();
}
+ /// reset the object to empty state again, clearing all values
void reset()
{
maRange.reset();
@@ -80,61 +100,67 @@ namespace basegfx
return (maRange != rBox.maRange);
}
- void operator=(const B1IBox& rBox)
- {
- maRange = rBox.maRange;
- }
-
+ /// get lower bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMinimum() const
{
return maRange.getMinimum();
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMaximum() const
{
return maRange.getMaximum();
}
+ /// return difference between upper and lower value. returns 0 for empty sets.
Int32Traits::DifferenceType getRange() const
{
return maRange.getRange();
}
+ /// return middle of upper and lower value. returns 0 for empty sets.
double getCenter() const
{
return maRange.getCenter();
}
+ /// yields true if value is contained in set
bool isInside(sal_Int32 nValue) const
{
return maRange.isInside(nValue);
}
+ /// yields true if rRange is inside, or equal to set
bool isInside(const B1IBox& rBox) const
{
return maRange.isInside(rBox.maRange);
}
+ /// yields true if rRange at least partly inside set
bool overlaps(const B1IBox& rBox) const
{
return maRange.overlaps(rBox.maRange);
}
+ /// add nValue to the set, expanding as necessary
void expand(sal_Int32 nValue)
{
maRange.expand(nValue);
}
+ /// add rBox to the set, expanding as necessary
void expand(const B1IBox& rBox)
{
maRange.expand(rBox.maRange);
}
+ /// calc set intersection
void intersect(const B1IBox& rBox)
{
maRange.intersect(rBox.maRange);
}
+ /// grow set by nValue on both sides
void grow(sal_Int32 nValue)
{
maRange.grow(nValue);
diff --git a/basegfx/inc/basegfx/range/b1irange.hxx b/basegfx/inc/basegfx/range/b1irange.hxx
index 81e19ef29904..6d0333521ceb 100644
--- a/basegfx/inc/basegfx/range/b1irange.hxx
+++ b/basegfx/inc/basegfx/range/b1irange.hxx
@@ -35,36 +35,55 @@
namespace basegfx
{
- class BASEGFX_DLLPUBLIC B1IRange
+ /** A one-dimensional interval over integers
+
+ This is a set of real numbers, bounded by a lower and an upper
+ value. All inbetween values are included in the set (see also
+ http://en.wikipedia.org/wiki/Interval_%28mathematics%29).
+
+ Probably you rather want B1IBox for integers.
+
+ The set is closed, i.e. the upper and the lower bound are
+ included (if you're used to the notation - we're talking about
+ [a,b] here, compared to half-open [a,b) or open intervals
+ (a,b)).
+
+ That means, isInside(val) will return true also for values of
+ val=a or val=b.
+
+ @see B1IBox
+ */
+ class B1IRange
{
::basegfx::BasicRange< sal_Int32, Int32Traits > maRange;
public:
- B1IRange()
- {
- }
+ B1IRange() {}
+ /// Create degenerate interval consisting of a single double number
explicit B1IRange(sal_Int32 nStartValue)
: maRange(nStartValue)
{
}
+ /// Create proper interval between the two given values
B1IRange(sal_Int32 nStartValue1, sal_Int32 nStartValue2)
: maRange(nStartValue1)
{
expand(nStartValue2);
}
- B1IRange(const B1IRange& rRange)
- : maRange(rRange.maRange)
- {
- }
+ /** Check if the interval set is empty
+ @return false, if no value is in this set - having a
+ single value included will already return true.
+ */
bool isEmpty() const
{
return maRange.isEmpty();
}
+ /// reset the object to empty state again, clearing all values
void reset()
{
maRange.reset();
@@ -80,67 +99,73 @@ namespace basegfx
return (maRange != rRange.maRange);
}
- B1IRange& operator=(const B1IRange& rRange)
- {
- maRange = rRange.maRange;
- return *this;
- }
-
+ /// get lower bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMinimum() const
{
return maRange.getMinimum();
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMaximum() const
{
return maRange.getMaximum();
}
+ /// return difference between upper and lower value. returns 0 for empty sets.
Int32Traits::DifferenceType getRange() const
{
return maRange.getRange();
}
+ /// return middle of upper and lower value. returns 0 for empty sets.
double getCenter() const
{
return maRange.getCenter();
}
+ /// yields true if value is contained in set
bool isInside(sal_Int32 nValue) const
{
return maRange.isInside(nValue);
}
+ /// yields true if rRange is inside, or equal to set
bool isInside(const B1IRange& rRange) const
{
return maRange.isInside(rRange.maRange);
}
+ /// yields true if rRange at least partly inside set
bool overlaps(const B1IRange& rRange) const
{
return maRange.overlaps(rRange.maRange);
}
+ /// yields true if overlaps(rRange) does, and the overlap is larger than infinitesimal
bool overlapsMore(const B1IRange& rRange) const
{
return maRange.overlapsMore(rRange.maRange);
}
+ /// add nValue to the set, expanding as necessary
void expand(sal_Int32 nValue)
{
maRange.expand(nValue);
}
+ /// add rRange to the set, expanding as necessary
void expand(const B1IRange& rRange)
{
maRange.expand(rRange.maRange);
}
+ /// calc set intersection
void intersect(const B1IRange& rRange)
{
maRange.intersect(rRange.maRange);
}
+ /// grow set by nValue on both sides
void grow(sal_Int32 nValue)
{
maRange.grow(nValue);
diff --git a/basegfx/inc/basegfx/range/b2drange.hxx b/basegfx/inc/basegfx/range/b2drange.hxx
index 0631f5e2cb70..b8a51aeb8800 100644
--- a/basegfx/inc/basegfx/range/b2drange.hxx
+++ b/basegfx/inc/basegfx/range/b2drange.hxx
@@ -43,22 +43,38 @@ namespace basegfx
class B2IRange;
class B2DHomMatrix;
+ /** A two-dimensional interval over doubles
+
+ This is a set of real numbers, bounded by a lower and an upper
+ pair. All inbetween values are included in the set (see also
+ http://en.wikipedia.org/wiki/Interval_%28mathematics%29).
+
+ The set is closed, i.e. the upper and the lower bound are
+ included (if you're used to the notation - we're talking about
+ [a,b] here, compared to half-open [a,b) or open intervals
+ (a,b)).
+
+ That means, isInside(val) will return true also for values of
+ val=a or val=b.
+
+ @see B1DRange
+ */
class B2DRange
{
public:
typedef double ValueType;
typedef DoubleTraits TraitsType;
- B2DRange()
- {
- }
+ B2DRange() {}
+ /// Create degenerate interval consisting of a single point
explicit B2DRange(const B2DTuple& rTuple)
: maRangeX(rTuple.getX()),
maRangeY(rTuple.getY())
{
}
+ /// Create proper interval between the two given double pairs
B2DRange(double x1,
double y1,
double x2,
@@ -70,6 +86,7 @@ namespace basegfx
maRangeY.expand(y2);
}
+ /// Create proper interval between the two given points
B2DRange(const B2DTuple& rTuple1,
const B2DTuple& rTuple2)
: maRangeX(rTuple1.getX()),
@@ -78,14 +95,13 @@ namespace basegfx
expand( rTuple2 );
}
- B2DRange(const B2DRange& rRange)
- : maRangeX(rRange.maRangeX),
- maRangeY(rRange.maRangeY)
- {
- }
-
BASEGFX_DLLPUBLIC explicit B2DRange(const B2IRange& rRange);
+ /** Check if the interval set is empty
+
+ @return false, if no value is in this set - having a
+ single point included will already return true.
+ */
bool isEmpty() const
{
return (
@@ -94,6 +110,7 @@ namespace basegfx
);
}
+ /// reset the object to empty state again, clearing all values
void reset()
{
maRangeX.reset();
@@ -112,49 +129,49 @@ namespace basegfx
|| maRangeY != rRange.maRangeY);
}
- B2DRange& operator=(const B2DRange& rRange)
- {
- maRangeX = rRange.maRangeX;
- maRangeY = rRange.maRangeY;
- return *this;
- }
-
bool equal(const B2DRange& rRange) const
{
return (maRangeX.equal(rRange.maRangeX)
&& maRangeY.equal(rRange.maRangeY));
}
+ /// get lower bound of the set. returns arbitrary values for empty sets.
double getMinX() const
{
return maRangeX.getMinimum();
}
+ /// get lower bound of the set. returns arbitrary values for empty sets.
double getMinY() const
{
return maRangeY.getMinimum();
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
double getMaxX() const
{
return maRangeX.getMaximum();
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
double getMaxY() const
{
return maRangeY.getMaximum();
}
+ /// return difference between upper and lower X value. returns 0 for empty sets.
double getWidth() const
{
return maRangeX.getRange();
}
+ /// return difference between upper and lower Y value. returns 0 for empty sets.
double getHeight() const
{
return maRangeY.getRange();
}
+ /// get lower bound of the set. returns arbitrary values for empty sets.
B2DPoint getMinimum() const
{
return B2DPoint(
@@ -163,6 +180,7 @@ namespace basegfx
);
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
B2DPoint getMaximum() const
{
return B2DPoint(
@@ -171,6 +189,7 @@ namespace basegfx
);
}
+ /// return difference between upper and lower point. returns (0,0) for empty sets.
B2DVector getRange() const
{
return B2DVector(
@@ -179,6 +198,7 @@ namespace basegfx
);
}
+ /// return center point of set. returns (0,0) for empty sets.
B2DPoint getCenter() const
{
return B2DPoint(
@@ -187,16 +207,19 @@ namespace basegfx
);
}
+ /// return center X value of set. returns 0 for empty sets.
double getCenterX() const
{
return maRangeX.getCenter();
}
+ /// return center Y value of set. returns 0 for empty sets.
double getCenterY() const
{
return maRangeY.getCenter();
}
+ /// yields true if given point is contained in set
bool isInside(const B2DTuple& rTuple) const
{
return (
@@ -205,6 +228,7 @@ namespace basegfx
);
}
+ /// yields true if rRange is inside, or equal to set
bool isInside(const B2DRange& rRange) const
{
return (
@@ -213,6 +237,7 @@ namespace basegfx
);
}
+ /// yields true if rRange at least partly inside set
bool overlaps(const B2DRange& rRange) const
{
return (
@@ -221,6 +246,7 @@ namespace basegfx
);
}
+ /// yields true if overlaps(rRange) does, and the overlap is larger than infinitesimal
bool overlapsMore(const B2DRange& rRange) const
{
return (
@@ -229,24 +255,28 @@ namespace basegfx
);
}
+ /// add point to the set, expanding as necessary
void expand(const B2DTuple& rTuple)
{
maRangeX.expand(rTuple.getX());
maRangeY.expand(rTuple.getY());
}
+ /// add rRange to the set, expanding as necessary
void expand(const B2DRange& rRange)
{
maRangeX.expand(rRange.maRangeX);
maRangeY.expand(rRange.maRangeY);
}
+ /// calc set intersection
void intersect(const B2DRange& rRange)
{
maRangeX.intersect(rRange.maRangeX);
maRangeY.intersect(rRange.maRangeY);
}
+ /// grow set by fValue on all sides
void grow(double fValue)
{
maRangeX.grow(fValue);
diff --git a/basegfx/inc/basegfx/range/b2ibox.hxx b/basegfx/inc/basegfx/range/b2ibox.hxx
index 0a123018f090..dd23b7058e2e 100644
--- a/basegfx/inc/basegfx/range/b2ibox.hxx
+++ b/basegfx/inc/basegfx/range/b2ibox.hxx
@@ -40,22 +40,48 @@
namespace basegfx
{
- class BASEGFX_DLLPUBLIC B2IBox
+ /** A two-dimensional interval over integers
+
+ This is most easily depicted as a set of integers, bounded by
+ a lower and an upper value - but excluding the upper
+ value. All inbetween values are included in the set (see also
+ http://en.wikipedia.org/wiki/Interval_%28mathematics%29).
+
+ The set is half-open, i.e. the lower bound is included, the
+ upper bound not (if you're used to the notation - we're
+ talking about [a,b) here, compared to closed [a,b] or fully
+ open intervals (a,b)).
+
+ If you don't need a half-open interval, check B2IRange.
+
+ That means, isInside(val) will return true also for values of
+ val=a, but not for val=b.
+
+ Alternatively, consider this a rectangle, where the rightmost
+ pixel column and the bottommost pixel row are excluded - this
+ is much like polygon filling. As a result, filling a given
+ rectangle with basebmp::BitmapDevice::fillPolyPolygon(), will
+ affect exactly the same set of pixel as isInside() would
+ return true for.
+
+ @see B2IRange
+ */
+ class B2IBox
{
public:
typedef sal_Int32 ValueType;
typedef Int32Traits TraitsType;
- B2IBox()
- {
- }
+ B2IBox() {}
+ /// Create degenerate interval that's still empty
explicit B2IBox(const B2ITuple& rTuple)
: maRangeX(rTuple.getX()),
maRangeY(rTuple.getY())
{
}
+ /// Create proper interval between the two given points
B2IBox(sal_Int32 x1,
sal_Int32 y1,
sal_Int32 x2,
@@ -67,6 +93,7 @@ namespace basegfx
maRangeY.expand(y2);
}
+ /// Create proper interval between the two given points
B2IBox(const B2ITuple& rTuple1,
const B2ITuple& rTuple2) :
maRangeX(rTuple1.getX()),
@@ -75,17 +102,17 @@ namespace basegfx
expand( rTuple2 );
}
- B2IBox(const B2IBox& rBox) :
- maRangeX(rBox.maRangeX),
- maRangeY(rBox.maRangeY)
- {
- }
+ /** Check if the interval set is empty
+ @return false, if no value is in this set - having a
+ single value included will still return false.
+ */
bool isEmpty() const
{
return maRangeX.isEmpty() || maRangeY.isEmpty();
}
+ /// reset the object to empty state again, clearing all values
void reset()
{
maRangeX.reset();
@@ -104,42 +131,43 @@ namespace basegfx
|| maRangeY != rBox.maRangeY);
}
- void operator=(const B2IBox& rBox)
- {
- maRangeX = rBox.maRangeX;
- maRangeY = rBox.maRangeY;
- }
-
+ /// get lower bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMinX() const
{
return maRangeX.getMinimum();
}
+ /// get lower bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMinY() const
{
return maRangeY.getMinimum();
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMaxX() const
{
return maRangeX.getMaximum();
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMaxY() const
{
return maRangeY.getMaximum();
}
+ /// return difference between upper and lower X value. returns 0 for empty sets.
sal_Int64 getWidth() const
{
return maRangeX.getRange();
}
+ /// return difference between upper and lower Y value. returns 0 for empty sets.
sal_Int64 getHeight() const
{
return maRangeY.getRange();
}
+ /// get lower bound of the set. returns arbitrary values for empty sets.
B2IPoint getMinimum() const
{
return B2IPoint(
@@ -148,6 +176,7 @@ namespace basegfx
);
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
B2IPoint getMaximum() const
{
return B2IPoint(
@@ -156,6 +185,7 @@ namespace basegfx
);
}
+ /// return difference between upper and lower value. returns (0,0) for empty sets.
B2I64Tuple getRange() const
{
return B2I64Tuple(
@@ -164,6 +194,7 @@ namespace basegfx
);
}
+ /// return center point of set. returns (0,0) for empty sets.
B2DPoint getCenter() const
{
return B2DPoint(
@@ -172,6 +203,7 @@ namespace basegfx
);
}
+ /// yields true if point is contained in set
bool isInside(const B2ITuple& rTuple) const
{
return (
@@ -180,6 +212,7 @@ namespace basegfx
);
}
+ /// yields true if rBox is inside, or equal to set
bool isInside(const B2IBox& rBox) const
{
return (
@@ -188,6 +221,7 @@ namespace basegfx
);
}
+ /// yields true if rBox at least partly inside set
bool overlaps(const B2IBox& rBox) const
{
return (
@@ -196,24 +230,28 @@ namespace basegfx
);
}
+ /// add point to the set, expanding as necessary
void expand(const B2ITuple& rTuple)
{
maRangeX.expand(rTuple.getX());
maRangeY.expand(rTuple.getY());
}
+ /// add rBox to the set, expanding as necessary
void expand(const B2IBox& rBox)
{
maRangeX.expand(rBox.maRangeX);
maRangeY.expand(rBox.maRangeY);
}
+ /// calc set intersection
void intersect(const B2IBox& rBox)
{
maRangeX.intersect(rBox.maRangeX);
maRangeY.intersect(rBox.maRangeY);
}
+ /// grow set by nValue on all sides
void grow(sal_Int32 nValue)
{
maRangeX.grow(nValue);
@@ -244,9 +282,9 @@ namespace basegfx
@return the input vector
*/
- ::std::vector< B2IBox >& computeSetDifference( ::std::vector< B2IBox >& o_rResult,
- const B2IBox& rFirst,
- const B2IBox& rSecond );
+ BASEGFX_DLLPUBLIC ::std::vector< B2IBox >& computeSetDifference( ::std::vector< B2IBox >& o_rResult,
+ const B2IBox& rFirst,
+ const B2IBox& rSecond );
} // end of namespace basegfx
diff --git a/basegfx/inc/basegfx/range/b2irange.hxx b/basegfx/inc/basegfx/range/b2irange.hxx
index b899b0e04f6f..6f1f84a315b9 100644
--- a/basegfx/inc/basegfx/range/b2irange.hxx
+++ b/basegfx/inc/basegfx/range/b2irange.hxx
@@ -40,22 +40,40 @@
namespace basegfx
{
- class BASEGFX_DLLPUBLIC B2IRange
+ /** A two-dimensional interval over integers
+
+ This is a set of real numbers, bounded by a lower and an upper
+ pair. All inbetween values are included in the set (see also
+ http://en.wikipedia.org/wiki/Interval_%28mathematics%29).
+
+ Probably you rather want B2IBox for integers.
+
+ The set is closed, i.e. the upper and the lower bound are
+ included (if you're used to the notation - we're talking about
+ [a,b] here, compared to half-open [a,b) or open intervals
+ (a,b)).
+
+ That means, isInside(val) will return true also for values of
+ val=a or val=b.
+
+ @see B2IBox
+ */
+ class B2IRange
{
public:
typedef sal_Int32 ValueType;
typedef Int32Traits TraitsType;
- B2IRange()
- {
- }
+ B2IRange() {}
+ /// Create degenerate interval consisting of a single point
explicit B2IRange(const B2ITuple& rTuple)
: maRangeX(rTuple.getX()),
maRangeY(rTuple.getY())
{
}
+ /// Create proper interval between the two given integer pairs
B2IRange(sal_Int32 x1,
sal_Int32 y1,
sal_Int32 x2,
@@ -67,6 +85,7 @@ namespace basegfx
maRangeY.expand(y2);
}
+ /// Create proper interval between the two given points
B2IRange(const B2ITuple& rTuple1,
const B2ITuple& rTuple2)
: maRangeX(rTuple1.getX()),
@@ -75,17 +94,17 @@ namespace basegfx
expand( rTuple2 );
}
- B2IRange(const B2IRange& rRange)
- : maRangeX(rRange.maRangeX),
- maRangeY(rRange.maRangeY)
- {
- }
+ /** Check if the interval set is empty
+ @return false, if no value is in this set - having a
+ single point included will already return true.
+ */
bool isEmpty() const
{
return maRangeX.isEmpty() || maRangeY.isEmpty();
}
+ /// reset the object to empty state again, clearing all values
void reset()
{
maRangeX.reset();
@@ -104,43 +123,43 @@ namespace basegfx
|| maRangeY != rRange.maRangeY);
}
- B2IRange& operator=(const B2IRange& rRange)
- {
- maRangeX = rRange.maRangeX;
- maRangeY = rRange.maRangeY;
- return *this;
- }
-
+ /// get lower bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMinX() const
{
return maRangeX.getMinimum();
}
+ /// get lower bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMinY() const
{
return maRangeY.getMinimum();
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMaxX() const
{
return maRangeX.getMaximum();
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
sal_Int32 getMaxY() const
{
return maRangeY.getMaximum();
}
+ /// return difference between upper and lower X value. returns 0 for empty sets.
sal_Int64 getWidth() const
{
return maRangeX.getRange();
}
+ /// return difference between upper and lower Y value. returns 0 for empty sets.
sal_Int64 getHeight() const
{
return maRangeY.getRange();
}
+ /// get lower bound of the set. returns arbitrary values for empty sets.
B2IPoint getMinimum() const
{
return B2IPoint(
@@ -149,6 +168,7 @@ namespace basegfx
);
}
+ /// get upper bound of the set. returns arbitrary values for empty sets.
B2IPoint getMaximum() const
{
return B2IPoint(
@@ -157,6 +177,7 @@ namespace basegfx
);
}
+ /// return difference between upper and lower point. returns (0,0) for empty sets.
B2I64Tuple getRange() const
{
return B2I64Tuple(
@@ -165,6 +186,7 @@ namespace basegfx
);
}
+ /// return center point of set. returns (0,0) for empty sets.
B2DPoint getCenter() const
{
return B2DPoint(
@@ -173,6 +195,7 @@ namespace basegfx
);
}
+ /// yields true if given point is contained in set
bool isInside(const B2ITuple& rTuple) const
{
return (
@@ -181,6 +204,7 @@ namespace basegfx
);
}
+ /// yields true if rRange is inside, or equal to set
bool isInside(const B2IRange& rRange) const
{
return (
@@ -189,6 +213,7 @@ namespace basegfx
);
}
+ /// yields true if rRange at least partly inside set
bool overlaps(const B2IRange& rRange) const
{
return (
@@ -197,24 +222,37 @@ namespace basegfx
);
}
+ /// yields true if overlaps(rRange) does, and the overlap is larger than infinitesimal
+ bool overlapsMore(const B2IRange& rRange) const
+ {
+ return (
+ maRangeX.overlapsMore(rRange.maRangeX)
+ && maRangeY.overlapsMore(rRange.maRangeY)
+ );
+ }
+
+ /// add point to the set, expanding as necessary
void expand(const B2ITuple& rTuple)
{
maRangeX.expand(rTuple.getX());
maRangeY.expand(rTuple.getY());
}
+ /// add rRange to the set, expanding as necessary
void expand(const B2IRange& rRange)
{
maRangeX.expand(rRange.maRangeX);
maRangeY.expand(rRange.maRangeY);
}
+ /// calc set intersection
void intersect(const B2IRange& rRange)
{
maRangeX.intersect(rRange.maRangeX);
maRangeY.intersect(rRange.maRangeY);
}
+ /// grow set by nValue on all sides
void grow(sal_Int32 nValue)
{
maRangeX.grow(nValue);
diff --git a/basegfx/inc/basegfx/range/b3drange.hxx b/basegfx/inc/basegfx/range/b3drange.hxx
index ca51b4f04a35..353d16cddc69 100644
--- a/basegfx/inc/basegfx/range/b3drange.hxx
+++ b/basegfx/inc/basegfx/range/b3drange.hxx
@@ -41,7 +41,7 @@ namespace basegfx
class B3IRange;
class B3DHomMatrix;
- class BASEGFX_DLLPUBLIC B3DRange
+ class B3DRange
{
typedef ::basegfx::BasicRange< double, DoubleTraits > MyBasicRange;
@@ -50,9 +50,7 @@ namespace basegfx
MyBasicRange maRangeZ;
public:
- B3DRange()
- {
- }
+ B3DRange() {}
explicit B3DRange(const B3DTuple& rTuple)
: maRangeX(rTuple.getX()),
@@ -85,14 +83,7 @@ namespace basegfx
expand(rTuple2);
}
- B3DRange(const B3DRange& rRange)
- : maRangeX(rRange.maRangeX),
- maRangeY(rRange.maRangeY),
- maRangeZ(rRange.maRangeZ)
- {
- }
-
- explicit B3DRange(const B3IRange& rRange);
+ BASEGFX_DLLPUBLIC explicit B3DRange(const B3IRange& rRange);
bool isEmpty() const
{
@@ -124,14 +115,6 @@ namespace basegfx
|| maRangeZ != rRange.maRangeZ);
}
- B3DRange& operator=(const B3DRange& rRange)
- {
- maRangeX = rRange.maRangeX;
- maRangeY = rRange.maRangeY;
- maRangeZ = rRange.maRangeZ;
- return *this;
- }
-
bool equal(const B3DRange& rRange) const
{
return (maRangeX.equal(rRange.maRangeX)
@@ -290,7 +273,7 @@ namespace basegfx
maRangeZ.grow(fValue);
}
- void transform(const B3DHomMatrix& rMatrix);
+ BASEGFX_DLLPUBLIC void transform(const B3DHomMatrix& rMatrix);
};
/** Round double to nearest integer for 3D range
@@ -298,6 +281,7 @@ namespace basegfx
@return the nearest integer for this range
*/
BASEGFX_DLLPUBLIC B3IRange fround(const B3DRange& rRange);
+
} // end of namespace basegfx
diff --git a/basegfx/inc/basegfx/range/b3ibox.hxx b/basegfx/inc/basegfx/range/b3ibox.hxx
index 4ee65cd922f4..32f021f5c8b9 100644
--- a/basegfx/inc/basegfx/range/b3ibox.hxx
+++ b/basegfx/inc/basegfx/range/b3ibox.hxx
@@ -38,16 +38,14 @@
namespace basegfx
{
- class BASEGFX_DLLPUBLIC B3IBox
+ class B3IBox
{
BasicBox maRangeX;
BasicBox maRangeY;
BasicBox maRangeZ;
public:
- B3IBox()
- {
- }
+ B3IBox() {}
explicit B3IBox(const B3ITuple& rTuple) :
maRangeX(rTuple.getX()),
diff --git a/basegfx/inc/basegfx/range/b3irange.hxx b/basegfx/inc/basegfx/range/b3irange.hxx
index c3220d03234a..8cc2925f3dfe 100644
--- a/basegfx/inc/basegfx/range/b3irange.hxx
+++ b/basegfx/inc/basegfx/range/b3irange.hxx
@@ -38,7 +38,7 @@
namespace basegfx
{
- class BASEGFX_DLLPUBLIC B3IRange
+ class B3IRange
{
typedef ::basegfx::BasicRange< sal_Int32, Int32Traits > MyBasicRange;
@@ -47,9 +47,7 @@ namespace basegfx
MyBasicRange maRangeZ;
public:
- B3IRange()
- {
- }
+ B3IRange() {}
explicit B3IRange(const B3ITuple& rTuple)
: maRangeX(rTuple.getX()),
@@ -82,13 +80,6 @@ namespace basegfx
expand(rTuple2);
}
- B3IRange(const B3IRange& rRange)
- : maRangeX(rRange.maRangeX),
- maRangeY(rRange.maRangeY),
- maRangeZ(rRange.maRangeZ)
- {
- }
-
bool isEmpty() const
{
return maRangeX.isEmpty() || maRangeY.isEmpty() || maRangeZ.isEmpty();
@@ -115,14 +106,6 @@ namespace basegfx
|| maRangeZ != rRange.maRangeZ);
}
- B3IRange& operator=(const B3IRange& rRange)
- {
- maRangeX = rRange.maRangeX;
- maRangeY = rRange.maRangeY;
- maRangeZ = rRange.maRangeZ;
- return *this;
- }
-
sal_Int32 getMinX() const
{
return maRangeX.getMinimum();
diff --git a/basegfx/inc/basegfx/range/basicbox.hxx b/basegfx/inc/basegfx/range/basicbox.hxx
index a6eae3a628f2..8e2e0efb90b7 100644
--- a/basegfx/inc/basegfx/range/basicbox.hxx
+++ b/basegfx/inc/basegfx/range/basicbox.hxx
@@ -41,14 +41,11 @@ namespace basegfx
This is modelled after how polygon fill algorithms set pixel -
typically excluding rightmost and bottommost ones.
*/
- class BASEGFX_DLLPUBLIC BasicBox : public BasicRange< sal_Int32, Int32Traits >
+ class BasicBox : public BasicRange< sal_Int32, Int32Traits >
{
typedef BasicRange< sal_Int32, Int32Traits > Base;
public:
- BasicBox() :
- Base()
- {
- }
+ BasicBox() {}
BasicBox( sal_Int32 nValue ) :
Base( nValue )
diff --git a/basegfx/inc/basegfx/range/rangeexpander.hxx b/basegfx/inc/basegfx/range/rangeexpander.hxx
deleted file mode 100644
index 509757d79750..000000000000
--- a/basegfx/inc/basegfx/range/rangeexpander.hxx
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _BGFX_RANGE_RANGEEXPANDER_HXX
-#define _BGFX_RANGE_RANGEEXPANDER_HXX
-
-#include <basegfx/range/b1drange.hxx>
-#include <basegfx/range/b1irange.hxx>
-#include <basegfx/range/b2drange.hxx>
-#include <basegfx/range/b2irange.hxx>
-#include <basegfx/range/b3drange.hxx>
-#include <basegfx/range/b3irange.hxx>
-
-namespace basegfx
-{
- /** Generic functor for expanding a range with a number of other
- ranges.
-
- Since *Range::expand() is overloaded, straight-forward
- application of ::boost::bind and friends fails (because of
- ambiguities). Thus, this functor template can be used, to
- expand the given range with a number of other ranges, passed
- in at the function operator.
-
- @tpl RangeType
- Range type to operate with. Preferrably, one of B1*Range,
- B2*Range, or B3*Range.
- */
- template< typename RangeType > class RangeExpander
- {
- public:
- typedef RangeType ValueType;
- typedef void result_type;
-
- explicit RangeExpander( ValueType& rBounds ) :
- mrBounds( rBounds )
- {
- }
-
- void operator()( const ValueType& rBounds )
- {
- mrBounds.expand( rBounds );
- }
-
- private:
- ValueType& mrBounds;
- };
-
- typedef RangeExpander< B1DRange > B1DRangeExpander;
- typedef RangeExpander< B1IRange > B1IRangeExpander;
- typedef RangeExpander< B2DRange > B2DRangeExpander;
- typedef RangeExpander< B2IRange > B2IRangeExpander;
- typedef RangeExpander< B3DRange > B3DRangeExpander;
- typedef RangeExpander< B3IRange > B3IRangeExpander;
-
-} // end of namespace basegfx
-
-
-#endif /* _BGFX_RANGE_RANGEEXPANDER_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */