diff options
Diffstat (limited to 'basegfx/inc')
27 files changed, 3044 insertions, 3200 deletions
diff --git a/basegfx/inc/basegfx/curve/b2dbeziertools.hxx b/basegfx/inc/basegfx/curve/b2dbeziertools.hxx index f9d72cb47873..c3fa31095e10 100644 --- a/basegfx/inc/basegfx/curve/b2dbeziertools.hxx +++ b/basegfx/inc/basegfx/curve/b2dbeziertools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dbeziertools.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: thb $ $Date: 2003-11-12 12:09:50 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,169 +71,160 @@ namespace basegfx { - namespace polygon - { - class B2DPolygon; - } + class B2DPolygon; + class B2DCubicBezier; + class B2DQuadraticBezier; - namespace curve - { + /** Subdivide given cubic bezier segment. - class B2DCubicBezier; - class B2DQuadraticBezier; + This function adaptively subdivides the given bezier + segment into as much straight line segments as necessary, + such that the maximal orthogonal distance from any of the + segments to the true curve is less than the given error + value. - /** Subdivide given cubic bezier segment. + @param rPoly + Output polygon. The subdivided bezier segment is added to + this polygon via B2DPolygon::append(). - This function adaptively subdivides the given bezier - segment into as much straight line segments as necessary, - such that the maximal orthogonal distance from any of the - segments to the true curve is less than the given error - value. + @param rCurve + The cubic bezier curve to subdivide - @param rPoly - Output polygon. The subdivided bezier segment is added to - this polygon via B2DPolygon::append(). + @param distanceBound + Bound on the maximal distance of the approximation to the + true curve. - @param rCurve - The cubic bezier curve to subdivide - - @param distanceBound - Bound on the maximal distance of the approximation to the - true curve. - - @return the number of line segments created - */ - sal_Int32 adaptiveSubdivideByDistance( polygon::B2DPolygon& rPoly, - const B2DCubicBezier& rCurve, - double distanceBound ); + @return the number of line segments created + */ + sal_Int32 adaptiveSubdivideByDistance( B2DPolygon& rPoly, + const B2DCubicBezier& rCurve, + double distanceBound ); - /** Subdivide given cubic bezier segment. + /** Subdivide given cubic bezier segment. - This function adaptively subdivides the given bezier - segment into as much quadratic bezier curve segments as - necessary, such that the maximal orthogonal distance from - any of the segments to the true curve is less than the - given error value. + This function adaptively subdivides the given bezier + segment into as much quadratic bezier curve segments as + necessary, such that the maximal orthogonal distance from + any of the segments to the true curve is less than the + given error value. - @param rPoly - Output polygon. The subdivided bezier segments are added to - this polygon via B2DPolygon::append(). + @param rPoly + Output polygon. The subdivided bezier segments are added to + this polygon via B2DPolygon::append(). - @param rCurve - The cubic bezier curve to subdivide + @param rCurve + The cubic bezier curve to subdivide - @param distanceBound - Bound on the maximal distance of the approximation to the - true curve. + @param distanceBound + Bound on the maximal distance of the approximation to the + true curve. - @return the number of quadratic curve segments created - */ - sal_Int32 adaptiveDegreeReductionByDistance( polygon::B2DPolygon& rPoly, - const B2DCubicBezier& rCurve, - double distanceBound ); + @return the number of quadratic curve segments created + */ + sal_Int32 adaptiveDegreeReductionByDistance( B2DPolygon& rPoly, + const B2DCubicBezier& rCurve, + double distanceBound ); - /** Subdivide given cubic bezier segment. + /** Subdivide given cubic bezier segment. - This function adaptively subdivides the given bezier - segment into as much straight line segments as necessary, - such that the maximal angle change between any adjacent - lines is less than the given error value. + This function adaptively subdivides the given bezier + segment into as much straight line segments as necessary, + such that the maximal angle change between any adjacent + lines is less than the given error value. - @param rPoly - Output polygon. The subdivided bezier segment is added to - this polygon via B2DPolygon::append(). + @param rPoly + Output polygon. The subdivided bezier segment is added to + this polygon via B2DPolygon::append(). - @param rCurve - The cubic bezier curve to subdivide + @param rCurve + The cubic bezier curve to subdivide - @param angleBound - Bound on the maximal angle difference between two adjacent - polygon lines, in degrees. + @param angleBound + Bound on the maximal angle difference between two adjacent + polygon lines, in degrees. - @return the number of line segments created - */ - sal_Int32 adaptiveSubdivideByAngle( polygon::B2DPolygon& rPoly, - const B2DCubicBezier& rCurve, - double angleBound ); + @return the number of line segments created + */ + sal_Int32 adaptiveSubdivideByAngle( B2DPolygon& rPoly, + const B2DCubicBezier& rCurve, + double angleBound ); - /** Subdivide given cubic bezier segment. + /** Subdivide given cubic bezier segment. - This function adaptively subdivides the given bezier - segment into as much quadratic bezier curve segments as - necessary, such that the maximal angle difference of the - control vectors of any generated quadratic bezier segment - is less than the given error value. + This function adaptively subdivides the given bezier + segment into as much quadratic bezier curve segments as + necessary, such that the maximal angle difference of the + control vectors of any generated quadratic bezier segment + is less than the given error value. - @param rPoly - Output polygon. The subdivided bezier segments are added to - this polygon via B2DPolygon::append(). + @param rPoly + Output polygon. The subdivided bezier segments are added to + this polygon via B2DPolygon::append(). - @param rCurve - The cubic bezier curve to subdivide + @param rCurve + The cubic bezier curve to subdivide - @param distanceBound - Bound on the maximal angle difference between the control - vectors of any of the generated quadratic bezier - segments. The angle must be given in degrees. + @param distanceBound + Bound on the maximal angle difference between the control + vectors of any of the generated quadratic bezier + segments. The angle must be given in degrees. - @return the number of quadratic curve segments created - */ - sal_Int32 adaptiveDegreeReductionByAngle( polygon::B2DPolygon& rPoly, - const B2DCubicBezier& rCurve, - double angleBound ); + @return the number of quadratic curve segments created + */ + sal_Int32 adaptiveDegreeReductionByAngle( B2DPolygon& rPoly, + const B2DCubicBezier& rCurve, + double angleBound ); - /** Subdivide given quadratic bezier segment. + /** Subdivide given quadratic bezier segment. - This function adaptively subdivides the given bezier - segment into as much straight line segments as necessary, - such that the maximal orthogonal distance from any of the - segments to the true curve is less than the given error - value. + This function adaptively subdivides the given bezier + segment into as much straight line segments as necessary, + such that the maximal orthogonal distance from any of the + segments to the true curve is less than the given error + value. - @param rPoly - Output polygon. The subdivided bezier segment is added to - this polygon via B2DPolygon::append(). + @param rPoly + Output polygon. The subdivided bezier segment is added to + this polygon via B2DPolygon::append(). - @param rCurve - The cubic bezier curve to subdivide + @param rCurve + The cubic bezier curve to subdivide - @param distanceBound - Bound on the maximal distance of the approximation to the - true curve + @param distanceBound + Bound on the maximal distance of the approximation to the + true curve - @return the number of line segments created - */ - sal_Int32 adaptiveSubdivideByDistance( polygon::B2DPolygon& rPoly, - const B2DQuadraticBezier& rCurve, - double distanceBound ); - - /** Subdivide given quadratic bezier segment. + @return the number of line segments created + */ + sal_Int32 adaptiveSubdivideByDistance( B2DPolygon& rPoly, + const B2DQuadraticBezier& rCurve, + double distanceBound ); - This function adaptively subdivides the given bezier - segment into as much straight line segments as necessary, - such that the maximal angle change between any adjacent - lines is less than the given error value. + /** Subdivide given quadratic bezier segment. - @param rPoly - Output polygon. The subdivided bezier segment is added to - this polygon via B2DPolygon::append(). + This function adaptively subdivides the given bezier + segment into as much straight line segments as necessary, + such that the maximal angle change between any adjacent + lines is less than the given error value. - @param rCurve - The cubic bezier curve to subdivide + @param rPoly + Output polygon. The subdivided bezier segment is added to + this polygon via B2DPolygon::append(). - @param angleBound - Bound on the maximal angle difference between two adjacent - polygon lines, in degrees. + @param rCurve + The cubic bezier curve to subdivide - @return the number of line segments created - */ - sal_Int32 adaptiveSubdivideByAngle( polygon::B2DPolygon& rPoly, - const B2DQuadraticBezier& rCurve, - double angleBound ); + @param angleBound + Bound on the maximal angle difference between two adjacent + polygon lines, in degrees. - } + @return the number of line segments created + */ + sal_Int32 adaptiveSubdivideByAngle( B2DPolygon& rPoly, + const B2DQuadraticBezier& rCurve, + double angleBound ); } #endif // _BGFX_CURVE_B2DBEZIERTOOLS_HXX2 diff --git a/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx b/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx index 9761367bdd1b..83b18f9c75c5 100644 --- a/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx +++ b/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dcubicbezier.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-06 16:30:23 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,50 +70,47 @@ namespace basegfx { - namespace curve + class B2DCubicBezier { - class B2DCubicBezier - { - ::basegfx::point::B2DPoint maStartPoint; - ::basegfx::point::B2DPoint maEndPoint; - ::basegfx::point::B2DPoint maControlPointA; - ::basegfx::point::B2DPoint maControlPointB; + ::basegfx::B2DPoint maStartPoint; + ::basegfx::B2DPoint maEndPoint; + ::basegfx::B2DPoint maControlPointA; + ::basegfx::B2DPoint maControlPointB; - public: - B2DCubicBezier(); - B2DCubicBezier(const B2DCubicBezier& rBezier); - B2DCubicBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rEnd); - B2DCubicBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rControlPointA, - const ::basegfx::point::B2DPoint& rControlPointB, const ::basegfx::point::B2DPoint& rEnd); - ~B2DCubicBezier(); + public: + B2DCubicBezier(); + B2DCubicBezier(const B2DCubicBezier& rBezier); + B2DCubicBezier(const ::basegfx::B2DPoint& rStart, const ::basegfx::B2DPoint& rEnd); + B2DCubicBezier(const ::basegfx::B2DPoint& rStart, const ::basegfx::B2DPoint& rControlPointA, + const ::basegfx::B2DPoint& rControlPointB, const ::basegfx::B2DPoint& rEnd); + ~B2DCubicBezier(); - // assignment operator - B2DCubicBezier& operator=(const B2DCubicBezier& rBezier); + // assignment operator + B2DCubicBezier& operator=(const B2DCubicBezier& rBezier); - // compare operators - sal_Bool operator==(const B2DCubicBezier& rBezier) const; - sal_Bool operator!=(const B2DCubicBezier& rBezier) const; + // compare operators + sal_Bool operator==(const B2DCubicBezier& rBezier) const; + sal_Bool operator!=(const B2DCubicBezier& rBezier) const; - // test if vectors are used - sal_Bool isBezier() const; + // test if vectors are used + sal_Bool isBezier() const; - // test if contained bezier is trivial and reset vectors accordingly - void testAndSolveTrivialBezier(); + // test if contained bezier is trivial and reset vectors accordingly + void testAndSolveTrivialBezier(); - // data interface - ::basegfx::point::B2DPoint getStartPoint() const { return maStartPoint; } - void setStartPoint(const ::basegfx::point::B2DPoint& rValue) { maStartPoint = rValue; } + // data interface + ::basegfx::B2DPoint getStartPoint() const { return maStartPoint; } + void setStartPoint(const ::basegfx::B2DPoint& rValue) { maStartPoint = rValue; } - ::basegfx::point::B2DPoint getEndPoint() const { return maEndPoint; } - void setEndPoint(const ::basegfx::point::B2DPoint& rValue) { maEndPoint = rValue; } + ::basegfx::B2DPoint getEndPoint() const { return maEndPoint; } + void setEndPoint(const ::basegfx::B2DPoint& rValue) { maEndPoint = rValue; } - ::basegfx::point::B2DPoint getControlPointA() const { return maControlPointA; } - void setControlPointA(const ::basegfx::point::B2DPoint& rValue) { maControlPointA = rValue; } + ::basegfx::B2DPoint getControlPointA() const { return maControlPointA; } + void setControlPointA(const ::basegfx::B2DPoint& rValue) { maControlPointA = rValue; } - ::basegfx::point::B2DPoint getControlPointB() const { return maControlPointB; } - void setControlPointB(const ::basegfx::point::B2DPoint& rValue) { maControlPointB = rValue; } - }; - } // end of namespace curve + ::basegfx::B2DPoint getControlPointB() const { return maControlPointB; } + void setControlPointB(const ::basegfx::B2DPoint& rValue) { maControlPointB = rValue; } + }; } // end of namespace basegfx #endif // _BGFX_CURVE_B2DCUBICBEZIER_HXX diff --git a/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx b/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx index 95f7eeda845a..6f81f26d97a7 100644 --- a/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx +++ b/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dquadraticbezier.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-06 16:30:23 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,43 +70,40 @@ namespace basegfx { - namespace curve + class B2DQuadraticBezier { - class B2DQuadraticBezier - { - ::basegfx::point::B2DPoint maStartPoint; - ::basegfx::point::B2DPoint maEndPoint; - ::basegfx::point::B2DPoint maControlPoint; + ::basegfx::B2DPoint maStartPoint; + ::basegfx::B2DPoint maEndPoint; + ::basegfx::B2DPoint maControlPoint; - public: - B2DQuadraticBezier(); - B2DQuadraticBezier(const B2DQuadraticBezier& rBezier); - B2DQuadraticBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rEnd); - B2DQuadraticBezier(const ::basegfx::point::B2DPoint& rStart, - const ::basegfx::point::B2DPoint& rControlPoint, const ::basegfx::point::B2DPoint& rEnd); - ~B2DQuadraticBezier(); + public: + B2DQuadraticBezier(); + B2DQuadraticBezier(const B2DQuadraticBezier& rBezier); + B2DQuadraticBezier(const ::basegfx::B2DPoint& rStart, const ::basegfx::B2DPoint& rEnd); + B2DQuadraticBezier(const ::basegfx::B2DPoint& rStart, + const ::basegfx::B2DPoint& rControlPoint, const ::basegfx::B2DPoint& rEnd); + ~B2DQuadraticBezier(); - // assignment operator - B2DQuadraticBezier& operator=(const B2DQuadraticBezier& rBezier); + // assignment operator + B2DQuadraticBezier& operator=(const B2DQuadraticBezier& rBezier); - // compare operators - sal_Bool operator==(const B2DQuadraticBezier& rBezier) const; - sal_Bool operator!=(const B2DQuadraticBezier& rBezier) const; + // compare operators + sal_Bool operator==(const B2DQuadraticBezier& rBezier) const; + sal_Bool operator!=(const B2DQuadraticBezier& rBezier) const; - // test if control point is placed on the edge - sal_Bool isBezier() const; + // test if control point is placed on the edge + sal_Bool isBezier() const; - // data interface - ::basegfx::point::B2DPoint getStartPoint() const { return maStartPoint; } - void setStartPoint(const ::basegfx::point::B2DPoint& rValue) { maStartPoint = rValue; } + // data interface + ::basegfx::B2DPoint getStartPoint() const { return maStartPoint; } + void setStartPoint(const ::basegfx::B2DPoint& rValue) { maStartPoint = rValue; } - ::basegfx::point::B2DPoint getEndPoint() const { return maEndPoint; } - void setEndPoint(const ::basegfx::point::B2DPoint& rValue) { maEndPoint = rValue; } + ::basegfx::B2DPoint getEndPoint() const { return maEndPoint; } + void setEndPoint(const ::basegfx::B2DPoint& rValue) { maEndPoint = rValue; } - ::basegfx::point::B2DPoint getControlPoint() const { return maControlPoint; } - void setControlPoint(const ::basegfx::point::B2DPoint& rValue) { maControlPoint = rValue; } - }; - } // end of namespace curve + ::basegfx::B2DPoint getControlPoint() const { return maControlPoint; } + void setControlPoint(const ::basegfx::B2DPoint& rValue) { maControlPoint = rValue; } + }; } // end of namespace basegfx #endif // _BGFX_CURVE_B2DQUADRATICBEZIER_HXX diff --git a/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx b/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx index 7ff8dfec5ed3..f574e062f5c1 100644 --- a/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx +++ b/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dhommatrix.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: thb $ $Date: 2003-11-12 12:12:40 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,127 +68,121 @@ namespace basegfx { - namespace tuple - { - // predeclaration - class B2DTuple; - } // end of namespace tuple + // predeclaration + class B2DTuple; + + // forward declaration + class Impl2DHomMatrix; - namespace matrix + class B2DHomMatrix { - // forward declaration - class Impl2DHomMatrix; + private: + Impl2DHomMatrix* mpM; - class B2DHomMatrix - { - private: - Impl2DHomMatrix* mpM; + void implPrepareChange(); - void implPrepareChange(); + public: + B2DHomMatrix(); + B2DHomMatrix(const B2DHomMatrix& rMat); + ~B2DHomMatrix(); - public: - B2DHomMatrix(); - B2DHomMatrix(const B2DHomMatrix& rMat); - ~B2DHomMatrix(); + double get(sal_uInt16 nRow, sal_uInt16 nColumn) const; + void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue); - double get(sal_uInt16 nRow, sal_uInt16 nColumn) const; - void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue); + // Auf Einheitsmatrix zuruecksetzen + sal_Bool isIdentity() const; + void identity(); - // Auf Einheitsmatrix zuruecksetzen - sal_Bool isIdentity() const; - void identity(); + // Invertierung + sal_Bool isInvertible() const; + sal_Bool invert(); - // Invertierung - sal_Bool isInvertible() const; - sal_Bool invert(); + // Normalisierung + sal_Bool isNormalized() const; + void normalize(); - // Normalisierung - sal_Bool isNormalized() const; - void normalize(); + // Determinante + double determinant() const; - // Determinante - double determinant() const; + // Trace + double trace() const; - // Trace - double trace() const; + // Transpose + void transpose(); - // Transpose - void transpose(); + // Rotation + void rotate(double fRadiant); - // Rotation - void rotate(double fRadiant); + // Translation + void translate(double fX, double fY); - // Translation - void translate(double fX, double fY); + // Skalierung + void scale(double fX, double fY); - // Skalierung - void scale(double fX, double fY); + // Shearing-Matrices + void shearX(double fSx); + void shearY(double fSy); - // Shearing-Matrices - void shearX(double fSx); - void shearY(double fSy); + // Addition, Subtraktion + B2DHomMatrix& operator+=(const B2DHomMatrix& rMat); + B2DHomMatrix& operator-=(const B2DHomMatrix& rMat); - // Addition, Subtraktion - B2DHomMatrix& operator+=(const B2DHomMatrix& rMat); - B2DHomMatrix& operator-=(const B2DHomMatrix& rMat); + // Vergleichsoperatoren + sal_Bool operator==(const B2DHomMatrix& rMat) const; + sal_Bool operator!=(const B2DHomMatrix& rMat) const; - // Vergleichsoperatoren - sal_Bool operator==(const B2DHomMatrix& rMat) const; - sal_Bool operator!=(const B2DHomMatrix& rMat) const; + // Multiplikation, Division mit Konstante + B2DHomMatrix& operator*=(double fValue); + B2DHomMatrix& operator/=(double fValue); - // Multiplikation, Division mit Konstante - B2DHomMatrix& operator*=(double fValue); - B2DHomMatrix& operator/=(double fValue); + // Matritzenmultiplikation von links auf die lokale + B2DHomMatrix& operator*=(const B2DHomMatrix& rMat); - // Matritzenmultiplikation von links auf die lokale - B2DHomMatrix& operator*=(const B2DHomMatrix& rMat); + // assignment operator + B2DHomMatrix& operator=(const B2DHomMatrix& rMat); - // assignment operator - B2DHomMatrix& operator=(const B2DHomMatrix& rMat); + // Help routine to decompose given homogen 3x3 matrix to components. A correction of + // the components is done to avoid inaccuracies. + // Zerlegung + sal_Bool decompose(B2DTuple& rScale, B2DTuple& rTranslate, double& rRotate, double& rShearX) const; + }; - // Help routine to decompose given homogen 3x3 matrix to components. A correction of - // the components is done to avoid inaccuracies. - // Zerlegung - sal_Bool decompose(tuple::B2DTuple& rScale, tuple::B2DTuple& rTranslate, double& rRotate, double& rShearX) const; - }; + // Addition, Subtraktion + inline B2DHomMatrix operator+(const B2DHomMatrix& rMatA, const B2DHomMatrix& rMatB) + { + B2DHomMatrix aSum(rMatA); + aSum += rMatB; + return aSum; + } - // Addition, Subtraktion - inline B2DHomMatrix operator+(const B2DHomMatrix& rMatA, const B2DHomMatrix& rMatB) - { - B2DHomMatrix aSum(rMatA); - aSum += rMatB; - return aSum; - } - - inline B2DHomMatrix operator-(const B2DHomMatrix& rMatA, const B2DHomMatrix& rMatB) - { - B2DHomMatrix aDiv(rMatA); - aDiv -= rMatB; - return aDiv; - } + inline B2DHomMatrix operator-(const B2DHomMatrix& rMatA, const B2DHomMatrix& rMatB) + { + B2DHomMatrix aDiv(rMatA); + aDiv -= rMatB; + return aDiv; + } - // Multiplikation, Division mit Konstante - inline B2DHomMatrix operator*(const B2DHomMatrix& rMat, double fValue) - { - B2DHomMatrix aNew(rMat); - aNew *= fValue; - return aNew; - } - - inline B2DHomMatrix operator/(const B2DHomMatrix& rMat, double fValue) - { - B2DHomMatrix aNew(rMat); - aNew *= 1.0 / fValue; - return aNew; - } - - inline B2DHomMatrix operator*(const B2DHomMatrix& rMatA, const B2DHomMatrix& rMatB) - { - B2DHomMatrix aMul(rMatB); - aMul *= rMatA; - return aMul; - } - } // end of namespace matrix + // Multiplikation, Division mit Konstante + inline B2DHomMatrix operator*(const B2DHomMatrix& rMat, double fValue) + { + B2DHomMatrix aNew(rMat); + aNew *= fValue; + return aNew; + } + + inline B2DHomMatrix operator/(const B2DHomMatrix& rMat, double fValue) + { + B2DHomMatrix aNew(rMat); + aNew *= 1.0 / fValue; + return aNew; + } + + inline B2DHomMatrix operator*(const B2DHomMatrix& rMatA, const B2DHomMatrix& rMatB) + { + B2DHomMatrix aMul(rMatB); + aMul *= rMatA; + return aMul; + } } // end of namespace basegfx #endif // _BGFX_MATRIX_B2DHOMMATRIX_HXX diff --git a/basegfx/inc/basegfx/matrix/b3dhommatrix.hxx b/basegfx/inc/basegfx/matrix/b3dhommatrix.hxx index f16b81c930d7..e2751a76c3cd 100644 --- a/basegfx/inc/basegfx/matrix/b3dhommatrix.hxx +++ b/basegfx/inc/basegfx/matrix/b3dhommatrix.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dhommatrix.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: thb $ $Date: 2003-11-12 12:12:40 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,136 +68,130 @@ namespace basegfx { - namespace tuple - { - // predeclaration - class B3DTuple; - } // end of namespace tuple + // predeclaration + class B3DTuple; + + // forward declaration + class Impl3DHomMatrix; - namespace matrix + class B3DHomMatrix { - // forward declaration - class Impl3DHomMatrix; + private: + Impl3DHomMatrix* mpM; - class B3DHomMatrix - { - private: - Impl3DHomMatrix* mpM; + void implPrepareChange(); - void implPrepareChange(); + public: + B3DHomMatrix(); + B3DHomMatrix(const B3DHomMatrix& rMat); + ~B3DHomMatrix(); - public: - B3DHomMatrix(); - B3DHomMatrix(const B3DHomMatrix& rMat); - ~B3DHomMatrix(); + double get(sal_uInt16 nRow, sal_uInt16 nColumn) const; + void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue); - double get(sal_uInt16 nRow, sal_uInt16 nColumn) const; - void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue); + sal_Bool isIdentity() const; + /// Reset to the identity matrix + void identity(); - sal_Bool isIdentity() const; - /// Reset to the identity matrix - void identity(); + sal_Bool isInvertible() const; + /// Invert the matrix (if possible) + sal_Bool invert(); - sal_Bool isInvertible() const; - /// Invert the matrix (if possible) - sal_Bool invert(); + sal_Bool isNormalized() const; + /// Normalize (i.e. force w=1) the matrix + void normalize(); - sal_Bool isNormalized() const; - /// Normalize (i.e. force w=1) the matrix - void normalize(); + /// Calc the matrix determinant + double determinant() const; - /// Calc the matrix determinant - double determinant() const; + /// Calc the matrix trace + double trace() const; - /// Calc the matrix trace - double trace() const; + /// Transpose the matrix + void transpose(); - /// Transpose the matrix - void transpose(); + /// Rotation + void rotate(double fAngleX,double fAngleY,double fAngleZ); - /// Rotation - void rotate(double fAngleX,double fAngleY,double fAngleZ); + /// Translation + void translate(double fX, double fY, double fZ); - /// Translation - void translate(double fX, double fY, double fZ); + /// Scaling + void scale(double fX, double fY, double fZ); - /// Scaling - void scale(double fX, double fY, double fZ); + // Shearing-Matrices + void shearXY(double fSx, double fSy); + void shearYZ(double fSy, double fSz); + void shearXZ(double fSx, double fSz); - // Shearing-Matrices - void shearXY(double fSx, double fSy); - void shearYZ(double fSy, double fSz); - void shearXZ(double fSx, double fSz); + // Projection matrices, used for converting between eye and + // clip coordinates + void frustum(double fLeft = -1.0, double fRight = 1.0, + double fBottom = -1.0, double fTop = 1.0, + double fNear = 0.001, double fFar = 1.0); - // Projection matrices, used for converting between eye and - // clip coordinates - void frustum(double fLeft = -1.0, double fRight = 1.0, - double fBottom = -1.0, double fTop = 1.0, - double fNear = 0.001, double fFar = 1.0); + void ortho(double fLeft = -1.0, double fRight = 1.0, + double fBottom = -1.0, double fTop = 1.0, + double fNear = 0.0, double fFar = 1.0); - void ortho(double fLeft = -1.0, double fRight = 1.0, - double fBottom = -1.0, double fTop = 1.0, - double fNear = 0.0, double fFar = 1.0); + // addition, subtraction + B3DHomMatrix& operator+=(const B3DHomMatrix& rMat); + B3DHomMatrix& operator-=(const B3DHomMatrix& rMat); - // addition, subtraction - B3DHomMatrix& operator+=(const B3DHomMatrix& rMat); - B3DHomMatrix& operator-=(const B3DHomMatrix& rMat); + // comparison + sal_Bool operator==(const B3DHomMatrix& rMat) const; + sal_Bool operator!=(const B3DHomMatrix& rMat) const; - // comparison - sal_Bool operator==(const B3DHomMatrix& rMat) const; - sal_Bool operator!=(const B3DHomMatrix& rMat) const; + // multiplication, division by constant value + B3DHomMatrix& operator*=(double fValue); + B3DHomMatrix& operator/=(double fValue); - // multiplication, division by constant value - B3DHomMatrix& operator*=(double fValue); - B3DHomMatrix& operator/=(double fValue); + // matrix multiplication (from the left) + B3DHomMatrix& operator*=(const B3DHomMatrix& rMat); - // matrix multiplication (from the left) - B3DHomMatrix& operator*=(const B3DHomMatrix& rMat); + // assignment operator + B3DHomMatrix& operator=(const B3DHomMatrix& rMat); - // assignment operator - B3DHomMatrix& operator=(const B3DHomMatrix& rMat); + // decomposition + sal_Bool decompose(B3DTuple& rScale, B3DTuple& rTranslate, B3DTuple& rRotate, B3DTuple& rShear) const; + }; - // decomposition - sal_Bool decompose(tuple::B3DTuple& rScale, tuple::B3DTuple& rTranslate, tuple::B3DTuple& rRotate, tuple::B3DTuple& rShear) const; - }; + // addition, subtraction + inline B3DHomMatrix operator+(const B3DHomMatrix& rMatA, const B3DHomMatrix& rMatB) + { + B3DHomMatrix aSum(rMatA); + aSum += rMatB; + return aSum; + } - // addition, subtraction - inline B3DHomMatrix operator+(const B3DHomMatrix& rMatA, const B3DHomMatrix& rMatB) - { - B3DHomMatrix aSum(rMatA); - aSum += rMatB; - return aSum; - } - - inline B3DHomMatrix operator-(const B3DHomMatrix& rMatA, const B3DHomMatrix& rMatB) - { - B3DHomMatrix aDiv(rMatA); - aDiv -= rMatB; - return aDiv; - } + inline B3DHomMatrix operator-(const B3DHomMatrix& rMatA, const B3DHomMatrix& rMatB) + { + B3DHomMatrix aDiv(rMatA); + aDiv -= rMatB; + return aDiv; + } - // multiplication, division by constant value - inline B3DHomMatrix operator*(const B3DHomMatrix& rMat, double fValue) - { - B3DHomMatrix aNew(rMat); - aNew *= fValue; - return aNew; - } - - inline B3DHomMatrix operator/(const B3DHomMatrix& rMat, double fValue) - { - B3DHomMatrix aNew(rMat); - aNew *= 1.0 / fValue; - return aNew; - } - - inline B3DHomMatrix operator*(const B3DHomMatrix& rMatA, const B3DHomMatrix& rMatB) - { - B3DHomMatrix aMul(rMatB); - aMul *= rMatA; - return aMul; - } - } // end of namespace matrix + // multiplication, division by constant value + inline B3DHomMatrix operator*(const B3DHomMatrix& rMat, double fValue) + { + B3DHomMatrix aNew(rMat); + aNew *= fValue; + return aNew; + } + + inline B3DHomMatrix operator/(const B3DHomMatrix& rMat, double fValue) + { + B3DHomMatrix aNew(rMat); + aNew *= 1.0 / fValue; + return aNew; + } + + inline B3DHomMatrix operator*(const B3DHomMatrix& rMatA, const B3DHomMatrix& rMatB) + { + B3DHomMatrix aMul(rMatB); + aMul *= rMatA; + return aMul; + } } // end of namespace basegfx #endif // _BGFX_MATRIX_B3DHOMMATRIX_HXX diff --git a/basegfx/inc/basegfx/numeric/ftools.hxx b/basegfx/inc/basegfx/numeric/ftools.hxx index 4a8287ff164c..9ae52843cfe0 100644 --- a/basegfx/inc/basegfx/numeric/ftools.hxx +++ b/basegfx/inc/basegfx/numeric/ftools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ftools.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:39:52 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -100,80 +100,77 @@ namespace basegfx { - namespace numeric + class fTools { - class fTools + static double mfSmallValue; + + public: + static double getSmallValue() { return mfSmallValue; } + static void setSmallValue(const double& rfNew) { mfSmallValue = rfNew; } + + + static sal_Bool equalZero(const double& rfVal) + { + return (fabs(rfVal) <= getSmallValue()); + } + + static sal_Bool equalZero(const double& rfVal, const double& rfSmallValue) + { + return (fabs(rfVal) <= rfSmallValue); + } + + + static sal_Bool equal(const double& rfValA, const double& rfValB) + { + return (fabs(rfValB - rfValA) <= getSmallValue()); + } + + static sal_Bool less(const double& rfValA, const double& rfValB) + { + return (rfValA < rfValB && !equal(rfValA, rfValB)); + } + + static sal_Bool lessOrEqual(const double& rfValA, const double& rfValB) + { + return (rfValA < rfValB || equal(rfValA, rfValB)); + } + + static sal_Bool more(const double& rfValA, const double& rfValB) + { + return (rfValA > rfValB && !equal(rfValA, rfValB)); + } + + static sal_Bool moreOrEqual(const double& rfValA, const double& rfValB) + { + return (rfValA > rfValB || equal(rfValA, rfValB)); + } + + + static sal_Bool equal(const double& rfValA, const double& rfValB, const double& rfSmallValue) + { + return (fabs(rfValB - rfValA) <= rfSmallValue); + } + + static sal_Bool less(const double& rfValA, const double& rfValB, const double& rfSmallValue) + { + return (rfValA < rfValB && !equal(rfValA, rfValB, rfSmallValue)); + } + + static sal_Bool lessOrEqual(const double& rfValA, const double& rfValB, const double& rfSmallValue) + { + return (rfValA < rfValB || equal(rfValA, rfValB, rfSmallValue)); + } + + static sal_Bool more(const double& rfValA, const double& rfValB, const double& rfSmallValue) + { + return (rfValA > rfValB && !equal(rfValA, rfValB, rfSmallValue)); + } + + static sal_Bool moreOrEqual(const double& rfValA, const double& rfValB, const double& rfSmallValue) { - static double mfSmallValue; - - public: - static double getSmallValue() { return mfSmallValue; } - static void setSmallValue(const double& rfNew) { mfSmallValue = rfNew; } - - - static sal_Bool equalZero(const double& rfVal) - { - return (fabs(rfVal) <= getSmallValue()); - } - - static sal_Bool equalZero(const double& rfVal, const double& rfSmallValue) - { - return (fabs(rfVal) <= rfSmallValue); - } - - - static sal_Bool equal(const double& rfValA, const double& rfValB) - { - return (fabs(rfValB - rfValA) <= getSmallValue()); - } - - static sal_Bool less(const double& rfValA, const double& rfValB) - { - return (rfValA < rfValB && !equal(rfValA, rfValB)); - } - - static sal_Bool lessOrEqual(const double& rfValA, const double& rfValB) - { - return (rfValA < rfValB || equal(rfValA, rfValB)); - } - - static sal_Bool more(const double& rfValA, const double& rfValB) - { - return (rfValA > rfValB && !equal(rfValA, rfValB)); - } - - static sal_Bool moreOrEqual(const double& rfValA, const double& rfValB) - { - return (rfValA > rfValB || equal(rfValA, rfValB)); - } - - - static sal_Bool equal(const double& rfValA, const double& rfValB, const double& rfSmallValue) - { - return (fabs(rfValB - rfValA) <= rfSmallValue); - } - - static sal_Bool less(const double& rfValA, const double& rfValB, const double& rfSmallValue) - { - return (rfValA < rfValB && !equal(rfValA, rfValB, rfSmallValue)); - } - - static sal_Bool lessOrEqual(const double& rfValA, const double& rfValB, const double& rfSmallValue) - { - return (rfValA < rfValB || equal(rfValA, rfValB, rfSmallValue)); - } - - static sal_Bool more(const double& rfValA, const double& rfValB, const double& rfSmallValue) - { - return (rfValA > rfValB && !equal(rfValA, rfValB, rfSmallValue)); - } - - static sal_Bool moreOrEqual(const double& rfValA, const double& rfValB, const double& rfSmallValue) - { - return (rfValA > rfValB || equal(rfValA, rfValB, rfSmallValue)); - } - }; - } // end of namespace numeric + return (rfValA > rfValB || equal(rfValA, rfValB, rfSmallValue)); + } + }; } // end of namespace basegfx #endif _BGFX_NUMERIC_FTOOLS_HXX diff --git a/basegfx/inc/basegfx/point/b2dhompoint.hxx b/basegfx/inc/basegfx/point/b2dhompoint.hxx index 3b145bf4e444..911e61a884fd 100644 --- a/basegfx/inc/basegfx/point/b2dhompoint.hxx +++ b/basegfx/inc/basegfx/point/b2dhompoint.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dhompoint.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-06 16:30:23 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,209 +68,206 @@ namespace basegfx { - namespace point + /** Basic homogen Point class with two double values and one homogen factor + + This class provides access to homogen coordinates in 2D. + For this purpose all the operators which need to do specific + action due to their homogenity are implemented here. + The only caveat are member methods which are declared as const + but do change the content. These are documented for that reason. + The class is designed to provide homogenous coordinates without + direct access to the homogen part (mfW). This is also the reason + for leaving out the [] operators which return references to members. + + @see B2DTuple + */ + class B2DHomPoint { - /** Basic homogen Point class with two double values and one homogen factor - - This class provides access to homogen coordinates in 2D. - For this purpose all the operators which need to do specific - action due to their homogenity are implemented here. - The only caveat are member methods which are declared as const - but do change the content. These are documented for that reason. - The class is designed to provide homogenous coordinates without - direct access to the homogen part (mfW). This is also the reason - for leaving out the [] operators which return references to members. - - @see B2DTuple + protected: + /// This member contains the coordinate part of the point + ::basegfx::B2DTuple maTuple; + + /// This Member holds the homogenous part of the point + double mfW; + + /** Test if this homogen point does have a homogenous part + + @return Returns sal_True if this point has no homogenous part */ - class B2DHomPoint - { - protected: - /// This member contains the coordinate part of the point - ::basegfx::tuple::B2DTuple maTuple; - - /// This Member holds the homogenous part of the point - double mfW; - - /** Test if this homogen point does have a homogenous part - - @return Returns sal_True if this point has no homogenous part - */ - sal_Bool implIsHomogenized() const; - - /** Remove homogenous part of this Point - - This method does necessary calculations to remove - the evtl. homogenous part of this Point. This may - change all members. - */ - void implHomogenize(); + sal_Bool implIsHomogenized() const; - /** Test and on demand remove homogenous part - - This method tests if this Point does have a homogenous part - and then evtl. takes actions to remove that part. - - @attention Even when this method is const it may change all - members of this instance. This is due to the fact that changing - the homogenous part of a homogenous point does from a mathematical - point of view not change the point at all. - */ - void implTestAndHomogenize() const; + /** Remove homogenous part of this Point + + This method does necessary calculations to remove + the evtl. homogenous part of this Point. This may + change all members. + */ + void implHomogenize(); + + /** Test and on demand remove homogenous part + + This method tests if this Point does have a homogenous part + and then evtl. takes actions to remove that part. + + @attention Even when this method is const it may change all + members of this instance. This is due to the fact that changing + the homogenous part of a homogenous point does from a mathematical + point of view not change the point at all. + */ + void implTestAndHomogenize() const; - public: - /** Create a homogen point + public: + /** Create a homogen point - @param fVal - This parameter is used to initialize the coordinate - part of the Point. The homogenous part is initialized to 1.0. - */ - B2DHomPoint(double fVal = 0.0) - : maTuple(fVal), - mfW(1.0) - {} + @param fVal + This parameter is used to initialize the coordinate + part of the Point. The homogenous part is initialized to 1.0. + */ + B2DHomPoint(double fVal = 0.0) + : maTuple(fVal), + mfW(1.0) + {} - /** Create a homogen point + /** Create a homogen point - @param fX - This parameter is used to initialize the X-coordinate - of the Point. The homogenous part is initialized to 1.0. + @param fX + This parameter is used to initialize the X-coordinate + of the Point. The homogenous part is initialized to 1.0. - @param fY - This parameter is used to initialize the Y-coordinate - of the Point. The homogenous part is initialized to 1.0. - */ - B2DHomPoint(double fX, double fY) - : maTuple(fX, fY), - mfW(1.0) - {} + @param fY + This parameter is used to initialize the Y-coordinate + of the Point. The homogenous part is initialized to 1.0. + */ + B2DHomPoint(double fX, double fY) + : maTuple(fX, fY), + mfW(1.0) + {} - /** Create a copy of a 2D Point + /** Create a copy of a 2D Point - @param rVec - The 2D point which will be copied. The homogenous part - is initialized to 1.0. - */ - B2DHomPoint(const B2DPoint& rVec) - : maTuple(rVec), - mfW(1.0) - {} + @param rVec + The 2D point which will be copied. The homogenous part + is initialized to 1.0. + */ + B2DHomPoint(const B2DPoint& rVec) + : maTuple(rVec), + mfW(1.0) + {} - /** Create a copy of a homogen point + /** Create a copy of a homogen point - @param rVec - The homogen point which will be copied. The homogenous part - is copied, too. - */ - B2DHomPoint(const B2DHomPoint& rVec) - : maTuple(rVec.maTuple.getX(), rVec.maTuple.getY()), - mfW(rVec.mfW) - {} + @param rVec + The homogen point which will be copied. The homogenous part + is copied, too. + */ + B2DHomPoint(const B2DHomPoint& rVec) + : maTuple(rVec.maTuple.getX(), rVec.maTuple.getY()), + mfW(rVec.mfW) + {} - ~B2DHomPoint() - {} + ~B2DHomPoint() + {} - /** Get a 2D point from this homogenous point + /** Get a 2D point from this homogenous point - This method normalizes this homogen point if necessary and - returns the corresponding 2D point for this homogen point. + This method normalizes this homogen point if necessary and + returns the corresponding 2D point for this homogen point. - @attention Even when this method is const it may change all - members of this instance. - */ - B2DPoint getB2DPoint() const; + @attention Even when this method is const it may change all + members of this instance. + */ + B2DPoint getB2DPoint() const; - /** Get X-coordinate + /** Get X-coordinate - This method normalizes this homogen point if necessary and - returns the corresponding X-coordinate for this homogen point. + This method normalizes this homogen point if necessary and + returns the corresponding X-coordinate for this homogen point. - @attention Even when this method is const it may change all - members of this instance. - */ - double getX() const; + @attention Even when this method is const it may change all + members of this instance. + */ + double getX() const; - /** Get Y-coordinate + /** Get Y-coordinate - This method normalizes this homogen point if necessary and - returns the corresponding Y-coordinate for this homogen point. + This method normalizes this homogen point if necessary and + returns the corresponding Y-coordinate for this homogen point. - @attention Even when this method is const it may change all - members of this instance. - */ - double getY() const; + @attention Even when this method is const it may change all + members of this instance. + */ + double getY() const; - /** Set X-coordinate of the homogen point. + /** Set X-coordinate of the homogen point. - This method sets the X-coordinate of the homogen point. If - the point does have a homogenous part this is taken into account. + This method sets the X-coordinate of the homogen point. If + the point does have a homogenous part this is taken into account. - @param fX - The to-be-set X-coordinate without homogenous part. - */ - void setX(double fX); + @param fX + The to-be-set X-coordinate without homogenous part. + */ + void setX(double fX); - /** Set Y-coordinate of the homogen point. + /** Set Y-coordinate of the homogen point. - This method sets the Y-coordinate of the homogen point. If - the point does have a homogenous part this is taken into account. + This method sets the Y-coordinate of the homogen point. If + the point does have a homogenous part this is taken into account. - @param fY - The to-be-set Y-coordinate without homogenous part. - */ - void setY(double fY); + @param fY + The to-be-set Y-coordinate without homogenous part. + */ + void setY(double fY); - // operators - ////////////////////////////////////////////////////////////////////// + // operators + ////////////////////////////////////////////////////////////////////// - B2DHomPoint& operator+=( const B2DHomPoint& rPnt ); + B2DHomPoint& operator+=( const B2DHomPoint& rPnt ); - B2DHomPoint& operator-=( const B2DHomPoint& rPnt ); + B2DHomPoint& operator-=( const B2DHomPoint& rPnt ); - B2DHomPoint& operator*=(double t); + B2DHomPoint& operator*=(double t); - B2DHomPoint& operator*=( const matrix::B2DHomMatrix& rMat ); + B2DHomPoint& operator*=( const B2DHomMatrix& rMat ); - B2DHomPoint& operator/=(double t); + B2DHomPoint& operator/=(double t); - B2DHomPoint& operator-(void); + B2DHomPoint& operator-(void); - sal_Bool operator==( const B2DHomPoint& rPnt ) const; + sal_Bool operator==( const B2DHomPoint& rPnt ) const; - sal_Bool operator!=( const B2DHomPoint& rPnt ) const; + sal_Bool operator!=( const B2DHomPoint& rPnt ) const; - B2DHomPoint& operator=( const B2DHomPoint& rPnt ); - }; + B2DHomPoint& operator=( const B2DHomPoint& rPnt ); + }; - // external operators - ////////////////////////////////////////////////////////////////////////// + // external operators + ////////////////////////////////////////////////////////////////////////// - B2DHomPoint min(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); + B2DHomPoint min(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); - B2DHomPoint max(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); + B2DHomPoint max(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); - B2DHomPoint abs(const B2DHomPoint& rVec); + B2DHomPoint abs(const B2DHomPoint& rVec); - B2DHomPoint interpolate(B2DHomPoint& rOld1, B2DHomPoint& rOld2, double t); + B2DHomPoint interpolate(B2DHomPoint& rOld1, B2DHomPoint& rOld2, double t); - B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2); + B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2); - B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2, B2DHomPoint& rOld3); + B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2, B2DHomPoint& rOld3); - B2DHomPoint operator+(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); + B2DHomPoint operator+(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); - B2DHomPoint operator-(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); + B2DHomPoint operator-(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); - B2DHomPoint operator*(const B2DHomPoint& rVec, double t); + B2DHomPoint operator*(const B2DHomPoint& rVec, double t); - B2DHomPoint operator*(double t, const B2DHomPoint& rVec); + B2DHomPoint operator*(double t, const B2DHomPoint& rVec); - B2DHomPoint operator*( const matrix::B2DHomMatrix& rMat, const B2DHomPoint& rPoint ); + B2DHomPoint operator*( const B2DHomMatrix& rMat, const B2DHomPoint& rPoint ); - B2DHomPoint operator/(const B2DHomPoint& rVec, double t); + B2DHomPoint operator/(const B2DHomPoint& rVec, double t); - B2DHomPoint operator/(double t, const B2DHomPoint& rVec); - } // end of namespace point + B2DHomPoint operator/(double t, const B2DHomPoint& rVec); } // end of namespace basegfx #endif // _BGFX_POINT_B2DHOMPOINT_HXX diff --git a/basegfx/inc/basegfx/point/b2dpoint.hxx b/basegfx/inc/basegfx/point/b2dpoint.hxx index eb5f042f69e8..ed07229f4e59 100644 --- a/basegfx/inc/basegfx/point/b2dpoint.hxx +++ b/basegfx/inc/basegfx/point/b2dpoint.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpoint.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:39:54 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,104 +68,98 @@ namespace basegfx { - namespace matrix - { - // predeclaration - class B2DHomMatrix; - } // end of namespace matrix; + // predeclaration + class B2DHomMatrix; + + /** Base Point class with two double values + + This class derives all operators and common handling for + a 2D data class from B2DTuple. All necessary extensions + which are special for points will be added here. - namespace point + @see B2DTuple + */ + class B2DPoint : public ::basegfx::B2DTuple { - /** Base Point class with two double values + public: + /** Create a 2D Point + + @param fVal + This parameter is used to initialize the coordinate + part of the 2D Point. + */ + B2DPoint(double fVal = 0.0) + : B2DTuple(fVal) + {} + + /** Create a 2D Point + + @param fX + This parameter is used to initialize the X-coordinate + of the 2D Point. + + @param fY + This parameter is used to initialize the Y-coordinate + of the 2D Point. + */ + B2DPoint(double fX, double fY) + : B2DTuple(fX, fY) + {} + + /** Create a copy of a 2D Point + + @param rPoint + The 2D Point which will be copied. + */ + B2DPoint(const B2DPoint& rPoint) + : B2DTuple(rPoint) + {} - This class derives all operators and common handling for - a 2D data class from B2DTuple. All necessary extensions - which are special for points will be added here. + /** constructor with tuple to allow copy-constructing + from B2DTuple-based classes + */ + B2DPoint(const ::basegfx::B2DTuple& rTuple) + : B2DTuple(rTuple) + {} + + ~B2DPoint() + {} + + /** *=operator to allow usage from B2DPoint, too + */ + B2DPoint& operator*=( const B2DPoint& rPnt ) + { + mfX *= rPnt.mfX; + mfY *= rPnt.mfY; + return *this; + } + + /** *=operator to allow usage from B2DPoint, too + */ + B2DPoint& operator*=(double t) + { + mfX *= t; + mfY *= t; + return *this; + } + + /** assignment operator to allow assigning the results + of B2DTuple calculations + */ + B2DPoint& operator=( const ::basegfx::B2DTuple& rPoint ); + + /** Transform point by given transformation matrix. - @see B2DTuple + The translational components of the matrix are, in + contrast to B2DVector, applied. */ - class B2DPoint : public ::basegfx::tuple::B2DTuple + B2DPoint& operator*=( const ::basegfx::B2DHomMatrix& rMat ); + + static const B2DPoint& getEmptyPoint() { - public: - /** Create a 2D Point - - @param fVal - This parameter is used to initialize the coordinate - part of the 2D Point. - */ - B2DPoint(double fVal = 0.0) - : B2DTuple(fVal) - {} - - /** Create a 2D Point - - @param fX - This parameter is used to initialize the X-coordinate - of the 2D Point. - - @param fY - This parameter is used to initialize the Y-coordinate - of the 2D Point. - */ - B2DPoint(double fX, double fY) - : B2DTuple(fX, fY) - {} - - /** Create a copy of a 2D Point - - @param rPoint - The 2D Point which will be copied. - */ - B2DPoint(const B2DPoint& rPoint) - : B2DTuple(rPoint) - {} - - /** constructor with tuple to allow copy-constructing - from B2DTuple-based classes - */ - B2DPoint(const ::basegfx::tuple::B2DTuple& rTuple) - : B2DTuple(rTuple) - {} - - ~B2DPoint() - {} - - /** *=operator to allow usage from B2DPoint, too - */ - B2DPoint& operator*=( const B2DPoint& rPnt ) - { - mfX *= rPnt.mfX; - mfY *= rPnt.mfY; - return *this; - } - - /** *=operator to allow usage from B2DPoint, too - */ - B2DPoint& operator*=(double t) - { - mfX *= t; - mfY *= t; - return *this; - } - - /** assignment operator to allow assigning the results - of B2DTuple calculations - */ - B2DPoint& operator=( const ::basegfx::tuple::B2DTuple& rPoint ); - - /** Transform point by given transformation matrix. - - The translational components of the matrix are, in - contrast to B2DVector, applied. - */ - B2DPoint& operator*=( const ::basegfx::matrix::B2DHomMatrix& rMat ); - - static const B2DPoint& getEmptyPoint() - { - return (const B2DPoint&) ::basegfx::tuple::B2DTuple::getEmptyTuple(); - } - }; - } // end of namespace point + return (const B2DPoint&) ::basegfx::B2DTuple::getEmptyTuple(); + } + }; } // end of namespace basegfx #endif // _BGFX_POINT_B2DPOINT_HXX diff --git a/basegfx/inc/basegfx/point/b3dhompoint.hxx b/basegfx/inc/basegfx/point/b3dhompoint.hxx index 7cd82c364a7f..08079b90a983 100644 --- a/basegfx/inc/basegfx/point/b3dhompoint.hxx +++ b/basegfx/inc/basegfx/point/b3dhompoint.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dhompoint.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-10 11:45:47 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,379 +68,376 @@ namespace basegfx { - namespace point + /** Basic homogen Point class with three double values and one homogen factor + + This class provides access to homogen coordinates in 3D. + For this purpose all the operators which need to do specific + action due to their homogenity are implemented here. + The only caveat are member methods which are declared as const + but do change the content. These are documented for that reason. + The class is designed to provide homogenous coordinates without + direct access to the homogen part (mfW). This is also the reason + for leaving out the [] operators which return references to members. + + @see B3DTuple + */ + class B3DHomPoint { - /** Basic homogen Point class with three double values and one homogen factor - - This class provides access to homogen coordinates in 3D. - For this purpose all the operators which need to do specific - action due to their homogenity are implemented here. - The only caveat are member methods which are declared as const - but do change the content. These are documented for that reason. - The class is designed to provide homogenous coordinates without - direct access to the homogen part (mfW). This is also the reason - for leaving out the [] operators which return references to members. - - @see B3DTuple - */ - class B3DHomPoint - { - protected: - /// This member contains the coordinate part of the point - ::basegfx::tuple::B3DTuple maTuple; + protected: + /// This member contains the coordinate part of the point + ::basegfx::B3DTuple maTuple; - /// This Member holds the homogenous part of the point - double mfW; + /// This Member holds the homogenous part of the point + double mfW; - /** Test if this homogen point does have a homogenous part + /** Test if this homogen point does have a homogenous part - @return Returns sal_True if this point has no homogenous part - */ - sal_Bool implIsHomogenized() const - { - const double fOne(1.0); - return ::basegfx::numeric::fTools::equal(mfW, fOne); - } + @return Returns sal_True if this point has no homogenous part + */ + sal_Bool implIsHomogenized() const + { + const double fOne(1.0); + return ::basegfx::fTools::equal(mfW, fOne); + } - /** Remove homogenous part of this Point + /** Remove homogenous part of this Point - This method does necessary calculations to remove - the evtl. homogenous part of this Point. This may - change all members. - */ - void implHomogenize(); + This method does necessary calculations to remove + the evtl. homogenous part of this Point. This may + change all members. + */ + void implHomogenize(); - /** Test and on demand remove homogenous part + /** Test and on demand remove homogenous part - This method tests if this Point does have a homogenous part - and then evtl. takes actions to remove that part. + This method tests if this Point does have a homogenous part + and then evtl. takes actions to remove that part. - @attention Even when this method is const it may change all - members of this instance. This is due to the fact that changing - the homogenous part of a homogenous point does from a mathematical - point of view not change the point at all. - */ - void implTestAndHomogenize() const - { - if(!implIsHomogenized()) - ((B3DHomPoint*)this)->implHomogenize(); - } + @attention Even when this method is const it may change all + members of this instance. This is due to the fact that changing + the homogenous part of a homogenous point does from a mathematical + point of view not change the point at all. + */ + void implTestAndHomogenize() const + { + if(!implIsHomogenized()) + ((B3DHomPoint*)this)->implHomogenize(); + } - public: - /** Create a homogen point - - @param fVal - This parameter is used to initialize the coordinate - part of the Point. The homogenous part is initialized to 1.0. - */ - B3DHomPoint(double fVal = 0.0) - : maTuple(fVal), - mfW(1.0) - {} - - /** Create a homogen point - - @param fX - This parameter is used to initialize the X-coordinate - of the Point. The homogenous part is initialized to 1.0. - - @param fY - This parameter is used to initialize the Y-coordinate - of the Point. The homogenous part is initialized to 1.0. - - @param fZ - This parameter is used to initialize the Z-coordinate - of the Point. The homogenous part is initialized to 1.0. - */ - B3DHomPoint(double fX, double fY, double fZ) - : maTuple(fX, fY, fZ), - mfW(1.0) - {} - - /** Create a copy of a 3D Point - - @param rVec - The 3D point which will be copied. The homogenous part - is initialized to 1.0. - */ - B3DHomPoint(const B3DPoint& rVec) - : maTuple(rVec), - mfW(1.0) - {} - - /** Create a copy of a homogen point - - @param rVec - The homogen point which will be copied. The homogenous part - is copied, too. - */ - B3DHomPoint(const B3DHomPoint& rVec) - : maTuple(rVec.maTuple.getX(), rVec.maTuple.getY(), rVec.maTuple.getZ()), - mfW(rVec.mfW) - {} - - ~B3DHomPoint() - {} - - /** get a 3D point from this homogenous point - - This method normalizes this homogen point if necessary and - returns the corresponding 3D point for this homogen point. - - @attention Even when this method is const it may change all - members of this instance. - */ - B3DPoint getB3DPoint() const - { - implTestAndHomogenize(); - return B3DPoint(maTuple.getX(), maTuple.getY(), maTuple.getZ()); - } + public: + /** Create a homogen point - /** get X-coordinate + @param fVal + This parameter is used to initialize the coordinate + part of the Point. The homogenous part is initialized to 1.0. + */ + B3DHomPoint(double fVal = 0.0) + : maTuple(fVal), + mfW(1.0) + {} - This method normalizes this homogen point if necessary and - returns the corresponding X-coordinate for this homogen point. + /** Create a homogen point - @attention Even when this method is const it may change all - members of this instance. - */ - double getX() const - { - implTestAndHomogenize(); - return maTuple.getX(); - } + @param fX + This parameter is used to initialize the X-coordinate + of the Point. The homogenous part is initialized to 1.0. - /** get Y-coordinate + @param fY + This parameter is used to initialize the Y-coordinate + of the Point. The homogenous part is initialized to 1.0. - This method normalizes this homogen point if necessary and - returns the corresponding Y-coordinate for this homogen point. + @param fZ + This parameter is used to initialize the Z-coordinate + of the Point. The homogenous part is initialized to 1.0. + */ + B3DHomPoint(double fX, double fY, double fZ) + : maTuple(fX, fY, fZ), + mfW(1.0) + {} - @attention Even when this method is const it may change all - members of this instance. - */ - double getY() const - { - implTestAndHomogenize(); - return maTuple.getY(); - } + /** Create a copy of a 3D Point - /** get Z-coordinate + @param rVec + The 3D point which will be copied. The homogenous part + is initialized to 1.0. + */ + B3DHomPoint(const B3DPoint& rVec) + : maTuple(rVec), + mfW(1.0) + {} - This method normalizes this homogen point if necessary and - returns the corresponding Z-coordinate for this homogen point. + /** Create a copy of a homogen point - @attention Even when this method is const it may change all - members of this instance. - */ - double getZ() const - { - implTestAndHomogenize(); - return maTuple.getY(); - } + @param rVec + The homogen point which will be copied. The homogenous part + is copied, too. + */ + B3DHomPoint(const B3DHomPoint& rVec) + : maTuple(rVec.maTuple.getX(), rVec.maTuple.getY(), rVec.maTuple.getZ()), + mfW(rVec.mfW) + {} - /** Set X-coordinate of the homogen point. + ~B3DHomPoint() + {} - This method sets the X-coordinate of the homogen point. If - the point does have a homogenous part this is taken into account. + /** get a 3D point from this homogenous point - @param fX - The to-be-set X-coordinate without homogenous part. - */ - void setX(double fX) - { - maTuple.setX(implIsHomogenized() ? fX : fX * mfW ); - } + This method normalizes this homogen point if necessary and + returns the corresponding 3D point for this homogen point. - /** Set Y-coordinate of the homogen point. + @attention Even when this method is const it may change all + members of this instance. + */ + B3DPoint getB3DPoint() const + { + implTestAndHomogenize(); + return B3DPoint(maTuple.getX(), maTuple.getY(), maTuple.getZ()); + } - This method sets the Y-coordinate of the homogen point. If - the point does have a homogenous part this is taken into account. + /** get X-coordinate - @param fY - The to-be-set Y-coordinate without homogenous part. - */ - void setY(double fY) - { - maTuple.setY(implIsHomogenized() ? fY : fY * mfW ); - } + This method normalizes this homogen point if necessary and + returns the corresponding X-coordinate for this homogen point. - /** Set Z-coordinate of the homogen point. + @attention Even when this method is const it may change all + members of this instance. + */ + double getX() const + { + implTestAndHomogenize(); + return maTuple.getX(); + } - This method sets the Z-coordinate of the homogen point. If - the point does have a homogenous part this is taken into account. + /** get Y-coordinate - @param fZ - The to-be-set Z-coordinate without homogenous part. - */ - void setZ(double fZ) - { - maTuple.setZ(implIsHomogenized() ? fZ : fZ * mfW ); - } + This method normalizes this homogen point if necessary and + returns the corresponding Y-coordinate for this homogen point. - // operators - ////////////////////////////////////////////////////////////////////// + @attention Even when this method is const it may change all + members of this instance. + */ + double getY() const + { + implTestAndHomogenize(); + return maTuple.getY(); + } - B3DHomPoint& operator+=( const B3DHomPoint& rPnt ) - { - maTuple.setX(getX() * rPnt.mfW + rPnt.getX() * mfW); - maTuple.setY(getY() * rPnt.mfW + rPnt.getY() * mfW); - maTuple.setZ(getZ() * rPnt.mfW + rPnt.getZ() * mfW); - mfW = mfW * rPnt.mfW; + /** get Z-coordinate - return *this; - } + This method normalizes this homogen point if necessary and + returns the corresponding Z-coordinate for this homogen point. - B3DHomPoint& operator-=( const B3DHomPoint& rPnt ) - { - maTuple.setX(getX() * rPnt.mfW - rPnt.getX() * mfW); - maTuple.setY(getY() * rPnt.mfW - rPnt.getY() * mfW); - maTuple.setZ(getZ() * rPnt.mfW - rPnt.getZ() * mfW); - mfW = mfW * rPnt.mfW; + @attention Even when this method is const it may change all + members of this instance. + */ + double getZ() const + { + implTestAndHomogenize(); + return maTuple.getY(); + } - return *this; - } + /** Set X-coordinate of the homogen point. - B3DHomPoint& operator*=(double t) - { - if(!::basegfx::numeric::fTools::equalZero(t)) - { - mfW /= t; - } + This method sets the X-coordinate of the homogen point. If + the point does have a homogenous part this is taken into account. - return *this; - } - - B3DHomPoint& operator/=(double t) - { - mfW *= t; - return *this; - } + @param fX + The to-be-set X-coordinate without homogenous part. + */ + void setX(double fX) + { + maTuple.setX(implIsHomogenized() ? fX : fX * mfW ); + } - B3DHomPoint& operator-(void) - { - mfW = -mfW; - return *this; - } + /** Set Y-coordinate of the homogen point. - sal_Bool operator==( const B3DHomPoint& rPnt ) const - { - implTestAndHomogenize(); - return (maTuple == rPnt.maTuple); - } + This method sets the Y-coordinate of the homogen point. If + the point does have a homogenous part this is taken into account. - sal_Bool operator!=( const B3DHomPoint& rPnt ) const - { - implTestAndHomogenize(); - return (maTuple != rPnt.maTuple); - } + @param fY + The to-be-set Y-coordinate without homogenous part. + */ + void setY(double fY) + { + maTuple.setY(implIsHomogenized() ? fY : fY * mfW ); + } - B3DHomPoint& operator=( const B3DHomPoint& rPnt ) - { - maTuple = rPnt.maTuple; - mfW = rPnt.mfW; - return *this; - } - }; + /** Set Z-coordinate of the homogen point. - // external operators - ////////////////////////////////////////////////////////////////////////// + This method sets the Z-coordinate of the homogen point. If + the point does have a homogenous part this is taken into account. - inline B3DHomPoint min(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB) + @param fZ + The to-be-set Z-coordinate without homogenous part. + */ + void setZ(double fZ) { - B3DHomPoint aMin( - (rVecB.getX() < rVecA.getX()) ? rVecB.getX() : rVecA.getX(), - (rVecB.getY() < rVecA.getY()) ? rVecB.getY() : rVecA.getY(), - (rVecB.getZ() < rVecA.getZ()) ? rVecB.getZ() : rVecA.getZ()); - return aMin; + maTuple.setZ(implIsHomogenized() ? fZ : fZ * mfW ); } - inline B3DHomPoint max(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB) - { - B3DHomPoint aMax( - (rVecB.getX() > rVecA.getX()) ? rVecB.getX() : rVecA.getX(), - (rVecB.getY() > rVecA.getY()) ? rVecB.getY() : rVecA.getY(), - (rVecB.getZ() > rVecA.getZ()) ? rVecB.getZ() : rVecA.getZ()); - return aMax; - } + // operators + ////////////////////////////////////////////////////////////////////// - inline B3DHomPoint abs(const B3DHomPoint& rVec) + B3DHomPoint& operator+=( const B3DHomPoint& rPnt ) { - B3DHomPoint aAbs( - (0.0 > rVec.getX()) ? -rVec.getX() : rVec.getX(), - (0.0 > rVec.getY()) ? -rVec.getY() : rVec.getY(), - (0.0 > rVec.getZ()) ? -rVec.getZ() : rVec.getZ()); - return aAbs; - } + maTuple.setX(getX() * rPnt.mfW + rPnt.getX() * mfW); + maTuple.setY(getY() * rPnt.mfW + rPnt.getY() * mfW); + maTuple.setZ(getZ() * rPnt.mfW + rPnt.getZ() * mfW); + mfW = mfW * rPnt.mfW; - inline B3DHomPoint interpolate(B3DHomPoint& rOld1, B3DHomPoint& rOld2, double t) - { - B3DHomPoint aInt( - ((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), - ((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(), - ((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()); - return aInt; + return *this; } - inline B3DHomPoint average(B3DHomPoint& rOld1, B3DHomPoint& rOld2) + B3DHomPoint& operator-=( const B3DHomPoint& rPnt ) { - B3DHomPoint aAvg( - (rOld1.getX() + rOld2.getX()) * 0.5, - (rOld1.getY() + rOld2.getY()) * 0.5, - (rOld1.getZ() + rOld2.getZ()) * 0.5); - return aAvg; - } + maTuple.setX(getX() * rPnt.mfW - rPnt.getX() * mfW); + maTuple.setY(getY() * rPnt.mfW - rPnt.getY() * mfW); + maTuple.setZ(getZ() * rPnt.mfW - rPnt.getZ() * mfW); + mfW = mfW * rPnt.mfW; - inline B3DHomPoint average(B3DHomPoint& rOld1, B3DHomPoint& rOld2, B3DHomPoint& rOld3) - { - B3DHomPoint aAvg( - (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), - (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0), - (rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)); - return aAvg; + return *this; } - inline B3DHomPoint operator+(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB) + B3DHomPoint& operator*=(double t) { - B3DHomPoint aSum(rVecA); - aSum += rVecB; - return aSum; + if(!::basegfx::fTools::equalZero(t)) + { + mfW /= t; + } + + return *this; } - inline B3DHomPoint operator-(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB) + B3DHomPoint& operator/=(double t) { - B3DHomPoint aSub(rVecA); - aSub -= rVecB; - return aSub; + mfW *= t; + return *this; } - inline B3DHomPoint operator*(const B3DHomPoint& rVec, double t) + B3DHomPoint& operator-(void) { - B3DHomPoint aNew(rVec); - aNew *= t; - return aNew; + mfW = -mfW; + return *this; } - inline B3DHomPoint operator*(double t, const B3DHomPoint& rVec) + sal_Bool operator==( const B3DHomPoint& rPnt ) const { - B3DHomPoint aNew(rVec); - aNew *= t; - return aNew; + implTestAndHomogenize(); + return (maTuple == rPnt.maTuple); } - inline B3DHomPoint operator/(const B3DHomPoint& rVec, double t) + sal_Bool operator!=( const B3DHomPoint& rPnt ) const { - B3DHomPoint aNew(rVec); - aNew /= t; - return aNew; + implTestAndHomogenize(); + return (maTuple != rPnt.maTuple); } - inline B3DHomPoint operator/(double t, const B3DHomPoint& rVec) + B3DHomPoint& operator=( const B3DHomPoint& rPnt ) { - B3DHomPoint aNew(rVec); - aNew /= t; - return aNew; + maTuple = rPnt.maTuple; + mfW = rPnt.mfW; + return *this; } - } // end of namespace point + }; + + // external operators + ////////////////////////////////////////////////////////////////////////// + + inline B3DHomPoint min(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB) + { + B3DHomPoint aMin( + (rVecB.getX() < rVecA.getX()) ? rVecB.getX() : rVecA.getX(), + (rVecB.getY() < rVecA.getY()) ? rVecB.getY() : rVecA.getY(), + (rVecB.getZ() < rVecA.getZ()) ? rVecB.getZ() : rVecA.getZ()); + return aMin; + } + + inline B3DHomPoint max(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB) + { + B3DHomPoint aMax( + (rVecB.getX() > rVecA.getX()) ? rVecB.getX() : rVecA.getX(), + (rVecB.getY() > rVecA.getY()) ? rVecB.getY() : rVecA.getY(), + (rVecB.getZ() > rVecA.getZ()) ? rVecB.getZ() : rVecA.getZ()); + return aMax; + } + + inline B3DHomPoint abs(const B3DHomPoint& rVec) + { + B3DHomPoint aAbs( + (0.0 > rVec.getX()) ? -rVec.getX() : rVec.getX(), + (0.0 > rVec.getY()) ? -rVec.getY() : rVec.getY(), + (0.0 > rVec.getZ()) ? -rVec.getZ() : rVec.getZ()); + return aAbs; + } + + inline B3DHomPoint interpolate(B3DHomPoint& rOld1, B3DHomPoint& rOld2, double t) + { + B3DHomPoint aInt( + ((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), + ((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(), + ((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()); + return aInt; + } + + inline B3DHomPoint average(B3DHomPoint& rOld1, B3DHomPoint& rOld2) + { + B3DHomPoint aAvg( + (rOld1.getX() + rOld2.getX()) * 0.5, + (rOld1.getY() + rOld2.getY()) * 0.5, + (rOld1.getZ() + rOld2.getZ()) * 0.5); + return aAvg; + } + + inline B3DHomPoint average(B3DHomPoint& rOld1, B3DHomPoint& rOld2, B3DHomPoint& rOld3) + { + B3DHomPoint aAvg( + (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), + (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0), + (rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)); + return aAvg; + } + + inline B3DHomPoint operator+(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB) + { + B3DHomPoint aSum(rVecA); + aSum += rVecB; + return aSum; + } + + inline B3DHomPoint operator-(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB) + { + B3DHomPoint aSub(rVecA); + aSub -= rVecB; + return aSub; + } + + inline B3DHomPoint operator*(const B3DHomPoint& rVec, double t) + { + B3DHomPoint aNew(rVec); + aNew *= t; + return aNew; + } + + inline B3DHomPoint operator*(double t, const B3DHomPoint& rVec) + { + B3DHomPoint aNew(rVec); + aNew *= t; + return aNew; + } + + inline B3DHomPoint operator/(const B3DHomPoint& rVec, double t) + { + B3DHomPoint aNew(rVec); + aNew /= t; + return aNew; + } + + inline B3DHomPoint operator/(double t, const B3DHomPoint& rVec) + { + B3DHomPoint aNew(rVec); + aNew /= t; + return aNew; + } } // end of namespace basegfx #endif // _BGFX_POINT_B3DHOMPOINT_HXX diff --git a/basegfx/inc/basegfx/point/b3dpoint.hxx b/basegfx/inc/basegfx/point/b3dpoint.hxx index 7f444b850234..06a4b7e346e1 100644 --- a/basegfx/inc/basegfx/point/b3dpoint.hxx +++ b/basegfx/inc/basegfx/point/b3dpoint.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dpoint.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:39:54 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,116 +68,110 @@ namespace basegfx { - namespace matrix - { - // predeclaration - class B3DHomMatrix; - } // end of namespace matrix; + // predeclaration + class B3DHomMatrix; + + /** Base Point class with three double values - namespace point + This class derives all operators and common handling for + a 3D data class from B3DTuple. All necessary extensions + which are special for points will be added here. + + @see B3DTuple + */ + class B3DPoint : public ::basegfx::B3DTuple { - /** Base Point class with three double values + public: + /** Create a 3D Point + + @param fVal + This parameter is used to initialize the coordinate + part of the 3D Point. + */ + B3DPoint(double fVal = 0.0) + : B3DTuple(fVal) + {} + + /** Create a 3D Point + + @param fX + This parameter is used to initialize the X-coordinate + of the 3D Point. - This class derives all operators and common handling for - a 3D data class from B3DTuple. All necessary extensions - which are special for points will be added here. + @param fY + This parameter is used to initialize the Y-coordinate + of the 3D Point. - @see B3DTuple + @param fZ + This parameter is used to initialize the Z-coordinate + of the 3D Point. */ - class B3DPoint : public ::basegfx::tuple::B3DTuple + B3DPoint(double fX, double fY, double fZ) + : B3DTuple(fX, fY, fZ) + {} + + /** Create a copy of a 3D Point + + @param rVec + The 3D Point which will be copied. + */ + B3DPoint(const B3DPoint& rVec) + : B3DTuple(rVec) + {} + + /** constructor with tuple to allow copy-constructing + from B3DTuple-based classes + */ + B3DPoint(const ::basegfx::B3DTuple& rTuple) + : B3DTuple(rTuple) + {} + + ~B3DPoint() + {} + + /** *=operator to allow usage from B3DPoint, too + */ + B3DPoint& operator*=( const B3DPoint& rPnt ) + { + mfX *= rPnt.mfX; + mfY *= rPnt.mfY; + mfZ *= rPnt.mfZ; + return *this; + } + + /** *=operator to allow usage from B3DPoint, too + */ + B3DPoint& operator*=(double t) + { + mfX *= t; + mfY *= t; + mfZ *= t; + return *this; + } + + /** assignment operator to allow assigning the results + of B3DTuple calculations + */ + B3DPoint& operator=( const ::basegfx::B3DTuple& rVec ) + { + mfX = rVec.getX(); + mfY = rVec.getY(); + mfZ = rVec.getZ(); + return *this; + } + + /** Transform point by given transformation matrix. + + The translational components of the matrix are, in + contrast to B3DVector, applied. + */ + B3DPoint& operator*=( const ::basegfx::B3DHomMatrix& rMat ); + + static const B3DPoint& getEmptyPoint() { - public: - /** Create a 3D Point - - @param fVal - This parameter is used to initialize the coordinate - part of the 3D Point. - */ - B3DPoint(double fVal = 0.0) - : B3DTuple(fVal) - {} - - /** Create a 3D Point - - @param fX - This parameter is used to initialize the X-coordinate - of the 3D Point. - - @param fY - This parameter is used to initialize the Y-coordinate - of the 3D Point. - - @param fZ - This parameter is used to initialize the Z-coordinate - of the 3D Point. - */ - B3DPoint(double fX, double fY, double fZ) - : B3DTuple(fX, fY, fZ) - {} - - /** Create a copy of a 3D Point - - @param rVec - The 3D Point which will be copied. - */ - B3DPoint(const B3DPoint& rVec) - : B3DTuple(rVec) - {} - - /** constructor with tuple to allow copy-constructing - from B3DTuple-based classes - */ - B3DPoint(const ::basegfx::tuple::B3DTuple& rTuple) - : B3DTuple(rTuple) - {} - - ~B3DPoint() - {} - - /** *=operator to allow usage from B3DPoint, too - */ - B3DPoint& operator*=( const B3DPoint& rPnt ) - { - mfX *= rPnt.mfX; - mfY *= rPnt.mfY; - mfZ *= rPnt.mfZ; - return *this; - } - - /** *=operator to allow usage from B3DPoint, too - */ - B3DPoint& operator*=(double t) - { - mfX *= t; - mfY *= t; - mfZ *= t; - return *this; - } - - /** assignment operator to allow assigning the results - of B3DTuple calculations - */ - B3DPoint& operator=( const ::basegfx::tuple::B3DTuple& rVec ) - { - mfX = rVec.getX(); - mfY = rVec.getY(); - mfZ = rVec.getZ(); - return *this; - } - - /** Transform point by given transformation matrix. - - The translational components of the matrix are, in - contrast to B3DVector, applied. - */ - B3DPoint& operator*=( const ::basegfx::matrix::B3DHomMatrix& rMat ); - - static const B3DPoint& getEmptyPoint() - { - return (const B3DPoint&) ::basegfx::tuple::B3DTuple::getEmptyTuple(); - } - }; - } // end of namespace point + return (const B3DPoint&) ::basegfx::B3DTuple::getEmptyTuple(); + } + }; } // end of namespace basegfx #endif // _BGFX_POINT_B3DPOINT_HXX diff --git a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx index c58be040d447..610ce5c75df6 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolygon.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:39:56 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,101 +72,83 @@ class ImplB2DPolygon; namespace basegfx { - namespace polygon - { - class B2DPolygon; - } // end of namespace polygon - - namespace point - { - class B2DPoint; - } // end of namespace point - - namespace vector - { - class B2DVector; - } // end of namespace vector - - namespace matrix - { - class B2DHomMatrix; - } // end of namespace matrix + class B2DPolygon; + class B2DPoint; + class B2DVector; + class B2DHomMatrix; } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// namespace basegfx { - namespace polygon + class B2DPolygon { - class B2DPolygon - { - private: - // internal data. - ImplB2DPolygon* mpPolygon; - - // internal method to force a ref-counted instance to be copied - // to a modifyable unique copy. - void implForceUniqueCopy(); - - public: - B2DPolygon(); - B2DPolygon(const B2DPolygon& rPolygon); - B2DPolygon(const B2DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 nCount); - ~B2DPolygon(); - - // assignment operator - B2DPolygon& operator=(const B2DPolygon& rPolygon); - - // compare operators - sal_Bool operator==(const B2DPolygon& rPolygon) const; - sal_Bool operator!=(const B2DPolygon& rPolygon) const; - - // member count - sal_uInt32 count() const; - - // Coordinate interface - ::basegfx::point::B2DPoint getB2DPoint(sal_uInt32 nIndex) const; - void setB2DPoint(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rValue); - - // Coordinate insert/append - void insert(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount = 1); - void append(const ::basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount = 1); - - // ControlVector interface - ::basegfx::vector::B2DVector getControlVectorA(sal_uInt32 nIndex) const; - void setControlVectorA(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue); - ::basegfx::vector::B2DVector getControlVectorB(sal_uInt32 nIndex) const; - void setControlVectorB(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue); - sal_Bool areControlPointsUsed() const; - - // insert/append other 2D polygons - void insert(sal_uInt32 nIndex, const B2DPolygon& rPoly, sal_uInt32 nIndex2 = 0, sal_uInt32 nCount = 0); - void append(const B2DPolygon& rPoly, sal_uInt32 nIndex = 0, sal_uInt32 nCount = 0); - - // remove - void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1); - - // clear all points - void clear(); - - // closed state - sal_Bool isClosed() const; - void setClosed(sal_Bool bNew); - - // flip polygon direction - void flip(); - - // test if Polygon has double points - sal_Bool hasDoublePoints() const; - - // remove double points, at the begin/end and follow-ups, too - void removeDoublePoints(); - - // apply transformation given in matrix form to the polygon - void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix); - }; - } // end of namespace polygon + private: + // internal data. + ImplB2DPolygon* mpPolygon; + + // internal method to force a ref-counted instance to be copied + // to a modifyable unique copy. + void implForceUniqueCopy(); + + public: + B2DPolygon(); + B2DPolygon(const B2DPolygon& rPolygon); + B2DPolygon(const B2DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 nCount); + ~B2DPolygon(); + + // assignment operator + B2DPolygon& operator=(const B2DPolygon& rPolygon); + + // compare operators + sal_Bool operator==(const B2DPolygon& rPolygon) const; + sal_Bool operator!=(const B2DPolygon& rPolygon) const; + + // member count + sal_uInt32 count() const; + + // Coordinate interface + ::basegfx::B2DPoint getB2DPoint(sal_uInt32 nIndex) const; + void setB2DPoint(sal_uInt32 nIndex, const ::basegfx::B2DPoint& rValue); + + // Coordinate insert/append + void insert(sal_uInt32 nIndex, const ::basegfx::B2DPoint& rPoint, sal_uInt32 nCount = 1); + void append(const ::basegfx::B2DPoint& rPoint, sal_uInt32 nCount = 1); + + // ControlVector interface + ::basegfx::B2DVector getControlVectorA(sal_uInt32 nIndex) const; + void setControlVectorA(sal_uInt32 nIndex, const ::basegfx::B2DVector& rValue); + ::basegfx::B2DVector getControlVectorB(sal_uInt32 nIndex) const; + void setControlVectorB(sal_uInt32 nIndex, const ::basegfx::B2DVector& rValue); + sal_Bool areControlPointsUsed() const; + + // insert/append other 2D polygons + void insert(sal_uInt32 nIndex, const B2DPolygon& rPoly, sal_uInt32 nIndex2 = 0, sal_uInt32 nCount = 0); + void append(const B2DPolygon& rPoly, sal_uInt32 nIndex = 0, sal_uInt32 nCount = 0); + + // remove + void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1); + + // clear all points + void clear(); + + // closed state + sal_Bool isClosed() const; + void setClosed(sal_Bool bNew); + + // flip polygon direction + void flip(); + + // test if Polygon has double points + sal_Bool hasDoublePoints() const; + + // remove double points, at the begin/end and follow-ups, too + void removeDoublePoints(); + + // apply transformation given in matrix form to the polygon + void transform(const ::basegfx::B2DHomMatrix& rMatrix); + }; } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// diff --git a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx index b2fc5f9c16e5..4da9f650a526 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolygontools.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:39:56 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,148 +70,137 @@ #include <basegfx/vector/b2dvector.hxx> #endif +#include <vector> + ////////////////////////////////////////////////////////////////////////////// namespace basegfx { // predefinitions - namespace polygon - { - class B2DPolygon; - } // end of namespace polygon - - // predefinitions - namespace range - { - class B2DRange; - } // end of namespace range + class B2DPolygon; + class B2DRange; - namespace polygon + namespace tools { - namespace tools - { - // B2DPolygon tools - - /** Check if given polygon is closed. This is kind of a - 'classic' method to support old polygon definitions. - Those old polygon definitions define the closed state - of the polygon using identical start and endpoints. This - method corrects this (removes double start/end points) - and sets the Closed()-state of the polygon correctly. - */ - void checkClosed(::basegfx::polygon::B2DPolygon& rCandidate); - - // Get index of outmost point (e.g. biggest X and biggest Y) - sal_uInt32 getIndexOfOutmostPoint(const ::basegfx::polygon::B2DPolygon& rCandidate); - - // Get successor and predecessor indices. Returning the same index means there - // is none. Same for successor. - sal_uInt32 getIndexOfPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate); - sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate); - - // Get index of first different predecessor. Returning the same index means there - // is none. Same for successor. - sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate); - sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate); - - // Get orientation of Polygon - ::basegfx::vector::B2DVectorOrientation getOrientation(const ::basegfx::polygon::B2DPolygon& rCandidate); - - // isInside tests for B2dPoint and other B2dPolygon. On border is not inside as long as - // not sal_True is given in bWithBorder flag. - sal_Bool isInside(const ::basegfx::polygon::B2DPolygon& rCandidate, const ::basegfx::point::B2DPoint& rPoint, sal_Bool bWithBorder = sal_False); - sal_Bool isInside(const ::basegfx::polygon::B2DPolygon& rCandidate, const ::basegfx::polygon::B2DPolygon& rPolygon, sal_Bool bWithBorder = sal_False); - - // get size of polygon. Control vectors are included in that ranges. - ::basegfx::range::B2DRange getRange(const ::basegfx::polygon::B2DPolygon& rCandidate); - - // get area of polygon - double getArea(const ::basegfx::polygon::B2DPolygon& rCandidate); - - // get length of polygon edge from point nIndex to nIndex + 1 - double getEdgeLength(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex); - - // get length of polygon - double getLength(const ::basegfx::polygon::B2DPolygon& rCandidate); - - // get position on polygon for absolute given distance. If - // length is given, it is assumed the correct polygon length, if 0.0 it is calculated - // using getLength(...) - ::basegfx::point::B2DPoint getPositionAbsolute(const ::basegfx::polygon::B2DPolygon& rCandidate, double fDistance, double fLength = 0.0); - - // get position on polygon for relative given distance in range [0.0 .. 1.0]. If - // length is given, it is assumed the correct polygon length, if 0.0 it is calculated - // using getLength(...) - ::basegfx::point::B2DPoint getPositionRelative(const ::basegfx::polygon::B2DPolygon& rCandidate, double fDistance, double fLength = 0.0); - - // get orientation at given polygon point - ::basegfx::vector::B2DVectorOrientation getPointOrientation(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex); - - // Continuity check for point with given index - ::basegfx::vector::B2DVectorContinuity getContinuityInPoint(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex); - - // Subdivide all contained curves. Use distanceBound value if given. - ::basegfx::polygon::B2DPolygon adaptiveSubdivideByDistance(const ::basegfx::polygon::B2DPolygon& rCandidate, double fDistanceBound = 0.0); - - // Subdivide all contained curves. Use distanceBound value if given. - ::basegfx::polygon::B2DPolygon adaptiveSubdivideByAngle(const ::basegfx::polygon::B2DPolygon& rCandidate, double fAngleBound = 5.0); - - // Definitions for the cut flags used from the findCut methods - typedef sal_uInt16 CutFlagValue; - - #define CUTFLAG_NONE (0x0000) - #define CUTFLAG_LINE (0x0001) - #define CUTFLAG_START1 (0x0002) - #define CUTFLAG_START2 (0x0004) - #define CUTFLAG_END1 (0x0008) - #define CUTFLAG_END2 (0x0010) - #define CUTFLAG_ALL (CUTFLAG_LINE|CUTFLAG_START1|CUTFLAG_START2|CUTFLAG_END1|CUTFLAG_END2) - #define CUTFLAG_DEFAULT (CUTFLAG_LINE|CUTFLAG_START2|CUTFLAG_END2) - - // Calculate cut between the points given by the two indices. pCut1 - // and pCut2 will contain the cut coordinate on each edge in ]0.0, 1.0] - // (if given) and the return value will contain a cut description. - CutFlagValue findCut( - const ::basegfx::polygon::B2DPolygon& rCandidate, - sal_uInt32 nIndex1, sal_uInt32 nIndex2, - CutFlagValue aCutFlags = CUTFLAG_DEFAULT, - double* pCut1 = 0L, double* pCut2 = 0L); - - // This version is working with two indexed edges from different - // polygons. - CutFlagValue findCut( - const ::basegfx::polygon::B2DPolygon& rCandidate1, sal_uInt32 nIndex1, - const ::basegfx::polygon::B2DPolygon& rCandidate2, sal_uInt32 nIndex2, - CutFlagValue aCutFlags = CUTFLAG_DEFAULT, - double* pCut1 = 0L, double* pCut2 = 0L); - - // This version works with two points and vectors to define the - // edges for the cut test. - CutFlagValue findCut( - const ::basegfx::point::B2DPoint& rEdge1Start, const ::basegfx::vector::B2DVector& rEdge1Delta, - const ::basegfx::point::B2DPoint& rEdge2Start, const ::basegfx::vector::B2DVector& rEdge2Delta, - CutFlagValue aCutFlags = CUTFLAG_DEFAULT, - double* pCut1 = 0L, double* pCut2 = 0L); - - // test if point is on the given edge in range ]0.0..1.0[ without - // the start/end points. If so, return sal_True and put the parameter - // value in pCut (if provided) - sal_Bool isPointOnEdge( - const ::basegfx::point::B2DPoint& rPoint, - const ::basegfx::point::B2DPoint& rEdgeStart, - const ::basegfx::vector::B2DVector& rEdgeDelta, - double* pCut = 0L); - - - - /* Still missing: - void transform(const Matrix4D& rTfMatrix); - Polygon3D getExpandedPolygon(sal_uInt32 nNum); - */ - - - } // end of namespace tools - } // end of namespace polygon + // B2DPolygon tools + + /** Check if given polygon is closed. This is kind of a + 'classic' method to support old polygon definitions. + Those old polygon definitions define the closed state + of the polygon using identical start and endpoints. This + method corrects this (removes double start/end points) + and sets the Closed()-state of the polygon correctly. + */ + void checkClosed(::basegfx::B2DPolygon& rCandidate); + + // Get index of outmost point (e.g. biggest X and biggest Y) + sal_uInt32 getIndexOfOutmostPoint(const ::basegfx::B2DPolygon& rCandidate); + + // Get successor and predecessor indices. Returning the same index means there + // is none. Same for successor. + sal_uInt32 getIndexOfPredecessor(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rCandidate); + sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rCandidate); + + // Get index of first different predecessor. Returning the same index means there + // is none. Same for successor. + sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rCandidate); + sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rCandidate); + + // Get orientation of Polygon + ::basegfx::B2DVectorOrientation getOrientation(const ::basegfx::B2DPolygon& rCandidate); + + // isInside tests for B2dPoint and other B2dPolygon. On border is not inside as long as + // not sal_True is given in bWithBorder flag. + sal_Bool isInside(const ::basegfx::B2DPolygon& rCandidate, const ::basegfx::B2DPoint& rPoint, sal_Bool bWithBorder = sal_False); + sal_Bool isInside(const ::basegfx::B2DPolygon& rCandidate, const ::basegfx::B2DPolygon& rPolygon, sal_Bool bWithBorder = sal_False); + + // get size of polygon. Control vectors are included in that ranges. + ::basegfx::B2DRange getRange(const ::basegfx::B2DPolygon& rCandidate); + + // get area of polygon + double getArea(const ::basegfx::B2DPolygon& rCandidate); + + // get length of polygon edge from point nIndex to nIndex + 1 + double getEdgeLength(const ::basegfx::B2DPolygon& rCandidate, sal_uInt32 nIndex); + + // get length of polygon + double getLength(const ::basegfx::B2DPolygon& rCandidate); + + // get position on polygon for absolute given distance. If + // length is given, it is assumed the correct polygon length, if 0.0 it is calculated + // using getLength(...) + ::basegfx::B2DPoint getPositionAbsolute(const ::basegfx::B2DPolygon& rCandidate, double fDistance, double fLength = 0.0); + + // get position on polygon for relative given distance in range [0.0 .. 1.0]. If + // length is given, it is assumed the correct polygon length, if 0.0 it is calculated + // using getLength(...) + ::basegfx::B2DPoint getPositionRelative(const ::basegfx::B2DPolygon& rCandidate, double fDistance, double fLength = 0.0); + + // get orientation at given polygon point + ::basegfx::B2DVectorOrientation getPointOrientation(const ::basegfx::B2DPolygon& rCandidate, sal_uInt32 nIndex); + + // Continuity check for point with given index + ::basegfx::B2DVectorContinuity getContinuityInPoint(const ::basegfx::B2DPolygon& rCandidate, sal_uInt32 nIndex); + + // Subdivide all contained curves. Use distanceBound value if given. + ::basegfx::B2DPolygon adaptiveSubdivideByDistance(const ::basegfx::B2DPolygon& rCandidate, double fDistanceBound = 0.0); + + // Subdivide all contained curves. Use distanceBound value if given. + ::basegfx::B2DPolygon adaptiveSubdivideByAngle(const ::basegfx::B2DPolygon& rCandidate, double fAngleBound = 5.0); + + // Definitions for the cut flags used from the findCut methods + typedef sal_uInt16 CutFlagValue; + + #define CUTFLAG_NONE (0x0000) + #define CUTFLAG_LINE (0x0001) + #define CUTFLAG_START1 (0x0002) + #define CUTFLAG_START2 (0x0004) + #define CUTFLAG_END1 (0x0008) + #define CUTFLAG_END2 (0x0010) + #define CUTFLAG_ALL (CUTFLAG_LINE|CUTFLAG_START1|CUTFLAG_START2|CUTFLAG_END1|CUTFLAG_END2) + #define CUTFLAG_DEFAULT (CUTFLAG_LINE|CUTFLAG_START2|CUTFLAG_END2) + + // Calculate cut between the points given by the two indices. pCut1 + // and pCut2 will contain the cut coordinate on each edge in ]0.0, 1.0] + // (if given) and the return value will contain a cut description. + CutFlagValue findCut( + const ::basegfx::B2DPolygon& rCandidate, + sal_uInt32 nIndex1, sal_uInt32 nIndex2, + CutFlagValue aCutFlags = CUTFLAG_DEFAULT, + double* pCut1 = 0L, double* pCut2 = 0L); + + // This version is working with two indexed edges from different + // polygons. + CutFlagValue findCut( + const ::basegfx::B2DPolygon& rCandidate1, sal_uInt32 nIndex1, + const ::basegfx::B2DPolygon& rCandidate2, sal_uInt32 nIndex2, + CutFlagValue aCutFlags = CUTFLAG_DEFAULT, + double* pCut1 = 0L, double* pCut2 = 0L); + + // This version works with two points and vectors to define the + // edges for the cut test. + CutFlagValue findCut( + const ::basegfx::B2DPoint& rEdge1Start, const ::basegfx::B2DVector& rEdge1Delta, + const ::basegfx::B2DPoint& rEdge2Start, const ::basegfx::B2DVector& rEdge2Delta, + CutFlagValue aCutFlags = CUTFLAG_DEFAULT, + double* pCut1 = 0L, double* pCut2 = 0L); + + // test if point is on the given edge in range ]0.0..1.0[ without + // the start/end points. If so, return sal_True and put the parameter + // value in pCut (if provided) + sal_Bool isPointOnEdge( + const ::basegfx::B2DPoint& rPoint, + const ::basegfx::B2DPoint& rEdgeStart, + const ::basegfx::B2DVector& rEdgeDelta, + double* pCut = 0L); + + + + /* Still missing: + void transform(const Matrix4D& rTfMatrix); + Polygon3D getExpandedPolygon(sal_uInt32 nNum); + */ + } // end of namespace tools } // end of namespace basegfx #endif // _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx index 89e6b68b4072..1bffaee504f4 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygon.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:39:57 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,84 +71,74 @@ class ImplB2DPolyPolygon; namespace basegfx { - namespace polygon - { - class B2DPolygon; - } // end of namespace polygon - - namespace matrix - { - class B2DHomMatrix; - } // end of namespace matrix + class B2DPolygon; + class B2DHomMatrix; } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// namespace basegfx { - namespace polygon + class B2DPolyPolygon { - class B2DPolyPolygon - { - private: - ImplB2DPolyPolygon* mpPolyPolygon; + private: + ImplB2DPolyPolygon* mpPolyPolygon; - // internal method to force a ref-counted instance to be copied - // to a modifyable unique copy. - void implForceUniqueCopy(); + // internal method to force a ref-counted instance to be copied + // to a modifyable unique copy. + void implForceUniqueCopy(); - public: - B2DPolyPolygon(); - B2DPolyPolygon(const B2DPolyPolygon& rPolyPolygon); - ~B2DPolyPolygon(); + public: + B2DPolyPolygon(); + B2DPolyPolygon(const B2DPolyPolygon& rPolyPolygon); + ~B2DPolyPolygon(); - // assignment operator - B2DPolyPolygon& operator=(const B2DPolyPolygon& rPolyPolygon); + // assignment operator + B2DPolyPolygon& operator=(const B2DPolyPolygon& rPolyPolygon); - // compare operators - sal_Bool operator==(const B2DPolyPolygon& rPolyPolygon) const; - sal_Bool operator!=(const B2DPolyPolygon& rPolyPolygon) const; + // compare operators + sal_Bool operator==(const B2DPolyPolygon& rPolyPolygon) const; + sal_Bool operator!=(const B2DPolyPolygon& rPolyPolygon) const; - // polygon interface - sal_uInt32 count() const; + // polygon interface + sal_uInt32 count() const; - B2DPolygon getB2DPolygon(sal_uInt32 nIndex) const; - void setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon); + B2DPolygon getB2DPolygon(sal_uInt32 nIndex) const; + void setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon); - // test for curve - sal_Bool areControlPointsUsed() const; + // test for curve + sal_Bool areControlPointsUsed() const; - // insert/append single polygon - void insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount = 1); - void append(const B2DPolygon& rPolygon, sal_uInt32 nCount = 1); + // insert/append single polygon + void insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount = 1); + void append(const B2DPolygon& rPolygon, sal_uInt32 nCount = 1); - // insert/append multiple polygons - void insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon); - void append(const B2DPolyPolygon& rPolyPolygon); + // insert/append multiple polygons + void insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon); + void append(const B2DPolyPolygon& rPolyPolygon); - // remove - void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1); + // remove + void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1); - // reset to empty state - void clear(); + // reset to empty state + void clear(); - // closed state - sal_Bool isClosed() const; - void setClosed(sal_Bool bNew); + // closed state + sal_Bool isClosed() const; + void setClosed(sal_Bool bNew); - // flip polygon direction - void flip(); + // flip polygon direction + void flip(); - // test if PolyPolygon has double points - sal_Bool hasDoublePoints() const; + // test if PolyPolygon has double points + sal_Bool hasDoublePoints() const; - // remove double points, at the begin/end and follow-ups, too - void removeDoublePoints(); + // remove double points, at the begin/end and follow-ups, too + void removeDoublePoints(); - // apply transformation given in matrix form to the polygon - void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix); - }; - } // end of namespace polygon + // apply transformation given in matrix form to the polygon + void transform(const ::basegfx::B2DHomMatrix& rMatrix); + }; } // end of namespace basegfx #endif // _BGFX_POLYGON_B2DPOLYPOLYGON_HXX diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygoncutter.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygoncutter.hxx index c118076d82fe..641045afa14e 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolypolygoncutter.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolypolygoncutter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygoncutter.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2003-11-10 11:45:48 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,48 +93,45 @@ namespace basegfx { - namespace polygon + class B2DPolygonNode { - class B2DPolygonNode - { - ::basegfx::point::B2DPoint maPosition; - B2DPolygonNode* mpPrevious; - B2DPolygonNode* mpNext; + ::basegfx::B2DPoint maPosition; + B2DPolygonNode* mpPrevious; + B2DPolygonNode* mpNext; - B2DPolygonNode* mpListPrevious; - B2DPolygonNode* mpListNext; + B2DPolygonNode* mpListPrevious; + B2DPolygonNode* mpListNext; - public: - B2DPolygonNode(const ::basegfx::point::B2DPoint& rPosition, B2DPolygonNode* pPrevious); - ~B2DPolygonNode(); + public: + B2DPolygonNode(const ::basegfx::B2DPoint& rPosition, B2DPolygonNode* pPrevious); + ~B2DPolygonNode(); - B2DPolygonNode* getPrevious() const { return mpPrevious; } - B2DPolygonNode* getNext() const { return mpNext; } - const ::basegfx::point::B2DPoint& getPosition() const { return maPosition; } + B2DPolygonNode* getPrevious() const { return mpPrevious; } + B2DPolygonNode* getNext() const { return mpNext; } + const ::basegfx::B2DPoint& getPosition() const { return maPosition; } - void calcMinMaxX(double& fMaxAX, double& fMinAX) const; - void calcMinMaxY(double& fMaxAY, double& fMinAY) const; + void calcMinMaxX(double& fMaxAX, double& fMinAX) const; + void calcMinMaxY(double& fMaxAY, double& fMinAY) const; - void swapPreviousNext() { B2DPolygonNode* pZwi = mpPrevious; mpPrevious = mpNext; mpNext = pZwi; } - void swapNextPointers(B2DPolygonNode* pCand); + void swapPreviousNext() { B2DPolygonNode* pZwi = mpPrevious; mpPrevious = mpNext; mpNext = pZwi; } + void swapNextPointers(B2DPolygonNode* pCand); - void addToList(B2DPolygonNode*& rpList); - void remFromList(B2DPolygonNode*& rpList); + void addToList(B2DPolygonNode*& rpList); + void remFromList(B2DPolygonNode*& rpList); - sal_Bool getOrientation() const; - void swapOrientation(); - ::basegfx::range::B2DRange getRange() const; + sal_Bool getOrientation() const; + void swapOrientation(); + ::basegfx::B2DRange getRange() const; - // isInside tests for B2dPoint and other B2DPolygonNode Polygon. On border is not inside as long as - // not sal_True is given in bWithBorder flag. - sal_Bool isInside(const ::basegfx::point::B2DPoint& rPnt, sal_Bool bWithBorder = sal_False) const; - sal_Bool isPolygonInside(B2DPolygonNode* pPoly, sal_Bool bWithBorder = sal_False) const; - }; + // isInside tests for B2dPoint and other B2DPolygonNode Polygon. On border is not inside as long as + // not sal_True is given in bWithBorder flag. + sal_Bool isInside(const ::basegfx::B2DPoint& rPnt, sal_Bool bWithBorder = sal_False) const; + sal_Bool isPolygonInside(B2DPolygonNode* pPoly, sal_Bool bWithBorder = sal_False) const; + }; - // a type definition to have a vector of pointers to B2DPolygonNodes - typedef ::std::vector< B2DPolygonNode* > B2DPolygonNodeVector; + // a type definition to have a vector of pointers to B2DPolygonNodes + typedef ::std::vector< B2DPolygonNode* > B2DPolygonNodeVector; - } // end of namespace polygon } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// @@ -142,40 +139,37 @@ namespace basegfx namespace basegfx { - namespace polygon + class B2DSimpleCut { - class B2DSimpleCut + B2DPolygonNode* mpLeft; + B2DPolygonNode* mpRight; + + // bitfield + unsigned mbCorrectOrientation : 1; + unsigned mbOrientation : 1; + + public: + B2DSimpleCut(B2DPolygonNode* pL, B2DPolygonNode* pR, sal_Bool bCoOr = sal_False, sal_Bool bOr = sal_True) + : mpLeft(pL), + mpRight(pR), + mbCorrectOrientation(bCoOr), + mbOrientation(bOr) + { + } + + void solve(); + B2DPolygonNode* getLeft() const { return mpLeft; } + B2DPolygonNode* getRight() const { return mpRight; } + + sal_Bool isSameCut(B2DPolygonNode* pA, B2DPolygonNode* pB) const { - B2DPolygonNode* mpLeft; - B2DPolygonNode* mpRight; - - // bitfield - unsigned mbCorrectOrientation : 1; - unsigned mbOrientation : 1; - - public: - B2DSimpleCut(B2DPolygonNode* pL, B2DPolygonNode* pR, sal_Bool bCoOr = sal_False, sal_Bool bOr = sal_True) - : mpLeft(pL), - mpRight(pR), - mbCorrectOrientation(bCoOr), - mbOrientation(bOr) - { - } - - void solve(); - B2DPolygonNode* getLeft() const { return mpLeft; } - B2DPolygonNode* getRight() const { return mpRight; } - - sal_Bool isSameCut(B2DPolygonNode* pA, B2DPolygonNode* pB) const - { - return ((pA == mpLeft && pB == mpRight) || (pB == mpLeft && pA == mpRight)); - } - }; - - // a type definition to have a vector of pointers to B2DSimpleCuts - typedef ::std::vector< B2DSimpleCut* > B2DSimpleCutVector; - - } // end of namespace polygon + return ((pA == mpLeft && pB == mpRight) || (pB == mpLeft && pA == mpRight)); + } + }; + + // a type definition to have a vector of pointers to B2DSimpleCuts + typedef ::std::vector< B2DSimpleCut* > B2DSimpleCutVector; + } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// @@ -183,27 +177,24 @@ namespace basegfx namespace basegfx { - namespace polygon + class B2DClipExtraPolygonInfo { - class B2DClipExtraPolygonInfo - { - ::basegfx::range::B2DRange maRange; - sal_Int32 mnDepth; + ::basegfx::B2DRange maRange; + sal_Int32 mnDepth; - // bitfield - unsigned mbOrientation : 1; + // bitfield + unsigned mbOrientation : 1; - public: - B2DClipExtraPolygonInfo() {} + public: + B2DClipExtraPolygonInfo() {} - void init(B2DPolygonNode* pNew); - const ::basegfx::range::B2DRange& getRange() const { return maRange; } - sal_Bool getOrientation() const { return mbOrientation; } + void init(B2DPolygonNode* pNew); + const ::basegfx::B2DRange& getRange() const { return maRange; } + sal_Bool getOrientation() const { return mbOrientation; } - sal_Int32 getDepth() const { return mnDepth; } - void changeDepth(sal_Bool bOrientation); - }; - } // end of namespace polygon + sal_Int32 getDepth() const { return mnDepth; } + void changeDepth(sal_Bool bOrientation); + }; } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// @@ -211,69 +202,66 @@ namespace basegfx namespace basegfx { - namespace polygon + class B2DPolyPolygonCutter { - class B2DPolyPolygonCutter + // list of polys + B2DPolygonNodeVector maPolygonList; + B2DPolyPolygon maNotClosedPolygons; + + // help routines + sal_Bool isSamePos(const ::basegfx::B2DPoint& rPntA, const ::basegfx::B2DPoint& rPntB) + { + return rPntA.equal(rPntB); + } + + B2DSimpleCut* getExistingCut(B2DSimpleCutVector& rTmpCuts, B2DPolygonNode* pA, B2DPolygonNode* pB); + B2DPolygonNode* extractNextPolygon(B2DPolygonNode*& rpList); + sal_Bool isCrossover(B2DPolygonNode* pA, B2DPolygonNode* pB); + sal_Bool isCrossover(B2DSimpleCut* pEnter, B2DSimpleCut* pLeave); + + sal_Bool isNextSamePos(B2DPolygonNode* pA, B2DPolygonNode* pB) { - // list of polys - B2DPolygonNodeVector maPolygonList; - B2DPolyPolygon maNotClosedPolygons; - - // help routines - sal_Bool isSamePos(const ::basegfx::point::B2DPoint& rPntA, const ::basegfx::point::B2DPoint& rPntB) - { - return rPntA.equal(rPntB); - } - - B2DSimpleCut* getExistingCut(B2DSimpleCutVector& rTmpCuts, B2DPolygonNode* pA, B2DPolygonNode* pB); - B2DPolygonNode* extractNextPolygon(B2DPolygonNode*& rpList); - sal_Bool isCrossover(B2DPolygonNode* pA, B2DPolygonNode* pB); - sal_Bool isCrossover(B2DSimpleCut* pEnter, B2DSimpleCut* pLeave); - - sal_Bool isNextSamePos(B2DPolygonNode* pA, B2DPolygonNode* pB) - { - return isSamePos(pA->getNext()->getPosition(), pB->getNext()->getPosition()); - } - - sal_Bool isPrevSamePos(B2DPolygonNode* pA, B2DPolygonNode* pB) - { - return isSamePos(pA->getPrevious()->getPosition(), pB->getPrevious()->getPosition()); - } - - void addAllNodes(B2DPolygonNode* pPolygon, B2DPolygonNode*& rpList); - B2DPolygonNode* createNewPolygon(const B2DPolygon& rPolygon); - void deletePolygon(B2DPolygonNode* pCand); - void polysToList(B2DPolygonNode*& rpList); - void listToPolys(B2DPolygonNode*& rpList); - - sal_Bool doRangesIntersect(const ::basegfx::range::B2DRange& rRange1, const ::basegfx::range::B2DRange& rRange2) const - { - return rRange1.overlaps(rRange2); - } - - sal_Bool doRangesInclude(const ::basegfx::range::B2DRange& rRange1, const ::basegfx::range::B2DRange& rRange2) const - { - return rRange1.isInside(rRange2); - } - - void solveAllCuts(B2DSimpleCutVector& rCuts); - - public: - B2DPolyPolygonCutter() {} - ~B2DPolyPolygonCutter(); - - // put/get poly - void addPolyPolygon(const B2DPolyPolygon& rPolyPolygon, sal_Bool bForceOrientation = sal_False); - void getPolyPolygon(B2DPolyPolygon& rPolyPolygon); - - // transformations - void removeSelfIntersections(); - void removeDoubleIntersections(); - - // remove included - void removeIncludedPolygons(sal_Bool bUseOr = sal_True); - }; - } // end of namespace polygon + return isSamePos(pA->getNext()->getPosition(), pB->getNext()->getPosition()); + } + + sal_Bool isPrevSamePos(B2DPolygonNode* pA, B2DPolygonNode* pB) + { + return isSamePos(pA->getPrevious()->getPosition(), pB->getPrevious()->getPosition()); + } + + void addAllNodes(B2DPolygonNode* pPolygon, B2DPolygonNode*& rpList); + B2DPolygonNode* createNewPolygon(const B2DPolygon& rPolygon); + void deletePolygon(B2DPolygonNode* pCand); + void polysToList(B2DPolygonNode*& rpList); + void listToPolys(B2DPolygonNode*& rpList); + + sal_Bool doRangesIntersect(const ::basegfx::B2DRange& rRange1, const ::basegfx::B2DRange& rRange2) const + { + return rRange1.overlaps(rRange2); + } + + sal_Bool doRangesInclude(const ::basegfx::B2DRange& rRange1, const ::basegfx::B2DRange& rRange2) const + { + return rRange1.isInside(rRange2); + } + + void solveAllCuts(B2DSimpleCutVector& rCuts); + + public: + B2DPolyPolygonCutter() {} + ~B2DPolyPolygonCutter(); + + // put/get poly + void addPolyPolygon(const B2DPolyPolygon& rPolyPolygon, sal_Bool bForceOrientation = sal_False); + void getPolyPolygon(B2DPolyPolygon& rPolyPolygon); + + // transformations + void removeSelfIntersections(); + void removeDoubleIntersections(); + + // remove included + void removeIncludedPolygons(sal_Bool bUseOr = sal_True); + }; } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx index 5165ef6a37ed..f51f64e9ec23 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygontools.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:39:57 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,56 +70,59 @@ #include <basegfx/vector/b2dvector.hxx> #endif +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#include <vector> + ////////////////////////////////////////////////////////////////////////////// namespace basegfx { // predefinitions - namespace polygon - { - class B2DPolyPolygon; - } // end of namespace polygon + class B2DPolyPolygon; + class B2DRange; - // predefinitions - namespace range + namespace tools { - class B2DRange; - } // end of namespace range + // B2DPolyPolygon tools - namespace polygon - { - namespace tools - { - // B2DPolyPolygon tools - - // Check and evtl. correct orientations of all contained Polygons so that - // the orientations of contained polygons will variate to express areas and - // holes - void correctOrientations(::basegfx::polygon::B2DPolyPolygon& rCandidate); - - // Remove all intersections, the self intersections and the in-between - // polygon intersections. After this operation there are no more intersections - // in the given PolyPolygon. Only closed polygons are handled. The non-closed - // polygons or the ones with less than 3 points are preserved, but not - // computed. - // bForceOrientation: If sal_True, the orientations of all contained polygons - // is changed to ORIENTATION_POSITIVE before computing. - // bInvertRemove: if sal_True, created polygons which are inside others and - // have the same orientation are removed (cleanup). - void removeIntersections(::basegfx::polygon::B2DPolyPolygon& rCandidate, - sal_Bool bForceOrientation = sal_True, sal_Bool bInvertRemove = sal_False); - - // Subdivide all contained curves. Use distanceBound value if given. - ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivideByDistance(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fDistanceBound = 0.0); - - // Subdivide all contained curves. Use distanceBound value if given. - ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivideByAngle(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fAngleBound = 5.0); - - // get size of PolyPolygon. Control vectors are included in that ranges. - ::basegfx::range::B2DRange getRange(const ::basegfx::polygon::B2DPolyPolygon& rCandidate); - - } // end of namespace tools - } // end of namespace polygon + // Check and evtl. correct orientations of all contained Polygons so that + // the orientations of contained polygons will variate to express areas and + // holes + void correctOrientations(::basegfx::B2DPolyPolygon& rCandidate); + + // Remove all intersections, the self intersections and the in-between + // polygon intersections. After this operation there are no more intersections + // in the given PolyPolygon. Only closed polygons are handled. The non-closed + // polygons or the ones with less than 3 points are preserved, but not + // computed. + // bForceOrientation: If sal_True, the orientations of all contained polygons + // is changed to ORIENTATION_POSITIVE before computing. + // bInvertRemove: if sal_True, created polygons which are inside others and + // have the same orientation are removed (cleanup). + void removeIntersections(::basegfx::B2DPolyPolygon& rCandidate, + sal_Bool bForceOrientation = sal_True, sal_Bool bInvertRemove = sal_False); + + // Subdivide all contained curves. Use distanceBound value if given. + ::basegfx::B2DPolyPolygon adaptiveSubdivideByDistance(const ::basegfx::B2DPolyPolygon& rCandidate, double fDistanceBound = 0.0); + + // Subdivide all contained curves. Use distanceBound value if given. + ::basegfx::B2DPolyPolygon adaptiveSubdivideByAngle(const ::basegfx::B2DPolyPolygon& rCandidate, double fAngleBound = 5.0); + + // get size of PolyPolygon. Control vectors are included in that ranges. + ::basegfx::B2DRange getRange(const ::basegfx::B2DPolyPolygon& rCandidate); + + // Apply Line Dashing. This cuts every contained PolyPolygon into line pieces + // which are inserted as single polygons into the result. + ::basegfx::B2DPolyPolygon applyLineDashing(const ::basegfx::B2DPolyPolygon& rCandidate, const ::std::vector<double>& raDashDotArray, double fFullDashDotLen); + + // Apply Line Dashing. This cuts the Polygon into line pieces + // which are inserted as single polygons into the result. + ::basegfx::B2DPolyPolygon applyLineDashing(const ::basegfx::B2DPolygon& rCandidate, const ::std::vector<double>& raDashDotArray, double fFullDashDotLen); + + } // end of namespace tools } // end of namespace basegfx #endif // _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX diff --git a/basegfx/inc/basegfx/polygon/b3dpolygon.hxx b/basegfx/inc/basegfx/polygon/b3dpolygon.hxx index 4df95083ee57..ef18da4035f9 100644 --- a/basegfx/inc/basegfx/polygon/b3dpolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b3dpolygon.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dpolygon.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:29:18 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,89 +72,75 @@ class ImplB3DPolygon; namespace basegfx { - namespace polygon - { - class B3DPolygon; - } // end of namespace polygon - - namespace point - { - class B3DPoint; - } // end of namespace point - - namespace matrix - { - class B3DHomMatrix; - } // end of namespace matrix + class B3DPolygon; + class B3DPoint; + class B3DHomMatrix; } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// namespace basegfx { - namespace polygon + class B3DPolygon { - class B3DPolygon - { - private: - // internal data. - ImplB3DPolygon* mpPolygon; + private: + // internal data. + ImplB3DPolygon* mpPolygon; - // internal method to force a ref-counted instance to be copied - // to a modifyable unique copy. - void implForceUniqueCopy(); + // internal method to force a ref-counted instance to be copied + // to a modifyable unique copy. + void implForceUniqueCopy(); - public: - B3DPolygon(); - B3DPolygon(const B3DPolygon& rPolygon); - B3DPolygon(const B3DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 nCount); - ~B3DPolygon(); + public: + B3DPolygon(); + B3DPolygon(const B3DPolygon& rPolygon); + B3DPolygon(const B3DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 nCount); + ~B3DPolygon(); - // assignment operator - B3DPolygon& operator=(const B3DPolygon& rPolygon); + // assignment operator + B3DPolygon& operator=(const B3DPolygon& rPolygon); - // compare operators - sal_Bool operator==(const B3DPolygon& rPolygon) const; - sal_Bool operator!=(const B3DPolygon& rPolygon) const; + // compare operators + sal_Bool operator==(const B3DPolygon& rPolygon) const; + sal_Bool operator!=(const B3DPolygon& rPolygon) const; - // member count - sal_uInt32 count() const; + // member count + sal_uInt32 count() const; - // Coordinate interface - ::basegfx::point::B3DPoint getB3DPoint(sal_uInt32 nIndex) const; - void setB3DPoint(sal_uInt32 nIndex, const ::basegfx::point::B3DPoint& rValue); + // Coordinate interface + ::basegfx::B3DPoint getB3DPoint(sal_uInt32 nIndex) const; + void setB3DPoint(sal_uInt32 nIndex, const ::basegfx::B3DPoint& rValue); - // Coordinate insert/append - void insert(sal_uInt32 nIndex, const ::basegfx::point::B3DPoint& rPoint, sal_uInt32 nCount = 1); - void append(const ::basegfx::point::B3DPoint& rPoint, sal_uInt32 nCount = 1); + // Coordinate insert/append + void insert(sal_uInt32 nIndex, const ::basegfx::B3DPoint& rPoint, sal_uInt32 nCount = 1); + void append(const ::basegfx::B3DPoint& rPoint, sal_uInt32 nCount = 1); - // insert/append other 2D polygons - void insert(sal_uInt32 nIndex, const B3DPolygon& rPoly, sal_uInt32 nIndex2 = 0, sal_uInt32 nCount = 0); - void append(const B3DPolygon& rPoly, sal_uInt32 nIndex = 0, sal_uInt32 nCount = 0); + // insert/append other 2D polygons + void insert(sal_uInt32 nIndex, const B3DPolygon& rPoly, sal_uInt32 nIndex2 = 0, sal_uInt32 nCount = 0); + void append(const B3DPolygon& rPoly, sal_uInt32 nIndex = 0, sal_uInt32 nCount = 0); - // remove - void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1); + // remove + void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1); - // clear all points - void clear(); + // clear all points + void clear(); - // closed state - sal_Bool isClosed() const; - void setClosed(sal_Bool bNew); + // closed state + sal_Bool isClosed() const; + void setClosed(sal_Bool bNew); - // flip polygon direction - void flip(); + // flip polygon direction + void flip(); - // test if Polygon has double points - sal_Bool hasDoublePoints() const; + // test if Polygon has double points + sal_Bool hasDoublePoints() const; - // remove double points, at the begin/end and follow-ups, too - void removeDoublePoints(); + // remove double points, at the begin/end and follow-ups, too + void removeDoublePoints(); - // apply transformation given in matrix form to the polygon - void transform(const ::basegfx::matrix::B3DHomMatrix& rMatrix); - }; - } // end of namespace polygon + // apply transformation given in matrix form to the polygon + void transform(const ::basegfx::B3DHomMatrix& rMatrix); + }; } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// diff --git a/basegfx/inc/basegfx/polygon/b3dpolygontools.hxx b/basegfx/inc/basegfx/polygon/b3dpolygontools.hxx index 7536de67bb21..e8d71b52197d 100644 --- a/basegfx/inc/basegfx/polygon/b3dpolygontools.hxx +++ b/basegfx/inc/basegfx/polygon/b3dpolygontools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dpolygontools.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:29:20 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,68 +70,67 @@ #include <basegfx/vector/b3dvector.hxx> #endif +#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX +#include <basegfx/polygon/b3dpolypolygon.hxx> +#endif + +#include <vector> + ////////////////////////////////////////////////////////////////////////////// namespace basegfx { // predefinitions - namespace polygon - { - class B3DPolygon; - } // end of namespace polygon - - // predefinitions - namespace range - { - class B3DRange; - } // end of namespace range + class B3DPolygon; + class B3DRange; - namespace polygon + namespace tools { - namespace tools - { - // B3DPolygon tools - - /** Check if given polygon is closed. This is kind of a - 'classic' method to support old polygon definitions. - Those old polygon definitions define the closed state - of the polygon using identical start and endpoints. This - method corrects this (removes double start/end points) - and sets the Closed()-state of the polygon correctly. - */ - void checkClosed(::basegfx::polygon::B3DPolygon& rCandidate); - - // Get successor and predecessor indices. Returning the same index means there - // is none. Same for successor. - sal_uInt32 getIndexOfPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B3DPolygon& rCandidate); - sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B3DPolygon& rCandidate); - - // Get index of first different predecessor. Returning the same index means there - // is none. Same for successor. - sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B3DPolygon& rCandidate); - sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B3DPolygon& rCandidate); - - // get size of polygon. Control vectors are included in that ranges. - ::basegfx::range::B3DRange getRange(const ::basegfx::polygon::B3DPolygon& rCandidate); - - // get length of polygon edge from point nIndex to nIndex + 1 - double getEdgeLength(const ::basegfx::polygon::B3DPolygon& rCandidate, sal_uInt32 nIndex); - - // get length of polygon - double getLength(const ::basegfx::polygon::B3DPolygon& rCandidate); - - // get position on polygon for absolute given distance. If - // length is given, it is assumed the correct polygon length, if 0.0 it is calculated - // using getLength(...) - ::basegfx::point::B3DPoint getPositionAbsolute(const ::basegfx::polygon::B3DPolygon& rCandidate, double fDistance, double fLength = 0.0); - - // get position on polygon for relative given distance in range [0.0 .. 1.0]. If - // length is given, it is assumed the correct polygon length, if 0.0 it is calculated - // using getLength(...) - ::basegfx::point::B3DPoint getPositionRelative(const ::basegfx::polygon::B3DPolygon& rCandidate, double fDistance, double fLength = 0.0); - - } // end of namespace tools - } // end of namespace polygon + // B3DPolygon tools + + /** Check if given polygon is closed. This is kind of a + 'classic' method to support old polygon definitions. + Those old polygon definitions define the closed state + of the polygon using identical start and endpoints. This + method corrects this (removes double start/end points) + and sets the Closed()-state of the polygon correctly. + */ + void checkClosed(::basegfx::B3DPolygon& rCandidate); + + // Get successor and predecessor indices. Returning the same index means there + // is none. Same for successor. + sal_uInt32 getIndexOfPredecessor(sal_uInt32 nIndex, const ::basegfx::B3DPolygon& rCandidate); + sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::B3DPolygon& rCandidate); + + // Get index of first different predecessor. Returning the same index means there + // is none. Same for successor. + sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::B3DPolygon& rCandidate); + sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::B3DPolygon& rCandidate); + + // get size of polygon. Control vectors are included in that ranges. + ::basegfx::B3DRange getRange(const ::basegfx::B3DPolygon& rCandidate); + + // get length of polygon edge from point nIndex to nIndex + 1 + double getEdgeLength(const ::basegfx::B3DPolygon& rCandidate, sal_uInt32 nIndex); + + // get length of polygon + double getLength(const ::basegfx::B3DPolygon& rCandidate); + + // get position on polygon for absolute given distance. If + // length is given, it is assumed the correct polygon length, if 0.0 it is calculated + // using getLength(...) + ::basegfx::B3DPoint getPositionAbsolute(const ::basegfx::B3DPolygon& rCandidate, double fDistance, double fLength = 0.0); + + // get position on polygon for relative given distance in range [0.0 .. 1.0]. If + // length is given, it is assumed the correct polygon length, if 0.0 it is calculated + // using getLength(...) + ::basegfx::B3DPoint getPositionRelative(const ::basegfx::B3DPolygon& rCandidate, double fDistance, double fLength = 0.0); + + // Apply Line Dashing. This cuts the Polygon into line pieces + // which are inserted as single polygons into the result. + ::basegfx::B3DPolyPolygon applyLineDashing(const ::basegfx::B3DPolygon& rCandidate, const ::std::vector<double>& raDashDotArray, double fFullDashDotLen); + + } // end of namespace tools } // end of namespace basegfx #endif // _BGFX_POLYGON_B3DPOLYGONTOOLS_HXX diff --git a/basegfx/inc/basegfx/polygon/b3dpolypolygon.hxx b/basegfx/inc/basegfx/polygon/b3dpolypolygon.hxx index 1fcd5634d15c..c3a84e3e8750 100644 --- a/basegfx/inc/basegfx/polygon/b3dpolypolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b3dpolypolygon.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dpolypolygon.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:29:18 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,81 +71,71 @@ class ImplB3DPolyPolygon; namespace basegfx { - namespace polygon - { - class B3DPolygon; - } // end of namespace polygon - - namespace matrix - { - class B3DHomMatrix; - } // end of namespace matrix + class B3DPolygon; + class B3DHomMatrix; } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// namespace basegfx { - namespace polygon + class B3DPolyPolygon { - class B3DPolyPolygon - { - private: - ImplB3DPolyPolygon* mpPolyPolygon; + private: + ImplB3DPolyPolygon* mpPolyPolygon; - // internal method to force a ref-counted instance to be copied - // to a modifyable unique copy. - void implForceUniqueCopy(); + // internal method to force a ref-counted instance to be copied + // to a modifyable unique copy. + void implForceUniqueCopy(); - public: - B3DPolyPolygon(); - B3DPolyPolygon(const B3DPolyPolygon& rPolyPolygon); - ~B3DPolyPolygon(); + public: + B3DPolyPolygon(); + B3DPolyPolygon(const B3DPolyPolygon& rPolyPolygon); + ~B3DPolyPolygon(); - // assignment operator - B3DPolyPolygon& operator=(const B3DPolyPolygon& rPolyPolygon); + // assignment operator + B3DPolyPolygon& operator=(const B3DPolyPolygon& rPolyPolygon); - // compare operators - sal_Bool operator==(const B3DPolyPolygon& rPolyPolygon) const; - sal_Bool operator!=(const B3DPolyPolygon& rPolyPolygon) const; + // compare operators + sal_Bool operator==(const B3DPolyPolygon& rPolyPolygon) const; + sal_Bool operator!=(const B3DPolyPolygon& rPolyPolygon) const; - // polygon interface - sal_uInt32 count() const; + // polygon interface + sal_uInt32 count() const; - B3DPolygon getB3DPolygon(sal_uInt32 nIndex) const; - void setB3DPolygon(sal_uInt32 nIndex, const B3DPolygon& rPolygon); + B3DPolygon getB3DPolygon(sal_uInt32 nIndex) const; + void setB3DPolygon(sal_uInt32 nIndex, const B3DPolygon& rPolygon); - // insert/append single polygon - void insert(sal_uInt32 nIndex, const B3DPolygon& rPolygon, sal_uInt32 nCount = 1); - void append(const B3DPolygon& rPolygon, sal_uInt32 nCount = 1); + // insert/append single polygon + void insert(sal_uInt32 nIndex, const B3DPolygon& rPolygon, sal_uInt32 nCount = 1); + void append(const B3DPolygon& rPolygon, sal_uInt32 nCount = 1); - // insert/append multiple polygons - void insert(sal_uInt32 nIndex, const B3DPolyPolygon& rPolyPolygon); - void append(const B3DPolyPolygon& rPolyPolygon); + // insert/append multiple polygons + void insert(sal_uInt32 nIndex, const B3DPolyPolygon& rPolyPolygon); + void append(const B3DPolyPolygon& rPolyPolygon); - // remove - void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1); + // remove + void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1); - // reset to empty state - void clear(); + // reset to empty state + void clear(); - // closed state - sal_Bool isClosed() const; - void setClosed(sal_Bool bNew); + // closed state + sal_Bool isClosed() const; + void setClosed(sal_Bool bNew); - // flip polygon direction - void flip(); + // flip polygon direction + void flip(); - // test if PolyPolygon has double points - sal_Bool hasDoublePoints() const; + // test if PolyPolygon has double points + sal_Bool hasDoublePoints() const; - // remove double points, at the begin/end and follow-ups, too - void removeDoublePoints(); + // remove double points, at the begin/end and follow-ups, too + void removeDoublePoints(); - // apply transformation given in matrix form to the polygon - void transform(const ::basegfx::matrix::B3DHomMatrix& rMatrix); - }; - } // end of namespace polygon + // apply transformation given in matrix form to the polygon + void transform(const ::basegfx::B3DHomMatrix& rMatrix); + }; } // end of namespace basegfx #endif // _BGFX_POLYGON_B3DPOLYPOLYGON_HXX diff --git a/basegfx/inc/basegfx/polygon/b3dpolypolygontools.hxx b/basegfx/inc/basegfx/polygon/b3dpolypolygontools.hxx index c731930fa69a..aa056975971e 100644 --- a/basegfx/inc/basegfx/polygon/b3dpolypolygontools.hxx +++ b/basegfx/inc/basegfx/polygon/b3dpolypolygontools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dpolypolygontools.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:29:22 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,33 +70,28 @@ #include <basegfx/vector/b2dvector.hxx> #endif +#include <vector> + ////////////////////////////////////////////////////////////////////////////// namespace basegfx { // predefinitions - namespace polygon - { - class B3DPolyPolygon; - } // end of namespace polygon + class B3DPolyPolygon; + class B3DRange; - // predefinitions - namespace range + namespace tools { - class B3DRange; - } // end of namespace range + // B3DPolyPolygon tools - namespace polygon - { - namespace tools - { - // B3DPolyPolygon tools + // get size of PolyPolygon. Control vectors are included in that ranges. + ::basegfx::B3DRange getRange(const ::basegfx::B3DPolyPolygon& rCandidate); - // get size of PolyPolygon. Control vectors are included in that ranges. - ::basegfx::range::B3DRange getRange(const ::basegfx::polygon::B3DPolyPolygon& rCandidate); + // Apply Line Dashing. This cuts every contained PolyPolygon into line pieces + // which are inserted as single polygons into the result. + ::basegfx::B3DPolyPolygon applyLineDashing(const ::basegfx::B3DPolyPolygon& rCandidate, const ::std::vector<double>& raDashDotArray, double fFullDashDotLen); - } // end of namespace tools - } // end of namespace polygon + } // end of namespace tools } // end of namespace basegfx #endif // _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX diff --git a/basegfx/inc/basegfx/range/b1drange.hxx b/basegfx/inc/basegfx/range/b1drange.hxx index e2fd154b5e11..4bb457b28d35 100644 --- a/basegfx/inc/basegfx/range/b1drange.hxx +++ b/basegfx/inc/basegfx/range/b1drange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b1drange.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:40:00 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,88 +68,85 @@ namespace basegfx { - namespace range + class B1DRange { - class B1DRange + ::basegfx::BasicRange maRange; + + public: + B1DRange() + { + } + + B1DRange(double fStartValue) + : maRange(fStartValue) + { + } + + B1DRange(const B1DRange& rRange) + : maRange(rRange.maRange) + { + } + + sal_Bool isEmpty() const + { + return maRange.isEmpty(); + } + + void reset() + { + maRange.reset(); + } + + void operator=(const B1DRange& rRange) + { + maRange = rRange.maRange; + } + + double getMinimum() const + { + return maRange.getMinimum(); + } + + double getMaximum() const + { + return maRange.getMaximum(); + } + + double getRange() const + { + return maRange.getRange(); + } + + double getCenter() const + { + return maRange.getCenter(); + } + + sal_Bool isInside(double fValue) const + { + return maRange.isInside(fValue); + } + + sal_Bool isInside(const B1DRange& rRange) const + { + return maRange.isInside(rRange.maRange); + } + + sal_Bool overlaps(const B1DRange& rRange) const + { + return maRange.overlaps(rRange.maRange); + } + + void expand(double fValue) + { + maRange.expand(fValue); + } + + void expand(const B1DRange& rRange) { - ::basegfx::range::BasicRange maRange; - - public: - B1DRange() - { - } - - B1DRange(double fStartValue) - : maRange(fStartValue) - { - } - - B1DRange(const B1DRange& rRange) - : maRange(rRange.maRange) - { - } - - sal_Bool isEmpty() const - { - return maRange.isEmpty(); - } - - void reset() - { - maRange.reset(); - } - - void operator=(const B1DRange& rRange) - { - maRange = rRange.maRange; - } - - double getMinimum() const - { - return maRange.getMinimum(); - } - - double getMaximum() const - { - return maRange.getMaximum(); - } - - double getRange() const - { - return maRange.getRange(); - } - - double getCenter() const - { - return maRange.getCenter(); - } - - sal_Bool isInside(double fValue) const - { - return maRange.isInside(fValue); - } - - sal_Bool isInside(const B1DRange& rRange) const - { - return maRange.isInside(rRange.maRange); - } - - sal_Bool overlaps(const B1DRange& rRange) const - { - return maRange.overlaps(rRange.maRange); - } - - void expand(double fValue) - { - maRange.expand(fValue); - } - - void expand(const B1DRange& rRange) - { - maRange.expand(rRange.maRange); - } - }; - } // end of namespace range + maRange.expand(rRange.maRange); + } + }; } // end of namespace basegfx #endif // _BGFX_RANGE_B1DRANGE_HXX diff --git a/basegfx/inc/basegfx/range/b2drange.hxx b/basegfx/inc/basegfx/range/b2drange.hxx index 10f14abe9fd7..c30d461f259a 100644 --- a/basegfx/inc/basegfx/range/b2drange.hxx +++ b/basegfx/inc/basegfx/range/b2drange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2drange.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:40:01 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,119 +72,116 @@ namespace basegfx { - namespace range + class B2DRange { - class B2DRange + ::basegfx::BasicRange maRangeX; + ::basegfx::BasicRange maRangeY; + + public: + B2DRange() + { + } + + B2DRange(const B2DTuple& rTuple) + : maRangeX(rTuple.getX()), + maRangeY(rTuple.getY()) + { + } + + B2DRange(const B2DRange& rRange) + : maRangeX(rRange.maRangeX), + maRangeY(rRange.maRangeY) + { + } + + sal_Bool isEmpty() const + { + return ( + maRangeX.isEmpty() + || maRangeY.isEmpty() + ); + } + + void reset() + { + maRangeX.reset(); + maRangeY.reset(); + } + + void operator=(const B2DRange& rRange) + { + maRangeX = rRange.maRangeX; + maRangeY = rRange.maRangeY; + } + + B2DTuple getMinimum() const + { + return B2DTuple( + maRangeX.getMinimum(), + maRangeY.getMinimum() + ); + } + + B2DTuple getMaximum() const + { + return B2DTuple( + maRangeX.getMaximum(), + maRangeY.getMaximum() + ); + } + + B2DTuple getRange() const + { + return B2DTuple( + maRangeX.getRange(), + maRangeY.getRange() + ); + } + + B2DTuple getCenter() const + { + return B2DTuple( + maRangeX.getCenter(), + maRangeY.getCenter() + ); + } + + sal_Bool isInside(const B2DTuple& rTuple) const + { + return ( + maRangeX.isInside(rTuple.getX()) + && maRangeY.isInside(rTuple.getY()) + ); + } + + sal_Bool isInside(const B2DRange& rRange) const + { + return ( + maRangeX.isInside(rRange.maRangeX) + && maRangeY.isInside(rRange.maRangeY) + ); + } + + sal_Bool overlaps(const B2DRange& rRange) const + { + return ( + maRangeX.overlaps(rRange.maRangeX) + && maRangeY.overlaps(rRange.maRangeY) + ); + } + + void expand(const B2DTuple& rTuple) + { + maRangeX.expand(rTuple.getX()); + maRangeY.expand(rTuple.getY()); + } + + void expand(const B2DRange& rRange) { - ::basegfx::range::BasicRange maRangeX; - ::basegfx::range::BasicRange maRangeY; - - public: - B2DRange() - { - } - - B2DRange(const tuple::B2DTuple& rTuple) - : maRangeX(rTuple.getX()), - maRangeY(rTuple.getY()) - { - } - - B2DRange(const B2DRange& rRange) - : maRangeX(rRange.maRangeX), - maRangeY(rRange.maRangeY) - { - } - - sal_Bool isEmpty() const - { - return ( - maRangeX.isEmpty() - || maRangeY.isEmpty() - ); - } - - void reset() - { - maRangeX.reset(); - maRangeY.reset(); - } - - void operator=(const B2DRange& rRange) - { - maRangeX = rRange.maRangeX; - maRangeY = rRange.maRangeY; - } - - tuple::B2DTuple getMinimum() const - { - return tuple::B2DTuple( - maRangeX.getMinimum(), - maRangeY.getMinimum() - ); - } - - tuple::B2DTuple getMaximum() const - { - return tuple::B2DTuple( - maRangeX.getMaximum(), - maRangeY.getMaximum() - ); - } - - tuple::B2DTuple getRange() const - { - return tuple::B2DTuple( - maRangeX.getRange(), - maRangeY.getRange() - ); - } - - tuple::B2DTuple getCenter() const - { - return tuple::B2DTuple( - maRangeX.getCenter(), - maRangeY.getCenter() - ); - } - - sal_Bool isInside(const tuple::B2DTuple& rTuple) const - { - return ( - maRangeX.isInside(rTuple.getX()) - && maRangeY.isInside(rTuple.getY()) - ); - } - - sal_Bool isInside(const B2DRange& rRange) const - { - return ( - maRangeX.isInside(rRange.maRangeX) - && maRangeY.isInside(rRange.maRangeY) - ); - } - - sal_Bool overlaps(const B2DRange& rRange) const - { - return ( - maRangeX.overlaps(rRange.maRangeX) - && maRangeY.overlaps(rRange.maRangeY) - ); - } - - void expand(const tuple::B2DTuple& rTuple) - { - maRangeX.expand(rTuple.getX()); - maRangeY.expand(rTuple.getY()); - } - - void expand(const B2DRange& rRange) - { - maRangeX.expand(rRange.maRangeX); - maRangeY.expand(rRange.maRangeY); - } - }; - } // end of namespace range + maRangeX.expand(rRange.maRangeX); + maRangeY.expand(rRange.maRangeY); + } + }; } // end of namespace basegfx #endif // _BGFX_RANGE_B2DRANGE_HXX diff --git a/basegfx/inc/basegfx/range/b3drange.hxx b/basegfx/inc/basegfx/range/b3drange.hxx index 3d6c3c958d1a..a4d5be99f6ec 100644 --- a/basegfx/inc/basegfx/range/b3drange.hxx +++ b/basegfx/inc/basegfx/range/b3drange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3drange.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:40:02 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,134 +72,131 @@ namespace basegfx { - namespace range + class B3DRange { - class B3DRange + ::basegfx::BasicRange maRangeX; + ::basegfx::BasicRange maRangeY; + ::basegfx::BasicRange maRangeZ; + + public: + B3DRange() + { + } + + B3DRange(const B3DTuple& rTuple) + : maRangeX(rTuple.getX()), + maRangeY(rTuple.getY()), + maRangeZ(rTuple.getZ()) + { + } + + B3DRange(const B3DRange& rRange) + : maRangeX(rRange.maRangeX), + maRangeY(rRange.maRangeY), + maRangeZ(rRange.maRangeZ) + { + } + + sal_Bool isEmpty() const + { + return ( + maRangeX.isEmpty() + || maRangeY.isEmpty() + || maRangeZ.isEmpty() + ); + } + + void reset() + { + maRangeX.reset(); + maRangeY.reset(); + maRangeZ.reset(); + } + + void operator=(const B3DRange& rRange) + { + maRangeX = rRange.maRangeX; + maRangeY = rRange.maRangeY; + maRangeZ = rRange.maRangeZ; + } + + B3DTuple getMinimum() const + { + return B3DTuple( + maRangeX.getMinimum(), + maRangeY.getMinimum(), + maRangeZ.getMinimum() + ); + } + + B3DTuple getMaximum() const + { + return B3DTuple( + maRangeX.getMaximum(), + maRangeY.getMaximum(), + maRangeZ.getMaximum() + ); + } + + B3DTuple getRange() const + { + return B3DTuple( + maRangeX.getRange(), + maRangeY.getRange(), + maRangeZ.getRange() + ); + } + + B3DTuple getCenter() const + { + return B3DTuple( + maRangeX.getCenter(), + maRangeY.getCenter(), + maRangeZ.getCenter() + ); + } + + sal_Bool isInside(const B3DTuple& rTuple) const + { + return ( + maRangeX.isInside(rTuple.getX()) + && maRangeY.isInside(rTuple.getY()) + && maRangeZ.isInside(rTuple.getZ()) + ); + } + + sal_Bool isInside(const B3DRange& rRange) const + { + return ( + maRangeX.isInside(rRange.maRangeX) + && maRangeY.isInside(rRange.maRangeY) + && maRangeZ.isInside(rRange.maRangeZ) + ); + } + + sal_Bool overlaps(const B3DRange& rRange) const + { + return ( + maRangeX.overlaps(rRange.maRangeX) + && maRangeY.overlaps(rRange.maRangeY) + && maRangeZ.overlaps(rRange.maRangeZ) + ); + } + + void expand(const B3DTuple& rTuple) + { + maRangeX.expand(rTuple.getX()); + maRangeY.expand(rTuple.getY()); + maRangeZ.expand(rTuple.getZ()); + } + + void expand(const B3DRange& rRange) { - ::basegfx::range::BasicRange maRangeX; - ::basegfx::range::BasicRange maRangeY; - ::basegfx::range::BasicRange maRangeZ; - - public: - B3DRange() - { - } - - B3DRange(const tuple::B3DTuple& rTuple) - : maRangeX(rTuple.getX()), - maRangeY(rTuple.getY()), - maRangeZ(rTuple.getZ()) - { - } - - B3DRange(const B3DRange& rRange) - : maRangeX(rRange.maRangeX), - maRangeY(rRange.maRangeY), - maRangeZ(rRange.maRangeZ) - { - } - - sal_Bool isEmpty() const - { - return ( - maRangeX.isEmpty() - || maRangeY.isEmpty() - || maRangeZ.isEmpty() - ); - } - - void reset() - { - maRangeX.reset(); - maRangeY.reset(); - maRangeZ.reset(); - } - - void operator=(const B3DRange& rRange) - { - maRangeX = rRange.maRangeX; - maRangeY = rRange.maRangeY; - maRangeZ = rRange.maRangeZ; - } - - tuple::B3DTuple getMinimum() const - { - return tuple::B3DTuple( - maRangeX.getMinimum(), - maRangeY.getMinimum(), - maRangeZ.getMinimum() - ); - } - - tuple::B3DTuple getMaximum() const - { - return tuple::B3DTuple( - maRangeX.getMaximum(), - maRangeY.getMaximum(), - maRangeZ.getMaximum() - ); - } - - tuple::B3DTuple getRange() const - { - return tuple::B3DTuple( - maRangeX.getRange(), - maRangeY.getRange(), - maRangeZ.getRange() - ); - } - - tuple::B3DTuple getCenter() const - { - return tuple::B3DTuple( - maRangeX.getCenter(), - maRangeY.getCenter(), - maRangeZ.getCenter() - ); - } - - sal_Bool isInside(const tuple::B3DTuple& rTuple) const - { - return ( - maRangeX.isInside(rTuple.getX()) - && maRangeY.isInside(rTuple.getY()) - && maRangeZ.isInside(rTuple.getZ()) - ); - } - - sal_Bool isInside(const B3DRange& rRange) const - { - return ( - maRangeX.isInside(rRange.maRangeX) - && maRangeY.isInside(rRange.maRangeY) - && maRangeZ.isInside(rRange.maRangeZ) - ); - } - - sal_Bool overlaps(const B3DRange& rRange) const - { - return ( - maRangeX.overlaps(rRange.maRangeX) - && maRangeY.overlaps(rRange.maRangeY) - && maRangeZ.overlaps(rRange.maRangeZ) - ); - } - - void expand(const tuple::B3DTuple& rTuple) - { - maRangeX.expand(rTuple.getX()); - maRangeY.expand(rTuple.getY()); - maRangeZ.expand(rTuple.getZ()); - } - - void expand(const B3DRange& rRange) - { - maRangeX.expand(rRange.maRangeX); - maRangeY.expand(rRange.maRangeY); - maRangeZ.expand(rRange.maRangeZ); - } - }; - } // end of namespace range + maRangeX.expand(rRange.maRangeX); + maRangeY.expand(rRange.maRangeY); + maRangeZ.expand(rRange.maRangeZ); + } + }; } // end of namespace basegfx #endif // _BGFX_RANGE_B3DRANGE_HXX diff --git a/basegfx/inc/basegfx/range/basicrange.hxx b/basegfx/inc/basegfx/range/basicrange.hxx index 700f2b17add4..732a95abcf70 100644 --- a/basegfx/inc/basegfx/range/basicrange.hxx +++ b/basegfx/inc/basegfx/range/basicrange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: basicrange.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:30:28 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,103 +75,100 @@ namespace basegfx { - namespace range + class BasicRange { - class BasicRange + protected: + double mfMinimum; + double mfMaximum; + + public: + void reset() { - protected: - double mfMinimum; - double mfMaximum; + mfMinimum = START_MINIMUM_VALUE; + mfMaximum = START_MAXIMUM_VALUE; + } - public: - void reset() - { - mfMinimum = START_MINIMUM_VALUE; - mfMaximum = START_MAXIMUM_VALUE; - } + sal_Bool isEmpty() const + { + return sal_Bool(START_MINIMUM_VALUE == mfMinimum && START_MAXIMUM_VALUE == mfMaximum); + } - sal_Bool isEmpty() const - { - return sal_Bool(START_MINIMUM_VALUE == mfMinimum && START_MAXIMUM_VALUE == mfMaximum); - } + double getMinimum() const { return mfMinimum; } + double getMaximum() const { return mfMaximum; } - double getMinimum() const { return mfMinimum; } - double getMaximum() const { return mfMaximum; } + double getRange() const + { + return (mfMaximum - mfMinimum); + } - double getRange() const - { - return (mfMaximum - mfMinimum); - } + double getCenter() const + { + return ((mfMaximum + mfMinimum) / 2.0); + } - double getCenter() const - { - return ((mfMaximum + mfMinimum) / 2.0); - } + sal_Bool isInside(double fValue) const + { + return sal_Bool((fValue >= mfMinimum) && (fValue <= mfMaximum)); + } - sal_Bool isInside(double fValue) const - { - return sal_Bool((fValue >= mfMinimum) && (fValue <= mfMaximum)); - } + sal_Bool isInside(const BasicRange& rRange) const + { + return sal_Bool((rRange.getMinimum() >= mfMinimum) && (rRange.getMaximum() <= mfMaximum)); + } - sal_Bool isInside(const BasicRange& rRange) const - { - return sal_Bool((rRange.getMinimum() >= mfMinimum) && (rRange.getMaximum() <= mfMaximum)); - } + sal_Bool overlaps(const BasicRange& rRange) const + { + return !sal_Bool((rRange.getMaximum() < mfMinimum) || (rRange.getMinimum() > mfMaximum)); + } - sal_Bool overlaps(const BasicRange& rRange) const - { - return !sal_Bool((rRange.getMaximum() < mfMinimum) || (rRange.getMinimum() > mfMaximum)); - } + BasicRange() + : mfMinimum(START_MINIMUM_VALUE), + mfMaximum(START_MAXIMUM_VALUE) + { + } + BasicRange(double fStartValue) + : mfMinimum(fStartValue), + mfMaximum(fStartValue) + { + } + BasicRange(const BasicRange& rRange) + : mfMinimum(rRange.getMinimum()), + mfMaximum(rRange.getMaximum()) + { + } - BasicRange() - : mfMinimum(START_MINIMUM_VALUE), - mfMaximum(START_MAXIMUM_VALUE) - { - } - BasicRange(double fStartValue) - : mfMinimum(fStartValue), - mfMaximum(fStartValue) - { - } - BasicRange(const BasicRange& rRange) - : mfMinimum(rRange.getMinimum()), - mfMaximum(rRange.getMaximum()) + void operator=(const BasicRange& rRange) + { + mfMinimum = rRange.getMinimum(); + mfMaximum = rRange.getMaximum(); + } + + void expand(double fValue) + { + if(fValue < mfMinimum) { + mfMinimum = fValue; } - void operator=(const BasicRange& rRange) + if(fValue > mfMaximum) { - mfMinimum = rRange.getMinimum(); - mfMaximum = rRange.getMaximum(); + mfMaximum = fValue; } + } - void expand(double fValue) + void expand(const BasicRange& rRange) + { + if(rRange.getMinimum() < mfMinimum) { - if(fValue < mfMinimum) - { - mfMinimum = fValue; - } - - if(fValue > mfMaximum) - { - mfMaximum = fValue; - } + mfMinimum = rRange.getMinimum(); } - void expand(const BasicRange& rRange) + if(rRange.getMaximum() > mfMaximum) { - if(rRange.getMinimum() < mfMinimum) - { - mfMinimum = rRange.getMinimum(); - } - - if(rRange.getMaximum() > mfMaximum) - { - mfMaximum = rRange.getMaximum(); - } + mfMaximum = rRange.getMaximum(); } - }; - } // end of namespace range + } + }; } // end of namespace basegfx #endif _BGFX_RANGE_BASICRANGE_HXX diff --git a/basegfx/inc/basegfx/tuple/b2dtuple.hxx b/basegfx/inc/basegfx/tuple/b2dtuple.hxx index dd775d8c399e..4f555481c2c2 100644 --- a/basegfx/inc/basegfx/tuple/b2dtuple.hxx +++ b/basegfx/inc/basegfx/tuple/b2dtuple.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dtuple.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-10 11:45:48 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,301 +72,298 @@ namespace basegfx { - namespace tuple + /** Base class for all Points/Vectors with two double values + + This class provides all methods common to Point + avd Vector classes which are derived from here. + + @derive Use this class to implement Points or Vectors + which are based on two double values + */ + class B2DTuple { - /** Base class for all Points/Vectors with two double values + private: + static B2DTuple maEmptyTuple; + + protected: + double mfX; + double mfY; + + public: + /** Create a 2D Tuple + + @param fVal + This parameter is used to initialize the coordinate + part of the 2D Tuple. + */ + B2DTuple(double fVal = 0.0) + : mfX(fVal), + mfY(fVal) + {} + + /** Create a 2D Tuple - This class provides all methods common to Point - avd Vector classes which are derived from here. + @param fX + This parameter is used to initialize the X-coordinate + of the 2D Tuple. - @derive Use this class to implement Points or Vectors - which are based on two double values + @param fY + This parameter is used to initialize the Y-coordinate + of the 2D Tuple. */ - class B2DTuple + B2DTuple(double fX, double fY) + : mfX( fX ), + mfY( fY ) + {} + + /** Create a copy of a 2D Tuple + + @param rTup + The 2D Tuple which will be copied. + */ + B2DTuple(const B2DTuple& rTup) + : mfX( rTup.mfX ), + mfY( rTup.mfY ) + {} + + ~B2DTuple() + {} + + /// Get X-Coordinate of 2D Tuple + double getX() const + { + return mfX; + } + + /// Get Y-Coordinate of 2D Tuple + double getY() const { - private: - static B2DTuple maEmptyTuple; - - protected: - double mfX; - double mfY; - - public: - /** Create a 2D Tuple - - @param fVal - This parameter is used to initialize the coordinate - part of the 2D Tuple. - */ - B2DTuple(double fVal = 0.0) - : mfX(fVal), - mfY(fVal) - {} - - /** Create a 2D Tuple - - @param fX - This parameter is used to initialize the X-coordinate - of the 2D Tuple. - - @param fY - This parameter is used to initialize the Y-coordinate - of the 2D Tuple. - */ - B2DTuple(double fX, double fY) - : mfX( fX ), - mfY( fY ) - {} - - /** Create a copy of a 2D Tuple - - @param rTup - The 2D Tuple which will be copied. - */ - B2DTuple(const B2DTuple& rTup) - : mfX( rTup.mfX ), - mfY( rTup.mfY ) - {} - - ~B2DTuple() - {} - - /// Get X-Coordinate of 2D Tuple - double getX() const - { - return mfX; - } - - /// Get Y-Coordinate of 2D Tuple - double getY() const - { - return mfY; - } - - /// Set X-Coordinate of 2D Tuple - void setX(double fX) - { - mfX = fX; - } - - /// Set Y-Coordinate of 2D Tuple - void setY(double fY) - { - mfY = fY; - } - - /// Array-access to 2D Tuple - const double& operator[] (int nPos) const - { - // Here, normally one if(...) should be used. In the assumption that - // both double members can be accessed as an array a shortcut is used here. - // if(0 == nPos) return mfX; return mfY; - return *((&mfX) + nPos); - } - - /// Array-access to 2D Tuple - double& operator[] (int nPos) - { - // Here, normally one if(...) should be used. In the assumption that - // both double members can be accessed as an array a shortcut is used here. - // if(0 == nPos) return mfX; return mfY; - return *((&mfX) + nPos); - } - - // comparators with tolerance - ////////////////////////////////////////////////////////////////////// - - sal_Bool equalZero() const; - - sal_Bool equalZero(const double& rfSmallValue) const; - - sal_Bool equal(const B2DTuple& rTup) const; - - sal_Bool equal(const B2DTuple& rTup, const double& rfSmallValue) const; - - // operators - ////////////////////////////////////////////////////////////////////// - - B2DTuple& operator+=( const B2DTuple& rTup ) - { - mfX += rTup.mfX; - mfY += rTup.mfY; - return *this; - } - - B2DTuple& operator-=( const B2DTuple& rTup ) - { - mfX -= rTup.mfX; - mfY -= rTup.mfY; - return *this; - } - - B2DTuple& operator/=( const B2DTuple& rTup ) - { - mfX /= rTup.mfX; - mfY /= rTup.mfY; - return *this; - } - - B2DTuple& operator*=( const B2DTuple& rTup ) - { - mfX *= rTup.mfX; - mfY *= rTup.mfY; - return *this; - } - - B2DTuple& operator*=(double t) - { - mfX *= t; - mfY *= t; - return *this; - } - - B2DTuple& operator/=(double t) - { - const double fVal(1.0 / t); - mfX *= fVal; - mfY *= fVal; - return *this; - } - - B2DTuple operator-(void) const - { - return B2DTuple(-mfX, -mfY); - } - - sal_Bool operator==( const B2DTuple& rTup ) const - { - return equal(rTup); - } - - sal_Bool operator!=( const B2DTuple& rTup ) const - { - return !equal(rTup); - } - - B2DTuple& operator=( const B2DTuple& rTup ) - { - mfX = rTup.mfX; - mfY = rTup.mfY; - return *this; - } - - void correctValues(const double fCompareValue = 0.0); - - static const B2DTuple& getEmptyTuple() - { - return maEmptyTuple; - } - }; - - // external operators - ////////////////////////////////////////////////////////////////////////// - - inline B2DTuple min(const B2DTuple& rTupA, const B2DTuple& rTupB) + return mfY; + } + + /// Set X-Coordinate of 2D Tuple + void setX(double fX) { - B2DTuple aMin( - (rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(), - (rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY()); - return aMin; + mfX = fX; } - inline B2DTuple max(const B2DTuple& rTupA, const B2DTuple& rTupB) + /// Set Y-Coordinate of 2D Tuple + void setY(double fY) { - B2DTuple aMax( - (rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(), - (rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY()); - return aMax; + mfY = fY; } - inline B2DTuple abs(const B2DTuple& rTup) + /// Array-access to 2D Tuple + const double& operator[] (int nPos) const { - B2DTuple aAbs( - (0.0 > rTup.getX()) ? -rTup.getX() : rTup.getX(), - (0.0 > rTup.getY()) ? -rTup.getY() : rTup.getY()); - return aAbs; + // Here, normally one if(...) should be used. In the assumption that + // both double members can be accessed as an array a shortcut is used here. + // if(0 == nPos) return mfX; return mfY; + return *((&mfX) + nPos); } - inline B2DTuple interpolate(const B2DTuple& rOld1, const B2DTuple& rOld2, double t) + /// Array-access to 2D Tuple + double& operator[] (int nPos) + { + // Here, normally one if(...) should be used. In the assumption that + // both double members can be accessed as an array a shortcut is used here. + // if(0 == nPos) return mfX; return mfY; + return *((&mfX) + nPos); + } + + // comparators with tolerance + ////////////////////////////////////////////////////////////////////// + + sal_Bool equalZero() const; + + sal_Bool equalZero(const double& rfSmallValue) const; + + sal_Bool equal(const B2DTuple& rTup) const; + + sal_Bool equal(const B2DTuple& rTup, const double& rfSmallValue) const; + + // operators + ////////////////////////////////////////////////////////////////////// + + B2DTuple& operator+=( const B2DTuple& rTup ) { - B2DTuple aInt( - ((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), - ((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY()); - return aInt; + mfX += rTup.mfX; + mfY += rTup.mfY; + return *this; } - inline B2DTuple average(const B2DTuple& rOld1, const B2DTuple& rOld2) + B2DTuple& operator-=( const B2DTuple& rTup ) { - B2DTuple aAvg( - (rOld1.getX() + rOld2.getX()) * 0.5, - (rOld1.getY() + rOld2.getY()) * 0.5); - return aAvg; + mfX -= rTup.mfX; + mfY -= rTup.mfY; + return *this; } - inline B2DTuple average(const B2DTuple& rOld1, const B2DTuple& rOld2, const B2DTuple& rOld3) + B2DTuple& operator/=( const B2DTuple& rTup ) { - B2DTuple aAvg( - (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), - (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0)); - return aAvg; + mfX /= rTup.mfX; + mfY /= rTup.mfY; + return *this; } - inline B2DTuple operator+(const B2DTuple& rTupA, const B2DTuple& rTupB) + B2DTuple& operator*=( const B2DTuple& rTup ) { - B2DTuple aSum(rTupA); - aSum += rTupB; - return aSum; + mfX *= rTup.mfX; + mfY *= rTup.mfY; + return *this; } - inline B2DTuple operator-(const B2DTuple& rTupA, const B2DTuple& rTupB) + B2DTuple& operator*=(double t) { - B2DTuple aSub(rTupA); - aSub -= rTupB; - return aSub; + mfX *= t; + mfY *= t; + return *this; } - inline B2DTuple operator/(const B2DTuple& rTupA, const B2DTuple& rTupB) + B2DTuple& operator/=(double t) { - B2DTuple aDiv(rTupA); - aDiv /= rTupB; - return aDiv; + const double fVal(1.0 / t); + mfX *= fVal; + mfY *= fVal; + return *this; } - inline B2DTuple operator*(const B2DTuple& rTupA, const B2DTuple& rTupB) + B2DTuple operator-(void) const { - B2DTuple aMul(rTupA); - aMul *= rTupB; - return aMul; + return B2DTuple(-mfX, -mfY); } - inline B2DTuple operator*(const B2DTuple& rTup, double t) + sal_Bool operator==( const B2DTuple& rTup ) const { - B2DTuple aNew(rTup); - aNew *= t; - return aNew; + return equal(rTup); } - inline B2DTuple operator*(double t, const B2DTuple& rTup) + sal_Bool operator!=( const B2DTuple& rTup ) const { - B2DTuple aNew(rTup); - aNew *= t; - return aNew; + return !equal(rTup); } - inline B2DTuple operator/(const B2DTuple& rTup, double t) + B2DTuple& operator=( const B2DTuple& rTup ) { - B2DTuple aNew(rTup); - aNew /= t; - return aNew; + mfX = rTup.mfX; + mfY = rTup.mfY; + return *this; } - inline B2DTuple operator/(double t, const B2DTuple& rTup) + void correctValues(const double fCompareValue = 0.0); + + static const B2DTuple& getEmptyTuple() { - B2DTuple aNew(rTup); - aNew /= t; - return aNew; + return maEmptyTuple; } - } // end of namespace tuple + }; + + // external operators + ////////////////////////////////////////////////////////////////////////// + + inline B2DTuple min(const B2DTuple& rTupA, const B2DTuple& rTupB) + { + B2DTuple aMin( + (rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(), + (rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY()); + return aMin; + } + + inline B2DTuple max(const B2DTuple& rTupA, const B2DTuple& rTupB) + { + B2DTuple aMax( + (rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(), + (rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY()); + return aMax; + } + + inline B2DTuple abs(const B2DTuple& rTup) + { + B2DTuple aAbs( + (0.0 > rTup.getX()) ? -rTup.getX() : rTup.getX(), + (0.0 > rTup.getY()) ? -rTup.getY() : rTup.getY()); + return aAbs; + } + + inline B2DTuple interpolate(const B2DTuple& rOld1, const B2DTuple& rOld2, double t) + { + B2DTuple aInt( + ((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), + ((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY()); + return aInt; + } + + inline B2DTuple average(const B2DTuple& rOld1, const B2DTuple& rOld2) + { + B2DTuple aAvg( + (rOld1.getX() + rOld2.getX()) * 0.5, + (rOld1.getY() + rOld2.getY()) * 0.5); + return aAvg; + } + + inline B2DTuple average(const B2DTuple& rOld1, const B2DTuple& rOld2, const B2DTuple& rOld3) + { + B2DTuple aAvg( + (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), + (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0)); + return aAvg; + } + + inline B2DTuple operator+(const B2DTuple& rTupA, const B2DTuple& rTupB) + { + B2DTuple aSum(rTupA); + aSum += rTupB; + return aSum; + } + + inline B2DTuple operator-(const B2DTuple& rTupA, const B2DTuple& rTupB) + { + B2DTuple aSub(rTupA); + aSub -= rTupB; + return aSub; + } + + inline B2DTuple operator/(const B2DTuple& rTupA, const B2DTuple& rTupB) + { + B2DTuple aDiv(rTupA); + aDiv /= rTupB; + return aDiv; + } + + inline B2DTuple operator*(const B2DTuple& rTupA, const B2DTuple& rTupB) + { + B2DTuple aMul(rTupA); + aMul *= rTupB; + return aMul; + } + + inline B2DTuple operator*(const B2DTuple& rTup, double t) + { + B2DTuple aNew(rTup); + aNew *= t; + return aNew; + } + + inline B2DTuple operator*(double t, const B2DTuple& rTup) + { + B2DTuple aNew(rTup); + aNew *= t; + return aNew; + } + + inline B2DTuple operator/(const B2DTuple& rTup, double t) + { + B2DTuple aNew(rTup); + aNew /= t; + return aNew; + } + + inline B2DTuple operator/(double t, const B2DTuple& rTup) + { + B2DTuple aNew(rTup); + aNew /= t; + return aNew; + } } // end of namespace basegfx #endif // _BGFX_TUPLE_B2DTUPLE_HXX diff --git a/basegfx/inc/basegfx/tuple/b3dtuple.hxx b/basegfx/inc/basegfx/tuple/b3dtuple.hxx index 48f1fde48a24..928f1f081855 100644 --- a/basegfx/inc/basegfx/tuple/b3dtuple.hxx +++ b/basegfx/inc/basegfx/tuple/b3dtuple.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dtuple.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:40:04 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,394 +68,391 @@ namespace basegfx { - namespace tuple - { - /** Base class for all Points/Vectors with three double values - - This class provides all methods common to Point - avd Vector classes which are derived from here. - - @derive Use this class to implement Points or Vectors - which are based on three double values - */ - class B3DTuple - { - private: - static B3DTuple maEmptyTuple; - - protected: - double mfX; - double mfY; - double mfZ; - - public: - /** Create a 3D Tuple - - @param fVal - This parameter is used to initialize the coordinate - part of the 3D Tuple. - */ - B3DTuple(double fVal = 0.0) - : mfX(fVal), - mfY(fVal), - mfZ(fVal) - {} - - /** Create a 3D Tuple - - @param fX - This parameter is used to initialize the X-coordinate - of the 3D Tuple. - - @param fY - This parameter is used to initialize the Y-coordinate - of the 3D Tuple. - - @param fZ - This parameter is used to initialize the Z-coordinate - of the 3D Tuple. - */ - B3DTuple(double fX, double fY, double fZ) - : mfX(fX), - mfY(fY), - mfZ(fZ) - {} - - /** Create a copy of a 3D Tuple - - @param rTup - The 3D Tuple which will be copied. - */ - B3DTuple(const B3DTuple& rTup) - : mfX( rTup.mfX ), - mfY( rTup.mfY ), - mfZ( rTup.mfZ ) - {} - - ~B3DTuple() - {} - - /// get X-Coordinate of 3D Tuple - double getX() const - { - return mfX; - } - - /// get Y-Coordinate of 3D Tuple - double getY() const - { - return mfY; - } - - /// get Z-Coordinate of 3D Tuple - double getZ() const - { - return mfZ; - } - - /// set X-Coordinate of 3D Tuple - void setX(double fX) - { - mfX = fX; - } + /** Base class for all Points/Vectors with three double values - /// set Y-Coordinate of 3D Tuple - void setY(double fY) - { - mfY = fY; - } + This class provides all methods common to Point + avd Vector classes which are derived from here. - /// set Z-Coordinate of 3D Tuple - void setZ(double fZ) - { - mfZ = fZ; - } + @derive Use this class to implement Points or Vectors + which are based on three double values + */ + class B3DTuple + { + private: + static B3DTuple maEmptyTuple; - /// Array-access to 3D Tuple - const double& operator[] (int nPos) const - { - // Here, normally two if(...)'s should be used. In the assumption that - // both double members can be accessed as an array a shortcut is used here. - // if(0 == nPos) return mfX; if(1 == nPos) return mfY; return mfZ; - return *((&mfX) + nPos); - } + protected: + double mfX; + double mfY; + double mfZ; - /// Array-access to 3D Tuple - double& operator[] (int nPos) - { - // Here, normally two if(...)'s should be used. In the assumption that - // both double members can be accessed as an array a shortcut is used here. - // if(0 == nPos) return mfX; if(1 == nPos) return mfY; return mfZ; - return *((&mfX) + nPos); - } + public: + /** Create a 3D Tuple - // comparators with tolerance - ////////////////////////////////////////////////////////////////////// + @param fVal + This parameter is used to initialize the coordinate + part of the 3D Tuple. + */ + B3DTuple(double fVal = 0.0) + : mfX(fVal), + mfY(fVal), + mfZ(fVal) + {} - sal_Bool equalZero() const - { - return (this == &maEmptyTuple || - (::basegfx::numeric::fTools::equalZero(mfX) - && ::basegfx::numeric::fTools::equalZero(mfY) - && ::basegfx::numeric::fTools::equalZero(mfZ))); - } + /** Create a 3D Tuple - sal_Bool equalZero(const double& rfSmallValue) const - { - return (this == &maEmptyTuple || - (::basegfx::numeric::fTools::equalZero(mfX, rfSmallValue) - && ::basegfx::numeric::fTools::equalZero(mfY, rfSmallValue) - && ::basegfx::numeric::fTools::equalZero(mfZ, rfSmallValue))); - } + @param fX + This parameter is used to initialize the X-coordinate + of the 3D Tuple. - sal_Bool equal(const B3DTuple& rTup) const - { - return ( - ::basegfx::numeric::fTools::equal(mfX, rTup.mfX) && - ::basegfx::numeric::fTools::equal(mfY, rTup.mfY) && - ::basegfx::numeric::fTools::equal(mfZ, rTup.mfZ)); - } + @param fY + This parameter is used to initialize the Y-coordinate + of the 3D Tuple. - sal_Bool equal(const B3DTuple& rTup, const double& rfSmallValue) const - { - return ( - ::basegfx::numeric::fTools::equal(mfX, rTup.mfX, rfSmallValue) && - ::basegfx::numeric::fTools::equal(mfY, rTup.mfY, rfSmallValue) && - ::basegfx::numeric::fTools::equal(mfZ, rTup.mfZ, rfSmallValue)); - } + @param fZ + This parameter is used to initialize the Z-coordinate + of the 3D Tuple. + */ + B3DTuple(double fX, double fY, double fZ) + : mfX(fX), + mfY(fY), + mfZ(fZ) + {} - // operators - ////////////////////////////////////////////////////////////////////// + /** Create a copy of a 3D Tuple - B3DTuple& operator+=( const B3DTuple& rTup ) - { - mfX += rTup.mfX; - mfY += rTup.mfY; - mfZ += rTup.mfZ; - return *this; - } + @param rTup + The 3D Tuple which will be copied. + */ + B3DTuple(const B3DTuple& rTup) + : mfX( rTup.mfX ), + mfY( rTup.mfY ), + mfZ( rTup.mfZ ) + {} - B3DTuple& operator-=( const B3DTuple& rTup ) - { - mfX -= rTup.mfX; - mfY -= rTup.mfY; - mfZ -= rTup.mfZ; - return *this; - } + ~B3DTuple() + {} - B3DTuple& operator/=( const B3DTuple& rTup ) - { - mfX /= rTup.mfX; - mfY /= rTup.mfY; - mfZ /= rTup.mfZ; - return *this; - } + /// get X-Coordinate of 3D Tuple + double getX() const + { + return mfX; + } - B3DTuple& operator*=( const B3DTuple& rTup ) - { - mfX *= rTup.mfX; - mfY *= rTup.mfY; - mfZ *= rTup.mfZ; - return *this; - } + /// get Y-Coordinate of 3D Tuple + double getY() const + { + return mfY; + } - B3DTuple& operator*=(double t) - { - mfX *= t; - mfY *= t; - mfZ *= t; - return *this; - } + /// get Z-Coordinate of 3D Tuple + double getZ() const + { + return mfZ; + } - B3DTuple& operator/=(double t) - { - const double fVal(1.0 / t); - mfX *= t; - mfY *= t; - mfZ *= t; - return *this; - } + /// set X-Coordinate of 3D Tuple + void setX(double fX) + { + mfX = fX; + } - B3DTuple operator-(void) const - { - return B3DTuple(-mfX, -mfY, -mfZ); - } + /// set Y-Coordinate of 3D Tuple + void setY(double fY) + { + mfY = fY; + } - sal_Bool operator==( const B3DTuple& rTup ) const - { - return equal(rTup); - } + /// set Z-Coordinate of 3D Tuple + void setZ(double fZ) + { + mfZ = fZ; + } - sal_Bool operator!=( const B3DTuple& rTup ) const - { - return !equal(rTup); - } + /// Array-access to 3D Tuple + const double& operator[] (int nPos) const + { + // Here, normally two if(...)'s should be used. In the assumption that + // both double members can be accessed as an array a shortcut is used here. + // if(0 == nPos) return mfX; if(1 == nPos) return mfY; return mfZ; + return *((&mfX) + nPos); + } - B3DTuple& operator=( const B3DTuple& rTup ) - { - mfX = rTup.mfX; - mfY = rTup.mfY; - mfZ = rTup.mfZ; - return *this; - } + /// Array-access to 3D Tuple + double& operator[] (int nPos) + { + // Here, normally two if(...)'s should be used. In the assumption that + // both double members can be accessed as an array a shortcut is used here. + // if(0 == nPos) return mfX; if(1 == nPos) return mfY; return mfZ; + return *((&mfX) + nPos); + } - void correctValues(const double fCompareValue = 0.0) - { - if(0.0 == fCompareValue) - { - if(::basegfx::numeric::fTools::equalZero(mfX)) - { - mfX = 0.0; - } - - if(::basegfx::numeric::fTools::equalZero(mfY)) - { - mfY = 0.0; - } - - if(::basegfx::numeric::fTools::equalZero(mfZ)) - { - mfZ = 0.0; - } - } - else - { - if(::basegfx::numeric::fTools::equal(mfX, fCompareValue)) - { - mfX = fCompareValue; - } - - if(::basegfx::numeric::fTools::equal(mfY, fCompareValue)) - { - mfY = fCompareValue; - } - - if(::basegfx::numeric::fTools::equal(mfZ, fCompareValue)) - { - mfZ = fCompareValue; - } - } - } + // comparators with tolerance + ////////////////////////////////////////////////////////////////////// - static const B3DTuple& getEmptyTuple() - { - return maEmptyTuple; - } - }; + sal_Bool equalZero() const + { + return (this == &maEmptyTuple || + (::basegfx::fTools::equalZero(mfX) + && ::basegfx::fTools::equalZero(mfY) + && ::basegfx::fTools::equalZero(mfZ))); + } - // external operators - ////////////////////////////////////////////////////////////////////////// + sal_Bool equalZero(const double& rfSmallValue) const + { + return (this == &maEmptyTuple || + (::basegfx::fTools::equalZero(mfX, rfSmallValue) + && ::basegfx::fTools::equalZero(mfY, rfSmallValue) + && ::basegfx::fTools::equalZero(mfZ, rfSmallValue))); + } - inline B3DTuple min(const B3DTuple& rTupA, const B3DTuple& rTupB) + sal_Bool equal(const B3DTuple& rTup) const { - B3DTuple aMin( - (rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(), - (rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY(), - (rTupB.getZ() < rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ()); - return aMin; + return ( + ::basegfx::fTools::equal(mfX, rTup.mfX) && + ::basegfx::fTools::equal(mfY, rTup.mfY) && + ::basegfx::fTools::equal(mfZ, rTup.mfZ)); } - inline B3DTuple max(const B3DTuple& rTupA, const B3DTuple& rTupB) + sal_Bool equal(const B3DTuple& rTup, const double& rfSmallValue) const { - B3DTuple aMax( - (rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(), - (rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY(), - (rTupB.getZ() > rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ()); - return aMax; + return ( + ::basegfx::fTools::equal(mfX, rTup.mfX, rfSmallValue) && + ::basegfx::fTools::equal(mfY, rTup.mfY, rfSmallValue) && + ::basegfx::fTools::equal(mfZ, rTup.mfZ, rfSmallValue)); } - inline B3DTuple abs(const B3DTuple& rTup) + // operators + ////////////////////////////////////////////////////////////////////// + + B3DTuple& operator+=( const B3DTuple& rTup ) { - B3DTuple aAbs( - (0.0 > rTup.getX()) ? -rTup.getX() : rTup.getX(), - (0.0 > rTup.getY()) ? -rTup.getY() : rTup.getY(), - (0.0 > rTup.getZ()) ? -rTup.getZ() : rTup.getZ()); - return aAbs; + mfX += rTup.mfX; + mfY += rTup.mfY; + mfZ += rTup.mfZ; + return *this; } - inline B3DTuple interpolate(const B3DTuple& rOld1, const B3DTuple& rOld2, double t) + B3DTuple& operator-=( const B3DTuple& rTup ) { - B3DTuple aInt( - ((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), - ((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(), - ((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()); - return aInt; + mfX -= rTup.mfX; + mfY -= rTup.mfY; + mfZ -= rTup.mfZ; + return *this; } - inline B3DTuple average(const B3DTuple& rOld1, const B3DTuple& rOld2) + B3DTuple& operator/=( const B3DTuple& rTup ) { - B3DTuple aAvg( - (rOld1.getX() + rOld2.getX()) * 0.5, - (rOld1.getY() + rOld2.getY()) * 0.5, - (rOld1.getZ() + rOld2.getZ()) * 0.5); - return aAvg; + mfX /= rTup.mfX; + mfY /= rTup.mfY; + mfZ /= rTup.mfZ; + return *this; } - inline B3DTuple average(const B3DTuple& rOld1, const B3DTuple& rOld2, const B3DTuple& rOld3) + B3DTuple& operator*=( const B3DTuple& rTup ) { - B3DTuple aAvg( - (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), - (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0), - (rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)); - return aAvg; + mfX *= rTup.mfX; + mfY *= rTup.mfY; + mfZ *= rTup.mfZ; + return *this; } - inline B3DTuple operator+(const B3DTuple& rTupA, const B3DTuple& rTupB) + B3DTuple& operator*=(double t) { - B3DTuple aSum(rTupA); - aSum += rTupB; - return aSum; + mfX *= t; + mfY *= t; + mfZ *= t; + return *this; } - inline B3DTuple operator-(const B3DTuple& rTupA, const B3DTuple& rTupB) + B3DTuple& operator/=(double t) { - B3DTuple aSub(rTupA); - aSub -= rTupB; - return aSub; + const double fVal(1.0 / t); + mfX *= t; + mfY *= t; + mfZ *= t; + return *this; } - inline B3DTuple operator/(const B3DTuple& rTupA, const B3DTuple& rTupB) + B3DTuple operator-(void) const { - B3DTuple aDiv(rTupA); - aDiv /= rTupB; - return aDiv; + return B3DTuple(-mfX, -mfY, -mfZ); } - inline B3DTuple operator*(const B3DTuple& rTupA, const B3DTuple& rTupB) + sal_Bool operator==( const B3DTuple& rTup ) const { - B3DTuple aMul(rTupA); - aMul *= rTupB; - return aMul; + return equal(rTup); } - inline B3DTuple operator*(const B3DTuple& rTup, double t) + sal_Bool operator!=( const B3DTuple& rTup ) const { - B3DTuple aNew(rTup); - aNew *= t; - return aNew; + return !equal(rTup); } - inline B3DTuple operator*(double t, const B3DTuple& rTup) + B3DTuple& operator=( const B3DTuple& rTup ) { - B3DTuple aNew(rTup); - aNew *= t; - return aNew; + mfX = rTup.mfX; + mfY = rTup.mfY; + mfZ = rTup.mfZ; + return *this; } - inline B3DTuple operator/(const B3DTuple& rTup, double t) + void correctValues(const double fCompareValue = 0.0) { - B3DTuple aNew(rTup); - aNew /= t; - return aNew; + if(0.0 == fCompareValue) + { + if(::basegfx::fTools::equalZero(mfX)) + { + mfX = 0.0; + } + + if(::basegfx::fTools::equalZero(mfY)) + { + mfY = 0.0; + } + + if(::basegfx::fTools::equalZero(mfZ)) + { + mfZ = 0.0; + } + } + else + { + if(::basegfx::fTools::equal(mfX, fCompareValue)) + { + mfX = fCompareValue; + } + + if(::basegfx::fTools::equal(mfY, fCompareValue)) + { + mfY = fCompareValue; + } + + if(::basegfx::fTools::equal(mfZ, fCompareValue)) + { + mfZ = fCompareValue; + } + } } - inline B3DTuple operator/(double t, const B3DTuple& rTup) + static const B3DTuple& getEmptyTuple() { - B3DTuple aNew(rTup); - aNew /= t; - return aNew; + return maEmptyTuple; } - } // end of namespace tuple + }; + + // external operators + ////////////////////////////////////////////////////////////////////////// + + inline B3DTuple min(const B3DTuple& rTupA, const B3DTuple& rTupB) + { + B3DTuple aMin( + (rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(), + (rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY(), + (rTupB.getZ() < rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ()); + return aMin; + } + + inline B3DTuple max(const B3DTuple& rTupA, const B3DTuple& rTupB) + { + B3DTuple aMax( + (rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(), + (rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY(), + (rTupB.getZ() > rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ()); + return aMax; + } + + inline B3DTuple abs(const B3DTuple& rTup) + { + B3DTuple aAbs( + (0.0 > rTup.getX()) ? -rTup.getX() : rTup.getX(), + (0.0 > rTup.getY()) ? -rTup.getY() : rTup.getY(), + (0.0 > rTup.getZ()) ? -rTup.getZ() : rTup.getZ()); + return aAbs; + } + + inline B3DTuple interpolate(const B3DTuple& rOld1, const B3DTuple& rOld2, double t) + { + B3DTuple aInt( + ((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), + ((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(), + ((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()); + return aInt; + } + + inline B3DTuple average(const B3DTuple& rOld1, const B3DTuple& rOld2) + { + B3DTuple aAvg( + (rOld1.getX() + rOld2.getX()) * 0.5, + (rOld1.getY() + rOld2.getY()) * 0.5, + (rOld1.getZ() + rOld2.getZ()) * 0.5); + return aAvg; + } + + inline B3DTuple average(const B3DTuple& rOld1, const B3DTuple& rOld2, const B3DTuple& rOld3) + { + B3DTuple aAvg( + (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), + (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0), + (rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)); + return aAvg; + } + + inline B3DTuple operator+(const B3DTuple& rTupA, const B3DTuple& rTupB) + { + B3DTuple aSum(rTupA); + aSum += rTupB; + return aSum; + } + + inline B3DTuple operator-(const B3DTuple& rTupA, const B3DTuple& rTupB) + { + B3DTuple aSub(rTupA); + aSub -= rTupB; + return aSub; + } + + inline B3DTuple operator/(const B3DTuple& rTupA, const B3DTuple& rTupB) + { + B3DTuple aDiv(rTupA); + aDiv /= rTupB; + return aDiv; + } + + inline B3DTuple operator*(const B3DTuple& rTupA, const B3DTuple& rTupB) + { + B3DTuple aMul(rTupA); + aMul *= rTupB; + return aMul; + } + + inline B3DTuple operator*(const B3DTuple& rTup, double t) + { + B3DTuple aNew(rTup); + aNew *= t; + return aNew; + } + + inline B3DTuple operator*(double t, const B3DTuple& rTup) + { + B3DTuple aNew(rTup); + aNew *= t; + return aNew; + } + + inline B3DTuple operator/(const B3DTuple& rTup, double t) + { + B3DTuple aNew(rTup); + aNew /= t; + return aNew; + } + + inline B3DTuple operator/(double t, const B3DTuple& rTup) + { + B3DTuple aNew(rTup); + aNew /= t; + return aNew; + } } // end of namespace basegfx #endif // _BGFX_TUPLE_B3DTUPLE_HXX diff --git a/basegfx/inc/basegfx/vector/b2dvector.hxx b/basegfx/inc/basegfx/vector/b2dvector.hxx index f35c38bb3236..6b5fe724b3e9 100644 --- a/basegfx/inc/basegfx/vector/b2dvector.hxx +++ b/basegfx/inc/basegfx/vector/b2dvector.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dvector.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:40:05 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,250 +68,244 @@ namespace basegfx { - namespace matrix + // predeclaration + class B2DHomMatrix; + + /** Descriptor for the mathematical orientations of two 2D Vectors + */ + enum B2DVectorOrientation + { + /// mathematically positive oriented + ORIENTATION_POSITIVE = 0, + + /// mathematically negative oriented + ORIENTATION_NEGATIVE, + + /// mathematically neutral, thus parallel + ORIENTATION_NEUTRAL + }; + + /** Descriptor for the mathematical continuity of two 2D Vectors + */ + enum B2DVectorContinuity { - // predeclaration - class B2DHomMatrix; - } // end of namespace matrix; + /// none + CONTINUITY_NONE = 0, + + /// mathematically negative oriented + CONTINUITY_C1, - namespace vector + /// mathematically neutral, thus parallel + CONTINUITY_C2 + }; + + /** Base Point class with two double values + + This class derives all operators and common handling for + a 2D data class from B2DTuple. All necessary extensions + which are special for 2D Vectors are added here. + + @see B2DTuple + */ + class B2DVector : public ::basegfx::B2DTuple { - /** Descriptor for the mathematical orientations of two 2D Vectors + public: + /** Create a 2D Vector + + @param fVal + This parameter is used to initialize the coordinate + part of the 2D Vector. */ - enum B2DVectorOrientation - { - /// mathematically positive oriented - ORIENTATION_POSITIVE = 0, + B2DVector(double fVal = 0.0) + : B2DTuple(fVal) + {} - /// mathematically negative oriented - ORIENTATION_NEGATIVE, + /** Create a 2D Vector - /// mathematically neutral, thus parallel - ORIENTATION_NEUTRAL - }; + @param fX + This parameter is used to initialize the X-coordinate + of the 2D Vector. - /** Descriptor for the mathematical continuity of two 2D Vectors + @param fY + This parameter is used to initialize the Y-coordinate + of the 2D Vector. */ - enum B2DVectorContinuity - { - /// none - CONTINUITY_NONE = 0, + B2DVector(double fX, double fY) + : B2DTuple(fX, fY) + {} - /// mathematically negative oriented - CONTINUITY_C1, + /** Create a copy of a 2D Vector - /// mathematically neutral, thus parallel - CONTINUITY_C2 - }; + @param rVec + The 2D Vector which will be copied. + */ + B2DVector(const B2DVector& rVec) + : B2DTuple(rVec) + {} - /** Base Point class with two double values + /** constructor with tuple to allow copy-constructing + from B2DTuple-based classes + */ + B2DVector(const ::basegfx::B2DTuple& rTuple) + : B2DTuple(rTuple) + {} - This class derives all operators and common handling for - a 2D data class from B2DTuple. All necessary extensions - which are special for 2D Vectors are added here. + ~B2DVector() + {} - @see B2DTuple + /** *=operator to allow usage from B2DVector, too */ - class B2DVector : public ::basegfx::tuple::B2DTuple + B2DVector& operator*=( const B2DVector& rPnt ) { - public: - /** Create a 2D Vector - - @param fVal - This parameter is used to initialize the coordinate - part of the 2D Vector. - */ - B2DVector(double fVal = 0.0) - : B2DTuple(fVal) - {} - - /** Create a 2D Vector - - @param fX - This parameter is used to initialize the X-coordinate - of the 2D Vector. - - @param fY - This parameter is used to initialize the Y-coordinate - of the 2D Vector. - */ - B2DVector(double fX, double fY) - : B2DTuple(fX, fY) - {} - - /** Create a copy of a 2D Vector - - @param rVec - The 2D Vector which will be copied. - */ - B2DVector(const B2DVector& rVec) - : B2DTuple(rVec) - {} - - /** constructor with tuple to allow copy-constructing - from B2DTuple-based classes - */ - B2DVector(const ::basegfx::tuple::B2DTuple& rTuple) - : B2DTuple(rTuple) - {} - - ~B2DVector() - {} - - /** *=operator to allow usage from B2DVector, too - */ - B2DVector& operator*=( const B2DVector& rPnt ) - { - mfX *= rPnt.mfX; - mfY *= rPnt.mfY; - return *this; - } - - /** *=operator to allow usage from B2DVector, too - */ - B2DVector& operator*=(double t) - { - mfX *= t; - mfY *= t; - return *this; - } - - /** assignment operator to allow assigning the results - of B2DTuple calculations - */ - B2DVector& operator=( const ::basegfx::tuple::B2DTuple& rVec ); - - /** Calculate the length of this 2D Vector - - @return The Length of the 2D Vector - */ - double getLength() const; - - /** Set the length of this 2D Vector - - @param fLen - The to be achieved length of the 2D Vector - */ - B2DVector& setLength(double fLen); - - /** Normalize this 2D Vector - - The length of the 2D Vector is set to 1.0 - */ - B2DVector& normalize(); - - /** Test if this 2D Vector is normalized - - @return - sal_True if lenth of vector is equal to 1.0 - sal_False else - */ - sal_Bool isNormalized() const; - - /** Calculate the Scalar with another 2D Vector - - @param rVec - The second 2D Vector - - @return - The Scalar value of the two involved 2D Vectors - */ - double scalar( const B2DVector& rVec ) const; - - /** Calculate the length of the cross product with another 2D Vector - - In 2D, returning an actual vector does not make much - sense here. The magnitude, although, can be readily - used for tasks such as angle calculations, since for - the returned value, the following equation holds: - retVal = getLength(this)*getLength(rVec)*sin(theta), - with theta being the angle between the two vectors. + mfX *= rPnt.mfX; + mfY *= rPnt.mfY; + return *this; + } - @param rVec - The second 2D Vector + /** *=operator to allow usage from B2DVector, too + */ + B2DVector& operator*=(double t) + { + mfX *= t; + mfY *= t; + return *this; + } - @return - The length of the cross product of the two involved 2D Vectors - */ - double cross( const B2DVector& rVec ) const; + /** assignment operator to allow assigning the results + of B2DTuple calculations + */ + B2DVector& operator=( const ::basegfx::B2DTuple& rVec ); - /** Calculate the Angle with another 2D Vector + /** Calculate the length of this 2D Vector - @param rVec - The second 2D Vector + @return The Length of the 2D Vector + */ + double getLength() const; - @return - The Angle value of the two involved 2D Vectors in -pi/2 < return < pi/2 - */ - double angle( const B2DVector& rVec ) const; + /** Set the length of this 2D Vector - /** Transform vector by given transformation matrix. + @param fLen + The to be achieved length of the 2D Vector + */ + B2DVector& setLength(double fLen); - Since this is a vector, translational components of the - matrix are disregarded. - */ - B2DVector& operator*=( const matrix::B2DHomMatrix& rMat ); + /** Normalize this 2D Vector - static const B2DVector& getEmptyVector(); - }; + The length of the 2D Vector is set to 1.0 + */ + B2DVector& normalize(); - // external operators - ////////////////////////////////////////////////////////////////////////// + /** Test if this 2D Vector is normalized - /** Calculate the orientation to another 2D Vector + @return + sal_True if lenth of vector is equal to 1.0 + sal_False else + */ + sal_Bool isNormalized() const; - @param rVecA - The first 2D Vector + /** Calculate the Scalar with another 2D Vector - @param rVecB + @param rVec The second 2D Vector @return - The mathematical Orientation of the two involved 2D Vectors + The Scalar value of the two involved 2D Vectors */ - B2DVectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB ); + double scalar( const B2DVector& rVec ) const; - /** Calculate a perpendicular 2D Vector to the given one + /** Calculate the length of the cross product with another 2D Vector - @param rVec - The source 2D Vector + In 2D, returning an actual vector does not make much + sense here. The magnitude, although, can be readily + used for tasks such as angle calculations, since for + the returned value, the following equation holds: + retVal = getLength(this)*getLength(rVec)*sin(theta), + with theta being the angle between the two vectors. - @attention This only works if the given 2D Vector is normalized. + @param rVec + The second 2D Vector @return - A 2D Vector perpendicular to the one given in parameter rVec + The length of the cross product of the two involved 2D Vectors */ - B2DVector getPerpendicular( const B2DVector& rNormalizedVec ); - - /** Test two vectors which need not to be normalized for parallelism + double cross( const B2DVector& rVec ) const; - @param rVecA - The first 2D Vector + /** Calculate the Angle with another 2D Vector - @param rVecB + @param rVec The second 2D Vector @return - sal_Bool if the two values are parallel. Also sal_True if - one of the vectors is empty. + The Angle value of the two involved 2D Vectors in -pi/2 < return < pi/2 */ - sal_Bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB ); + double angle( const B2DVector& rVec ) const; /** Transform vector by given transformation matrix. Since this is a vector, translational components of the matrix are disregarded. */ - B2DVector operator*( const matrix::B2DHomMatrix& rMat, const B2DVector& rVec ); + B2DVector& operator*=( const B2DHomMatrix& rMat ); - /** Test continuity between given vectors. + static const B2DVector& getEmptyVector(); + }; - The two given vectors are assumed to describe control points on a - common point. Calculate if there is a continuity between them. - */ - ::basegfx::vector::B2DVectorContinuity getContinuity( const B2DVector& rBackVector, const B2DVector& rForwardVector ); + // external operators + ////////////////////////////////////////////////////////////////////////// + + /** Calculate the orientation to another 2D Vector + + @param rVecA + The first 2D Vector + + @param rVecB + The second 2D Vector + + @return + The mathematical Orientation of the two involved 2D Vectors + */ + B2DVectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB ); + + /** Calculate a perpendicular 2D Vector to the given one + + @param rVec + The source 2D Vector + + @attention This only works if the given 2D Vector is normalized. + + @return + A 2D Vector perpendicular to the one given in parameter rVec + */ + B2DVector getPerpendicular( const B2DVector& rNormalizedVec ); + + /** Test two vectors which need not to be normalized for parallelism + + @param rVecA + The first 2D Vector + + @param rVecB + The second 2D Vector + + @return + sal_Bool if the two values are parallel. Also sal_True if + one of the vectors is empty. + */ + sal_Bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB ); + + /** Transform vector by given transformation matrix. + + Since this is a vector, translational components of the + matrix are disregarded. + */ + B2DVector operator*( const B2DHomMatrix& rMat, const B2DVector& rVec ); + + /** Test continuity between given vectors. + + The two given vectors are assumed to describe control points on a + common point. Calculate if there is a continuity between them. + */ + ::basegfx::B2DVectorContinuity getContinuity( const B2DVector& rBackVector, const B2DVector& rForwardVector ); - } // end of namespace vector } // end of namespace basegfx #endif // _BGFX_VECTOR_B2DVECTOR_HXX diff --git a/basegfx/inc/basegfx/vector/b3dvector.hxx b/basegfx/inc/basegfx/vector/b3dvector.hxx index 855abb7f71e8..094bacfb50a1 100644 --- a/basegfx/inc/basegfx/vector/b3dvector.hxx +++ b/basegfx/inc/basegfx/vector/b3dvector.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dvector.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:40:05 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:17:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,270 +68,232 @@ namespace basegfx { - namespace matrix - { - // predeclaration - class B3DHomMatrix; - } // end of namespace matrix; + // predeclaration + class B3DHomMatrix; - namespace vector - { - /** Base Point class with three double values + /** Base Point class with three double values + + This class derives all operators and common handling for + a 3D data class from B3DTuple. All necessary extensions + which are special for 3D Vectors are added here. - This class derives all operators and common handling for - a 3D data class from B3DTuple. All necessary extensions - which are special for 3D Vectors are added here. + @see B3DTuple + */ + class B3DVector : public ::basegfx::B3DTuple + { + public: + /** Create a 3D Vector - @see B3DTuple + @param fVal + This parameter is used to initialize the coordinate + part of the 3D Vector. */ - class B3DVector : public ::basegfx::tuple::B3DTuple - { - public: - /** Create a 3D Vector - - @param fVal - This parameter is used to initialize the coordinate - part of the 3D Vector. - */ - B3DVector(double fVal = 0.0) - : B3DTuple(fVal) - {} - - /** Create a 3D Vector - - @param fX - This parameter is used to initialize the X-coordinate - of the 3D Vector. - - @param fY - This parameter is used to initialize the Y-coordinate - of the 3D Vector. - - @param fZ - This parameter is used to initialize the Z-coordinate - of the 3D Vector. - */ - B3DVector(double fX, double fY, double fZ) - : B3DTuple(fX, fY, fZ) - {} - - /** Create a copy of a 3D Vector - - @param rVec - The 3D Vector which will be copied. - */ - B3DVector(const B3DVector& rVec) - : B3DTuple(rVec) - {} - - /** constructor with tuple to allow copy-constructing - from B3DTuple-based classes - */ - B3DVector(const ::basegfx::tuple::B3DTuple& rTuple) - : B3DTuple(rTuple) - {} - - ~B3DVector() - {} - - /** *=operator to allow usage from B3DVector, too - */ - B3DVector& operator*=( const B3DVector& rPnt ) - { - mfX *= rPnt.mfX; - mfY *= rPnt.mfY; - mfZ *= rPnt.mfZ; - return *this; - } + B3DVector(double fVal = 0.0) + : B3DTuple(fVal) + {} - /** *=operator to allow usage from B3DVector, too - */ - B3DVector& operator*=(double t) - { - mfX *= t; - mfY *= t; - mfZ *= t; - return *this; - } + /** Create a 3D Vector - /** assignment operator to allow assigning the results - of B3DTuple calculations - */ - B3DVector& operator=( const ::basegfx::tuple::B3DTuple& rVec ) - { - mfX = rVec.getX(); - mfY = rVec.getY(); - mfZ = rVec.getZ(); - return *this; - } + @param fX + This parameter is used to initialize the X-coordinate + of the 3D Vector. - /** Calculate the length of this 3D Vector + @param fY + This parameter is used to initialize the Y-coordinate + of the 3D Vector. - @return The Length of the 3D Vector - */ - double getLength(void) const - { - double fLen(scalar(*this)); - if((0.0 == fLen) || (1.0 == fLen)) - return fLen; - return sqrt(fLen); - } + @param fZ + This parameter is used to initialize the Z-coordinate + of the 3D Vector. + */ + B3DVector(double fX, double fY, double fZ) + : B3DTuple(fX, fY, fZ) + {} - /** Calculate the length in the XY-Plane for this 3D Vector + /** Create a copy of a 3D Vector - @return The XY-Plane Length of the 3D Vector - */ - double getXYLength(void) const - { - double fLen((mfX * mfX) + (mfY * mfY)); - if((0.0 == fLen) || (1.0 == fLen)) - return fLen; - return sqrt(fLen); - } + @param rVec + The 3D Vector which will be copied. + */ + B3DVector(const B3DVector& rVec) + : B3DTuple(rVec) + {} - /** Calculate the length in the XZ-Plane for this 3D Vector + /** constructor with tuple to allow copy-constructing + from B3DTuple-based classes + */ + B3DVector(const ::basegfx::B3DTuple& rTuple) + : B3DTuple(rTuple) + {} - @return The XZ-Plane Length of the 3D Vector - */ - double getXZLength(void) const - { - double fLen((mfX * mfZ) + (mfY * mfZ)); - if((0.0 == fLen) || (1.0 == fLen)) - return fLen; - return sqrt(fLen); - } + ~B3DVector() + {} + + /** *=operator to allow usage from B3DVector, too + */ + B3DVector& operator*=( const B3DVector& rPnt ) + { + mfX *= rPnt.mfX; + mfY *= rPnt.mfY; + mfZ *= rPnt.mfZ; + return *this; + } - /** Calculate the length in the YZ-Plane for this 3D Vector + /** *=operator to allow usage from B3DVector, too + */ + B3DVector& operator*=(double t) + { + mfX *= t; + mfY *= t; + mfZ *= t; + return *this; + } - @return The YZ-Plane Length of the 3D Vector - */ - double getYZLength(void) const - { - double fLen((mfY * mfY) + (mfZ * mfZ)); - if((0.0 == fLen) || (1.0 == fLen)) - return fLen; - return sqrt(fLen); - } + /** assignment operator to allow assigning the results + of B3DTuple calculations + */ + B3DVector& operator=( const ::basegfx::B3DTuple& rVec ) + { + mfX = rVec.getX(); + mfY = rVec.getY(); + mfZ = rVec.getZ(); + return *this; + } - /** Set the length of this 3D Vector + /** Calculate the length of this 3D Vector - @param fLen - The to be achieved length of the 3D Vector - */ - B3DVector& setLength(double fLen) - { - double fLenNow(scalar(*this)); + @return The Length of the 3D Vector + */ + double getLength(void) const + { + double fLen(scalar(*this)); + if((0.0 == fLen) || (1.0 == fLen)) + return fLen; + return sqrt(fLen); + } - if(!::basegfx::numeric::fTools::equalZero(fLenNow)) - { - const double fOne(1.0); + /** Calculate the length in the XY-Plane for this 3D Vector - if(!::basegfx::numeric::fTools::equal(fOne, fLenNow)) - { - fLen /= sqrt(fLenNow); - } + @return The XY-Plane Length of the 3D Vector + */ + double getXYLength(void) const + { + double fLen((mfX * mfX) + (mfY * mfY)); + if((0.0 == fLen) || (1.0 == fLen)) + return fLen; + return sqrt(fLen); + } - mfX *= fLen; - mfY *= fLen; - mfZ *= fLen; - } + /** Calculate the length in the XZ-Plane for this 3D Vector - return *this; - } + @return The XZ-Plane Length of the 3D Vector + */ + double getXZLength(void) const + { + double fLen((mfX * mfZ) + (mfY * mfZ)); + if((0.0 == fLen) || (1.0 == fLen)) + return fLen; + return sqrt(fLen); + } + + /** Calculate the length in the YZ-Plane for this 3D Vector - /** Normalize this 3D Vector + @return The YZ-Plane Length of the 3D Vector + */ + double getYZLength(void) const + { + double fLen((mfY * mfY) + (mfZ * mfZ)); + if((0.0 == fLen) || (1.0 == fLen)) + return fLen; + return sqrt(fLen); + } - The length of the 3D Vector is set to 1.0 - */ - B3DVector& normalize(); + /** Set the length of this 3D Vector - /** Test if this 3D Vector is normalized + @param fLen + The to be achieved length of the 3D Vector + */ + B3DVector& setLength(double fLen) + { + double fLenNow(scalar(*this)); - @return - sal_True if lenth of vector is equal to 1.0 - sal_False else - */ - sal_Bool isNormalized() const + if(!::basegfx::fTools::equalZero(fLenNow)) { const double fOne(1.0); - const double fScalar(scalar(*this)); - - return (::basegfx::numeric::fTools::equal(fOne, fScalar)); - } - /** get a 3D Vector which is perpendicular to this and a given 3D Vector + if(!::basegfx::fTools::equal(fOne, fLenNow)) + { + fLen /= sqrt(fLenNow); + } - @attention This only works if this and the given 3D Vector are - both normalized. + mfX *= fLen; + mfY *= fLen; + mfZ *= fLen; + } - @param rNormalizedVec - A normalized 3D Vector. + return *this; + } - @return - A 3D Vector perpendicular to this and the given one - */ - B3DVector getPerpendicular(const B3DVector& rNormalizedVec) const; + /** Normalize this 3D Vector - /** get the projection of this Vector on the given Plane + The length of the 3D Vector is set to 1.0 + */ + B3DVector& normalize(); - @attention This only works if the given 3D Vector defining - the Plane is normalized. + /** Test if this 3D Vector is normalized - @param rNormalizedPlane - A normalized 3D Vector defining a Plane. + @return + sal_True if lenth of vector is equal to 1.0 + sal_False else + */ + sal_Bool isNormalized() const + { + const double fOne(1.0); + const double fScalar(scalar(*this)); - @return - The projected 3D Vector - */ - B3DVector getProjectionOnPlane(const B3DVector& rNormalizedPlane) const; + return (::basegfx::fTools::equal(fOne, fScalar)); + } - /** Calculate the Scalar product + /** get a 3D Vector which is perpendicular to this and a given 3D Vector - This method calculates the Scalar product between this - and the given 3D Vector. + @attention This only works if this and the given 3D Vector are + both normalized. - @param rVec - A second 3D Vector. + @param rNormalizedVec + A normalized 3D Vector. - @return - The Scalar Product of two 3D Vectors - */ - double scalar(const B3DVector& rVec) const - { - return ((mfX * rVec.mfX) + (mfY * rVec.mfY) + (mfZ * rVec.mfZ)); - } + @return + A 3D Vector perpendicular to this and the given one + */ + B3DVector getPerpendicular(const B3DVector& rNormalizedVec) const; - /** Transform vector by given transformation matrix. + /** get the projection of this Vector on the given Plane - Since this is a vector, translational components of the - matrix are disregarded. - */ - B3DVector& operator*=( const matrix::B3DHomMatrix& rMat ); + @attention This only works if the given 3D Vector defining + the Plane is normalized. - static const B3DVector& getEmptyVector() - { - return (const B3DVector&) ::basegfx::tuple::B3DTuple::getEmptyTuple(); - } - }; + @param rNormalizedPlane + A normalized 3D Vector defining a Plane. - // external operators - ////////////////////////////////////////////////////////////////////////// + @return + The projected 3D Vector + */ + B3DVector getProjectionOnPlane(const B3DVector& rNormalizedPlane) const; - /** get a 3D Vector which is in 2D (ignoring - the Z-Coordinate) perpendicular to a given 3D Vector + /** Calculate the Scalar product - @attention This only works if the given 3D Vector is normalized. + This method calculates the Scalar product between this + and the given 3D Vector. - @param rNormalizedVec - A normalized 3D Vector. + @param rVec + A second 3D Vector. @return - A 3D Vector perpendicular to the given one in X,Y (2D). + The Scalar Product of two 3D Vectors */ - inline B3DVector getPerpendicular2D( const B3DVector& rNormalizedVec ) + double scalar(const B3DVector& rVec) const { - B3DVector aPerpendicular(-rNormalizedVec.getY(), rNormalizedVec.getX(), rNormalizedVec.getZ()); - return aPerpendicular; + return ((mfX * rVec.mfX) + (mfY * rVec.mfY) + (mfZ * rVec.mfZ)); } /** Transform vector by given transformation matrix. @@ -339,28 +301,60 @@ namespace basegfx Since this is a vector, translational components of the matrix are disregarded. */ - B3DVector operator*( const matrix::B3DHomMatrix& rMat, const B3DVector& rVec ); + B3DVector& operator*=( const B3DHomMatrix& rMat ); - /** Calculate the Cross Product of two 3D Vectors + static const B3DVector& getEmptyVector() + { + return (const B3DVector&) ::basegfx::B3DTuple::getEmptyTuple(); + } + }; - @param rVecA - A first 3D Vector. + // external operators + ////////////////////////////////////////////////////////////////////////// - @param rVecB - A second 3D Vector. + /** get a 3D Vector which is in 2D (ignoring + the Z-Coordinate) perpendicular to a given 3D Vector - @return - The Cross Product of both 3D Vectors - */ - inline B3DVector cross(const B3DVector& rVecA, const B3DVector& rVecB) - { - B3DVector aVec( - rVecA.getY() * rVecB.getZ() - rVecA.getZ() * rVecB.getY(), - rVecA.getZ() * rVecB.getX() - rVecA.getX() * rVecB.getZ(), - rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX()); - return aVec; - } - } // end of namespace vector + @attention This only works if the given 3D Vector is normalized. + + @param rNormalizedVec + A normalized 3D Vector. + + @return + A 3D Vector perpendicular to the given one in X,Y (2D). + */ + inline B3DVector getPerpendicular2D( const B3DVector& rNormalizedVec ) + { + B3DVector aPerpendicular(-rNormalizedVec.getY(), rNormalizedVec.getX(), rNormalizedVec.getZ()); + return aPerpendicular; + } + + /** Transform vector by given transformation matrix. + + Since this is a vector, translational components of the + matrix are disregarded. + */ + B3DVector operator*( const B3DHomMatrix& rMat, const B3DVector& rVec ); + + /** Calculate the Cross Product of two 3D Vectors + + @param rVecA + A first 3D Vector. + + @param rVecB + A second 3D Vector. + + @return + The Cross Product of both 3D Vectors + */ + inline B3DVector cross(const B3DVector& rVecA, const B3DVector& rVecB) + { + B3DVector aVec( + rVecA.getY() * rVecB.getZ() - rVecA.getZ() * rVecB.getY(), + rVecA.getZ() * rVecB.getX() - rVecA.getX() * rVecB.getZ(), + rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX()); + return aVec; + } } // end of namespace basegfx #endif // _BGFX_VECTOR_B3DVECTOR_HXX |