diff options
author | Thorsten Behrens <thb@openoffice.org> | 2003-11-12 11:09:52 +0000 |
---|---|---|
committer | Thorsten Behrens <thb@openoffice.org> | 2003-11-12 11:09:52 +0000 |
commit | d29fb24a43fc4d8477181c2b693e163d97c07218 (patch) | |
tree | 6fb6740004e788c9dae1f6ef9244a045771c3196 /basegfx/inc | |
parent | db78936286f5b9adf396e92383041b4f515b0edd (diff) |
Added second adaptive subdivision method (this time with an angle differences as the stopping criterion
Diffstat (limited to 'basegfx/inc')
-rw-r--r-- | basegfx/inc/basegfx/curve/b2dbeziertools.hxx | 146 | ||||
-rw-r--r-- | basegfx/inc/basegfx/vector/b2dvector.hxx | 21 |
2 files changed, 146 insertions, 21 deletions
diff --git a/basegfx/inc/basegfx/curve/b2dbeziertools.hxx b/basegfx/inc/basegfx/curve/b2dbeziertools.hxx index 23231bd9a763..f9d72cb47873 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.1 $ + * $Revision: 1.2 $ * - * last change: $Author: thb $ $Date: 2003-11-10 13:33:07 $ + * last change: $Author: thb $ $Date: 2003-11-12 12:09:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,11 @@ #ifndef _BGFX_CURVE_B2DBEZIERTOOLS_HXX #define _BGFX_CURVE_B2DBEZIERTOOLS_HXX +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + + ////////////////////////////////////////////////////////////////////////////// namespace basegfx @@ -80,9 +85,10 @@ namespace basegfx /** Subdivide given cubic bezier segment. This function adaptively subdivides the given bezier - segment into as much straight line segments, such that the - maximal orthogonal distance from any of the segments to - the true curve is less than the given error value. + 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 @@ -91,22 +97,100 @@ namespace basegfx @param rCurve The cubic bezier curve to subdivide - @param distanceBounds - Bounds 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 */ - int adaptiveSubdivide( polygon::B2DPolygon& rPoly, - const B2DCubicBezier& rCurve, - double distanceBounds ); + sal_Int32 adaptiveSubdivideByDistance( polygon::B2DPolygon& rPoly, + const B2DCubicBezier& rCurve, + double distanceBound ); + + /** 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. + + @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 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 ); + + + /** 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. + + @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 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 ); + + /** 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. + + @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 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 ); + /** Subdivide given quadratic bezier segment. This function adaptively subdivides the given bezier - segment into as much straight line segments, such that the - maximal orthogonal distance from any of the segments to - the true curve is less than the given error value. + 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 @@ -115,15 +199,39 @@ namespace basegfx @param rCurve The cubic bezier curve to subdivide - @param distanceBounds - Bounds on the maximal distance of the approximation to the + @param distanceBound + Bound on the maximal distance of the approximation to the true curve @return the number of line segments created */ - int adaptiveSubdivide( polygon::B2DPolygon& rPoly, - const B2DQuadraticBezier& rCurve, - double distanceBounds ); + sal_Int32 adaptiveSubdivideByDistance( polygon::B2DPolygon& rPoly, + const B2DQuadraticBezier& rCurve, + double distanceBound ); + + /** 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 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 rCurve + The cubic bezier curve to subdivide + + @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 B2DQuadraticBezier& rCurve, + double angleBound ); } } diff --git a/basegfx/inc/basegfx/vector/b2dvector.hxx b/basegfx/inc/basegfx/vector/b2dvector.hxx index 0735d52cd7e0..0a3a896733a0 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.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-11-11 09:56:09 $ + * last change: $Author: thb $ $Date: 2003-11-12 12:09:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -200,6 +200,23 @@ namespace basegfx */ 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. + + @param rVec + The second 2D Vector + + @return + The length of the cross product of the two involved 2D Vectors + */ + double cross( const B2DVector& rVec ) const; + /** Calculate the Angle with another 2D Vector @param rVec |