summaryrefslogtreecommitdiff
path: root/basegfx/source
diff options
context:
space:
mode:
authorArmin Weiss <aw@openoffice.org>2003-11-28 10:18:16 +0000
committerArmin Weiss <aw@openoffice.org>2003-11-28 10:18:16 +0000
commitd539c95155ccc7030411f7494704894a3ac610a8 (patch)
treedc3dbd283a5f501f6e48dd585d80bb158db920e3 /basegfx/source
parentce0ce72d1fd37f7b8e7cb4ebc372d8cd6b4ab9c0 (diff)
Removed in-between namespaces (curve, matrix, numeric, point, polygon, range, tuple, vector). Names were too common and e.g. vector leaded to problems with some defines. This is now avoided. Also some bug fixes, addition of 3d polygon tooling etc.
Diffstat (limited to 'basegfx/source')
-rw-r--r--basegfx/source/curve/b2dbeziertools.cxx767
-rw-r--r--basegfx/source/curve/b2dcubicbezier.cxx146
-rw-r--r--basegfx/source/curve/b2dquadraticbezier.cxx117
-rw-r--r--basegfx/source/inc/hommatrixtemplate.hxx30
-rw-r--r--basegfx/source/matrix/b2dhommatrix.cxx493
-rw-r--r--basegfx/source/matrix/b3dhommatrix.cxx861
-rw-r--r--basegfx/source/numeric/ftools.cxx11
-rw-r--r--basegfx/source/point/b2dhompoint.cxx383
-rw-r--r--basegfx/source/point/b2dpoint.cxx41
-rw-r--r--basegfx/source/point/b3dhompoint.cxx21
-rw-r--r--basegfx/source/point/b3dpoint.cxx43
-rw-r--r--basegfx/source/polygon/b2dpolygon.cxx495
-rw-r--r--basegfx/source/polygon/b2dpolygontools.cxx1410
-rw-r--r--basegfx/source/polygon/b2dpolypolygon.cxx349
-rw-r--r--basegfx/source/polygon/b2dpolypolygoncutter.cxx1542
-rw-r--r--basegfx/source/polygon/b2dpolypolygontools.cxx221
-rw-r--r--basegfx/source/polygon/b3dpolygon.cxx373
-rw-r--r--basegfx/source/polygon/b3dpolygontools.cxx453
-rw-r--r--basegfx/source/polygon/b3dpolypolygon.cxx331
-rw-r--r--basegfx/source/polygon/b3dpolypolygontools.cxx43
-rw-r--r--basegfx/source/range/b1drange.cxx7
-rw-r--r--basegfx/source/range/b2drange.cxx7
-rw-r--r--basegfx/source/range/b3drange.cxx7
-rw-r--r--basegfx/source/tuple/b2dtuple.cxx93
-rw-r--r--basegfx/source/tuple/b3dtuple.cxx11
-rw-r--r--basegfx/source/vector/b2dvector.cxx233
-rw-r--r--basegfx/source/vector/b3dvector.cxx99
27 files changed, 4337 insertions, 4250 deletions
diff --git a/basegfx/source/curve/b2dbeziertools.cxx b/basegfx/source/curve/b2dbeziertools.cxx
index 3512b87ca992..67c25aacb17a 100644
--- a/basegfx/source/curve/b2dbeziertools.cxx
+++ b/basegfx/source/curve/b2dbeziertools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dbeziertools.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:07 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:00 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -95,441 +95,438 @@
namespace basegfx
{
- namespace curve
+ namespace
{
- namespace
+ class DistanceErrorFunctor
{
- class DistanceErrorFunctor
+ public:
+ DistanceErrorFunctor( const double& distance ) :
+ mfDistance2( distance*distance ),
+ mfLastDistanceError2( ::std::numeric_limits<double>::max() )
{
- public:
- DistanceErrorFunctor( const double& distance ) :
- mfDistance2( distance*distance ),
- mfLastDistanceError2( ::std::numeric_limits<double>::max() )
- {
- }
-
- bool subdivideFurther( const double& P1x, const double& P1y,
- const double& P2x, const double& P2y,
- const double& P3x, const double& P3y,
- const double& P4x, const double& P4y,
- const double&, const double& ) // last two values not used here
- {
- // Perform bezier flatness test (lecture notes from R. Schaback,
- // Mathematics of Computer-Aided Design, Uni Goettingen, 2000)
- //
- // ||P(t) - L(t)|| <= max ||b_j - b_0 - j/n(b_n - b_0)||
- // 0<=j<=n
- //
- // What is calculated here is an upper bound to the distance from
- // a line through b_0 and b_3 (P1 and P4 in our notation) and the
- // curve. We can drop 0 and n from the running indices, since the
- // argument of max becomes zero for those cases.
- const double fJ1x( P2x - P1x - 1.0/3.0*(P4x - P1x) );
- const double fJ1y( P2y - P1y - 1.0/3.0*(P4y - P1y) );
- const double fJ2x( P3x - P1x - 2.0/3.0*(P4x - P1x) );
- const double fJ2y( P3y - P1y - 2.0/3.0*(P4y - P1y) );
- const double distanceError2( ::std::max( fJ1x*fJ1x + fJ1y*fJ1y,
- fJ2x*fJ2x + fJ2y*fJ2y) );
-
- // stop if error measure does not improve anymore. This is a
- // safety guard against floating point inaccuracies.
- // stop if distance from line is guaranteed to be bounded by d
- bool bRet( mfLastDistanceError2 > distanceError2 &&
- distanceError2 >= mfDistance2 );
-
- mfLastDistanceError2 = distanceError2;
+ }
- return bRet;
- }
+ bool subdivideFurther( const double& P1x, const double& P1y,
+ const double& P2x, const double& P2y,
+ const double& P3x, const double& P3y,
+ const double& P4x, const double& P4y,
+ const double&, const double& ) // last two values not used here
+ {
+ // Perform bezier flatness test (lecture notes from R. Schaback,
+ // Mathematics of Computer-Aided Design, Uni Goettingen, 2000)
+ //
+ // ||P(t) - L(t)|| <= max ||b_j - b_0 - j/n(b_n - b_0)||
+ // 0<=j<=n
+ //
+ // What is calculated here is an upper bound to the distance from
+ // a line through b_0 and b_3 (P1 and P4 in our notation) and the
+ // curve. We can drop 0 and n from the running indices, since the
+ // argument of max becomes zero for those cases.
+ const double fJ1x( P2x - P1x - 1.0/3.0*(P4x - P1x) );
+ const double fJ1y( P2y - P1y - 1.0/3.0*(P4y - P1y) );
+ const double fJ2x( P3x - P1x - 2.0/3.0*(P4x - P1x) );
+ const double fJ2y( P3y - P1y - 2.0/3.0*(P4y - P1y) );
+ const double distanceError2( ::std::max( fJ1x*fJ1x + fJ1y*fJ1y,
+ fJ2x*fJ2x + fJ2y*fJ2y) );
+
+ // stop if error measure does not improve anymore. This is a
+ // safety guard against floating point inaccuracies.
+ // stop if distance from line is guaranteed to be bounded by d
+ bool bRet( mfLastDistanceError2 > distanceError2 &&
+ distanceError2 >= mfDistance2 );
+
+ mfLastDistanceError2 = distanceError2;
+
+ return bRet;
+ }
- private:
- double mfDistance2;
- double mfLastDistanceError2;
- };
+ private:
+ double mfDistance2;
+ double mfLastDistanceError2;
+ };
- class AngleErrorFunctor
+ class AngleErrorFunctor
+ {
+ public:
+ AngleErrorFunctor( const double& angleBounds ) :
+ mfTanAngle( angleBounds * F_PI180 ),
+ mfLastTanAngle( ::std::numeric_limits<double>::max() )
{
- public:
- AngleErrorFunctor( const double& angleBounds ) :
- mfTanAngle( angleBounds * F_PI180 ),
- mfLastTanAngle( ::std::numeric_limits<double>::max() )
- {
- }
+ }
- bool subdivideFurther( const double P1x, const double P1y,
- const double P2x, const double P2y,
- const double P3x, const double P3y,
- const double P4x, const double P4y,
- const double Pdx, const double Pdy )
+ bool subdivideFurther( const double P1x, const double P1y,
+ const double P2x, const double P2y,
+ const double P3x, const double P3y,
+ const double P4x, const double P4y,
+ const double Pdx, const double Pdy )
+ {
+ // Test angle differences between two lines (ad
+ // and bd), meeting in the t=0.5 division point
+ // (d), and the angle from the other ends of those
+ // lines (b and a, resp.) to the tangents to the
+ // curve at this points:
+ //
+ // *__________
+ // ......*b
+ // ...
+ // ..
+ // .
+ // * *d
+ // | .
+ // | .
+ // | .
+ // | .
+ // |.
+ // |.
+ // *
+ // a
+ //
+ // When using half of the angle bound for the
+ // difference to the tangents at a or b, resp.,
+ // this procedure guarantees that no angle in the
+ // resulting line polygon is larger than the
+ // specified angle bound. This is because during
+ // subdivision, adjacent curve segments will have
+ // collinear tangent vectors, thus, when each
+ // side's line segments differs by at most angle/2
+ // from that tangent, the summed difference will
+ // be at most angle (this was modeled after an
+ // idea from Armin Weiss).
+
+ // To stay within the notation above, a equals P1,
+ // the other end point of the tangent starting at
+ // a is P2, d is Pd, and so forth. The
+ const B2DVector vecAD( Pdx - P1x, Pdy - P1y );
+ const B2DVector vecDB( P4x - Pdx, P4y - Pdy );
+
+ const double scalarVecADDB( vecAD.scalar( vecDB ) );
+ const double crossVecADDB( vecAD.cross( vecDB ) );
+
+ const B2DVector vecStartTangent( P2x - P1x, P2y - P1y );
+ const B2DVector vecEndTangent( P4x - P3x, P4y - P3y );
+
+ const double scalarVecStartTangentAD( vecStartTangent.scalar( vecAD ) );
+ const double crossVecStartTangentAD( vecStartTangent.cross( vecAD ) );
+
+ const double scalarVecDBEndTangent( vecDB.scalar( vecEndTangent ) );
+ const double crossVecDBEndTangent( vecDB.cross( vecEndTangent ) );
+
+
+ double fCurrAngle( ::std::numeric_limits<double>::max() );
+
+ // anyone has zero denominator? then we're at
+ // +infinity, anyway
+ if( !fTools::equalZero( scalarVecADDB ) &&
+ !fTools::equalZero( scalarVecStartTangentAD ) &&
+ !fTools::equalZero( scalarVecDBEndTangent ) )
{
- // Test angle differences between two lines (ad
- // and bd), meeting in the t=0.5 division point
- // (d), and the angle from the other ends of those
- // lines (b and a, resp.) to the tangents to the
- // curve at this points:
- //
- // *__________
- // ......*b
- // ...
- // ..
- // .
- // * *d
- // | .
- // | .
- // | .
- // | .
- // |.
- // |.
- // *
- // a
- //
- // When using half of the angle bound for the
- // difference to the tangents at a or b, resp.,
- // this procedure guarantees that no angle in the
- // resulting line polygon is larger than the
- // specified angle bound. This is because during
- // subdivision, adjacent curve segments will have
- // collinear tangent vectors, thus, when each
- // side's line segments differs by at most angle/2
- // from that tangent, the summed difference will
- // be at most angle (this was modeled after an
- // idea from Armin Weiss).
-
- // To stay within the notation above, a equals P1,
- // the other end point of the tangent starting at
- // a is P2, d is Pd, and so forth. The
- const vector::B2DVector vecAD( Pdx - P1x, Pdy - P1y );
- const vector::B2DVector vecDB( P4x - Pdx, P4y - Pdy );
-
- const double scalarVecADDB( vecAD.scalar( vecDB ) );
- const double crossVecADDB( vecAD.cross( vecDB ) );
-
- const vector::B2DVector vecStartTangent( P2x - P1x, P2y - P1y );
- const vector::B2DVector vecEndTangent( P4x - P3x, P4y - P3y );
-
- const double scalarVecStartTangentAD( vecStartTangent.scalar( vecAD ) );
- const double crossVecStartTangentAD( vecStartTangent.cross( vecAD ) );
-
- const double scalarVecDBEndTangent( vecDB.scalar( vecEndTangent ) );
- const double crossVecDBEndTangent( vecDB.cross( vecEndTangent ) );
-
-
- double fCurrAngle( ::std::numeric_limits<double>::max() );
-
- // anyone has zero denominator? then we're at
- // +infinity, anyway
- if( !numeric::fTools::equalZero( scalarVecADDB ) &&
- !numeric::fTools::equalZero( scalarVecStartTangentAD ) &&
- !numeric::fTools::equalZero( scalarVecDBEndTangent ) )
+ if( scalarVecADDB > 0.0 &&
+ scalarVecStartTangentAD > 0.0 &&
+ scalarVecDBEndTangent > 0.0 )
{
- if( scalarVecADDB > 0.0 &&
- scalarVecStartTangentAD > 0.0 &&
- scalarVecDBEndTangent > 0.0 )
- {
- fCurrAngle = ::std::max( fabs( atan2( crossVecADDB, scalarVecADDB ) ),
- ::std::max( fabs( atan2( crossVecStartTangentAD, scalarVecStartTangentAD ) ),
- fabs( atan2( crossVecDBEndTangent, scalarVecDBEndTangent ) ) ) );
- }
+ fCurrAngle = ::std::max( fabs( atan2( crossVecADDB, scalarVecADDB ) ),
+ ::std::max( fabs( atan2( crossVecStartTangentAD, scalarVecStartTangentAD ) ),
+ fabs( atan2( crossVecDBEndTangent, scalarVecDBEndTangent ) ) ) );
}
+ }
- // stop if error measure does not improve anymore. This is a
- // safety guard against floating point inaccuracies.
- // stop if angle difference is guaranteed to be bounded by mfTanAngle
- bool bRet( mfLastTanAngle > fCurrAngle &&
- fCurrAngle >= mfTanAngle );
+ // stop if error measure does not improve anymore. This is a
+ // safety guard against floating point inaccuracies.
+ // stop if angle difference is guaranteed to be bounded by mfTanAngle
+ bool bRet( mfLastTanAngle > fCurrAngle &&
+ fCurrAngle >= mfTanAngle );
- mfLastTanAngle = fCurrAngle;
+ mfLastTanAngle = fCurrAngle;
- return bRet;
- }
+ return bRet;
+ }
- private:
- double mfTanAngle;
- double mfLastTanAngle;
- };
+ private:
+ double mfTanAngle;
+ double mfLastTanAngle;
+ };
- /* Recursively subdivide cubic bezier curve via deCasteljau.
+ /* Recursively subdivide cubic bezier curve via deCasteljau.
- @param rPoly
- Polygon to append generated points to
+ @param rPoly
+ Polygon to append generated points to
- @param d2
- Maximal squared difference of curve to a straight line
+ @param d2
+ Maximal squared difference of curve to a straight line
- @param P*
- Exactly four points, interpreted as support and control points of
- a cubic bezier curve.
+ @param P*
+ Exactly four points, interpreted as support and control points of
+ a cubic bezier curve.
- @param old_distance2
- Last squared distance to line for this recursion
- path. Used as an end condition, if it is no longer
- improving.
+ @param old_distance2
+ Last squared distance to line for this recursion
+ path. Used as an end condition, if it is no longer
+ improving.
- @param recursionDepth
- Depth of recursion. Used as a termination criterion, to
- prevent endless looping.
- */
- template < class ErrorFunctor > int ImplAdaptiveSubdivide( polygon::B2DPolygon& rPoly,
- ErrorFunctor rErrorFunctor,
- const double P1x, const double P1y,
- const double P2x, const double P2y,
- const double P3x, const double P3y,
- const double P4x, const double P4y,
- int recursionDepth )
+ @param recursionDepth
+ Depth of recursion. Used as a termination criterion, to
+ prevent endless looping.
+ */
+ template < class ErrorFunctor > int ImplAdaptiveSubdivide( B2DPolygon& rPoly,
+ ErrorFunctor rErrorFunctor,
+ const double P1x, const double P1y,
+ const double P2x, const double P2y,
+ const double P3x, const double P3y,
+ const double P4x, const double P4y,
+ int recursionDepth )
+ {
+ // Hard limit on recursion depth, empiric number.
+ enum {maxRecursionDepth=128};
+
+ // deCasteljau bezier arc, split at t=0.5
+ // Foley/vanDam, p. 508
+
+ // Note that for the pure distance error method, this
+ // subdivision could be moved into the if-branch. But
+ // since this accounts for saved work only for the
+ // very last subdivision step, and we need the
+ // subdivided curve for the angle criterium, I think
+ // it's justified here.
+ const double L1x( P1x ), L1y( P1y );
+ const double L2x( (P1x + P2x)*0.5 ), L2y( (P1y + P2y)*0.5 );
+ const double Hx ( (P2x + P3x)*0.5 ), Hy ( (P2y + P3y)*0.5 );
+ const double L3x( (L2x + Hx)*0.5 ), L3y( (L2y + Hy)*0.5 );
+ const double R4x( P4x ), R4y( P4y );
+ const double R3x( (P3x + P4x)*0.5 ), R3y( (P3y + P4y)*0.5 );
+ const double R2x( (Hx + R3x)*0.5 ), R2y( (Hy + R3y)*0.5 );
+ const double R1x( (L3x + R2x)*0.5 ), R1y( (L3y + R2y)*0.5 );
+ const double L4x( R1x ), L4y( R1y );
+
+ // stop at recursion level 128. This is a safety guard against
+ // floating point inaccuracies.
+ if( recursionDepth < maxRecursionDepth &&
+ rErrorFunctor.subdivideFurther( P1x, P1y,
+ P2x, P2y,
+ P3x, P3y,
+ P4x, P4y,
+ R1x, R1y ) )
{
- // Hard limit on recursion depth, empiric number.
- enum {maxRecursionDepth=128};
-
- // deCasteljau bezier arc, split at t=0.5
- // Foley/vanDam, p. 508
-
- // Note that for the pure distance error method, this
- // subdivision could be moved into the if-branch. But
- // since this accounts for saved work only for the
- // very last subdivision step, and we need the
- // subdivided curve for the angle criterium, I think
- // it's justified here.
- const double L1x( P1x ), L1y( P1y );
- const double L2x( (P1x + P2x)*0.5 ), L2y( (P1y + P2y)*0.5 );
- const double Hx ( (P2x + P3x)*0.5 ), Hy ( (P2y + P3y)*0.5 );
- const double L3x( (L2x + Hx)*0.5 ), L3y( (L2y + Hy)*0.5 );
- const double R4x( P4x ), R4y( P4y );
- const double R3x( (P3x + P4x)*0.5 ), R3y( (P3y + P4y)*0.5 );
- const double R2x( (Hx + R3x)*0.5 ), R2y( (Hy + R3y)*0.5 );
- const double R1x( (L3x + R2x)*0.5 ), R1y( (L3y + R2y)*0.5 );
- const double L4x( R1x ), L4y( R1y );
-
- // stop at recursion level 128. This is a safety guard against
- // floating point inaccuracies.
- if( recursionDepth < maxRecursionDepth &&
- rErrorFunctor.subdivideFurther( P1x, P1y,
- P2x, P2y,
- P3x, P3y,
- P4x, P4y,
- R1x, R1y ) )
- {
- // subdivide further
- ++recursionDepth;
+ // subdivide further
+ ++recursionDepth;
- int nGeneratedPoints(0);
+ int nGeneratedPoints(0);
- nGeneratedPoints += ImplAdaptiveSubdivide(rPoly, rErrorFunctor, L1x, L1y, L2x, L2y, L3x, L3y, L4x, L4y, recursionDepth);
- nGeneratedPoints += ImplAdaptiveSubdivide(rPoly, rErrorFunctor, R1x, R1y, R2x, R2y, R3x, R3y, R4x, R4y, recursionDepth);
+ nGeneratedPoints += ImplAdaptiveSubdivide(rPoly, rErrorFunctor, L1x, L1y, L2x, L2y, L3x, L3y, L4x, L4y, recursionDepth);
+ nGeneratedPoints += ImplAdaptiveSubdivide(rPoly, rErrorFunctor, R1x, R1y, R2x, R2y, R3x, R3y, R4x, R4y, recursionDepth);
- // return number of points generated in this
- // recursion branch
- return nGeneratedPoints;
- }
- else
- {
- // requested resolution reached. Add end points to
- // output iterator. order is preserved, since
- // this is so to say depth first traversal.
- rPoly.append( point::B2DPoint( P1x, P1y ) );
-
- // return number of points generated in this
- // recursion branch
- return 1;
- }
+ // return number of points generated in this
+ // recursion branch
+ return nGeneratedPoints;
}
+ else
+ {
+ // requested resolution reached. Add end points to
+ // output iterator. order is preserved, since
+ // this is so to say depth first traversal.
+ rPoly.append( B2DPoint( P1x, P1y ) );
+
+ // return number of points generated in this
+ // recursion branch
+ return 1;
+ }
+ }
// LATER
#if 0
- /* Approximate given cubic bezier curve by quadratic bezier segments */
- void ImplQuadBezierApprox( polygon::B2DPolygon& rPoly,
- BitStream& rBits,
- Point& rLastPoint,
- const double d2,
- const double P1x, const double P1y,
- const double P2x, const double P2y,
- const double P3x, const double P3y,
- const double P4x, const double P4y )
+ /* Approximate given cubic bezier curve by quadratic bezier segments */
+ void ImplQuadBezierApprox( B2DPolygon& rPoly,
+ BitStream& rBits,
+ Point& rLastPoint,
+ const double d2,
+ const double P1x, const double P1y,
+ const double P2x, const double P2y,
+ const double P3x, const double P3y,
+ const double P4x, const double P4y )
+ {
+ // Check for degenerate case, where the given cubic bezier curve
+ // is already quadratic: P4 == 3P3 - 3P2 + P1
+ if( P4x == 3.0*P3x - 3.0*P2x + P1x &&
+ P4y == 3.0*P3y - 3.0*P2y + P1y )
+ {
+ Impl_addQuadBezier( rBits, rLastPoint,
+ 3.0/2.0*P2x - 1.0/2.0*P1x, 3.0/2.0*P2y - 1.0/2.0*P1y,
+ P4x, P4y);
+ }
+ else
{
- // Check for degenerate case, where the given cubic bezier curve
- // is already quadratic: P4 == 3P3 - 3P2 + P1
- if( P4x == 3.0*P3x - 3.0*P2x + P1x &&
- P4y == 3.0*P3y - 3.0*P2y + P1y )
+ // Create quadratic segment for given cubic:
+ // Start and end point must coincide, determine quadratic control
+ // point in such a way that it lies on the intersection of the
+ // tangents at start and end point, resp. Thus, both cubic and
+ // quadratic curve segments will match in 0th and 1st derivative
+ // at the start and end points
+
+ // Intersection of P2P1 and P4P3
+ // (P2y-P4y)(P3x-P4x)-(P2x-P4x)(P3y-P4y)
+ // lambda = -------------------------------------
+ // (P1x-P2x)(P3y-P4y)-(P1y-P2y)(P3x-P4x)
+ //
+ // Intersection point IP is now
+ // IP = P2 + lambda(P1-P2)
+ //
+ const double nominator( (P2y-P4y)*(P3x-P4x) - (P2x-P4x)*(P3y-P4y) );
+ const double denominator( (P1x-P2x)*(P3y-P4y) - (P1y-P2y)*(P3x-P4x) );
+ const double lambda( nominator / denominator );
+
+ const double IPx( P2x + lambda*( P1x - P2x) );
+ const double IPy( P2y + lambda*( P1y - P2y) );
+
+ // Introduce some alias names: quadratic start point is P1, end
+ // point is P4, control point is IP
+ const double QP1x( P1x );
+ const double QP1y( P1y );
+ const double QP2x( IPx );
+ const double QP2y( IPy );
+ const double QP3x( P4x );
+ const double QP3y( P4y );
+
+ // Adapted bezier flatness test (lecture notes from R. Schaback,
+ // Mathematics of Computer-Aided Design, Uni Goettingen, 2000)
+ //
+ // ||C(t) - Q(t)|| <= max ||c_j - q_j||
+ // 0<=j<=n
+ //
+ // In this case, we don't need the distance from the cubic bezier
+ // to a straight line, but to a quadratic bezier. The c_j's are
+ // the cubic bezier's bernstein coefficients, the q_j's the
+ // quadratic bezier's. We have the c_j's given, the q_j's can be
+ // calculated from QPi like this (sorry, mixed index notation, we
+ // use [1,n], formulas use [0,n-1]):
+ //
+ // q_0 = QP1 = P1
+ // q_1 = 1/3 QP1 + 2/3 QP2
+ // q_2 = 2/3 QP2 + 1/3 QP3
+ // q_3 = QP3 = P4
+ //
+ // We can drop case 0 and 3, since there the curves coincide
+ // (distance is zero)
+
+ // calculate argument of max for j=1 and j=2
+ const double fJ1x( P2x - 1.0/3.0*QP1x - 2.0/3.0*QP2x );
+ const double fJ1y( P2y - 1.0/3.0*QP1y - 2.0/3.0*QP2y );
+ const double fJ2x( P3x - 2.0/3.0*QP2x - 1.0/3.0*QP3x );
+ const double fJ2y( P3y - 2.0/3.0*QP2y - 1.0/3.0*QP3y );
+
+ // stop if distance from cubic curve is guaranteed to be bounded by d
+ // Should denominator be 0: then P1P2 and P3P4 are parallel (P1P2^T R[90,P3P4] = 0.0),
+ // meaning that either we have a straight line or an inflexion point (see else block below)
+ if( 0.0 != denominator &&
+ ::std::max( fJ1x*fJ1x + fJ1y*fJ1y,
+ fJ2x*fJ2x + fJ2y*fJ2y) < d2 )
{
+ // requested resolution reached.
+ // Add end points to output file.
+ // order is preserved, since this is so to say depth first traversal.
Impl_addQuadBezier( rBits, rLastPoint,
- 3.0/2.0*P2x - 1.0/2.0*P1x, 3.0/2.0*P2y - 1.0/2.0*P1y,
- P4x, P4y);
+ QP2x, QP2y,
+ QP3x, QP3y);
}
else
{
- // Create quadratic segment for given cubic:
- // Start and end point must coincide, determine quadratic control
- // point in such a way that it lies on the intersection of the
- // tangents at start and end point, resp. Thus, both cubic and
- // quadratic curve segments will match in 0th and 1st derivative
- // at the start and end points
-
- // Intersection of P2P1 and P4P3
- // (P2y-P4y)(P3x-P4x)-(P2x-P4x)(P3y-P4y)
- // lambda = -------------------------------------
- // (P1x-P2x)(P3y-P4y)-(P1y-P2y)(P3x-P4x)
- //
- // Intersection point IP is now
- // IP = P2 + lambda(P1-P2)
- //
- const double nominator( (P2y-P4y)*(P3x-P4x) - (P2x-P4x)*(P3y-P4y) );
- const double denominator( (P1x-P2x)*(P3y-P4y) - (P1y-P2y)*(P3x-P4x) );
- const double lambda( nominator / denominator );
-
- const double IPx( P2x + lambda*( P1x - P2x) );
- const double IPy( P2y + lambda*( P1y - P2y) );
-
- // Introduce some alias names: quadratic start point is P1, end
- // point is P4, control point is IP
- const double QP1x( P1x );
- const double QP1y( P1y );
- const double QP2x( IPx );
- const double QP2y( IPy );
- const double QP3x( P4x );
- const double QP3y( P4y );
-
- // Adapted bezier flatness test (lecture notes from R. Schaback,
+ // Maybe subdivide further
+
+ // This is for robustness reasons, since the line intersection
+ // method below gets instable if the curve gets closer to a
+ // straight line. If the given cubic bezier does not deviate by
+ // more than d/4 from a straight line, either:
+ // - take the line (that's what we do here)
+ // - express the line by a quadratic bezier
+
+ // Perform bezier flatness test (lecture notes from R. Schaback,
// Mathematics of Computer-Aided Design, Uni Goettingen, 2000)
//
- // ||C(t) - Q(t)|| <= max ||c_j - q_j||
+ // ||P(t) - L(t)|| <= max ||b_j - b_0 - j/n(b_n - b_0)||
// 0<=j<=n
//
- // In this case, we don't need the distance from the cubic bezier
- // to a straight line, but to a quadratic bezier. The c_j's are
- // the cubic bezier's bernstein coefficients, the q_j's the
- // quadratic bezier's. We have the c_j's given, the q_j's can be
- // calculated from QPi like this (sorry, mixed index notation, we
- // use [1,n], formulas use [0,n-1]):
- //
- // q_0 = QP1 = P1
- // q_1 = 1/3 QP1 + 2/3 QP2
- // q_2 = 2/3 QP2 + 1/3 QP3
- // q_3 = QP3 = P4
- //
- // We can drop case 0 and 3, since there the curves coincide
- // (distance is zero)
-
- // calculate argument of max for j=1 and j=2
- const double fJ1x( P2x - 1.0/3.0*QP1x - 2.0/3.0*QP2x );
- const double fJ1y( P2y - 1.0/3.0*QP1y - 2.0/3.0*QP2y );
- const double fJ2x( P3x - 2.0/3.0*QP2x - 1.0/3.0*QP3x );
- const double fJ2y( P3y - 2.0/3.0*QP2y - 1.0/3.0*QP3y );
-
- // stop if distance from cubic curve is guaranteed to be bounded by d
- // Should denominator be 0: then P1P2 and P3P4 are parallel (P1P2^T R[90,P3P4] = 0.0),
- // meaning that either we have a straight line or an inflexion point (see else block below)
- if( 0.0 != denominator &&
- ::std::max( fJ1x*fJ1x + fJ1y*fJ1y,
- fJ2x*fJ2x + fJ2y*fJ2y) < d2 )
+ // What is calculated here is an upper bound to the distance from
+ // a line through b_0 and b_3 (P1 and P4 in our notation) and the
+ // curve. We can drop 0 and n from the running indices, since the
+ // argument of max becomes zero for those cases.
+ const double fJ1x( P2x - P1x - 1.0/3.0*(P4x - P1x) );
+ const double fJ1y( P2y - P1y - 1.0/3.0*(P4y - P1y) );
+ const double fJ2x( P3x - P1x - 2.0/3.0*(P4x - P1x) );
+ const double fJ2y( P3y - P1y - 2.0/3.0*(P4y - P1y) );
+
+ // stop if distance from line is guaranteed to be bounded by d/4
+ if( ::std::max( fJ1x*fJ1x + fJ1y*fJ1y,
+ fJ2x*fJ2x + fJ2y*fJ2y) < d2/16.0 )
{
- // requested resolution reached.
- // Add end points to output file.
- // order is preserved, since this is so to say depth first traversal.
- Impl_addQuadBezier( rBits, rLastPoint,
- QP2x, QP2y,
- QP3x, QP3y);
+ // do not subdivide further, add straight line instead
+ Impl_addStraightLine( rBits, rLastPoint, P4x, P4y);
}
else
{
- // Maybe subdivide further
-
- // This is for robustness reasons, since the line intersection
- // method below gets instable if the curve gets closer to a
- // straight line. If the given cubic bezier does not deviate by
- // more than d/4 from a straight line, either:
- // - take the line (that's what we do here)
- // - express the line by a quadratic bezier
-
- // Perform bezier flatness test (lecture notes from R. Schaback,
- // Mathematics of Computer-Aided Design, Uni Goettingen, 2000)
- //
- // ||P(t) - L(t)|| <= max ||b_j - b_0 - j/n(b_n - b_0)||
- // 0<=j<=n
- //
- // What is calculated here is an upper bound to the distance from
- // a line through b_0 and b_3 (P1 and P4 in our notation) and the
- // curve. We can drop 0 and n from the running indices, since the
- // argument of max becomes zero for those cases.
- const double fJ1x( P2x - P1x - 1.0/3.0*(P4x - P1x) );
- const double fJ1y( P2y - P1y - 1.0/3.0*(P4y - P1y) );
- const double fJ2x( P3x - P1x - 2.0/3.0*(P4x - P1x) );
- const double fJ2y( P3y - P1y - 2.0/3.0*(P4y - P1y) );
-
- // stop if distance from line is guaranteed to be bounded by d/4
- if( ::std::max( fJ1x*fJ1x + fJ1y*fJ1y,
- fJ2x*fJ2x + fJ2y*fJ2y) < d2/16.0 )
- {
- // do not subdivide further, add straight line instead
- Impl_addStraightLine( rBits, rLastPoint, P4x, P4y);
- }
- else
- {
- // deCasteljau bezier arc, split at t=0.5
- // Foley/vanDam, p. 508
- const double L1x( P1x ), L1y( P1y );
- const double L2x( (P1x + P2x)*0.5 ), L2y( (P1y + P2y)*0.5 );
- const double Hx ( (P2x + P3x)*0.5 ), Hy ( (P2y + P3y)*0.5 );
- const double L3x( (L2x + Hx)*0.5 ), L3y( (L2y + Hy)*0.5 );
- const double R4x( P4x ), R4y( P4y );
- const double R3x( (P3x + P4x)*0.5 ), R3y( (P3y + P4y)*0.5 );
- const double R2x( (Hx + R3x)*0.5 ), R2y( (Hy + R3y)*0.5 );
- const double R1x( (L3x + R2x)*0.5 ), R1y( (L3y + R2y)*0.5 );
- const double L4x( R1x ), L4y( R1y );
-
- // subdivide further
- Impl_quadBezierApprox(rBits, rLastPoint, d2, L1x, L1y, L2x, L2y, L3x, L3y, L4x, L4y);
- Impl_quadBezierApprox(rBits, rLastPoint, d2, R1x, R1y, R2x, R2y, R3x, R3y, R4x, R4y);
- }
+ // deCasteljau bezier arc, split at t=0.5
+ // Foley/vanDam, p. 508
+ const double L1x( P1x ), L1y( P1y );
+ const double L2x( (P1x + P2x)*0.5 ), L2y( (P1y + P2y)*0.5 );
+ const double Hx ( (P2x + P3x)*0.5 ), Hy ( (P2y + P3y)*0.5 );
+ const double L3x( (L2x + Hx)*0.5 ), L3y( (L2y + Hy)*0.5 );
+ const double R4x( P4x ), R4y( P4y );
+ const double R3x( (P3x + P4x)*0.5 ), R3y( (P3y + P4y)*0.5 );
+ const double R2x( (Hx + R3x)*0.5 ), R2y( (Hy + R3y)*0.5 );
+ const double R1x( (L3x + R2x)*0.5 ), R1y( (L3y + R2y)*0.5 );
+ const double L4x( R1x ), L4y( R1y );
+
+ // subdivide further
+ Impl_quadBezierApprox(rBits, rLastPoint, d2, L1x, L1y, L2x, L2y, L3x, L3y, L4x, L4y);
+ Impl_quadBezierApprox(rBits, rLastPoint, d2, R1x, R1y, R2x, R2y, R3x, R3y, R4x, R4y);
}
}
}
-#endif
- }
-
- sal_Int32 adaptiveSubdivideByDistance( polygon::B2DPolygon& rPoly,
- const B2DCubicBezier& rCurve,
- double distanceBounds )
- {
- const point::B2DPoint start( rCurve.getStartPoint() );
- const point::B2DPoint control1( rCurve.getControlPointA() );
- const point::B2DPoint control2( rCurve.getControlPointB() );
- const point::B2DPoint end( rCurve.getEndPoint() );
-
- return ImplAdaptiveSubdivide( rPoly,
- DistanceErrorFunctor( distanceBounds ),
- start.getX(), start.getY(),
- control1.getX(), control1.getY(),
- control2.getX(), control2.getY(),
- end.getX(), end.getY(),
- 0 );
}
+#endif
+ }
- sal_Int32 adaptiveSubdivideByAngle( polygon::B2DPolygon& rPoly,
+ sal_Int32 adaptiveSubdivideByDistance( B2DPolygon& rPoly,
const B2DCubicBezier& rCurve,
- double angleBounds )
- {
- const point::B2DPoint start( rCurve.getStartPoint() );
- const point::B2DPoint control1( rCurve.getControlPointA() );
- const point::B2DPoint control2( rCurve.getControlPointB() );
- const point::B2DPoint end( rCurve.getEndPoint() );
-
- return ImplAdaptiveSubdivide( rPoly,
- AngleErrorFunctor( angleBounds ),
- start.getX(), start.getY(),
- control1.getX(), control1.getY(),
- control2.getX(), control2.getY(),
- end.getX(), end.getY(),
- 0 );
- }
+ double distanceBounds )
+ {
+ const B2DPoint start( rCurve.getStartPoint() );
+ const B2DPoint control1( rCurve.getControlPointA() );
+ const B2DPoint control2( rCurve.getControlPointB() );
+ const B2DPoint end( rCurve.getEndPoint() );
+
+ return ImplAdaptiveSubdivide( rPoly,
+ DistanceErrorFunctor( distanceBounds ),
+ start.getX(), start.getY(),
+ control1.getX(), control1.getY(),
+ control2.getX(), control2.getY(),
+ end.getX(), end.getY(),
+ 0 );
+ }
- sal_Int32 adaptiveSubdivideByDistance( polygon::B2DPolygon& rPoly,
- const B2DQuadraticBezier& rCurve,
- double distanceBounds )
- {
- // TODO
- return 0;
- }
+ sal_Int32 adaptiveSubdivideByAngle( B2DPolygon& rPoly,
+ const B2DCubicBezier& rCurve,
+ double angleBounds )
+ {
+ const B2DPoint start( rCurve.getStartPoint() );
+ const B2DPoint control1( rCurve.getControlPointA() );
+ const B2DPoint control2( rCurve.getControlPointB() );
+ const B2DPoint end( rCurve.getEndPoint() );
+
+ return ImplAdaptiveSubdivide( rPoly,
+ AngleErrorFunctor( angleBounds ),
+ start.getX(), start.getY(),
+ control1.getX(), control1.getY(),
+ control2.getX(), control2.getY(),
+ end.getX(), end.getY(),
+ 0 );
+ }
+
+ sal_Int32 adaptiveSubdivideByDistance( B2DPolygon& rPoly,
+ const B2DQuadraticBezier& rCurve,
+ double distanceBounds )
+ {
+ // TODO
+ return 0;
}
}
diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx
index 9633aa6b5130..33f6fdb8f1ca 100644
--- a/basegfx/source/curve/b2dcubicbezier.cxx
+++ b/basegfx/source/curve/b2dcubicbezier.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dcubicbezier.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:07 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:00 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,90 +67,86 @@
namespace basegfx
{
- namespace curve
+ B2DCubicBezier::B2DCubicBezier(const B2DCubicBezier& rBezier)
+ : maStartPoint(rBezier.maStartPoint),
+ maEndPoint(rBezier.maEndPoint),
+ maControlPointA(rBezier.maControlPointA),
+ maControlPointB(rBezier.maControlPointB)
{
- B2DCubicBezier::B2DCubicBezier(const B2DCubicBezier& rBezier)
- : maStartPoint(rBezier.maStartPoint),
- maEndPoint(rBezier.maEndPoint),
- maControlPointA(rBezier.maControlPointA),
- maControlPointB(rBezier.maControlPointB)
- {
- }
-
- B2DCubicBezier::B2DCubicBezier()
- {
- }
-
- B2DCubicBezier::B2DCubicBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rEnd)
- : maStartPoint(rStart),
- maEndPoint(rEnd),
- maControlPointA(rStart),
- maControlPointB(rEnd)
- {
- }
+ }
- B2DCubicBezier::B2DCubicBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rControlPointA,
- const ::basegfx::point::B2DPoint& rControlPointB, const ::basegfx::point::B2DPoint& rEnd)
- : maStartPoint(rStart),
- maEndPoint(rEnd),
- maControlPointA(rControlPointA),
- maControlPointB(rControlPointB)
- {
- }
-
- B2DCubicBezier::~B2DCubicBezier()
- {
- }
+ B2DCubicBezier::B2DCubicBezier()
+ {
+ }
- // assignment operator
- B2DCubicBezier& B2DCubicBezier::operator=(const B2DCubicBezier& rBezier)
- {
- maStartPoint = rBezier.maStartPoint;
- maEndPoint = rBezier.maEndPoint;
- maControlPointA = rBezier.maControlPointA;
- maControlPointB = rBezier.maControlPointB;
+ B2DCubicBezier::B2DCubicBezier(const ::basegfx::B2DPoint& rStart, const ::basegfx::B2DPoint& rEnd)
+ : maStartPoint(rStart),
+ maEndPoint(rEnd),
+ maControlPointA(rStart),
+ maControlPointB(rEnd)
+ {
+ }
+
+ B2DCubicBezier::B2DCubicBezier(const ::basegfx::B2DPoint& rStart, const ::basegfx::B2DPoint& rControlPointA,
+ const ::basegfx::B2DPoint& rControlPointB, const ::basegfx::B2DPoint& rEnd)
+ : maStartPoint(rStart),
+ maEndPoint(rEnd),
+ maControlPointA(rControlPointA),
+ maControlPointB(rControlPointB)
+ {
+ }
- return *this;
- }
+ B2DCubicBezier::~B2DCubicBezier()
+ {
+ }
- // compare operators
- sal_Bool B2DCubicBezier::operator==(const B2DCubicBezier& rBezier) const
- {
- return (
- maStartPoint == rBezier.maStartPoint
- && maEndPoint == rBezier.maEndPoint
- && maControlPointA == rBezier.maControlPointA
- && maControlPointB == rBezier.maControlPointB
- );
- }
+ // assignment operator
+ B2DCubicBezier& B2DCubicBezier::operator=(const B2DCubicBezier& rBezier)
+ {
+ maStartPoint = rBezier.maStartPoint;
+ maEndPoint = rBezier.maEndPoint;
+ maControlPointA = rBezier.maControlPointA;
+ maControlPointB = rBezier.maControlPointB;
- sal_Bool B2DCubicBezier::operator!=(const B2DCubicBezier& rBezier) const
- {
- return (
- maStartPoint != rBezier.maStartPoint
- || maEndPoint != rBezier.maEndPoint
- || maControlPointA != rBezier.maControlPointA
- || maControlPointB != rBezier.maControlPointB
- );
- }
+ return *this;
+ }
- // test if vectors are used
- sal_Bool B2DCubicBezier::isBezier() const
+ // compare operators
+ sal_Bool B2DCubicBezier::operator==(const B2DCubicBezier& rBezier) const
+ {
+ return (
+ maStartPoint == rBezier.maStartPoint
+ && maEndPoint == rBezier.maEndPoint
+ && maControlPointA == rBezier.maControlPointA
+ && maControlPointB == rBezier.maControlPointB
+ );
+ }
+
+ sal_Bool B2DCubicBezier::operator!=(const B2DCubicBezier& rBezier) const
+ {
+ return (
+ maStartPoint != rBezier.maStartPoint
+ || maEndPoint != rBezier.maEndPoint
+ || maControlPointA != rBezier.maControlPointA
+ || maControlPointB != rBezier.maControlPointB
+ );
+ }
+
+ // test if vectors are used
+ sal_Bool B2DCubicBezier::isBezier() const
+ {
+ if(maControlPointA != maStartPoint || maControlPointB != maEndPoint)
{
- if(maControlPointA != maStartPoint || maControlPointB != maEndPoint)
- {
- return sal_True;
- }
-
- return sal_False;
+ return sal_True;
}
- void B2DCubicBezier::testAndSolveTrivialBezier()
- {
- // TODO
- }
+ return sal_False;
+ }
- } // end of namespace curve
+ void B2DCubicBezier::testAndSolveTrivialBezier()
+ {
+ // TODO
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/curve/b2dquadraticbezier.cxx b/basegfx/source/curve/b2dquadraticbezier.cxx
index 607d10b4a7bc..2086a9d1b15e 100644
--- a/basegfx/source/curve/b2dquadraticbezier.cxx
+++ b/basegfx/source/curve/b2dquadraticbezier.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dquadraticbezier.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:08 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:00 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,75 +71,72 @@
namespace basegfx
{
- namespace curve
+ B2DQuadraticBezier::B2DQuadraticBezier(const B2DQuadraticBezier& rBezier)
+ : maStartPoint(rBezier.maStartPoint),
+ maEndPoint(rBezier.maEndPoint),
+ maControlPoint(rBezier.maControlPoint)
{
- B2DQuadraticBezier::B2DQuadraticBezier(const B2DQuadraticBezier& rBezier)
- : maStartPoint(rBezier.maStartPoint),
- maEndPoint(rBezier.maEndPoint),
- maControlPoint(rBezier.maControlPoint)
- {
- }
+ }
- B2DQuadraticBezier::B2DQuadraticBezier()
- {
- }
+ B2DQuadraticBezier::B2DQuadraticBezier()
+ {
+ }
- B2DQuadraticBezier::B2DQuadraticBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rEnd)
- : maStartPoint(rStart),
- maEndPoint(rEnd)
- {
- }
+ B2DQuadraticBezier::B2DQuadraticBezier(const ::basegfx::B2DPoint& rStart, const ::basegfx::B2DPoint& rEnd)
+ : maStartPoint(rStart),
+ maEndPoint(rEnd)
+ {
+ }
- B2DQuadraticBezier::B2DQuadraticBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rControl, const ::basegfx::point::B2DPoint& rEnd)
- : maStartPoint(rStart),
- maEndPoint(rEnd),
- maControlPoint(rControl)
- {
- }
+ B2DQuadraticBezier::B2DQuadraticBezier(const ::basegfx::B2DPoint& rStart, const ::basegfx::B2DPoint& rControl, const ::basegfx::B2DPoint& rEnd)
+ : maStartPoint(rStart),
+ maEndPoint(rEnd),
+ maControlPoint(rControl)
+ {
+ }
- B2DQuadraticBezier::~B2DQuadraticBezier()
- {
- }
+ B2DQuadraticBezier::~B2DQuadraticBezier()
+ {
+ }
- // assignment operator
- B2DQuadraticBezier& B2DQuadraticBezier::operator=(const B2DQuadraticBezier& rBezier)
- {
- maStartPoint = rBezier.maStartPoint;
- maEndPoint = rBezier.maEndPoint;
- maControlPoint = rBezier.maControlPoint;
+ // assignment operator
+ B2DQuadraticBezier& B2DQuadraticBezier::operator=(const B2DQuadraticBezier& rBezier)
+ {
+ maStartPoint = rBezier.maStartPoint;
+ maEndPoint = rBezier.maEndPoint;
+ maControlPoint = rBezier.maControlPoint;
- return *this;
- }
+ return *this;
+ }
- // compare operators
- sal_Bool B2DQuadraticBezier::operator==(const B2DQuadraticBezier& rBezier) const
- {
- return (
- maStartPoint == rBezier.maStartPoint
- && maEndPoint == rBezier.maEndPoint
- && maControlPoint == rBezier.maControlPoint
- );
- }
+ // compare operators
+ sal_Bool B2DQuadraticBezier::operator==(const B2DQuadraticBezier& rBezier) const
+ {
+ return (
+ maStartPoint == rBezier.maStartPoint
+ && maEndPoint == rBezier.maEndPoint
+ && maControlPoint == rBezier.maControlPoint
+ );
+ }
- sal_Bool B2DQuadraticBezier::operator!=(const B2DQuadraticBezier& rBezier) const
- {
- return (
- maStartPoint != rBezier.maStartPoint
- || maEndPoint != rBezier.maEndPoint
- || maControlPoint != rBezier.maControlPoint
- );
- }
+ sal_Bool B2DQuadraticBezier::operator!=(const B2DQuadraticBezier& rBezier) const
+ {
+ return (
+ maStartPoint != rBezier.maStartPoint
+ || maEndPoint != rBezier.maEndPoint
+ || maControlPoint != rBezier.maControlPoint
+ );
+ }
- // test if control vector is used
- sal_Bool B2DQuadraticBezier::isBezier() const
- {
- // if control vector is empty, bezier is not used
- if(maControlPoint == maStartPoint || maControlPoint == maEndPoint)
- return sal_False;
+ // test if control vector is used
+ sal_Bool B2DQuadraticBezier::isBezier() const
+ {
+ // if control vector is empty, bezier is not used
+ if(maControlPoint == maStartPoint || maControlPoint == maEndPoint)
+ return sal_False;
- return sal_True;
- }
- } // end of namespace curve
+ return sal_True;
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/inc/hommatrixtemplate.hxx b/basegfx/source/inc/hommatrixtemplate.hxx
index 9711dd4e3c01..4c688b09a218 100644
--- a/basegfx/source/inc/hommatrixtemplate.hxx
+++ b/basegfx/source/inc/hommatrixtemplate.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hommatrixtemplate.hxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: thb $ $Date: 2003-11-10 15:10:41 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -139,7 +139,7 @@ namespace basegfx
const double fDefault(implGetDefaultValue((RowSize - 1), a));
const double fLineValue(mpLine->get(a));
- if(!::basegfx::numeric::fTools::equal(fDefault, fLineValue))
+ if(!::basegfx::fTools::equal(fDefault, fLineValue))
{
return sal_False;
}
@@ -226,7 +226,7 @@ namespace basegfx
{
const double fDefault(implGetDefaultValue((RowSize - 1), nColumn));
- if(!::basegfx::numeric::fTools::equal(fDefault, rValue))
+ if(!::basegfx::fTools::equal(fDefault, rValue))
{
mpLine = new ImplMatLine< RowSize >((RowSize - 1), 0L);
mpLine->set(nColumn, rValue);
@@ -245,7 +245,7 @@ namespace basegfx
const double fDefault(implGetDefaultValue((RowSize - 1), a));
const double fLineValue(mpLine->get(a));
- if(!::basegfx::numeric::fTools::equal(fDefault, fLineValue))
+ if(!::basegfx::fTools::equal(fDefault, fLineValue))
{
bNecessary = sal_True;
}
@@ -278,13 +278,13 @@ namespace basegfx
{
double fTemp(fabs(get(a, b)));
- if(::basegfx::numeric::fTools::more(fTemp, fBig))
+ if(::basegfx::fTools::more(fTemp, fBig))
{
fBig = fTemp;
}
}
- if(::basegfx::numeric::fTools::equalZero(fBig))
+ if(::basegfx::fTools::equalZero(fBig))
{
return sal_False;
}
@@ -321,7 +321,7 @@ namespace basegfx
set(a, b, fSum);
fDum = fStorage[a] * fabs(fSum);
- if(::basegfx::numeric::fTools::moreOrEqual(fDum, fBig))
+ if(::basegfx::fTools::moreOrEqual(fDum, fBig))
{
fBig = fDum;
nAMax = a;
@@ -346,7 +346,7 @@ namespace basegfx
// here the failure of precision occurs
const double fValBB(fabs(get(b, b)));
- if(::basegfx::numeric::fTools::equalZero(fValBB))
+ if(::basegfx::fTools::equalZero(fValBB))
{
return sal_False;
}
@@ -384,7 +384,7 @@ namespace basegfx
fSum -= get(a, b) * fRow[b];
}
}
- else if(!::basegfx::numeric::fTools::equalZero(fSum))
+ else if(!::basegfx::fTools::equalZero(fSum))
{
a2 = a;
}
@@ -403,7 +403,7 @@ namespace basegfx
const double fValueAA(get(a, a));
- if(!::basegfx::numeric::fTools::equalZero(fValueAA))
+ if(!::basegfx::fTools::equalZero(fValueAA))
{
fRow[a] = fSum / get(a, a);
}
@@ -422,7 +422,7 @@ namespace basegfx
const double fDefault(implGetDefaultValue(a, b));
const double fValueAB(get(a, b));
- if(!::basegfx::numeric::fTools::equal(fDefault, fValueAB))
+ if(!::basegfx::fTools::equal(fDefault, fValueAB))
{
return sal_False;
}
@@ -448,14 +448,14 @@ namespace basegfx
const double fHomValue(get((RowSize - 1), (RowSize - 1)));
- if(::basegfx::numeric::fTools::equalZero(fHomValue))
+ if(::basegfx::fTools::equalZero(fHomValue))
{
return sal_True;
}
const double fOne(1.0);
- if(::basegfx::numeric::fTools::equal(fOne, fHomValue))
+ if(::basegfx::fTools::equal(fOne, fHomValue))
{
return sal_True;
}
@@ -634,7 +634,7 @@ namespace basegfx
const double fValueA(get(a, b));
const double fValueB(rMat.get(a, b));
- if(!::basegfx::numeric::fTools::equal(fValueA, fValueB))
+ if(!::basegfx::fTools::equal(fValueA, fValueB))
{
return sal_False;
}
diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx
index d2175b502db3..ae36adfd72f9 100644
--- a/basegfx/source/matrix/b2dhommatrix.cxx
+++ b/basegfx/source/matrix/b2dhommatrix.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dhommatrix.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: thb $ $Date: 2003-11-10 15:10:57 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,336 +81,333 @@
namespace basegfx
{
- namespace matrix
+ class Impl2DHomMatrix : public ::basegfx::internal::ImplHomMatrixTemplate< 3 >
{
- class Impl2DHomMatrix : public ::basegfx::internal::ImplHomMatrixTemplate< 3 >
- {
- };
+ };
- static Impl2DHomMatrix& get2DIdentityMatrix()
- {
- static Impl2DHomMatrix maStatic2DIdentityHomMatrix;
- return maStatic2DIdentityHomMatrix;
- }
+ static Impl2DHomMatrix& get2DIdentityMatrix()
+ {
+ static Impl2DHomMatrix maStatic2DIdentityHomMatrix;
+ return maStatic2DIdentityHomMatrix;
+ }
- void B2DHomMatrix::implPrepareChange()
+ void B2DHomMatrix::implPrepareChange()
+ {
+ if(mpM->getRefCount())
{
- if(mpM->getRefCount())
- {
- mpM->decRefCount();
- mpM = new Impl2DHomMatrix(*mpM);
- }
+ mpM->decRefCount();
+ mpM = new Impl2DHomMatrix(*mpM);
}
+ }
- B2DHomMatrix::B2DHomMatrix()
- : mpM(&get2DIdentityMatrix())
- {
- mpM->incRefCount();
- }
+ B2DHomMatrix::B2DHomMatrix()
+ : mpM(&get2DIdentityMatrix())
+ {
+ mpM->incRefCount();
+ }
- B2DHomMatrix::B2DHomMatrix(const B2DHomMatrix& rMat)
- : mpM(rMat.mpM)
- {
- mpM->incRefCount();
- }
+ B2DHomMatrix::B2DHomMatrix(const B2DHomMatrix& rMat)
+ : mpM(rMat.mpM)
+ {
+ mpM->incRefCount();
+ }
- B2DHomMatrix::~B2DHomMatrix()
- {
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
- }
+ B2DHomMatrix::~B2DHomMatrix()
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
+ }
- B2DHomMatrix& B2DHomMatrix::operator=(const B2DHomMatrix& rMat)
- {
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ B2DHomMatrix& B2DHomMatrix::operator=(const B2DHomMatrix& rMat)
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
- mpM = rMat.mpM;
- mpM->incRefCount();
+ mpM = rMat.mpM;
+ mpM->incRefCount();
- return *this;
- }
+ return *this;
+ }
- double B2DHomMatrix::get(sal_uInt16 nRow, sal_uInt16 nColumn) const
- {
- return mpM->get(nRow, nColumn);
- }
+ double B2DHomMatrix::get(sal_uInt16 nRow, sal_uInt16 nColumn) const
+ {
+ return mpM->get(nRow, nColumn);
+ }
- void B2DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
- {
- implPrepareChange();
- mpM->set(nRow, nColumn, fValue);
- }
+ void B2DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
+ {
+ implPrepareChange();
+ mpM->set(nRow, nColumn, fValue);
+ }
- sal_Bool B2DHomMatrix::isIdentity() const
- {
- if(mpM == &get2DIdentityMatrix())
- return sal_True;
+ sal_Bool B2DHomMatrix::isIdentity() const
+ {
+ if(mpM == &get2DIdentityMatrix())
+ return sal_True;
- return mpM->isIdentity();
- }
+ return mpM->isIdentity();
+ }
- void B2DHomMatrix::identity()
+ void B2DHomMatrix::identity()
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
+
+ mpM = &get2DIdentityMatrix();
+ mpM->incRefCount();
+ }
+
+ sal_Bool B2DHomMatrix::isInvertible() const
+ {
+ return mpM->isInvertible();
+ }
+
+ sal_Bool B2DHomMatrix::invert()
+ {
+ Impl2DHomMatrix aWork(*mpM);
+ sal_uInt16* pIndex = new sal_uInt16[mpM->getEdgeLength()];
+ sal_Int16 nParity;
+
+ if(aWork.ludcmp(pIndex, nParity))
{
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ implPrepareChange();
+ mpM->doInvert(aWork, pIndex);
+ delete pIndex;
- mpM = &get2DIdentityMatrix();
- mpM->incRefCount();
+ return sal_True;
}
- sal_Bool B2DHomMatrix::isInvertible() const
+ delete pIndex;
+ return sal_False;
+ }
+
+ sal_Bool B2DHomMatrix::isNormalized() const
+ {
+ return mpM->isNormalized();
+ }
+
+ void B2DHomMatrix::normalize()
+ {
+ if(!mpM->isNormalized())
{
- return mpM->isInvertible();
+ implPrepareChange();
+ mpM->doNormalize();
}
+ }
- sal_Bool B2DHomMatrix::invert()
- {
- Impl2DHomMatrix aWork(*mpM);
- sal_uInt16* pIndex = new sal_uInt16[mpM->getEdgeLength()];
- sal_Int16 nParity;
+ double B2DHomMatrix::determinant() const
+ {
+ return mpM->doDeterminant();
+ }
- if(aWork.ludcmp(pIndex, nParity))
- {
- implPrepareChange();
- mpM->doInvert(aWork, pIndex);
- delete pIndex;
+ double B2DHomMatrix::trace() const
+ {
+ return mpM->doTrace();
+ }
- return sal_True;
- }
+ void B2DHomMatrix::transpose()
+ {
+ implPrepareChange();
+ mpM->doTranspose();
+ }
- delete pIndex;
- return sal_False;
- }
+ B2DHomMatrix& B2DHomMatrix::operator+=(const B2DHomMatrix& rMat)
+ {
+ implPrepareChange();
+ mpM->doAddMatrix(*rMat.mpM);
- sal_Bool B2DHomMatrix::isNormalized() const
- {
- return mpM->isNormalized();
- }
+ return *this;
+ }
- void B2DHomMatrix::normalize()
- {
- if(!mpM->isNormalized())
- {
- implPrepareChange();
- mpM->doNormalize();
- }
- }
+ B2DHomMatrix& B2DHomMatrix::operator-=(const B2DHomMatrix& rMat)
+ {
+ implPrepareChange();
+ mpM->doSubMatrix(*rMat.mpM);
- double B2DHomMatrix::determinant() const
- {
- return mpM->doDeterminant();
- }
+ return *this;
+ }
- double B2DHomMatrix::trace() const
- {
- return mpM->doTrace();
- }
+ B2DHomMatrix& B2DHomMatrix::operator*=(double fValue)
+ {
+ const double fOne(1.0);
- void B2DHomMatrix::transpose()
+ if(!::basegfx::fTools::equal(fOne, fValue))
{
implPrepareChange();
- mpM->doTranspose();
+ mpM->doMulMatrix(fValue);
}
- B2DHomMatrix& B2DHomMatrix::operator+=(const B2DHomMatrix& rMat)
- {
- implPrepareChange();
- mpM->doAddMatrix(*rMat.mpM);
+ return *this;
+ }
- return *this;
- }
+ B2DHomMatrix& B2DHomMatrix::operator/=(double fValue)
+ {
+ const double fOne(1.0);
- B2DHomMatrix& B2DHomMatrix::operator-=(const B2DHomMatrix& rMat)
+ if(!::basegfx::fTools::equal(fOne, fValue))
{
implPrepareChange();
- mpM->doSubMatrix(*rMat.mpM);
-
- return *this;
+ mpM->doMulMatrix(1.0 / fValue);
}
- B2DHomMatrix& B2DHomMatrix::operator*=(double fValue)
- {
- const double fOne(1.0);
-
- if(!::basegfx::numeric::fTools::equal(fOne, fValue))
- {
- implPrepareChange();
- mpM->doMulMatrix(fValue);
- }
+ return *this;
+ }
- return *this;
- }
-
- B2DHomMatrix& B2DHomMatrix::operator/=(double fValue)
+ B2DHomMatrix& B2DHomMatrix::operator*=(const B2DHomMatrix& rMat)
+ {
+ if(!rMat.isIdentity())
{
- const double fOne(1.0);
-
- if(!::basegfx::numeric::fTools::equal(fOne, fValue))
- {
- implPrepareChange();
- mpM->doMulMatrix(1.0 / fValue);
- }
-
- return *this;
+ implPrepareChange();
+ mpM->doMulMatrix(*rMat.mpM);
}
- B2DHomMatrix& B2DHomMatrix::operator*=(const B2DHomMatrix& rMat)
- {
- if(!rMat.isIdentity())
- {
- implPrepareChange();
- mpM->doMulMatrix(*rMat.mpM);
- }
+ return *this;
+ }
- return *this;
- }
+ sal_Bool B2DHomMatrix::operator==(const B2DHomMatrix& rMat) const
+ {
+ if(mpM == rMat.mpM)
+ return sal_True;
- sal_Bool B2DHomMatrix::operator==(const B2DHomMatrix& rMat) const
- {
- if(mpM == rMat.mpM)
- return sal_True;
+ return mpM->isEqual(*rMat.mpM);
+ }
- return mpM->isEqual(*rMat.mpM);
- }
+ sal_Bool B2DHomMatrix::operator!=(const B2DHomMatrix& rMat) const
+ {
+ if(mpM == rMat.mpM)
+ return sal_False;
+
+ return !mpM->isEqual(*rMat.mpM);
+ }
- sal_Bool B2DHomMatrix::operator!=(const B2DHomMatrix& rMat) const
+ void B2DHomMatrix::rotate(double fRadiant)
+ {
+ if(!::basegfx::fTools::equalZero(fRadiant))
{
- if(mpM == rMat.mpM)
- return sal_False;
+ Impl2DHomMatrix aRotMat(get2DIdentityMatrix());
+ double fSin(sin(fRadiant));
+ double fCos(cos(fRadiant));
- return !mpM->isEqual(*rMat.mpM);
- }
+ aRotMat.set(0, 0, fCos);
+ aRotMat.set(1, 1, fCos);
+ aRotMat.set(1, 0, fSin);
+ aRotMat.set(0, 1, -fSin);
- void B2DHomMatrix::rotate(double fRadiant)
- {
- if(!::basegfx::numeric::fTools::equalZero(fRadiant))
- {
- Impl2DHomMatrix aRotMat(get2DIdentityMatrix());
- double fSin(sin(fRadiant));
- double fCos(cos(fRadiant));
-
- aRotMat.set(0, 0, fCos);
- aRotMat.set(1, 1, fCos);
- aRotMat.set(1, 0, fSin);
- aRotMat.set(0, 1, -fSin);
-
- implPrepareChange();
- mpM->doMulMatrix(aRotMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aRotMat);
}
+ }
- void B2DHomMatrix::translate(double fX, double fY)
+ void B2DHomMatrix::translate(double fX, double fY)
+ {
+ if(!::basegfx::fTools::equalZero(fX) || !::basegfx::fTools::equalZero(fY))
{
- if(!::basegfx::numeric::fTools::equalZero(fX) || !::basegfx::numeric::fTools::equalZero(fY))
- {
- Impl2DHomMatrix aTransMat(get2DIdentityMatrix());
+ Impl2DHomMatrix aTransMat(get2DIdentityMatrix());
- aTransMat.set(0, 2, fX);
- aTransMat.set(1, 2, fY);
+ aTransMat.set(0, 2, fX);
+ aTransMat.set(1, 2, fY);
- implPrepareChange();
- mpM->doMulMatrix(aTransMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aTransMat);
}
+ }
- void B2DHomMatrix::scale(double fX, double fY)
- {
- const double fOne(1.0);
+ void B2DHomMatrix::scale(double fX, double fY)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fX) || !::basegfx::numeric::fTools::equal(fOne, fY))
- {
- Impl2DHomMatrix aScaleMat(get2DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fX) || !::basegfx::fTools::equal(fOne, fY))
+ {
+ Impl2DHomMatrix aScaleMat(get2DIdentityMatrix());
- aScaleMat.set(0, 0, fX);
- aScaleMat.set(1, 1, fY);
+ aScaleMat.set(0, 0, fX);
+ aScaleMat.set(1, 1, fY);
- implPrepareChange();
- mpM->doMulMatrix(aScaleMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aScaleMat);
}
+ }
- void B2DHomMatrix::shearX(double fSx)
- {
- const double fOne(1.0);
+ void B2DHomMatrix::shearX(double fSx)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fSx))
- {
- Impl2DHomMatrix aShearXMat(get2DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fSx))
+ {
+ Impl2DHomMatrix aShearXMat(get2DIdentityMatrix());
- aShearXMat.set(0, 1, fSx);
+ aShearXMat.set(0, 1, fSx);
- implPrepareChange();
- mpM->doMulMatrix(aShearXMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aShearXMat);
}
+ }
- void B2DHomMatrix::shearY(double fSy)
- {
- const double fOne(1.0);
+ void B2DHomMatrix::shearY(double fSy)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fSy))
- {
- Impl2DHomMatrix aShearYMat(get2DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fSy))
+ {
+ Impl2DHomMatrix aShearYMat(get2DIdentityMatrix());
- aShearYMat.set(1, 0, fSy);
+ aShearYMat.set(1, 0, fSy);
- implPrepareChange();
- mpM->doMulMatrix(aShearYMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aShearYMat);
}
+ }
- // Decomposition
- sal_Bool B2DHomMatrix::decompose(tuple::B2DTuple& rScale, tuple::B2DTuple& rTranslate, double& rRotate, double& rShearX) const
- {
- // when perspective is used, decompose is not made here
- if(!mpM->isLastLineDefault())
- return sal_False;
-
- // If determinant is zero, decomposition is not possible
- if(0.0 == mpM->doDeterminant())
- return sal_False;
+ // Decomposition
+ sal_Bool B2DHomMatrix::decompose(B2DTuple& rScale, B2DTuple& rTranslate, double& rRotate, double& rShearX) const
+ {
+ // when perspective is used, decompose is not made here
+ if(!mpM->isLastLineDefault())
+ return sal_False;
- // copy 2x2 matrix and translate vector to 3x3 matrix
- ::basegfx::matrix::B3DHomMatrix a3DHomMat;
+ // If determinant is zero, decomposition is not possible
+ if(0.0 == mpM->doDeterminant())
+ return sal_False;
- a3DHomMat.set(0, 0, get(0, 0));
- a3DHomMat.set(0, 1, get(0, 1));
- a3DHomMat.set(1, 0, get(1, 0));
- a3DHomMat.set(1, 1, get(1, 1));
- a3DHomMat.set(0, 2, get(0, 3));
- a3DHomMat.set(1, 2, get(1, 3));
+ // copy 2x2 matrix and translate vector to 3x3 matrix
+ ::basegfx::B3DHomMatrix a3DHomMat;
- ::basegfx::tuple::B3DTuple r3DScale, r3DTranslate, r3DRotate, r3DShear;
+ a3DHomMat.set(0, 0, get(0, 0));
+ a3DHomMat.set(0, 1, get(0, 1));
+ a3DHomMat.set(1, 0, get(1, 0));
+ a3DHomMat.set(1, 1, get(1, 1));
+ a3DHomMat.set(0, 2, get(0, 3));
+ a3DHomMat.set(1, 2, get(1, 3));
- if(a3DHomMat.decompose(r3DScale, r3DTranslate, r3DRotate, r3DShear))
- {
- // copy scale values
- rScale.setX(r3DScale.getX());
- rScale.setY(r3DScale.getY());
+ ::basegfx::B3DTuple r3DScale, r3DTranslate, r3DRotate, r3DShear;
- // copy shear
- rShearX = r3DShear.getX();
+ if(a3DHomMat.decompose(r3DScale, r3DTranslate, r3DRotate, r3DShear))
+ {
+ // copy scale values
+ rScale.setX(r3DScale.getX());
+ rScale.setY(r3DScale.getY());
- // copy rotate
- rRotate = r3DRotate.getZ();
+ // copy shear
+ rShearX = r3DShear.getX();
- // copy translate
- rTranslate.setX(r3DTranslate.getX());
- rTranslate.setY(r3DTranslate.getY());
+ // copy rotate
+ rRotate = r3DRotate.getZ();
- return sal_True;
- }
+ // copy translate
+ rTranslate.setX(r3DTranslate.getX());
+ rTranslate.setY(r3DTranslate.getY());
- return sal_False;
+ return sal_True;
}
- } // end of namespace matrix
+
+ return sal_False;
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/matrix/b3dhommatrix.cxx b/basegfx/source/matrix/b3dhommatrix.cxx
index dee47579741f..b6df9ff51767 100644
--- a/basegfx/source/matrix/b3dhommatrix.cxx
+++ b/basegfx/source/matrix/b3dhommatrix.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dhommatrix.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: thb $ $Date: 2003-11-10 15:10:57 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,567 +73,564 @@
namespace basegfx
{
- namespace matrix
+ class Impl3DHomMatrix : public ::basegfx::internal::ImplHomMatrixTemplate< 4 >
{
- class Impl3DHomMatrix : public ::basegfx::internal::ImplHomMatrixTemplate< 4 >
- {
- };
+ };
- static Impl3DHomMatrix& get3DIdentityMatrix()
- {
- static Impl3DHomMatrix maStatic3DIdentityHomMatrix;
- return maStatic3DIdentityHomMatrix;
- }
+ static Impl3DHomMatrix& get3DIdentityMatrix()
+ {
+ static Impl3DHomMatrix maStatic3DIdentityHomMatrix;
+ return maStatic3DIdentityHomMatrix;
+ }
- void B3DHomMatrix::implPrepareChange()
+ void B3DHomMatrix::implPrepareChange()
+ {
+ if(mpM->getRefCount())
{
- if(mpM->getRefCount())
- {
- mpM->decRefCount();
- mpM = new Impl3DHomMatrix(*mpM);
- }
+ mpM->decRefCount();
+ mpM = new Impl3DHomMatrix(*mpM);
}
+ }
- B3DHomMatrix::B3DHomMatrix()
- : mpM(&get3DIdentityMatrix())
- {
- mpM->incRefCount();
- }
+ B3DHomMatrix::B3DHomMatrix()
+ : mpM(&get3DIdentityMatrix())
+ {
+ mpM->incRefCount();
+ }
- B3DHomMatrix::B3DHomMatrix(const B3DHomMatrix& rMat)
- : mpM(rMat.mpM)
- {
- mpM->incRefCount();
- }
+ B3DHomMatrix::B3DHomMatrix(const B3DHomMatrix& rMat)
+ : mpM(rMat.mpM)
+ {
+ mpM->incRefCount();
+ }
- B3DHomMatrix::~B3DHomMatrix()
- {
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
- }
+ B3DHomMatrix::~B3DHomMatrix()
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
+ }
- B3DHomMatrix& B3DHomMatrix::operator=(const B3DHomMatrix& rMat)
- {
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ B3DHomMatrix& B3DHomMatrix::operator=(const B3DHomMatrix& rMat)
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
- mpM = rMat.mpM;
- mpM->incRefCount();
+ mpM = rMat.mpM;
+ mpM->incRefCount();
- return *this;
- }
+ return *this;
+ }
- double B3DHomMatrix::get(sal_uInt16 nRow, sal_uInt16 nColumn) const
- {
- return mpM->get(nRow, nColumn);
- }
+ double B3DHomMatrix::get(sal_uInt16 nRow, sal_uInt16 nColumn) const
+ {
+ return mpM->get(nRow, nColumn);
+ }
- void B3DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
- {
- implPrepareChange();
- mpM->set(nRow, nColumn, fValue);
- }
+ void B3DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
+ {
+ implPrepareChange();
+ mpM->set(nRow, nColumn, fValue);
+ }
- sal_Bool B3DHomMatrix::isIdentity() const
- {
- if(mpM == &get3DIdentityMatrix())
- return sal_True;
+ sal_Bool B3DHomMatrix::isIdentity() const
+ {
+ if(mpM == &get3DIdentityMatrix())
+ return sal_True;
- return mpM->isIdentity();
- }
+ return mpM->isIdentity();
+ }
+
+ void B3DHomMatrix::identity()
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
+
+ mpM = &get3DIdentityMatrix();
+ mpM->incRefCount();
+ }
+
+ sal_Bool B3DHomMatrix::isInvertible() const
+ {
+ return mpM->isInvertible();
+ }
+
+ sal_Bool B3DHomMatrix::invert()
+ {
+ Impl3DHomMatrix aWork(*mpM);
+ sal_uInt16* pIndex = new sal_uInt16[mpM->getEdgeLength()];
+ sal_Int16 nParity;
- void B3DHomMatrix::identity()
+ if(aWork.ludcmp(pIndex, nParity))
{
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ implPrepareChange();
+ mpM->doInvert(aWork, pIndex);
+ delete pIndex;
- mpM = &get3DIdentityMatrix();
- mpM->incRefCount();
+ return sal_True;
}
- sal_Bool B3DHomMatrix::isInvertible() const
+ delete pIndex;
+ return sal_False;
+ }
+
+ sal_Bool B3DHomMatrix::isNormalized() const
+ {
+ return mpM->isNormalized();
+ }
+
+ void B3DHomMatrix::normalize()
+ {
+ if(!mpM->isNormalized())
{
- return mpM->isInvertible();
+ implPrepareChange();
+ mpM->doNormalize();
}
+ }
- sal_Bool B3DHomMatrix::invert()
- {
- Impl3DHomMatrix aWork(*mpM);
- sal_uInt16* pIndex = new sal_uInt16[mpM->getEdgeLength()];
- sal_Int16 nParity;
+ double B3DHomMatrix::determinant() const
+ {
+ return mpM->doDeterminant();
+ }
- if(aWork.ludcmp(pIndex, nParity))
- {
- implPrepareChange();
- mpM->doInvert(aWork, pIndex);
- delete pIndex;
+ double B3DHomMatrix::trace() const
+ {
+ return mpM->doTrace();
+ }
- return sal_True;
- }
+ void B3DHomMatrix::transpose()
+ {
+ implPrepareChange();
+ mpM->doTranspose();
+ }
- delete pIndex;
- return sal_False;
- }
+ B3DHomMatrix& B3DHomMatrix::operator+=(const B3DHomMatrix& rMat)
+ {
+ implPrepareChange();
+ mpM->doAddMatrix(*rMat.mpM);
- sal_Bool B3DHomMatrix::isNormalized() const
- {
- return mpM->isNormalized();
- }
+ return *this;
+ }
- void B3DHomMatrix::normalize()
- {
- if(!mpM->isNormalized())
- {
- implPrepareChange();
- mpM->doNormalize();
- }
- }
+ B3DHomMatrix& B3DHomMatrix::operator-=(const B3DHomMatrix& rMat)
+ {
+ implPrepareChange();
+ mpM->doSubMatrix(*rMat.mpM);
- double B3DHomMatrix::determinant() const
- {
- return mpM->doDeterminant();
- }
+ return *this;
+ }
- double B3DHomMatrix::trace() const
- {
- return mpM->doTrace();
- }
+ B3DHomMatrix& B3DHomMatrix::operator*=(double fValue)
+ {
+ const double fOne(1.0);
- void B3DHomMatrix::transpose()
+ if(!::basegfx::fTools::equal(fOne, fValue))
{
implPrepareChange();
- mpM->doTranspose();
+ mpM->doMulMatrix(fValue);
}
- B3DHomMatrix& B3DHomMatrix::operator+=(const B3DHomMatrix& rMat)
+ return *this;
+ }
+
+ B3DHomMatrix& B3DHomMatrix::operator/=(double fValue)
+ {
+ const double fOne(1.0);
+
+ if(!::basegfx::fTools::equal(fOne, fValue))
{
implPrepareChange();
- mpM->doAddMatrix(*rMat.mpM);
-
- return *this;
+ mpM->doMulMatrix(1.0 / fValue);
}
- B3DHomMatrix& B3DHomMatrix::operator-=(const B3DHomMatrix& rMat)
+ return *this;
+ }
+
+ B3DHomMatrix& B3DHomMatrix::operator*=(const B3DHomMatrix& rMat)
+ {
+ if(!rMat.isIdentity())
{
implPrepareChange();
- mpM->doSubMatrix(*rMat.mpM);
-
- return *this;
+ mpM->doMulMatrix(*rMat.mpM);
}
- B3DHomMatrix& B3DHomMatrix::operator*=(double fValue)
- {
- const double fOne(1.0);
+ return *this;
+ }
- if(!::basegfx::numeric::fTools::equal(fOne, fValue))
- {
- implPrepareChange();
- mpM->doMulMatrix(fValue);
- }
+ sal_Bool B3DHomMatrix::operator==(const B3DHomMatrix& rMat) const
+ {
+ if(mpM == rMat.mpM)
+ return sal_True;
- return *this;
- }
+ return mpM->isEqual(*rMat.mpM);
+ }
+
+ sal_Bool B3DHomMatrix::operator!=(const B3DHomMatrix& rMat) const
+ {
+ if(mpM == rMat.mpM)
+ return sal_False;
- B3DHomMatrix& B3DHomMatrix::operator/=(double fValue)
+ return !mpM->isEqual(*rMat.mpM);
+ }
+
+ void B3DHomMatrix::rotate(double fAngleX,double fAngleY,double fAngleZ)
+ {
+ if(!::basegfx::fTools::equalZero(fAngleX) || !::basegfx::fTools::equalZero(fAngleY) || !::basegfx::fTools::equalZero(fAngleZ))
{
- const double fOne(1.0);
+ implPrepareChange();
- if(!::basegfx::numeric::fTools::equal(fOne, fValue))
+ if(!::basegfx::fTools::equalZero(fAngleX))
{
- implPrepareChange();
- mpM->doMulMatrix(1.0 / fValue);
- }
+ Impl3DHomMatrix aRotMatX(get3DIdentityMatrix());
+ double fSin(sin(fAngleX));
+ double fCos(cos(fAngleX));
- return *this;
- }
+ aRotMatX.set(1, 1, fCos);
+ aRotMatX.set(2, 2, fCos);
+ aRotMatX.set(2, 1, fSin);
+ aRotMatX.set(1, 2, -fSin);
- B3DHomMatrix& B3DHomMatrix::operator*=(const B3DHomMatrix& rMat)
- {
- if(!rMat.isIdentity())
- {
- implPrepareChange();
- mpM->doMulMatrix(*rMat.mpM);
+ mpM->doMulMatrix(aRotMatX);
}
- return *this;
- }
+ if(!::basegfx::fTools::equalZero(fAngleY))
+ {
+ Impl3DHomMatrix aRotMatY(get3DIdentityMatrix());
+ double fSin(sin(fAngleY));
+ double fCos(cos(fAngleY));
- sal_Bool B3DHomMatrix::operator==(const B3DHomMatrix& rMat) const
- {
- if(mpM == rMat.mpM)
- return sal_True;
+ aRotMatY.set(0, 0, fCos);
+ aRotMatY.set(2, 2, fCos);
+ aRotMatY.set(0, 2, fSin);
+ aRotMatY.set(2, 0, -fSin);
- return mpM->isEqual(*rMat.mpM);
- }
+ mpM->doMulMatrix(aRotMatY);
+ }
- sal_Bool B3DHomMatrix::operator!=(const B3DHomMatrix& rMat) const
- {
- if(mpM == rMat.mpM)
- return sal_False;
+ if(!::basegfx::fTools::equalZero(fAngleZ))
+ {
+ Impl3DHomMatrix aRotMatZ(get3DIdentityMatrix());
+ double fSin(sin(fAngleZ));
+ double fCos(cos(fAngleZ));
- return !mpM->isEqual(*rMat.mpM);
- }
+ aRotMatZ.set(0, 0, fCos);
+ aRotMatZ.set(1, 1, fCos);
+ aRotMatZ.set(1, 0, fSin);
+ aRotMatZ.set(0, 1, -fSin);
- void B3DHomMatrix::rotate(double fAngleX,double fAngleY,double fAngleZ)
- {
- if(!::basegfx::numeric::fTools::equalZero(fAngleX) || !::basegfx::numeric::fTools::equalZero(fAngleY) || !::basegfx::numeric::fTools::equalZero(fAngleZ))
- {
- implPrepareChange();
-
- if(!::basegfx::numeric::fTools::equalZero(fAngleX))
- {
- Impl3DHomMatrix aRotMatX(get3DIdentityMatrix());
- double fSin(sin(fAngleX));
- double fCos(cos(fAngleX));
-
- aRotMatX.set(1, 1, fCos);
- aRotMatX.set(2, 2, fCos);
- aRotMatX.set(2, 1, fSin);
- aRotMatX.set(1, 2, -fSin);
-
- mpM->doMulMatrix(aRotMatX);
- }
-
- if(!::basegfx::numeric::fTools::equalZero(fAngleY))
- {
- Impl3DHomMatrix aRotMatY(get3DIdentityMatrix());
- double fSin(sin(fAngleY));
- double fCos(cos(fAngleY));
-
- aRotMatY.set(0, 0, fCos);
- aRotMatY.set(2, 2, fCos);
- aRotMatY.set(0, 2, fSin);
- aRotMatY.set(2, 0, -fSin);
-
- mpM->doMulMatrix(aRotMatY);
- }
-
- if(!::basegfx::numeric::fTools::equalZero(fAngleZ))
- {
- Impl3DHomMatrix aRotMatZ(get3DIdentityMatrix());
- double fSin(sin(fAngleZ));
- double fCos(cos(fAngleZ));
-
- aRotMatZ.set(0, 0, fCos);
- aRotMatZ.set(1, 1, fCos);
- aRotMatZ.set(1, 0, fSin);
- aRotMatZ.set(0, 1, -fSin);
-
- mpM->doMulMatrix(aRotMatZ);
- }
+ mpM->doMulMatrix(aRotMatZ);
}
}
+ }
- void B3DHomMatrix::translate(double fX, double fY, double fZ)
+ void B3DHomMatrix::translate(double fX, double fY, double fZ)
+ {
+ if(!::basegfx::fTools::equalZero(fX) || !::basegfx::fTools::equalZero(fY) || !::basegfx::fTools::equalZero(fZ))
{
- if(!::basegfx::numeric::fTools::equalZero(fX) || !::basegfx::numeric::fTools::equalZero(fY) || !::basegfx::numeric::fTools::equalZero(fZ))
- {
- Impl3DHomMatrix aTransMat(get3DIdentityMatrix());
+ Impl3DHomMatrix aTransMat(get3DIdentityMatrix());
- aTransMat.set(0, 2, fX);
- aTransMat.set(1, 2, fY);
- aTransMat.set(2, 2, fZ);
+ aTransMat.set(0, 2, fX);
+ aTransMat.set(1, 2, fY);
+ aTransMat.set(2, 2, fZ);
- implPrepareChange();
- mpM->doMulMatrix(aTransMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aTransMat);
}
+ }
- void B3DHomMatrix::scale(double fX, double fY, double fZ)
- {
- const double fOne(1.0);
+ void B3DHomMatrix::scale(double fX, double fY, double fZ)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fX) || !::basegfx::numeric::fTools::equal(fOne, fY) ||!::basegfx::numeric::fTools::equal(fOne, fZ))
- {
- Impl3DHomMatrix aScaleMat(get3DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fX) || !::basegfx::fTools::equal(fOne, fY) ||!::basegfx::fTools::equal(fOne, fZ))
+ {
+ Impl3DHomMatrix aScaleMat(get3DIdentityMatrix());
- aScaleMat.set(0, 0, fX);
- aScaleMat.set(1, 1, fY);
- aScaleMat.set(2, 2, fZ);
+ aScaleMat.set(0, 0, fX);
+ aScaleMat.set(1, 1, fY);
+ aScaleMat.set(2, 2, fZ);
- implPrepareChange();
- mpM->doMulMatrix(aScaleMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aScaleMat);
}
+ }
- void B3DHomMatrix::shearXY(double fSx, double fSy)
- {
- const double fOne(1.0);
+ void B3DHomMatrix::shearXY(double fSx, double fSy)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fSx) || !::basegfx::numeric::fTools::equal(fOne, fSy))
- {
- Impl3DHomMatrix aShearXYMat(get3DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fSx) || !::basegfx::fTools::equal(fOne, fSy))
+ {
+ Impl3DHomMatrix aShearXYMat(get3DIdentityMatrix());
- aShearXYMat.set(0, 2, fSx);
- aShearXYMat.set(1, 2, fSy);
+ aShearXYMat.set(0, 2, fSx);
+ aShearXYMat.set(1, 2, fSy);
- implPrepareChange();
- mpM->doMulMatrix(aShearXYMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aShearXYMat);
}
+ }
- void B3DHomMatrix::shearYZ(double fSy, double fSz)
- {
- const double fOne(1.0);
+ void B3DHomMatrix::shearYZ(double fSy, double fSz)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fSy) || !::basegfx::numeric::fTools::equal(fOne, fSz))
- {
- Impl3DHomMatrix aShearYZMat(get3DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fSy) || !::basegfx::fTools::equal(fOne, fSz))
+ {
+ Impl3DHomMatrix aShearYZMat(get3DIdentityMatrix());
- aShearYZMat.set(1, 0, fSy);
- aShearYZMat.set(2, 0, fSz);
+ aShearYZMat.set(1, 0, fSy);
+ aShearYZMat.set(2, 0, fSz);
- implPrepareChange();
- mpM->doMulMatrix(aShearYZMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aShearYZMat);
}
+ }
- void B3DHomMatrix::shearXZ(double fSx, double fSz)
- {
- const double fOne(1.0);
+ void B3DHomMatrix::shearXZ(double fSx, double fSz)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fSx) || !::basegfx::numeric::fTools::equal(fOne, fSz))
- {
- Impl3DHomMatrix aShearXZMat(get3DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fSx) || !::basegfx::fTools::equal(fOne, fSz))
+ {
+ Impl3DHomMatrix aShearXZMat(get3DIdentityMatrix());
- aShearXZMat.set(0, 1, fSx);
- aShearXZMat.set(2, 1, fSz);
+ aShearXZMat.set(0, 1, fSx);
+ aShearXZMat.set(2, 1, fSz);
- implPrepareChange();
- mpM->doMulMatrix(aShearXZMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aShearXZMat);
}
+ }
- void B3DHomMatrix::frustum(double fLeft, double fRight, double fBottom, double fTop, double fNear, double fFar)
+ void B3DHomMatrix::frustum(double fLeft, double fRight, double fBottom, double fTop, double fNear, double fFar)
+ {
+ const double fZero(0.0);
+ const double fOne(1.0);
+
+ if(!::basegfx::fTools::more(fNear, fZero))
{
- const double fZero(0.0);
- const double fOne(1.0);
+ fNear = 0.001;
+ }
- if(!::basegfx::numeric::fTools::more(fNear, fZero))
- {
- fNear = 0.001;
- }
+ if(!::basegfx::fTools::more(fFar, fZero))
+ {
+ fFar = fOne;
+ }
- if(!::basegfx::numeric::fTools::more(fFar, fZero))
- {
- fFar = fOne;
- }
+ if(::basegfx::fTools::equal(fNear, fFar))
+ {
+ fFar = fNear + fOne;
+ }
- if(::basegfx::numeric::fTools::equal(fNear, fFar))
- {
- fFar = fNear + fOne;
- }
+ if(::basegfx::fTools::equal(fLeft, fRight))
+ {
+ fLeft -= fOne;
+ fRight += fOne;
+ }
- if(::basegfx::numeric::fTools::equal(fLeft, fRight))
- {
- fLeft -= fOne;
- fRight += fOne;
- }
+ if(::basegfx::fTools::equal(fTop, fBottom))
+ {
+ fBottom -= fOne;
+ fTop += fOne;
+ }
- if(::basegfx::numeric::fTools::equal(fTop, fBottom))
- {
- fBottom -= fOne;
- fTop += fOne;
- }
+ Impl3DHomMatrix aFrustumMat(get3DIdentityMatrix());
- Impl3DHomMatrix aFrustumMat(get3DIdentityMatrix());
+ aFrustumMat.set(0, 0, 2.0 * fNear / (fRight - fLeft));
+ aFrustumMat.set(1, 1, 2.0 * fNear / (fTop - fBottom));
+ aFrustumMat.set(0, 2, (fRight + fLeft) / (fRight - fLeft));
+ aFrustumMat.set(1, 2, (fTop + fBottom) / (fTop - fBottom));
+ aFrustumMat.set(2, 2, -fOne * ((fFar + fNear) / (fFar - fNear)));
+ aFrustumMat.set(3, 2, -fOne);
+ aFrustumMat.set(2, 3, -fOne * ((2.0 * fFar * fNear) / (fFar - fNear)));
+ aFrustumMat.set(3, 3, fZero);
- aFrustumMat.set(0, 0, 2.0 * fNear / (fRight - fLeft));
- aFrustumMat.set(1, 1, 2.0 * fNear / (fTop - fBottom));
- aFrustumMat.set(0, 2, (fRight + fLeft) / (fRight - fLeft));
- aFrustumMat.set(1, 2, (fTop + fBottom) / (fTop - fBottom));
- aFrustumMat.set(2, 2, -fOne * ((fFar + fNear) / (fFar - fNear)));
- aFrustumMat.set(3, 2, -fOne);
- aFrustumMat.set(2, 3, -fOne * ((2.0 * fFar * fNear) / (fFar - fNear)));
- aFrustumMat.set(3, 3, fZero);
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ mpM = new Impl3DHomMatrix(aFrustumMat);
+ }
- mpM = new Impl3DHomMatrix(aFrustumMat);
+ void B3DHomMatrix::ortho(double fLeft, double fRight, double fBottom, double fTop, double fNear, double fFar)
+ {
+ if(::basegfx::fTools::equal(fNear, fFar))
+ {
+ fFar = fNear + 1.0;
}
- void B3DHomMatrix::ortho(double fLeft, double fRight, double fBottom, double fTop, double fNear, double fFar)
+ if(::basegfx::fTools::equal(fLeft, fRight))
{
- if(::basegfx::numeric::fTools::equal(fNear, fFar))
- {
- fFar = fNear + 1.0;
- }
-
- if(::basegfx::numeric::fTools::equal(fLeft, fRight))
- {
- fLeft -= 1.0;
- fRight += 1.0;
- }
+ fLeft -= 1.0;
+ fRight += 1.0;
+ }
- if(::basegfx::numeric::fTools::equal(fTop, fBottom))
- {
- fBottom -= 1.0;
- fTop += 1.0;
- }
+ if(::basegfx::fTools::equal(fTop, fBottom))
+ {
+ fBottom -= 1.0;
+ fTop += 1.0;
+ }
- Impl3DHomMatrix aOrthoMat(get3DIdentityMatrix());
+ Impl3DHomMatrix aOrthoMat(get3DIdentityMatrix());
- aOrthoMat.set(0, 0, 2.0 / (fRight - fLeft));
- aOrthoMat.set(1, 1, 2.0 / (fTop - fBottom));
- aOrthoMat.set(2, 2, -1.0 * (2.0 / (fFar - fNear)));
- aOrthoMat.set(0, 3, -1.0 * ((fRight + fLeft) / (fRight - fLeft)));
- aOrthoMat.set(1, 3, -1.0 * ((fTop + fBottom) / (fTop - fBottom)));
- aOrthoMat.set(2, 3, -1.0 * ((fFar + fNear) / (fFar - fNear)));
+ aOrthoMat.set(0, 0, 2.0 / (fRight - fLeft));
+ aOrthoMat.set(1, 1, 2.0 / (fTop - fBottom));
+ aOrthoMat.set(2, 2, -1.0 * (2.0 / (fFar - fNear)));
+ aOrthoMat.set(0, 3, -1.0 * ((fRight + fLeft) / (fRight - fLeft)));
+ aOrthoMat.set(1, 3, -1.0 * ((fTop + fBottom) / (fTop - fBottom)));
+ aOrthoMat.set(2, 3, -1.0 * ((fFar + fNear) / (fFar - fNear)));
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
- mpM = new Impl3DHomMatrix(aOrthoMat);
- }
+ mpM = new Impl3DHomMatrix(aOrthoMat);
+ }
- sal_Bool B3DHomMatrix::decompose(tuple::B3DTuple& rScale, tuple::B3DTuple& rTranslate, tuple::B3DTuple& rRotate, tuple::B3DTuple& rShear) const
- {
- // when perspective is used, decompose is not made here
- if(!mpM->isLastLineDefault())
- return sal_False;
+ sal_Bool B3DHomMatrix::decompose(B3DTuple& rScale, B3DTuple& rTranslate, B3DTuple& rRotate, B3DTuple& rShear) const
+ {
+ // when perspective is used, decompose is not made here
+ if(!mpM->isLastLineDefault())
+ return sal_False;
- // If determinant is zero, decomposition is not possible
- if(0.0 == mpM->doDeterminant())
- return sal_False;
+ // If determinant is zero, decomposition is not possible
+ if(0.0 == mpM->doDeterminant())
+ return sal_False;
- // isolate translation
- rTranslate.setX(mpM->get(0, 3));
- rTranslate.setY(mpM->get(1, 3));
- rTranslate.setZ(mpM->get(2, 3));
+ // isolate translation
+ rTranslate.setX(mpM->get(0, 3));
+ rTranslate.setY(mpM->get(1, 3));
+ rTranslate.setZ(mpM->get(2, 3));
- // correct translate values
- rTranslate.correctValues();
+ // correct translate values
+ rTranslate.correctValues();
- // get scale and shear
- vector::B3DVector aCol0(mpM->get(0, 0), mpM->get(1, 0), mpM->get(2, 0));
- vector::B3DVector aCol1(mpM->get(0, 1), mpM->get(1, 1), mpM->get(2, 1));
- vector::B3DVector aCol2(mpM->get(0, 2), mpM->get(1, 2), mpM->get(2, 2));
- vector::B3DVector aTemp;
+ // get scale and shear
+ B3DVector aCol0(mpM->get(0, 0), mpM->get(1, 0), mpM->get(2, 0));
+ B3DVector aCol1(mpM->get(0, 1), mpM->get(1, 1), mpM->get(2, 1));
+ B3DVector aCol2(mpM->get(0, 2), mpM->get(1, 2), mpM->get(2, 2));
+ B3DVector aTemp;
- // get ScaleX
- rScale.setX(aCol0.getLength());
- aCol0.normalize();
+ // get ScaleX
+ rScale.setX(aCol0.getLength());
+ aCol0.normalize();
- // get ShearXY
- rShear.setX(aCol0.scalar(aCol1));
+ // get ShearXY
+ rShear.setX(aCol0.scalar(aCol1));
- if(::basegfx::numeric::fTools::equalZero(rShear.getX()))
- {
- rShear.setX(0.0);
- }
- else
- {
- aTemp.setX(aCol1.getX() - rShear.getX() * aCol0.getX());
- aTemp.setY(aCol1.getY() - rShear.getX() * aCol0.getY());
- aTemp.setZ(aCol1.getZ() - rShear.getX() * aCol0.getZ());
- aCol1 = aTemp;
- }
+ if(::basegfx::fTools::equalZero(rShear.getX()))
+ {
+ rShear.setX(0.0);
+ }
+ else
+ {
+ aTemp.setX(aCol1.getX() - rShear.getX() * aCol0.getX());
+ aTemp.setY(aCol1.getY() - rShear.getX() * aCol0.getY());
+ aTemp.setZ(aCol1.getZ() - rShear.getX() * aCol0.getZ());
+ aCol1 = aTemp;
+ }
- // get ScaleY
- rScale.setY(aCol1.getLength());
- aCol1.normalize();
+ // get ScaleY
+ rScale.setY(aCol1.getLength());
+ aCol1.normalize();
- const double fShearX(rShear.getX());
+ const double fShearX(rShear.getX());
- if(!::basegfx::numeric::fTools::equalZero(fShearX))
- {
- rShear.setX(rShear.getX() / rScale.getY());
- }
+ if(!::basegfx::fTools::equalZero(fShearX))
+ {
+ rShear.setX(rShear.getX() / rScale.getY());
+ }
- // get ShearXZ
- rShear.setY(aCol0.scalar(aCol2));
+ // get ShearXZ
+ rShear.setY(aCol0.scalar(aCol2));
- if(::basegfx::numeric::fTools::equalZero(rShear.getY()))
- {
- rShear.setY(0.0);
- }
- else
- {
- aTemp.setX(aCol2.getX() - rShear.getY() * aCol0.getX());
- aTemp.setY(aCol2.getY() - rShear.getY() * aCol0.getY());
- aTemp.setZ(aCol2.getZ() - rShear.getY() * aCol0.getZ());
- aCol2 = aTemp;
- }
+ if(::basegfx::fTools::equalZero(rShear.getY()))
+ {
+ rShear.setY(0.0);
+ }
+ else
+ {
+ aTemp.setX(aCol2.getX() - rShear.getY() * aCol0.getX());
+ aTemp.setY(aCol2.getY() - rShear.getY() * aCol0.getY());
+ aTemp.setZ(aCol2.getZ() - rShear.getY() * aCol0.getZ());
+ aCol2 = aTemp;
+ }
- // get ShearYZ
- rShear.setZ(aCol1.scalar(aCol2));
+ // get ShearYZ
+ rShear.setZ(aCol1.scalar(aCol2));
- if(::basegfx::numeric::fTools::equalZero(rShear.getZ()))
- {
- rShear.setZ(0.0);
- }
- else
- {
- aTemp.setX(aCol2.getX() - rShear.getZ() * aCol1.getX());
- aTemp.setY(aCol2.getY() - rShear.getZ() * aCol1.getY());
- aTemp.setZ(aCol2.getZ() - rShear.getZ() * aCol1.getZ());
- aCol2 = aTemp;
- }
+ if(::basegfx::fTools::equalZero(rShear.getZ()))
+ {
+ rShear.setZ(0.0);
+ }
+ else
+ {
+ aTemp.setX(aCol2.getX() - rShear.getZ() * aCol1.getX());
+ aTemp.setY(aCol2.getY() - rShear.getZ() * aCol1.getY());
+ aTemp.setZ(aCol2.getZ() - rShear.getZ() * aCol1.getZ());
+ aCol2 = aTemp;
+ }
- // get ScaleZ
- rScale.setZ(aCol2.getLength());
- aCol2.normalize();
+ // get ScaleZ
+ rScale.setZ(aCol2.getLength());
+ aCol2.normalize();
- const double fShearY(rShear.getY());
+ const double fShearY(rShear.getY());
- if(!::basegfx::numeric::fTools::equalZero(fShearY))
- {
- rShear.setY(rShear.getY() / rScale.getZ());
- }
+ if(!::basegfx::fTools::equalZero(fShearY))
+ {
+ rShear.setY(rShear.getY() / rScale.getZ());
+ }
- const double fShearZ(rShear.getZ());
+ const double fShearZ(rShear.getZ());
- if(!::basegfx::numeric::fTools::equalZero(fShearZ))
- {
- rShear.setZ(rShear.getZ() / rScale.getZ());
- }
+ if(!::basegfx::fTools::equalZero(fShearZ))
+ {
+ rShear.setZ(rShear.getZ() / rScale.getZ());
+ }
- // correct shear values
- rShear.correctValues();
+ // correct shear values
+ rShear.correctValues();
- // Coordinate system flip?
- if(0.0 > aCol0.scalar(aCol1.getPerpendicular(aCol2)))
- {
- rScale = -rScale;
- aCol0 = -aCol0;
- aCol1 = -aCol1;
- aCol2 = -aCol2;
- }
+ // Coordinate system flip?
+ if(0.0 > aCol0.scalar(aCol1.getPerpendicular(aCol2)))
+ {
+ rScale = -rScale;
+ aCol0 = -aCol0;
+ aCol1 = -aCol1;
+ aCol2 = -aCol2;
+ }
- // correct scale values
- rScale.correctValues(1.0);
+ // correct scale values
+ rScale.correctValues(1.0);
- // Get rotations
- rRotate.setY(asin(-aCol0.getZ()));
+ // Get rotations
+ rRotate.setY(asin(-aCol0.getZ()));
- if(::basegfx::numeric::fTools::equalZero(cos(rRotate.getY())))
- {
- rRotate.setX(atan2(aCol1.getX(), aCol1.getY()));
- rRotate.setZ(0.0);
- }
- else
- {
- rRotate.setX(atan2(aCol1.getZ(), aCol2.getZ()));
- rRotate.setZ(atan2(aCol0.getY(), aCol0.getX()));
- }
+ if(::basegfx::fTools::equalZero(cos(rRotate.getY())))
+ {
+ rRotate.setX(atan2(aCol1.getX(), aCol1.getY()));
+ rRotate.setZ(0.0);
+ }
+ else
+ {
+ rRotate.setX(atan2(aCol1.getZ(), aCol2.getZ()));
+ rRotate.setZ(atan2(aCol0.getY(), aCol0.getX()));
+ }
- // corrcet rotate values
- rRotate.correctValues();
+ // corrcet rotate values
+ rRotate.correctValues();
- return sal_True;
- }
- } // end of namespace matrix
+ return sal_True;
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/numeric/ftools.cxx b/basegfx/source/numeric/ftools.cxx
index 9470c249a756..c39ee766a2bc 100644
--- a/basegfx/source/numeric/ftools.cxx
+++ b/basegfx/source/numeric/ftools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftools.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-10-31 10:13:56 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,11 +65,8 @@
namespace basegfx
{
- namespace numeric
- {
- // init static member of class fTools
- double ::basegfx::numeric::fTools::mfSmallValue = 0.000000001;
- } // end of namespace numeric
+ // init static member of class fTools
+ double ::basegfx::fTools::mfSmallValue = 0.000000001;
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/point/b2dhompoint.cxx b/basegfx/source/point/b2dhompoint.cxx
index 575657491120..cda1e6f356b5 100644
--- a/basegfx/source/point/b2dhompoint.cxx
+++ b/basegfx/source/point/b2dhompoint.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dhompoint.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: aw $ $Date: 2003-11-10 11:45:49 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,230 +73,227 @@
namespace basegfx
{
- namespace point
+ sal_Bool B2DHomPoint::implIsHomogenized() const
{
- sal_Bool B2DHomPoint::implIsHomogenized() const
- {
- const double fOne(1.0);
- return ::basegfx::numeric::fTools::equal(fOne, mfW);
- }
+ const double fOne(1.0);
+ return ::basegfx::fTools::equal(fOne, mfW);
+ }
- void B2DHomPoint::implHomogenize()
- {
- const double fFactor(1.0 / mfW);
- maTuple.setX(maTuple.getX() * fFactor);
- maTuple.setY(maTuple.getY() * fFactor);
- mfW = 1.0;
- }
+ void B2DHomPoint::implHomogenize()
+ {
+ const double fFactor(1.0 / mfW);
+ maTuple.setX(maTuple.getX() * fFactor);
+ maTuple.setY(maTuple.getY() * fFactor);
+ mfW = 1.0;
+ }
- void B2DHomPoint::implTestAndHomogenize() const
- {
- if(!implIsHomogenized())
- ((B2DHomPoint*)this)->implHomogenize();
- }
+ void B2DHomPoint::implTestAndHomogenize() const
+ {
+ if(!implIsHomogenized())
+ ((B2DHomPoint*)this)->implHomogenize();
+ }
- B2DPoint B2DHomPoint::getB2DPoint() const
- {
- implTestAndHomogenize();
- return B2DPoint(maTuple.getX(), maTuple.getY());
- }
+ B2DPoint B2DHomPoint::getB2DPoint() const
+ {
+ implTestAndHomogenize();
+ return B2DPoint(maTuple.getX(), maTuple.getY());
+ }
- double B2DHomPoint::getX() const
- {
- implTestAndHomogenize();
- return maTuple.getX();
- }
+ double B2DHomPoint::getX() const
+ {
+ implTestAndHomogenize();
+ return maTuple.getX();
+ }
- double B2DHomPoint::getY() const
- {
- implTestAndHomogenize();
- return maTuple.getY();
- }
+ double B2DHomPoint::getY() const
+ {
+ implTestAndHomogenize();
+ return maTuple.getY();
+ }
- void B2DHomPoint::setX(double fX)
- {
- maTuple.setX(implIsHomogenized() ? fX : fX * mfW );
- }
+ void B2DHomPoint::setX(double fX)
+ {
+ maTuple.setX(implIsHomogenized() ? fX : fX * mfW );
+ }
- void B2DHomPoint::setY(double fY)
- {
- maTuple.setY(implIsHomogenized() ? fY : fY * mfW );
- }
+ void B2DHomPoint::setY(double fY)
+ {
+ maTuple.setY(implIsHomogenized() ? fY : fY * mfW );
+ }
- B2DHomPoint& B2DHomPoint::operator+=( const B2DHomPoint& rPnt )
- {
- maTuple.setX(getX() * rPnt.mfW + rPnt.getX() * mfW);
- maTuple.setY(getY() * rPnt.mfW + rPnt.getY() * mfW);
- mfW = mfW * rPnt.mfW;
+ B2DHomPoint& B2DHomPoint::operator+=( const B2DHomPoint& rPnt )
+ {
+ maTuple.setX(getX() * rPnt.mfW + rPnt.getX() * mfW);
+ maTuple.setY(getY() * rPnt.mfW + rPnt.getY() * mfW);
+ mfW = mfW * rPnt.mfW;
- return *this;
- }
+ return *this;
+ }
- B2DHomPoint& B2DHomPoint::operator-=( const B2DHomPoint& rPnt )
- {
- maTuple.setX(getX() * rPnt.mfW - rPnt.getX() * mfW);
- maTuple.setY(getY() * rPnt.mfW - rPnt.getY() * mfW);
- mfW = mfW * rPnt.mfW;
+ B2DHomPoint& B2DHomPoint::operator-=( const B2DHomPoint& rPnt )
+ {
+ maTuple.setX(getX() * rPnt.mfW - rPnt.getX() * mfW);
+ maTuple.setY(getY() * rPnt.mfW - rPnt.getY() * mfW);
+ mfW = mfW * rPnt.mfW;
- return *this;
- }
+ return *this;
+ }
- B2DHomPoint& B2DHomPoint::operator*=(double t)
+ B2DHomPoint& B2DHomPoint::operator*=(double t)
+ {
+ if(!::basegfx::fTools::equalZero(t))
{
- if(!::basegfx::numeric::fTools::equalZero(t))
- {
- mfW /= t;
- }
-
- return *this;
+ mfW /= t;
}
- B2DHomPoint& B2DHomPoint::operator*=( const matrix::B2DHomMatrix& rMat )
- {
- const double fTempX( rMat.get(0,0)*maTuple.getX() +
- rMat.get(0,1)*maTuple.getY() +
- rMat.get(0,2)*mfW );
-
- const double fTempY( rMat.get(1,0)*maTuple.getX() +
- rMat.get(1,1)*maTuple.getY() +
- rMat.get(1,2)*mfW );
-
- const double fTempZ( rMat.get(2,0)*maTuple.getX() +
- rMat.get(2,1)*maTuple.getY() +
- rMat.get(2,2)*mfW );
- maTuple.setX( fTempX );
- maTuple.setY( fTempY );
- mfW = fTempZ;
-
- return *this;
- }
+ return *this;
+ }
- B2DHomPoint& B2DHomPoint::operator/=(double t)
- {
- mfW *= t;
- return *this;
- }
+ B2DHomPoint& B2DHomPoint::operator*=( const B2DHomMatrix& rMat )
+ {
+ const double fTempX( rMat.get(0,0)*maTuple.getX() +
+ rMat.get(0,1)*maTuple.getY() +
+ rMat.get(0,2)*mfW );
- B2DHomPoint& B2DHomPoint::operator-(void)
- {
- mfW = -mfW;
- return *this;
- }
+ const double fTempY( rMat.get(1,0)*maTuple.getX() +
+ rMat.get(1,1)*maTuple.getY() +
+ rMat.get(1,2)*mfW );
- sal_Bool B2DHomPoint::operator==( const B2DHomPoint& rPnt ) const
- {
- implTestAndHomogenize();
- return (maTuple == rPnt.maTuple);
- }
+ const double fTempZ( rMat.get(2,0)*maTuple.getX() +
+ rMat.get(2,1)*maTuple.getY() +
+ rMat.get(2,2)*mfW );
+ maTuple.setX( fTempX );
+ maTuple.setY( fTempY );
+ mfW = fTempZ;
- sal_Bool B2DHomPoint::operator!=( const B2DHomPoint& rPnt ) const
- {
- implTestAndHomogenize();
- return (maTuple != rPnt.maTuple);
- }
+ return *this;
+ }
- B2DHomPoint& B2DHomPoint::operator=( const B2DHomPoint& rPnt )
- {
- maTuple = rPnt.maTuple;
- mfW = rPnt.mfW;
- return *this;
- }
+ B2DHomPoint& B2DHomPoint::operator/=(double t)
+ {
+ mfW *= t;
+ return *this;
+ }
- B2DHomPoint min(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
- {
- B2DHomPoint aMin(
- (rVecB.getX() < rVecA.getX()) ? rVecB.getX() : rVecA.getX(),
- (rVecB.getY() < rVecA.getY()) ? rVecB.getY() : rVecA.getY());
- return aMin;
- }
+ B2DHomPoint& B2DHomPoint::operator-(void)
+ {
+ mfW = -mfW;
+ return *this;
+ }
- B2DHomPoint max(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
- {
- B2DHomPoint aMax(
- (rVecB.getX() > rVecA.getX()) ? rVecB.getX() : rVecA.getX(),
- (rVecB.getY() > rVecA.getY()) ? rVecB.getY() : rVecA.getY());
- return aMax;
- }
- B2DHomPoint abs(const B2DHomPoint& rVec)
- {
- B2DHomPoint aAbs(
- (0.0 > rVec.getX()) ? -rVec.getX() : rVec.getX(),
- (0.0 > rVec.getY()) ? -rVec.getY() : rVec.getY());
- return aAbs;
- }
+ sal_Bool B2DHomPoint::operator==( const B2DHomPoint& rPnt ) const
+ {
+ implTestAndHomogenize();
+ return (maTuple == rPnt.maTuple);
+ }
- B2DHomPoint interpolate(B2DHomPoint& rOld1, B2DHomPoint& rOld2, double t)
- {
- B2DHomPoint aInt(
- ((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
- ((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY());
- return aInt;
- }
+ sal_Bool B2DHomPoint::operator!=( const B2DHomPoint& rPnt ) const
+ {
+ implTestAndHomogenize();
+ return (maTuple != rPnt.maTuple);
+ }
- B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2)
- {
- B2DHomPoint aAvg(
- (rOld1.getX() + rOld2.getX()) * 0.5,
- (rOld1.getY() + rOld2.getY()) * 0.5);
- return aAvg;
- }
+ B2DHomPoint& B2DHomPoint::operator=( const B2DHomPoint& rPnt )
+ {
+ maTuple = rPnt.maTuple;
+ mfW = rPnt.mfW;
+ return *this;
+ }
- B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2, B2DHomPoint& rOld3)
- {
- B2DHomPoint aAvg(
- (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
- (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0));
- return aAvg;
- }
+ B2DHomPoint min(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
+ {
+ B2DHomPoint aMin(
+ (rVecB.getX() < rVecA.getX()) ? rVecB.getX() : rVecA.getX(),
+ (rVecB.getY() < rVecA.getY()) ? rVecB.getY() : rVecA.getY());
+ return aMin;
+ }
- B2DHomPoint operator+(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
- {
- B2DHomPoint aSum(rVecA);
- aSum += rVecB;
- return aSum;
- }
+ B2DHomPoint max(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
+ {
+ B2DHomPoint aMax(
+ (rVecB.getX() > rVecA.getX()) ? rVecB.getX() : rVecA.getX(),
+ (rVecB.getY() > rVecA.getY()) ? rVecB.getY() : rVecA.getY());
+ return aMax;
+ }
+ B2DHomPoint abs(const B2DHomPoint& rVec)
+ {
+ B2DHomPoint aAbs(
+ (0.0 > rVec.getX()) ? -rVec.getX() : rVec.getX(),
+ (0.0 > rVec.getY()) ? -rVec.getY() : rVec.getY());
+ return aAbs;
+ }
- B2DHomPoint operator-(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
- {
- B2DHomPoint aSub(rVecA);
- aSub -= rVecB;
- return aSub;
- }
+ B2DHomPoint interpolate(B2DHomPoint& rOld1, B2DHomPoint& rOld2, double t)
+ {
+ B2DHomPoint aInt(
+ ((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
+ ((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY());
+ return aInt;
+ }
- B2DHomPoint operator*(const B2DHomPoint& rVec, double t)
- {
- B2DHomPoint aNew(rVec);
- aNew *= t;
- return aNew;
- }
+ B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2)
+ {
+ B2DHomPoint aAvg(
+ (rOld1.getX() + rOld2.getX()) * 0.5,
+ (rOld1.getY() + rOld2.getY()) * 0.5);
+ return aAvg;
+ }
- B2DHomPoint operator*(double t, const B2DHomPoint& rVec)
- {
- B2DHomPoint aNew(rVec);
- aNew *= t;
- return aNew;
- }
+ B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2, B2DHomPoint& rOld3)
+ {
+ B2DHomPoint aAvg(
+ (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
+ (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0));
+ return aAvg;
+ }
- B2DHomPoint operator*( const matrix::B2DHomMatrix& rMat, const B2DHomPoint& rPoint )
- {
- B2DHomPoint aNew(rPoint);
- return aNew*=rMat;
- }
+ B2DHomPoint operator+(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
+ {
+ B2DHomPoint aSum(rVecA);
+ aSum += rVecB;
+ return aSum;
+ }
- B2DHomPoint operator/(const B2DHomPoint& rVec, double t)
- {
- B2DHomPoint aNew(rVec);
- aNew /= t;
- return aNew;
- }
+ B2DHomPoint operator-(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
+ {
+ B2DHomPoint aSub(rVecA);
+ aSub -= rVecB;
+ return aSub;
+ }
- B2DHomPoint operator/(double t, const B2DHomPoint& rVec)
- {
- B2DHomPoint aNew(rVec);
- aNew /= t;
- return aNew;
- }
- } // end of namespace point
+ B2DHomPoint operator*(const B2DHomPoint& rVec, double t)
+ {
+ B2DHomPoint aNew(rVec);
+ aNew *= t;
+ return aNew;
+ }
+
+ B2DHomPoint operator*(double t, const B2DHomPoint& rVec)
+ {
+ B2DHomPoint aNew(rVec);
+ aNew *= t;
+ return aNew;
+ }
+
+ B2DHomPoint operator*( const B2DHomMatrix& rMat, const B2DHomPoint& rPoint )
+ {
+ B2DHomPoint aNew(rPoint);
+ return aNew*=rMat;
+ }
+
+ B2DHomPoint operator/(const B2DHomPoint& rVec, double t)
+ {
+ B2DHomPoint aNew(rVec);
+ aNew /= t;
+ return aNew;
+ }
+
+ B2DHomPoint operator/(double t, const B2DHomPoint& rVec)
+ {
+ B2DHomPoint aNew(rVec);
+ aNew /= t;
+ return aNew;
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/point/b2dpoint.cxx b/basegfx/source/point/b2dpoint.cxx
index 34c14f89bdac..dab49a9fe392 100644
--- a/basegfx/source/point/b2dpoint.cxx
+++ b/basegfx/source/point/b2dpoint.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpoint.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-06 16:30:28 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -69,29 +69,26 @@
namespace basegfx
{
- namespace point
+ B2DPoint& B2DPoint::operator=( const ::basegfx::B2DTuple& rPoint )
{
- B2DPoint& B2DPoint::operator=( const ::basegfx::tuple::B2DTuple& rPoint )
- {
- mfX = rPoint.getX();
- mfY = rPoint.getY();
- return *this;
- }
+ mfX = rPoint.getX();
+ mfY = rPoint.getY();
+ return *this;
+ }
- B2DPoint& B2DPoint::operator*=( const ::basegfx::matrix::B2DHomMatrix& rMat )
- {
- const double fTempX( rMat.get(0,0)*mfX +
- rMat.get(0,1)*mfY +
- rMat.get(0,2) );
- const double fTempY( rMat.get(1,0)*mfX +
- rMat.get(1,1)*mfY +
- rMat.get(1,2) );
- mfX = fTempX;
- mfY = fTempY;
+ B2DPoint& B2DPoint::operator*=( const ::basegfx::B2DHomMatrix& rMat )
+ {
+ const double fTempX( rMat.get(0,0)*mfX +
+ rMat.get(0,1)*mfY +
+ rMat.get(0,2) );
+ const double fTempY( rMat.get(1,0)*mfX +
+ rMat.get(1,1)*mfY +
+ rMat.get(1,2) );
+ mfX = fTempX;
+ mfY = fTempY;
- return *this;
- }
- } // end of namespace point
+ return *this;
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/point/b3dhompoint.cxx b/basegfx/source/point/b3dhompoint.cxx
index 07570ebd8208..7069ea73a9ba 100644
--- a/basegfx/source/point/b3dhompoint.cxx
+++ b/basegfx/source/point/b3dhompoint.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dhompoint.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-10-31 10:13:57 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,17 +65,14 @@
namespace basegfx
{
- namespace point
+ void B3DHomPoint::implHomogenize()
{
- void B3DHomPoint::implHomogenize()
- {
- const double fFactor(1.0 / mfW);
- maTuple.setX(maTuple.getX() * fFactor);
- maTuple.setY(maTuple.getY() * fFactor);
- maTuple.setZ(maTuple.getZ() * fFactor);
- mfW = 1.0;
- }
- } // end of namespace point
+ const double fFactor(1.0 / mfW);
+ maTuple.setX(maTuple.getX() * fFactor);
+ maTuple.setY(maTuple.getY() * fFactor);
+ maTuple.setZ(maTuple.getZ() * fFactor);
+ mfW = 1.0;
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/point/b3dpoint.cxx b/basegfx/source/point/b3dpoint.cxx
index 6d6471ffa07d..9ece7171af62 100644
--- a/basegfx/source/point/b3dpoint.cxx
+++ b/basegfx/source/point/b3dpoint.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dpoint.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:10 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -69,29 +69,26 @@
namespace basegfx
{
- namespace point
+ B3DPoint& B3DPoint::operator*=( const ::basegfx::B3DHomMatrix& rMat )
{
- B3DPoint& B3DPoint::operator*=( const ::basegfx::matrix::B3DHomMatrix& rMat )
- {
- const double fTempX(rMat.get(0,0)*mfX +
- rMat.get(0,1)*mfY +
- rMat.get(0,2)*mfZ +
- rMat.get(0,3));
- const double fTempY(rMat.get(1,0)*mfX +
- rMat.get(1,1)*mfY +
- rMat.get(1,2)*mfZ +
- rMat.get(1,3));
- const double fTempZ(rMat.get(2,0)*mfX +
- rMat.get(2,1)*mfY +
- rMat.get(2,2)*mfZ +
- rMat.get(2,3));
- mfX = fTempX;
- mfY = fTempY;
- mfZ = fTempZ;
+ const double fTempX(rMat.get(0,0)*mfX +
+ rMat.get(0,1)*mfY +
+ rMat.get(0,2)*mfZ +
+ rMat.get(0,3));
+ const double fTempY(rMat.get(1,0)*mfX +
+ rMat.get(1,1)*mfY +
+ rMat.get(1,2)*mfZ +
+ rMat.get(1,3));
+ const double fTempZ(rMat.get(2,0)*mfX +
+ rMat.get(2,1)*mfY +
+ rMat.get(2,2)*mfZ +
+ rMat.get(2,3));
+ mfX = fTempX;
+ mfY = fTempY;
+ mfZ = fTempZ;
- return *this;
- }
- } // end of namespace point
+ return *this;
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index 7a9b477081f5..0dcbeaa7a3a2 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolygon.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:10 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -86,17 +86,17 @@
class CoordinateData2D
{
- ::basegfx::point::B2DPoint maPoint;
+ ::basegfx::B2DPoint maPoint;
public:
CoordinateData2D() {}
- CoordinateData2D(const ::basegfx::point::B2DPoint& rData) : maPoint(rData) {}
+ CoordinateData2D(const ::basegfx::B2DPoint& rData) : maPoint(rData) {}
~CoordinateData2D() {}
- const ::basegfx::point::B2DPoint& getCoordinate() const { return maPoint; }
- void setCoordinate(const ::basegfx::point::B2DPoint& rValue) { if(rValue != maPoint) maPoint = rValue; }
+ const ::basegfx::B2DPoint& getCoordinate() const { return maPoint; }
+ void setCoordinate(const ::basegfx::B2DPoint& rValue) { if(rValue != maPoint) maPoint = rValue; }
sal_Bool operator==(const CoordinateData2D& rData ) const { return (maPoint == rData.getCoordinate()); }
- void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix) { maPoint *= rMatrix; }
+ void transform(const ::basegfx::B2DHomMatrix& rMatrix) { maPoint *= rMatrix; }
};
//////////////////////////////////////////////////////////////////////////////
@@ -137,12 +137,12 @@ public:
return (maVector == rCandidate.maVector);
}
- const ::basegfx::point::B2DPoint& getCoordinate(sal_uInt32 nIndex) const
+ const ::basegfx::B2DPoint& getCoordinate(sal_uInt32 nIndex) const
{
return maVector[nIndex].getCoordinate();
}
- void setCoordinate(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rValue)
+ void setCoordinate(sal_uInt32 nIndex, const ::basegfx::B2DPoint& rValue)
{
maVector[nIndex].setCoordinate(rValue);
}
@@ -233,7 +233,7 @@ public:
}
}
- void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix)
+ void transform(const ::basegfx::B2DHomMatrix& rMatrix)
{
CoordinateData2DVector::iterator aStart(maVector.begin());
CoordinateData2DVector::iterator aEnd(maVector.end());
@@ -249,18 +249,18 @@ public:
class ControlVectorPair2D
{
- ::basegfx::vector::B2DVector maVectorA;
- ::basegfx::vector::B2DVector maVectorB;
+ ::basegfx::B2DVector maVectorA;
+ ::basegfx::B2DVector maVectorB;
public:
ControlVectorPair2D() {}
~ControlVectorPair2D() {}
- const ::basegfx::vector::B2DVector& getVectorA() const { return maVectorA; }
- void setVectorA(const ::basegfx::vector::B2DVector& rValue) { if(rValue != maVectorA) maVectorA = rValue; }
+ const ::basegfx::B2DVector& getVectorA() const { return maVectorA; }
+ void setVectorA(const ::basegfx::B2DVector& rValue) { if(rValue != maVectorA) maVectorA = rValue; }
- const ::basegfx::vector::B2DVector& getVectorB() const { return maVectorB; }
- void setVectorB(const ::basegfx::vector::B2DVector& rValue) { if(rValue != maVectorB) maVectorB = rValue; }
+ const ::basegfx::B2DVector& getVectorB() const { return maVectorB; }
+ void setVectorB(const ::basegfx::B2DVector& rValue) { if(rValue != maVectorB) maVectorB = rValue; }
sal_Bool operator==(const ControlVectorPair2D& rData ) const
{ return (maVectorA == rData.getVectorA() && maVectorB == rData.getVectorB()); }
@@ -329,12 +329,12 @@ public:
return (0L != mnUsedVectors);
}
- const ::basegfx::vector::B2DVector& getVectorA(sal_uInt32 nIndex) const
+ const ::basegfx::B2DVector& getVectorA(sal_uInt32 nIndex) const
{
return maVector[nIndex].getVectorA();
}
- void setVectorA(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
+ void setVectorA(sal_uInt32 nIndex, const ::basegfx::B2DVector& rValue)
{
sal_Bool bWasUsed(mnUsedVectors && !maVector[nIndex].getVectorA().equalZero());
sal_Bool bIsUsed(!rValue.equalZero());
@@ -347,7 +347,7 @@ public:
}
else
{
- maVector[nIndex].setVectorA(::basegfx::vector::B2DVector::getEmptyVector());
+ maVector[nIndex].setVectorA(::basegfx::B2DVector::getEmptyVector());
mnUsedVectors--;
}
}
@@ -361,12 +361,12 @@ public:
}
}
- const ::basegfx::vector::B2DVector& getVectorB(sal_uInt32 nIndex) const
+ const ::basegfx::B2DVector& getVectorB(sal_uInt32 nIndex) const
{
return maVector[nIndex].getVectorB();
}
- void setVectorB(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
+ void setVectorB(sal_uInt32 nIndex, const ::basegfx::B2DVector& rValue)
{
sal_Bool bWasUsed(mnUsedVectors && !maVector[nIndex].getVectorB().equalZero());
sal_Bool bIsUsed(!rValue.equalZero());
@@ -379,7 +379,7 @@ public:
}
else
{
- maVector[nIndex].setVectorB(::basegfx::vector::B2DVector::getEmptyVector());
+ maVector[nIndex].setVectorB(::basegfx::B2DVector::getEmptyVector());
mnUsedVectors--;
}
}
@@ -601,17 +601,17 @@ public:
return sal_False;
}
- const ::basegfx::point::B2DPoint& getPoint(sal_uInt32 nIndex) const
+ const ::basegfx::B2DPoint& getPoint(sal_uInt32 nIndex) const
{
return maPoints.getCoordinate(nIndex);
}
- void setPoint(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rValue)
+ void setPoint(sal_uInt32 nIndex, const ::basegfx::B2DPoint& rValue)
{
maPoints.setCoordinate(nIndex, rValue);
}
- void insert(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount)
+ void insert(sal_uInt32 nIndex, const ::basegfx::B2DPoint& rPoint, sal_uInt32 nCount)
{
if(nCount)
{
@@ -626,7 +626,7 @@ public:
}
}
- const ::basegfx::vector::B2DVector& getControlVectorA(sal_uInt32 nIndex) const
+ const ::basegfx::B2DVector& getControlVectorA(sal_uInt32 nIndex) const
{
if(mpControlVector)
{
@@ -634,11 +634,11 @@ public:
}
else
{
- return ::basegfx::vector::B2DVector::getEmptyVector();
+ return ::basegfx::B2DVector::getEmptyVector();
}
}
- void setControlVectorA(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
+ void setControlVectorA(sal_uInt32 nIndex, const ::basegfx::B2DVector& rValue)
{
if(!mpControlVector)
{
@@ -665,7 +665,7 @@ public:
return (mpControlVector && mpControlVector->isUsed());
}
- const ::basegfx::vector::B2DVector& getControlVectorB(sal_uInt32 nIndex) const
+ const ::basegfx::B2DVector& getControlVectorB(sal_uInt32 nIndex) const
{
if(mpControlVector)
{
@@ -673,11 +673,11 @@ public:
}
else
{
- return ::basegfx::vector::B2DVector::getEmptyVector();
+ return ::basegfx::B2DVector::getEmptyVector();
}
}
- void setControlVectorB(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
+ void setControlVectorB(sal_uInt32 nIndex, const ::basegfx::B2DVector& rValue)
{
if(!mpControlVector)
{
@@ -775,10 +775,10 @@ public:
const sal_uInt32 nVectorSource(nCoorSource ? nCoorSource - 1L : nCount - 1L);
// get source data
- const ::basegfx::point::B2DPoint& rSourceCoor = pCoordinateCopy->getCoordinate(nCoorSource);
- const ::basegfx::point::B2DPoint& rVectorSourceCoor = pCoordinateCopy->getCoordinate(nVectorSource);
- const ::basegfx::vector::B2DVector& rVectorSourceA = pVectorCopy->getVectorA(nVectorSource);
- const ::basegfx::vector::B2DVector& rVectorSourceB = pVectorCopy->getVectorB(nVectorSource);
+ const ::basegfx::B2DPoint& rSourceCoor = pCoordinateCopy->getCoordinate(nCoorSource);
+ const ::basegfx::B2DPoint& rVectorSourceCoor = pCoordinateCopy->getCoordinate(nVectorSource);
+ const ::basegfx::B2DVector& rVectorSourceA = pVectorCopy->getVectorA(nVectorSource);
+ const ::basegfx::B2DVector& rVectorSourceB = pVectorCopy->getVectorB(nVectorSource);
// copy point data
maPoints.setCoordinate(a, rSourceCoor);
@@ -787,12 +787,12 @@ public:
if(rVectorSourceA.equalZero())
{
// unused, use zero vector
- mpControlVector->setVectorB(a, ::basegfx::vector::B2DVector::getEmptyVector());
+ mpControlVector->setVectorB(a, ::basegfx::B2DVector::getEmptyVector());
}
else
{
// calculate new vector relative to new point
- ::basegfx::vector::B2DVector aNewVectorB((rVectorSourceA + rVectorSourceCoor) - rSourceCoor);
+ ::basegfx::B2DVector aNewVectorB((rVectorSourceA + rVectorSourceCoor) - rSourceCoor);
mpControlVector->setVectorB(a, aNewVectorB);
}
@@ -800,12 +800,12 @@ public:
if(rVectorSourceB.equalZero())
{
// unused, use zero vector
- mpControlVector->setVectorA(a, ::basegfx::vector::B2DVector::getEmptyVector());
+ mpControlVector->setVectorA(a, ::basegfx::B2DVector::getEmptyVector());
}
else
{
// calculate new vector relative to new point
- ::basegfx::vector::B2DVector aNewVectorA((rVectorSourceB + rVectorSourceCoor) - rSourceCoor);
+ ::basegfx::B2DVector aNewVectorA((rVectorSourceB + rVectorSourceCoor) - rSourceCoor);
mpControlVector->setVectorA(a, aNewVectorA);
}
}
@@ -939,28 +939,28 @@ public:
}
}
- void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix)
+ void transform(const ::basegfx::B2DHomMatrix& rMatrix)
{
if(mpControlVector)
{
for(sal_uInt32 a(0L); a < maPoints.count(); a++)
{
- ::basegfx::point::B2DPoint aCandidate = maPoints.getCoordinate(a);
+ ::basegfx::B2DPoint aCandidate = maPoints.getCoordinate(a);
if(mpControlVector->isUsed())
{
- const ::basegfx::vector::B2DVector& rVectorA(mpControlVector->getVectorA(a));
- const ::basegfx::vector::B2DVector& rVectorB(mpControlVector->getVectorB(a));
+ const ::basegfx::B2DVector& rVectorA(mpControlVector->getVectorA(a));
+ const ::basegfx::B2DVector& rVectorB(mpControlVector->getVectorB(a));
if(!rVectorA.equalZero())
{
- ::basegfx::vector::B2DVector aVectorA(rMatrix * rVectorA);
+ ::basegfx::B2DVector aVectorA(rMatrix * rVectorA);
mpControlVector->setVectorA(a, aVectorA);
}
if(!rVectorB.equalZero())
{
- ::basegfx::vector::B2DVector aVectorB(rMatrix * rVectorB);
+ ::basegfx::B2DVector aVectorB(rMatrix * rVectorB);
mpControlVector->setVectorB(a, aVectorB);
}
}
@@ -986,294 +986,291 @@ public:
namespace basegfx
{
- namespace polygon
- {
- // init static default Polygon
- static ImplB2DPolygon maStaticDefaultPolygon;
+ // init static default Polygon
+ static ImplB2DPolygon maStaticDefaultPolygon;
- void B2DPolygon::implForceUniqueCopy()
+ void B2DPolygon::implForceUniqueCopy()
+ {
+ if(mpPolygon->getRefCount())
{
- if(mpPolygon->getRefCount())
- {
- mpPolygon->decRefCount();
- mpPolygon = new ImplB2DPolygon(*mpPolygon);
- }
+ mpPolygon->decRefCount();
+ mpPolygon = new ImplB2DPolygon(*mpPolygon);
}
+ }
- B2DPolygon::B2DPolygon()
- : mpPolygon(&maStaticDefaultPolygon)
- {
- mpPolygon->incRefCount();
- }
+ B2DPolygon::B2DPolygon()
+ : mpPolygon(&maStaticDefaultPolygon)
+ {
+ mpPolygon->incRefCount();
+ }
+
+ B2DPolygon::B2DPolygon(const B2DPolygon& rPolygon)
+ : mpPolygon(rPolygon.mpPolygon)
+ {
+ mpPolygon->incRefCount();
+ }
+
+ B2DPolygon::B2DPolygon(const B2DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 nCount)
+ : mpPolygon(new ImplB2DPolygon(*rPolygon.mpPolygon, nIndex, nCount))
+ {
+ OSL_ENSURE(nIndex + nCount > rPolygon.mpPolygon->count(), "B2DPolygon constructor outside range (!)");
+ }
- B2DPolygon::B2DPolygon(const B2DPolygon& rPolygon)
- : mpPolygon(rPolygon.mpPolygon)
+ B2DPolygon::~B2DPolygon()
+ {
+ if(mpPolygon->getRefCount())
{
- mpPolygon->incRefCount();
+ mpPolygon->decRefCount();
}
-
- B2DPolygon::B2DPolygon(const B2DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 nCount)
- : mpPolygon(new ImplB2DPolygon(*rPolygon.mpPolygon, nIndex, nCount))
+ else
{
- OSL_ENSURE(nIndex + nCount > rPolygon.mpPolygon->count(), "B2DPolygon constructor outside range (!)");
+ delete mpPolygon;
}
+ }
- B2DPolygon::~B2DPolygon()
+ B2DPolygon& B2DPolygon::operator=(const B2DPolygon& rPolygon)
+ {
+ if(mpPolygon->getRefCount())
{
- if(mpPolygon->getRefCount())
- {
- mpPolygon->decRefCount();
- }
- else
- {
- delete mpPolygon;
- }
+ mpPolygon->decRefCount();
}
-
- B2DPolygon& B2DPolygon::operator=(const B2DPolygon& rPolygon)
+ else
{
- if(mpPolygon->getRefCount())
- {
- mpPolygon->decRefCount();
- }
- else
- {
- delete mpPolygon;
- }
-
- mpPolygon = rPolygon.mpPolygon;
- mpPolygon->incRefCount();
-
- return *this;
+ delete mpPolygon;
}
- sal_Bool B2DPolygon::operator==(const B2DPolygon& rPolygon) const
- {
- if(mpPolygon == rPolygon.mpPolygon)
- {
- return sal_True;
- }
+ mpPolygon = rPolygon.mpPolygon;
+ mpPolygon->incRefCount();
- return mpPolygon->isEqual(*(rPolygon.mpPolygon));
- }
+ return *this;
+ }
- sal_Bool B2DPolygon::operator!=(const B2DPolygon& rPolygon) const
+ sal_Bool B2DPolygon::operator==(const B2DPolygon& rPolygon) const
+ {
+ if(mpPolygon == rPolygon.mpPolygon)
{
- if(mpPolygon == rPolygon.mpPolygon)
- {
- return sal_False;
- }
-
- return !mpPolygon->isEqual(*(rPolygon.mpPolygon));
+ return sal_True;
}
- sal_uInt32 B2DPolygon::count() const
+ return mpPolygon->isEqual(*(rPolygon.mpPolygon));
+ }
+
+ sal_Bool B2DPolygon::operator!=(const B2DPolygon& rPolygon) const
+ {
+ if(mpPolygon == rPolygon.mpPolygon)
{
- return mpPolygon->count();
+ return sal_False;
}
- ::basegfx::point::B2DPoint B2DPolygon::getB2DPoint(sal_uInt32 nIndex) const
- {
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
+ return !mpPolygon->isEqual(*(rPolygon.mpPolygon));
+ }
- return mpPolygon->getPoint(nIndex);
- }
+ sal_uInt32 B2DPolygon::count() const
+ {
+ return mpPolygon->count();
+ }
- void B2DPolygon::setB2DPoint(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rValue)
- {
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
+ ::basegfx::B2DPoint B2DPolygon::getB2DPoint(sal_uInt32 nIndex) const
+ {
+ OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- if(mpPolygon->getPoint(nIndex) != rValue)
- {
- implForceUniqueCopy();
- mpPolygon->setPoint(nIndex, rValue);
- }
- }
+ return mpPolygon->getPoint(nIndex);
+ }
- void B2DPolygon::insert(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount)
- {
- OSL_ENSURE(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)");
+ void B2DPolygon::setB2DPoint(sal_uInt32 nIndex, const ::basegfx::B2DPoint& rValue)
+ {
+ OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- if(nCount)
- {
- implForceUniqueCopy();
- mpPolygon->insert(nIndex, rPoint, nCount);
- }
+ if(mpPolygon->getPoint(nIndex) != rValue)
+ {
+ implForceUniqueCopy();
+ mpPolygon->setPoint(nIndex, rValue);
}
+ }
+
+ void B2DPolygon::insert(sal_uInt32 nIndex, const ::basegfx::B2DPoint& rPoint, sal_uInt32 nCount)
+ {
+ OSL_ENSURE(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)");
- void B2DPolygon::append(const ::basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount)
+ if(nCount)
{
- if(nCount)
- {
- implForceUniqueCopy();
- mpPolygon->insert(mpPolygon->count(), rPoint, nCount);
- }
+ implForceUniqueCopy();
+ mpPolygon->insert(nIndex, rPoint, nCount);
}
+ }
- ::basegfx::vector::B2DVector B2DPolygon::getControlVectorA(sal_uInt32 nIndex) const
+ void B2DPolygon::append(const ::basegfx::B2DPoint& rPoint, sal_uInt32 nCount)
+ {
+ if(nCount)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
-
- return mpPolygon->getControlVectorA(nIndex);
+ implForceUniqueCopy();
+ mpPolygon->insert(mpPolygon->count(), rPoint, nCount);
}
+ }
- void B2DPolygon::setControlVectorA(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
- {
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
+ ::basegfx::B2DVector B2DPolygon::getControlVectorA(sal_uInt32 nIndex) const
+ {
+ OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- if(mpPolygon->getControlVectorA(nIndex) != rValue)
- {
- implForceUniqueCopy();
- mpPolygon->setControlVectorA(nIndex, rValue);
- }
- }
+ return mpPolygon->getControlVectorA(nIndex);
+ }
- ::basegfx::vector::B2DVector B2DPolygon::getControlVectorB(sal_uInt32 nIndex) const
- {
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
+ void B2DPolygon::setControlVectorA(sal_uInt32 nIndex, const ::basegfx::B2DVector& rValue)
+ {
+ OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- return mpPolygon->getControlVectorB(nIndex);
+ if(mpPolygon->getControlVectorA(nIndex) != rValue)
+ {
+ implForceUniqueCopy();
+ mpPolygon->setControlVectorA(nIndex, rValue);
}
+ }
- void B2DPolygon::setControlVectorB(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
- {
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
+ ::basegfx::B2DVector B2DPolygon::getControlVectorB(sal_uInt32 nIndex) const
+ {
+ OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- if(mpPolygon->getControlVectorB(nIndex) != rValue)
- {
- implForceUniqueCopy();
- mpPolygon->setControlVectorB(nIndex, rValue);
- }
- }
+ return mpPolygon->getControlVectorB(nIndex);
+ }
- sal_Bool B2DPolygon::areControlPointsUsed() const
+ void B2DPolygon::setControlVectorB(sal_uInt32 nIndex, const ::basegfx::B2DVector& rValue)
+ {
+ OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
+
+ if(mpPolygon->getControlVectorB(nIndex) != rValue)
{
- return mpPolygon->areControlPointsUsed();
+ implForceUniqueCopy();
+ mpPolygon->setControlVectorB(nIndex, rValue);
}
+ }
- void B2DPolygon::insert(sal_uInt32 nIndex, const B2DPolygon& rPoly, sal_uInt32 nIndex2, sal_uInt32 nCount)
- {
- OSL_ENSURE(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)");
+ sal_Bool B2DPolygon::areControlPointsUsed() const
+ {
+ return mpPolygon->areControlPointsUsed();
+ }
- if(rPoly.count())
- {
- implForceUniqueCopy();
+ void B2DPolygon::insert(sal_uInt32 nIndex, const B2DPolygon& rPoly, sal_uInt32 nIndex2, sal_uInt32 nCount)
+ {
+ OSL_ENSURE(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)");
- if(!nCount)
- {
- nCount = rPoly.count();
- }
+ if(rPoly.count())
+ {
+ implForceUniqueCopy();
- if(0L == nIndex2 && nCount == rPoly.count())
- {
- mpPolygon->insert(nIndex, *rPoly.mpPolygon);
- }
- else
- {
- OSL_ENSURE(nIndex2 + nCount > rPoly.mpPolygon->count(), "B2DPolygon Insert outside range (!)");
- ImplB2DPolygon aTempPoly(*rPoly.mpPolygon, nIndex2, nCount);
- mpPolygon->insert(nIndex, aTempPoly);
- }
+ if(!nCount)
+ {
+ nCount = rPoly.count();
}
- }
- void B2DPolygon::append(const B2DPolygon& rPoly, sal_uInt32 nIndex, sal_uInt32 nCount)
- {
- if(rPoly.count())
+ if(0L == nIndex2 && nCount == rPoly.count())
{
- implForceUniqueCopy();
-
- if(!nCount)
- {
- nCount = rPoly.count();
- }
-
- if(0L == nIndex && nCount == rPoly.count())
- {
- mpPolygon->insert(mpPolygon->count(), *rPoly.mpPolygon);
- }
- else
- {
- OSL_ENSURE(nIndex + nCount > rPoly.mpPolygon->count(), "B2DPolygon Append outside range (!)");
- ImplB2DPolygon aTempPoly(*rPoly.mpPolygon, nIndex, nCount);
- mpPolygon->insert(mpPolygon->count(), aTempPoly);
- }
+ mpPolygon->insert(nIndex, *rPoly.mpPolygon);
+ }
+ else
+ {
+ OSL_ENSURE(nIndex2 + nCount > rPoly.mpPolygon->count(), "B2DPolygon Insert outside range (!)");
+ ImplB2DPolygon aTempPoly(*rPoly.mpPolygon, nIndex2, nCount);
+ mpPolygon->insert(nIndex, aTempPoly);
}
}
+ }
- void B2DPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
+ void B2DPolygon::append(const B2DPolygon& rPoly, sal_uInt32 nIndex, sal_uInt32 nCount)
+ {
+ if(rPoly.count())
{
- OSL_ENSURE(nIndex + nCount <= mpPolygon->count(), "B2DPolygon Remove outside range (!)");
+ implForceUniqueCopy();
- if(nCount)
+ if(!nCount)
{
- implForceUniqueCopy();
- mpPolygon->remove(nIndex, nCount);
+ nCount = rPoly.count();
}
- }
- void B2DPolygon::clear()
- {
- if(mpPolygon->getRefCount())
+ if(0L == nIndex && nCount == rPoly.count())
{
- mpPolygon->decRefCount();
+ mpPolygon->insert(mpPolygon->count(), *rPoly.mpPolygon);
}
else
{
- delete mpPolygon;
+ OSL_ENSURE(nIndex + nCount > rPoly.mpPolygon->count(), "B2DPolygon Append outside range (!)");
+ ImplB2DPolygon aTempPoly(*rPoly.mpPolygon, nIndex, nCount);
+ mpPolygon->insert(mpPolygon->count(), aTempPoly);
}
-
- mpPolygon = &maStaticDefaultPolygon;
- mpPolygon->incRefCount();
}
+ }
- sal_Bool B2DPolygon::isClosed() const
+ void B2DPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
+ {
+ OSL_ENSURE(nIndex + nCount <= mpPolygon->count(), "B2DPolygon Remove outside range (!)");
+
+ if(nCount)
{
- return mpPolygon->isClosed();
+ implForceUniqueCopy();
+ mpPolygon->remove(nIndex, nCount);
}
+ }
- void B2DPolygon::setClosed(sal_Bool bNew)
+ void B2DPolygon::clear()
+ {
+ if(mpPolygon->getRefCount())
{
- if(mpPolygon->isClosed() != bNew)
- {
- implForceUniqueCopy();
- mpPolygon->setClosed(bNew);
- }
+ mpPolygon->decRefCount();
+ }
+ else
+ {
+ delete mpPolygon;
}
- void B2DPolygon::flip()
+ mpPolygon = &maStaticDefaultPolygon;
+ mpPolygon->incRefCount();
+ }
+
+ sal_Bool B2DPolygon::isClosed() const
+ {
+ return mpPolygon->isClosed();
+ }
+
+ void B2DPolygon::setClosed(sal_Bool bNew)
+ {
+ if(mpPolygon->isClosed() != bNew)
{
- if(mpPolygon->count() > 1)
- {
- implForceUniqueCopy();
- mpPolygon->flip();
- }
+ implForceUniqueCopy();
+ mpPolygon->setClosed(bNew);
}
+ }
- sal_Bool B2DPolygon::hasDoublePoints() const
+ void B2DPolygon::flip()
+ {
+ if(mpPolygon->count() > 1)
{
- return mpPolygon->hasDoublePoints();
+ implForceUniqueCopy();
+ mpPolygon->flip();
}
+ }
- void B2DPolygon::removeDoublePoints()
+ sal_Bool B2DPolygon::hasDoublePoints() const
+ {
+ return mpPolygon->hasDoublePoints();
+ }
+
+ void B2DPolygon::removeDoublePoints()
+ {
+ if(mpPolygon->count() > 1)
{
- if(mpPolygon->count() > 1)
- {
- implForceUniqueCopy();
- mpPolygon->removeDoublePointsAtBeginEnd();
- mpPolygon->removeDoublePointsWholeTrack();
- }
+ implForceUniqueCopy();
+ mpPolygon->removeDoublePointsAtBeginEnd();
+ mpPolygon->removeDoublePointsWholeTrack();
}
+ }
- void B2DPolygon::transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix)
+ void B2DPolygon::transform(const ::basegfx::B2DHomMatrix& rMatrix)
+ {
+ if(mpPolygon->count())
{
- if(mpPolygon->count())
- {
- implForceUniqueCopy();
- mpPolygon->transform(rMatrix);
- }
+ implForceUniqueCopy();
+ mpPolygon->transform(rMatrix);
}
- } // end of namespace polygon
+ }
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index c2a6faf8909a..6f5ef6e89fba 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolygontools.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:11 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,6 +71,10 @@
#include <basegfx/polygon/b2dpolygon.hxx>
#endif
+#ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#endif
+
#ifndef _BGFX_NUMERIC_FTOOLS_HXX
#include <basegfx/numeric/ftools.hxx>
#endif
@@ -91,925 +95,993 @@
namespace basegfx
{
- namespace polygon
+ namespace tools
{
- namespace tools
+ // B2DPolygon tools
+ void checkClosed(B2DPolygon& rCandidate)
{
- // B2DPolygon tools
- void checkClosed(polygon::B2DPolygon& rCandidate)
+ while(rCandidate.count() > 1L
+ && rCandidate.getB2DPoint(0L).equal(rCandidate.getB2DPoint(rCandidate.count() - 1L)))
{
- while(rCandidate.count() > 1L
- && rCandidate.getB2DPoint(0L).equal(rCandidate.getB2DPoint(rCandidate.count() - 1L)))
- {
- rCandidate.setClosed(sal_True);
- rCandidate.remove(rCandidate.count() - 1L);
- }
+ rCandidate.setClosed(sal_True);
+ rCandidate.remove(rCandidate.count() - 1L);
}
+ }
+
+ // Get index of outmost point (e.g. biggest X and biggest Y)
+ sal_uInt32 getIndexOfOutmostPoint(const ::basegfx::B2DPolygon& rCandidate)
+ {
+ sal_uInt32 nRetval(0L);
- // Get index of outmost point (e.g. biggest X and biggest Y)
- sal_uInt32 getIndexOfOutmostPoint(const ::basegfx::polygon::B2DPolygon& rCandidate)
+ if(rCandidate.count())
{
- sal_uInt32 nRetval(0L);
+ ::basegfx::B2DPoint aOutmostPoint(rCandidate.getB2DPoint(0L));
- if(rCandidate.count())
+ for(sal_uInt32 a(1L); a < rCandidate.count(); a++)
{
- ::basegfx::point::B2DPoint aOutmostPoint(rCandidate.getB2DPoint(0L));
+ ::basegfx::B2DPoint rPoint(rCandidate.getB2DPoint(a));
- for(sal_uInt32 a(1L); a < rCandidate.count(); a++)
+ if(::basegfx::fTools::more(rPoint.getX(), aOutmostPoint.getX()))
{
- ::basegfx::point::B2DPoint rPoint(rCandidate.getB2DPoint(a));
-
- if(::basegfx::numeric::fTools::more(rPoint.getX(), aOutmostPoint.getX()))
+ nRetval = a;
+ aOutmostPoint = rPoint;
+ }
+ else
+ {
+ if(::basegfx::fTools::more(rPoint.getY(), aOutmostPoint.getY()))
{
nRetval = a;
aOutmostPoint = rPoint;
}
- else
- {
- if(::basegfx::numeric::fTools::more(rPoint.getY(), aOutmostPoint.getY()))
- {
- nRetval = a;
- aOutmostPoint = rPoint;
- }
- }
}
}
-
- return nRetval;
}
- // 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)
- {
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+ return nRetval;
+ }
- if(nIndex)
- {
- return nIndex - 1L;
- }
- else if(rCandidate.count())
- {
- return rCandidate.count() - 1L;
- }
- else
- {
- return nIndex;
- }
- }
+ // 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)
+ {
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
- sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate)
+ if(nIndex)
{
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
-
- if(nIndex + 1L < rCandidate.count())
- {
- return nIndex + 1L;
- }
- else
- {
- return 0L;
- }
+ return nIndex - 1L;
}
-
- sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate)
+ else if(rCandidate.count())
{
- sal_uInt32 nNewIndex(nIndex);
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
-
- if(rCandidate.count() > 1)
- {
- nNewIndex = getIndexOfPredecessor(nIndex, rCandidate);
- ::basegfx::point::B2DPoint aPoint(rCandidate.getB2DPoint(nIndex));
+ return rCandidate.count() - 1L;
+ }
+ else
+ {
+ return nIndex;
+ }
+ }
- while(nNewIndex != nIndex
- && aPoint.equal(rCandidate.getB2DPoint(nNewIndex)))
- {
- nNewIndex = getIndexOfPredecessor(nNewIndex, rCandidate);
- }
- }
+ sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rCandidate)
+ {
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
- return nNewIndex;
+ if(nIndex + 1L < rCandidate.count())
+ {
+ return nIndex + 1L;
}
+ else
+ {
+ return 0L;
+ }
+ }
+
+ sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rCandidate)
+ {
+ sal_uInt32 nNewIndex(nIndex);
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
- sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate)
+ if(rCandidate.count() > 1)
{
- sal_uInt32 nNewIndex(nIndex);
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+ nNewIndex = getIndexOfPredecessor(nIndex, rCandidate);
+ ::basegfx::B2DPoint aPoint(rCandidate.getB2DPoint(nIndex));
- if(rCandidate.count() > 1)
+ while(nNewIndex != nIndex
+ && aPoint.equal(rCandidate.getB2DPoint(nNewIndex)))
{
- nNewIndex = getIndexOfSuccessor(nIndex, rCandidate);
- ::basegfx::point::B2DPoint aPoint(rCandidate.getB2DPoint(nIndex));
-
- while(nNewIndex != nIndex
- && aPoint.equal(rCandidate.getB2DPoint(nNewIndex)))
- {
- nNewIndex = getIndexOfSuccessor(nNewIndex, rCandidate);
- }
+ nNewIndex = getIndexOfPredecessor(nNewIndex, rCandidate);
}
-
- return nNewIndex;
}
- ::basegfx::vector::B2DVectorOrientation getOrientation(const ::basegfx::polygon::B2DPolygon& rCandidate)
+ return nNewIndex;
+ }
+
+ sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rCandidate)
+ {
+ sal_uInt32 nNewIndex(nIndex);
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+
+ if(rCandidate.count() > 1)
{
- ::basegfx::vector::B2DVectorOrientation eRetval(::basegfx::vector::ORIENTATION_NEUTRAL);
+ nNewIndex = getIndexOfSuccessor(nIndex, rCandidate);
+ ::basegfx::B2DPoint aPoint(rCandidate.getB2DPoint(nIndex));
- if(rCandidate.count() > 2)
+ while(nNewIndex != nIndex
+ && aPoint.equal(rCandidate.getB2DPoint(nNewIndex)))
{
- sal_uInt32 nIndex = getIndexOfOutmostPoint(rCandidate);
- eRetval = getPointOrientation(rCandidate, nIndex);
+ nNewIndex = getIndexOfSuccessor(nNewIndex, rCandidate);
}
-
- return eRetval;
}
- ::basegfx::vector::B2DVectorContinuity getContinuityInPoint(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex)
+ return nNewIndex;
+ }
+
+ ::basegfx::B2DVectorOrientation getOrientation(const ::basegfx::B2DPolygon& rCandidate)
+ {
+ ::basegfx::B2DVectorOrientation eRetval(::basegfx::ORIENTATION_NEUTRAL);
+
+ if(rCandidate.count() > 2)
{
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
- ::basegfx::vector::B2DVectorContinuity eRetval(::basegfx::vector::CONTINUITY_NONE);
+ sal_uInt32 nIndex = getIndexOfOutmostPoint(rCandidate);
+ eRetval = getPointOrientation(rCandidate, nIndex);
+ }
- if(rCandidate.count() > 1L && rCandidate.areControlPointsUsed())
- {
- sal_uInt32 nPrevInd(getIndexOfPredecessor(nIndex, rCandidate));
- const ::basegfx::vector::B2DVector aForwardVector(rCandidate.getControlVectorA(nIndex));
- const ::basegfx::vector::B2DVector aBackVector(rCandidate.getControlVectorB(nPrevInd));
+ return eRetval;
+ }
- eRetval = ::basegfx::vector::getContinuity(aBackVector, aForwardVector);
- }
+ ::basegfx::B2DVectorContinuity getContinuityInPoint(const ::basegfx::B2DPolygon& rCandidate, sal_uInt32 nIndex)
+ {
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+ ::basegfx::B2DVectorContinuity eRetval(::basegfx::CONTINUITY_NONE);
+
+ if(rCandidate.count() > 1L && rCandidate.areControlPointsUsed())
+ {
+ sal_uInt32 nPrevInd(getIndexOfPredecessor(nIndex, rCandidate));
+ const ::basegfx::B2DVector aForwardVector(rCandidate.getControlVectorA(nIndex));
+ const ::basegfx::B2DVector aBackVector(rCandidate.getControlVectorB(nPrevInd));
- return eRetval;
+ eRetval = ::basegfx::getContinuity(aBackVector, aForwardVector);
}
- ::basegfx::polygon::B2DPolygon adaptiveSubdivideByDistance(const ::basegfx::polygon::B2DPolygon& rCandidate, double fDistanceBound)
+ return eRetval;
+ }
+
+ ::basegfx::B2DPolygon adaptiveSubdivideByDistance(const ::basegfx::B2DPolygon& rCandidate, double fDistanceBound)
+ {
+ ::basegfx::B2DPolygon aRetval(rCandidate);
+
+ if(aRetval.areControlPointsUsed())
{
- ::basegfx::polygon::B2DPolygon aRetval(rCandidate);
+ const sal_uInt32 nPointCount(rCandidate.isClosed() ? rCandidate.count() : rCandidate.count() - 1L);
+ aRetval.clear();
- if(aRetval.areControlPointsUsed())
+ for(sal_uInt32 a(0L); a < nPointCount; a++)
{
- const sal_uInt32 nPointCount(rCandidate.isClosed() ? rCandidate.count() : rCandidate.count() - 1L);
- aRetval.clear();
+ const ::basegfx::B2DVector aVectorA(rCandidate.getControlVectorA(a));
+ const ::basegfx::B2DVector aVectorB(rCandidate.getControlVectorB(a));
- for(sal_uInt32 a(0L); a < nPointCount; a++)
+ if(!aVectorA.equalZero() || !aVectorB.equalZero())
{
- const ::basegfx::vector::B2DVector aVectorA(rCandidate.getControlVectorA(a));
- const ::basegfx::vector::B2DVector aVectorB(rCandidate.getControlVectorB(a));
-
- if(!aVectorA.equalZero() || !aVectorB.equalZero())
- {
- // vectors are used, get points
- const sal_uInt32 nNext(getIndexOfSuccessor(a, rCandidate));
- ::basegfx::point::B2DPoint aPointA(rCandidate.getB2DPoint(a));
- ::basegfx::point::B2DPoint aPointB(rCandidate.getB2DPoint(nNext));
-
- // build CubicBezier segment
- ::basegfx::curve::B2DCubicBezier aBezier(
- aPointA, aPointA + aVectorA, aPointB + aVectorB, aPointB);
-
- // generate DistanceBound
- double fBound;
+ // vectors are used, get points
+ const sal_uInt32 nNext(getIndexOfSuccessor(a, rCandidate));
+ ::basegfx::B2DPoint aPointA(rCandidate.getB2DPoint(a));
+ ::basegfx::B2DPoint aPointB(rCandidate.getB2DPoint(nNext));
- if(0.0 == fDistanceBound)
- {
- // If not set, calculate rough length of bezier segment by taking
- // half of the sum of the edge and the control polygon
- ::basegfx::vector::B2DVector aSimpleDistance(aPointB - aPointA);
- ::basegfx::vector::B2DVector aTripleDistanceTop((aPointB + aVectorB) - (aPointA + aVectorA));
- const double fRoughLength(
- (aSimpleDistance.getLength()
- + (aVectorA.getLength() + aVectorB.getLength() + aTripleDistanceTop.getLength())) / 2.0);
-
- // take 1/100th of the rouch curve length
- fBound = fRoughLength * 0.01;
- }
- else
- {
- // use given bound value
- fBound = fDistanceBound;
- }
+ // build CubicBezier segment
+ ::basegfx::B2DCubicBezier aBezier(
+ aPointA, aPointA + aVectorA, aPointB + aVectorB, aPointB);
- // make sure bound value is not too small. The base units are 1/100th mm, thus
- // just make sure it's not smaller then 1/100th of that
- if(fBound < 0.01)
- {
- fBound = 0.01;
- }
+ // generate DistanceBound
+ double fBound;
- // call adaptive subdivide
- ::basegfx::curve::adaptiveSubdivideByDistance(aRetval, aBezier, fBound);
+ if(0.0 == fDistanceBound)
+ {
+ // If not set, calculate rough length of bezier segment by taking
+ // half of the sum of the edge and the control polygon
+ ::basegfx::B2DVector aSimpleDistance(aPointB - aPointA);
+ ::basegfx::B2DVector aTripleDistanceTop((aPointB + aVectorB) - (aPointA + aVectorA));
+ const double fRoughLength(
+ (aSimpleDistance.getLength()
+ + (aVectorA.getLength() + aVectorB.getLength() + aTripleDistanceTop.getLength())) / 2.0);
+
+ // take 1/100th of the rouch curve length
+ fBound = fRoughLength * 0.01;
}
else
{
- // no vectors used, add point
- aRetval.append(rCandidate.getB2DPoint(a));
+ // use given bound value
+ fBound = fDistanceBound;
+ }
+
+ // make sure bound value is not too small. The base units are 1/100th mm, thus
+ // just make sure it's not smaller then 1/100th of that
+ if(fBound < 0.01)
+ {
+ fBound = 0.01;
}
- }
- // check closed flag, aRetval was cleared and thus it may be invalid.
- if(aRetval.isClosed() != rCandidate.isClosed())
+ // call adaptive subdivide
+ ::basegfx::adaptiveSubdivideByDistance(aRetval, aBezier, fBound);
+ }
+ else
{
- aRetval.setClosed(rCandidate.isClosed());
+ // no vectors used, add point
+ aRetval.append(rCandidate.getB2DPoint(a));
}
}
- return aRetval;
+ // check closed flag, aRetval was cleared and thus it may be invalid.
+ if(aRetval.isClosed() != rCandidate.isClosed())
+ {
+ aRetval.setClosed(rCandidate.isClosed());
+ }
}
- ::basegfx::polygon::B2DPolygon adaptiveSubdivideByAngle(const ::basegfx::polygon::B2DPolygon& rCandidate, double fAngleBound)
+ return aRetval;
+ }
+
+ ::basegfx::B2DPolygon adaptiveSubdivideByAngle(const ::basegfx::B2DPolygon& rCandidate, double fAngleBound)
+ {
+ ::basegfx::B2DPolygon aRetval(rCandidate);
+
+ if(aRetval.areControlPointsUsed())
{
- ::basegfx::polygon::B2DPolygon aRetval(rCandidate);
+ const sal_uInt32 nPointCount(rCandidate.isClosed() ? rCandidate.count() : rCandidate.count() - 1L);
+ aRetval.clear();
- if(aRetval.areControlPointsUsed())
+ for(sal_uInt32 a(0L); a < nPointCount; a++)
{
- const sal_uInt32 nPointCount(rCandidate.isClosed() ? rCandidate.count() : rCandidate.count() - 1L);
- aRetval.clear();
+ const ::basegfx::B2DVector aVectorA(rCandidate.getControlVectorA(a));
+ const ::basegfx::B2DVector aVectorB(rCandidate.getControlVectorB(a));
- for(sal_uInt32 a(0L); a < nPointCount; a++)
+ if(!aVectorA.equalZero() || !aVectorB.equalZero())
{
- const ::basegfx::vector::B2DVector aVectorA(rCandidate.getControlVectorA(a));
- const ::basegfx::vector::B2DVector aVectorB(rCandidate.getControlVectorB(a));
-
- if(!aVectorA.equalZero() || !aVectorB.equalZero())
- {
- // vectors are used, get points
- const sal_uInt32 nNext(getIndexOfSuccessor(a, rCandidate));
- ::basegfx::point::B2DPoint aPointA(rCandidate.getB2DPoint(a));
- ::basegfx::point::B2DPoint aPointB(rCandidate.getB2DPoint(nNext));
+ // vectors are used, get points
+ const sal_uInt32 nNext(getIndexOfSuccessor(a, rCandidate));
+ ::basegfx::B2DPoint aPointA(rCandidate.getB2DPoint(a));
+ ::basegfx::B2DPoint aPointB(rCandidate.getB2DPoint(nNext));
- // build CubicBezier segment
- ::basegfx::curve::B2DCubicBezier aBezier(
- aPointA, aPointA + aVectorA, aPointB + aVectorB, aPointB);
+ // build CubicBezier segment
+ ::basegfx::B2DCubicBezier aBezier(
+ aPointA, aPointA + aVectorA, aPointB + aVectorB, aPointB);
- // generate AngleBound
- double fBound(fAngleBound);
+ // generate AngleBound
+ double fBound(fAngleBound);
- // make sure angle bound is not too small
- if(::basegfx::numeric::fTools::less(fAngleBound, 0.1))
- {
- fAngleBound = 0.1;
- }
-
- // call adaptive subdivide
- ::basegfx::curve::adaptiveSubdivideByAngle(aRetval, aBezier, fBound);
- }
- else
+ // make sure angle bound is not too small
+ if(::basegfx::fTools::less(fAngleBound, 0.1))
{
- // no vectors used, add point
- aRetval.append(rCandidate.getB2DPoint(a));
+ fAngleBound = 0.1;
}
- }
- // check closed flag, aRetval was cleared and thus it may be invalid.
- if(aRetval.isClosed() != rCandidate.isClosed())
+ // call adaptive subdivide
+ ::basegfx::adaptiveSubdivideByAngle(aRetval, aBezier, fBound);
+ }
+ else
{
- aRetval.setClosed(rCandidate.isClosed());
+ // no vectors used, add point
+ aRetval.append(rCandidate.getB2DPoint(a));
}
}
- return aRetval;
+ // check closed flag, aRetval was cleared and thus it may be invalid.
+ if(aRetval.isClosed() != rCandidate.isClosed())
+ {
+ aRetval.setClosed(rCandidate.isClosed());
+ }
}
- sal_Bool isInside(const ::basegfx::polygon::B2DPolygon& rCandidate, const ::basegfx::point::B2DPoint& rPoint, sal_Bool bWithBorder)
+ return aRetval;
+ }
+
+ sal_Bool isInside(const ::basegfx::B2DPolygon& rCandidate, const ::basegfx::B2DPoint& rPoint, sal_Bool bWithBorder)
+ {
+ sal_Bool bRetval(sal_False);
+ const sal_uInt32 nPointCount(rCandidate.count());
+
+ for(sal_uInt32 a(0L); a < nPointCount; a++)
{
- sal_Bool bRetval(sal_False);
- const sal_uInt32 nPointCount(rCandidate.count());
+ const ::basegfx::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
- for(sal_uInt32 a(0L); a < nPointCount; a++)
+ if(bWithBorder && aCurrentPoint.equal(rPoint))
{
- const ::basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
+ return sal_True;
+ }
- if(bWithBorder && aCurrentPoint.equal(rPoint))
- {
- return sal_True;
- }
+ // cross-over in Y?
+ const ::basegfx::B2DPoint aPreviousPoint(rCandidate.getB2DPoint((!a) ? nPointCount - 1L : a - 1L));
+ const sal_Bool bCompYA(::basegfx::fTools::more(aPreviousPoint.getY(), rPoint.getY()));
+ const sal_Bool bCompYB(::basegfx::fTools::more(aCurrentPoint.getY(), rPoint.getY()));
- // cross-over in Y?
- const ::basegfx::point::B2DPoint aPreviousPoint(rCandidate.getB2DPoint((!a) ? nPointCount - 1L : a - 1L));
- const sal_Bool bCompYA(::basegfx::numeric::fTools::more(aPreviousPoint.getY(), rPoint.getY()));
- const sal_Bool bCompYB(::basegfx::numeric::fTools::more(aCurrentPoint.getY(), rPoint.getY()));
+ if(bCompYA != bCompYB)
+ {
+ const sal_Bool bCompXA(::basegfx::fTools::more(aPreviousPoint.getX(), rPoint.getX()));
+ const sal_Bool bCompXB(::basegfx::fTools::more(aCurrentPoint.getX(), rPoint.getX()));
- if(bCompYA != bCompYB)
+ if(bCompXA == bCompXB)
{
- const sal_Bool bCompXA(::basegfx::numeric::fTools::more(aPreviousPoint.getX(), rPoint.getX()));
- const sal_Bool bCompXB(::basegfx::numeric::fTools::more(aCurrentPoint.getX(), rPoint.getX()));
+ if(bCompXA)
+ {
+ bRetval = !bRetval;
+ }
+ }
+ else
+ {
+ const double fCompare =
+ aCurrentPoint.getX() - (aCurrentPoint.getY() - rPoint.getY()) *
+ (aPreviousPoint.getX() - aCurrentPoint.getX()) /
+ (aPreviousPoint.getY() - aCurrentPoint.getY());
- if(bCompXA == bCompXB)
+ if(bWithBorder && ::basegfx::fTools::more(fCompare, rPoint.getX()))
{
- if(bCompXA)
- {
- bRetval = !bRetval;
- }
+ bRetval = !bRetval;
}
- else
+ else if(::basegfx::fTools::moreOrEqual(fCompare, rPoint.getX()))
{
- const double fCompare =
- aCurrentPoint.getX() - (aCurrentPoint.getY() - rPoint.getY()) *
- (aPreviousPoint.getX() - aCurrentPoint.getX()) /
- (aPreviousPoint.getY() - aCurrentPoint.getY());
-
- if(bWithBorder && ::basegfx::numeric::fTools::more(fCompare, rPoint.getX()))
- {
- bRetval = !bRetval;
- }
- else if(::basegfx::numeric::fTools::moreOrEqual(fCompare, rPoint.getX()))
- {
- bRetval = !bRetval;
- }
+ bRetval = !bRetval;
}
}
}
-
- return bRetval;
}
- sal_Bool isInside(const ::basegfx::polygon::B2DPolygon& rCandidate, const ::basegfx::polygon::B2DPolygon& rPolygon, sal_Bool bWithBorder)
+ return bRetval;
+ }
+
+ sal_Bool isInside(const ::basegfx::B2DPolygon& rCandidate, const ::basegfx::B2DPolygon& rPolygon, sal_Bool bWithBorder)
+ {
+ const sal_uInt32 nPointCount(rPolygon.count());
+
+ for(sal_uInt32 a(0L); a < nPointCount; a++)
{
- const sal_uInt32 nPointCount(rPolygon.count());
+ const ::basegfx::B2DPoint aTestPoint(rPolygon.getB2DPoint(a));
- for(sal_uInt32 a(0L); a < nPointCount; a++)
+ if(!isInside(rCandidate, aTestPoint, bWithBorder))
{
- const ::basegfx::point::B2DPoint aTestPoint(rPolygon.getB2DPoint(a));
-
- if(!isInside(rCandidate, aTestPoint, bWithBorder))
- {
- return sal_False;
- }
+ return sal_False;
}
-
- return sal_True;
}
- ::basegfx::range::B2DRange getRange(const ::basegfx::polygon::B2DPolygon& rCandidate)
- {
- ::basegfx::range::B2DRange aRetval;
- const sal_uInt32 nPointCount(rCandidate.count());
+ return sal_True;
+ }
+
+ ::basegfx::B2DRange getRange(const ::basegfx::B2DPolygon& rCandidate)
+ {
+ ::basegfx::B2DRange aRetval;
+ const sal_uInt32 nPointCount(rCandidate.count());
- if(rCandidate.areControlPointsUsed())
+ if(rCandidate.areControlPointsUsed())
+ {
+ for(sal_uInt32 a(0L); a < nPointCount; a++)
{
- for(sal_uInt32 a(0L); a < nPointCount; a++)
- {
- const ::basegfx::point::B2DPoint aTestPoint(rCandidate.getB2DPoint(a));
- const ::basegfx::vector::B2DVector aVectorA(rCandidate.getControlVectorA(a));
- const ::basegfx::vector::B2DVector aVectorB(rCandidate.getControlVectorB(a));
- aRetval.expand(aTestPoint);
+ const ::basegfx::B2DPoint aTestPoint(rCandidate.getB2DPoint(a));
+ const ::basegfx::B2DVector aVectorA(rCandidate.getControlVectorA(a));
+ const ::basegfx::B2DVector aVectorB(rCandidate.getControlVectorB(a));
+ aRetval.expand(aTestPoint);
- if(!aVectorA.equalZero())
- {
- aRetval.expand(aTestPoint + aVectorA);
- }
+ if(!aVectorA.equalZero())
+ {
+ aRetval.expand(aTestPoint + aVectorA);
+ }
- if(!aVectorB.equalZero())
- {
- const sal_uInt32 nNextIndex(getIndexOfSuccessor(a, rCandidate));
- const ::basegfx::point::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
- aRetval.expand(aNextPoint + aVectorB);
- }
+ if(!aVectorB.equalZero())
+ {
+ const sal_uInt32 nNextIndex(getIndexOfSuccessor(a, rCandidate));
+ const ::basegfx::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
+ aRetval.expand(aNextPoint + aVectorB);
}
}
- else
+ }
+ else
+ {
+ for(sal_uInt32 a(0L); a < nPointCount; a++)
{
- for(sal_uInt32 a(0L); a < nPointCount; a++)
- {
- const ::basegfx::point::B2DPoint aTestPoint(rCandidate.getB2DPoint(a));
- aRetval.expand(aTestPoint);
- }
+ const ::basegfx::B2DPoint aTestPoint(rCandidate.getB2DPoint(a));
+ aRetval.expand(aTestPoint);
}
-
- return aRetval;
}
- double getArea(const ::basegfx::polygon::B2DPolygon& rCandidate)
- {
- double fRetval(0.0);
- const sal_uInt32 nPointCount(rCandidate.count());
+ return aRetval;
+ }
- if(nPointCount > 2)
+ double getArea(const ::basegfx::B2DPolygon& rCandidate)
+ {
+ double fRetval(0.0);
+ const sal_uInt32 nPointCount(rCandidate.count());
+
+ if(nPointCount > 2)
+ {
+ for(sal_uInt32 a(0L); a < nPointCount; a++)
{
- for(sal_uInt32 a(0L); a < nPointCount; a++)
- {
- const ::basegfx::point::B2DPoint aPreviousPoint(rCandidate.getB2DPoint((!a) ? nPointCount - 1L : a - 1L));
- const ::basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
+ const ::basegfx::B2DPoint aPreviousPoint(rCandidate.getB2DPoint((!a) ? nPointCount - 1L : a - 1L));
+ const ::basegfx::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
- fRetval += aPreviousPoint.getX() * aCurrentPoint.getY();
- fRetval -= aPreviousPoint.getY() * aCurrentPoint.getX();
- }
+ fRetval += aPreviousPoint.getX() * aCurrentPoint.getY();
+ fRetval -= aPreviousPoint.getY() * aCurrentPoint.getX();
+ }
- fRetval /= 2.0;
+ fRetval /= 2.0;
- const double fZero(0.0);
+ const double fZero(0.0);
- if(::basegfx::numeric::fTools::less(fRetval, fZero))
- {
- fRetval = -fRetval;
- }
+ if(::basegfx::fTools::less(fRetval, fZero))
+ {
+ fRetval = -fRetval;
}
-
- return fRetval;
}
- double getEdgeLength(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex)
- {
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
- double fRetval(0.0);
- const sal_uInt32 nPointCount(rCandidate.count());
+ return fRetval;
+ }
+
+ double getEdgeLength(const ::basegfx::B2DPolygon& rCandidate, sal_uInt32 nIndex)
+ {
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+ double fRetval(0.0);
+ const sal_uInt32 nPointCount(rCandidate.count());
- if(nIndex < nPointCount)
+ if(nIndex < nPointCount)
+ {
+ if(rCandidate.isClosed() || nIndex + 1 != nPointCount)
{
- if(rCandidate.isClosed() || nIndex + 1 != nPointCount)
- {
- const sal_uInt32 nNextIndex(nIndex + 1 == nPointCount ? 0L : nIndex + 1L);
- const ::basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(nIndex));
- const ::basegfx::point::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
- const ::basegfx::vector::B2DVector aVector(aNextPoint - aCurrentPoint);
- fRetval = aVector.getLength();
- }
+ const sal_uInt32 nNextIndex(nIndex + 1 == nPointCount ? 0L : nIndex + 1L);
+ const ::basegfx::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(nIndex));
+ const ::basegfx::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
+ const ::basegfx::B2DVector aVector(aNextPoint - aCurrentPoint);
+ fRetval = aVector.getLength();
}
+ }
+
+ return fRetval;
+ }
- return fRetval;
+ double getLength(const ::basegfx::B2DPolygon& rCandidate)
+ {
+ // This method may also be implemented using a loop over getEdgeLength, but
+ // since this would cause a lot of sqare roots to be solved it is much better
+ // to sum up the quadrats first and then use a singe suare root (if necessary)
+ double fRetval(0.0);
+ const sal_uInt32 nPointCount(rCandidate.count());
+ const sal_uInt32 nLoopCount(rCandidate.isClosed() ? nPointCount : nPointCount - 1L);
+
+ for(sal_uInt32 a(0L); a < nLoopCount; a++)
+ {
+ const sal_uInt32 nNextIndex(a + 1 == nPointCount ? 0L : a + 1L);
+ const ::basegfx::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
+ const ::basegfx::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
+ const ::basegfx::B2DVector aVector(aNextPoint - aCurrentPoint);
+ fRetval += aVector.scalar(aVector);
}
- double getLength(const ::basegfx::polygon::B2DPolygon& rCandidate)
+ if(!::basegfx::fTools::equalZero(fRetval))
{
- // This method may also be implemented using a loop over getEdgeLength, but
- // since this would cause a lot of sqare roots to be solved it is much better
- // to sum up the quadrats first and then use a singe suare root (if necessary)
- double fRetval(0.0);
- const sal_uInt32 nPointCount(rCandidate.count());
- const sal_uInt32 nLoopCount(rCandidate.isClosed() ? nPointCount : nPointCount - 1L);
+ const double fOne(1.0);
- for(sal_uInt32 a(0L); a < nLoopCount; a++)
+ if(!::basegfx::fTools::equal(fOne, fRetval))
{
- const sal_uInt32 nNextIndex(a + 1 == nPointCount ? 0L : a + 1L);
- const ::basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
- const ::basegfx::point::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
- const ::basegfx::vector::B2DVector aVector(aNextPoint - aCurrentPoint);
- fRetval += aVector.scalar(aVector);
+ fRetval = sqrt(fRetval);
}
+ }
- if(!::basegfx::numeric::fTools::equalZero(fRetval))
- {
- const double fOne(1.0);
+ return fRetval;
+ }
- if(!::basegfx::numeric::fTools::equal(fOne, fRetval))
- {
- fRetval = sqrt(fRetval);
- }
- }
-
- return fRetval;
- }
+ ::basegfx::B2DPoint getPositionAbsolute(const ::basegfx::B2DPolygon& rCandidate, double fDistance, double fLength)
+ {
+ ::basegfx::B2DPoint aRetval;
+ const sal_uInt32 nPointCount(rCandidate.count());
- ::basegfx::point::B2DPoint getPositionAbsolute(const ::basegfx::polygon::B2DPolygon& rCandidate, double fDistance, double fLength)
+ if(nPointCount > 1L)
{
- ::basegfx::point::B2DPoint aRetval;
- const sal_uInt32 nPointCount(rCandidate.count());
+ sal_uInt32 nIndex(0L);
+ sal_Bool bIndexDone(sal_False);
+ const double fZero(0.0);
+ double fEdgeLength(fZero);
- if(nPointCount > 1L)
+ // get length if not given
+ if(::basegfx::fTools::equalZero(fLength))
{
- sal_uInt32 nIndex(0L);
- sal_Bool bIndexDone(sal_False);
- const double fZero(0.0);
- double fEdgeLength(fZero);
+ fLength = getLength(rCandidate);
+ }
- // get length if not given
- if(::basegfx::numeric::fTools::equalZero(fLength))
+ // handle fDistance < 0.0
+ if(::basegfx::fTools::less(fDistance, fZero))
+ {
+ if(rCandidate.isClosed())
{
- fLength = getLength(rCandidate);
+ // if fDistance < 0.0 increment with multiple of fLength
+ sal_uInt32 nCount(sal_uInt32(-fDistance / fLength));
+ fDistance += double(nCount + 1L) * fLength;
}
+ else
+ {
+ // crop to polygon start
+ fDistance = fZero;
+ bIndexDone = sal_True;
+ }
+ }
- // handle fDistance < 0.0
- if(::basegfx::numeric::fTools::less(fDistance, fZero))
+ // handle fDistance >= fLength
+ if(::basegfx::fTools::moreOrEqual(fDistance, fLength))
+ {
+ if(rCandidate.isClosed())
{
- if(rCandidate.isClosed())
- {
- // if fDistance < 0.0 increment with multiple of fLength
- sal_uInt32 nCount(sal_uInt32(-fDistance / fLength));
- fDistance += double(nCount + 1L) * fLength;
- }
- else
- {
- // crop to polygon start
- fDistance = fZero;
- bIndexDone = sal_True;
- }
+ // if fDistance >= fLength decrement with multiple of fLength
+ sal_uInt32 nCount(sal_uInt32(fDistance / fLength));
+ fDistance -= (double)(nCount) * fLength;
+ }
+ else
+ {
+ // crop to polygon end
+ fDistance = fZero;
+ nIndex = nPointCount - 1L;
+ bIndexDone = sal_True;
}
+ }
- // handle fDistance >= fLength
- if(::basegfx::numeric::fTools::moreOrEqual(fDistance, fLength))
+ // look for correct index. fDistance is now [0.0 .. fLength[
+ if(!bIndexDone)
+ {
+ do
{
- if(rCandidate.isClosed())
+ // get length of next edge
+ fEdgeLength = getEdgeLength(rCandidate, nIndex);
+
+ if(::basegfx::fTools::moreOrEqual(fDistance, fEdgeLength))
{
- // if fDistance >= fLength decrement with multiple of fLength
- sal_uInt32 nCount(sal_uInt32(fDistance / fLength));
- fDistance -= (double)(nCount) * fLength;
+ // go to next edge
+ fDistance -= fEdgeLength;
+ nIndex++;
}
else
{
- // crop to polygon end
- fDistance = fZero;
- nIndex = nPointCount - 1L;
+ // it's on this edge, stop
bIndexDone = sal_True;
}
- }
-
- // look for correct index. fDistance is now [0.0 .. fLength[
- if(!bIndexDone)
- {
- do
- {
- // get length of next edge
- fEdgeLength = getEdgeLength(rCandidate, nIndex);
+ } while (!bIndexDone);
+ }
- if(::basegfx::numeric::fTools::moreOrEqual(fDistance, fEdgeLength))
- {
- // go to next edge
- fDistance -= fEdgeLength;
- nIndex++;
- }
- else
- {
- // it's on this edge, stop
- bIndexDone = sal_True;
- }
- } while (!bIndexDone);
- }
+ // get the point using nIndex
+ aRetval = rCandidate.getB2DPoint(nIndex);
- // get the point using nIndex
- aRetval = rCandidate.getB2DPoint(nIndex);
+ // if fDistance != 0.0, move that length on the edge. The edge
+ // length is in fEdgeLength.
+ if(!::basegfx::fTools::equalZero(fDistance))
+ {
+ sal_uInt32 nNextIndex(getIndexOfSuccessor(nIndex, rCandidate));
+ const ::basegfx::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
+ double fRelative(fZero);
- // if fDistance != 0.0, move that length on the edge. The edge
- // length is in fEdgeLength.
- if(!::basegfx::numeric::fTools::equalZero(fDistance))
+ if(!::basegfx::fTools::equalZero(fEdgeLength))
{
- sal_uInt32 nNextIndex(getIndexOfSuccessor(nIndex, rCandidate));
- const ::basegfx::point::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
- double fRelative(fZero);
-
- if(!::basegfx::numeric::fTools::equalZero(fEdgeLength))
- {
- fRelative = fDistance / fEdgeLength;
- }
-
- // add calculated average value to the return value
- aRetval += ::basegfx::tuple::average(aRetval, aNextPoint, fRelative);
+ fRelative = fDistance / fEdgeLength;
}
- }
- return aRetval;
+ // add calculated average value to the return value
+ aRetval = ::basegfx::interpolate(aRetval, aNextPoint, fRelative);
+ }
}
- ::basegfx::point::B2DPoint getPositionRelative(const ::basegfx::polygon::B2DPolygon& rCandidate, double fDistance, double fLength)
- {
- // get length if not given
- if(::basegfx::numeric::fTools::equalZero(fLength))
- {
- fLength = getLength(rCandidate);
- }
+ return aRetval;
+ }
- // multiply fDistance with real length to get absolute position and
- // use getPositionAbsolute
- return getPositionAbsolute(rCandidate, fDistance * fLength, fLength);
+ ::basegfx::B2DPoint getPositionRelative(const ::basegfx::B2DPolygon& rCandidate, double fDistance, double fLength)
+ {
+ // get length if not given
+ if(::basegfx::fTools::equalZero(fLength))
+ {
+ fLength = getLength(rCandidate);
}
- ::basegfx::vector::B2DVectorOrientation getPointOrientation(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex)
+ // multiply fDistance with real length to get absolute position and
+ // use getPositionAbsolute
+ return getPositionAbsolute(rCandidate, fDistance * fLength, fLength);
+ }
+
+ ::basegfx::B2DVectorOrientation getPointOrientation(const ::basegfx::B2DPolygon& rCandidate, sal_uInt32 nIndex)
+ {
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+ ::basegfx::B2DVectorOrientation eRetval(::basegfx::ORIENTATION_NEUTRAL);
+
+ if(rCandidate.count() > 2)
{
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
- ::basegfx::vector::B2DVectorOrientation eRetval(::basegfx::vector::ORIENTATION_NEUTRAL);
+ sal_uInt32 nIndPrev = getIndexOfDifferentPredecessor(nIndex, rCandidate);
- if(rCandidate.count() > 2)
+ if(nIndPrev != nIndex)
{
- sal_uInt32 nIndPrev = getIndexOfDifferentPredecessor(nIndex, rCandidate);
+ sal_uInt32 nIndNext = getIndexOfDifferentSuccessor(nIndex, rCandidate);
- if(nIndPrev != nIndex)
+ if(nIndNext != nIndex && nIndNext != nIndPrev)
{
- sal_uInt32 nIndNext = getIndexOfDifferentSuccessor(nIndex, rCandidate);
-
- if(nIndNext != nIndex && nIndNext != nIndPrev)
- {
- ::basegfx::point::B2DPoint aPoint(rCandidate.getB2DPoint(nIndex));
- ::basegfx::vector::B2DVector aVecPrev(rCandidate.getB2DPoint(nIndPrev) - aPoint);
- ::basegfx::vector::B2DVector aVecNext(rCandidate.getB2DPoint(nIndNext) - aPoint);
- eRetval = ::basegfx::vector::getOrientation(aVecPrev, aVecNext);
- }
+ ::basegfx::B2DPoint aPoint(rCandidate.getB2DPoint(nIndex));
+ ::basegfx::B2DVector aVecPrev(rCandidate.getB2DPoint(nIndPrev) - aPoint);
+ ::basegfx::B2DVector aVecNext(rCandidate.getB2DPoint(nIndNext) - aPoint);
+ eRetval = ::basegfx::getOrientation(aVecPrev, aVecNext);
}
}
-
- return eRetval;
}
- CutFlagValue findCut(
- const ::basegfx::polygon::B2DPolygon& rCandidate,
- sal_uInt32 nIndex1, sal_uInt32 nIndex2,
- CutFlagValue aCutFlags,
- double* pCut1, double* pCut2)
- {
- CutFlagValue aRetval(CUTFLAG_NONE);
- const sal_uInt32 nPointCount(rCandidate.count());
+ return eRetval;
+ }
- if(nIndex1 < nPointCount && nIndex2 < nPointCount && nIndex1 != nIndex2)
- {
- sal_uInt32 nEnd1(getIndexOfSuccessor(nIndex1, rCandidate));
- sal_uInt32 nEnd2(getIndexOfSuccessor(nIndex2, rCandidate));
+ CutFlagValue findCut(
+ const ::basegfx::B2DPolygon& rCandidate,
+ sal_uInt32 nIndex1, sal_uInt32 nIndex2,
+ CutFlagValue aCutFlags,
+ double* pCut1, double* pCut2)
+ {
+ CutFlagValue aRetval(CUTFLAG_NONE);
+ const sal_uInt32 nPointCount(rCandidate.count());
- const ::basegfx::point::B2DPoint aStart1(rCandidate.getB2DPoint(nIndex1));
- const ::basegfx::point::B2DPoint aEnd1(rCandidate.getB2DPoint(nEnd1));
- const ::basegfx::vector::B2DVector aVector1(aEnd1 - aStart1);
+ if(nIndex1 < nPointCount && nIndex2 < nPointCount && nIndex1 != nIndex2)
+ {
+ sal_uInt32 nEnd1(getIndexOfSuccessor(nIndex1, rCandidate));
+ sal_uInt32 nEnd2(getIndexOfSuccessor(nIndex2, rCandidate));
- const ::basegfx::point::B2DPoint aStart2(rCandidate.getB2DPoint(nIndex2));
- const ::basegfx::point::B2DPoint aEnd2(rCandidate.getB2DPoint(nEnd2));
- const ::basegfx::vector::B2DVector aVector2(aEnd2 - aStart2);
+ const ::basegfx::B2DPoint aStart1(rCandidate.getB2DPoint(nIndex1));
+ const ::basegfx::B2DPoint aEnd1(rCandidate.getB2DPoint(nEnd1));
+ const ::basegfx::B2DVector aVector1(aEnd1 - aStart1);
- aRetval = findCut(
- aStart1, aVector1, aStart2, aVector2,
- aCutFlags, pCut1, pCut2);
- }
+ const ::basegfx::B2DPoint aStart2(rCandidate.getB2DPoint(nIndex2));
+ const ::basegfx::B2DPoint aEnd2(rCandidate.getB2DPoint(nEnd2));
+ const ::basegfx::B2DVector aVector2(aEnd2 - aStart2);
- return aRetval;
+ aRetval = findCut(
+ aStart1, aVector1, aStart2, aVector2,
+ aCutFlags, pCut1, pCut2);
}
- CutFlagValue findCut(
- const ::basegfx::polygon::B2DPolygon& rCandidate1, sal_uInt32 nIndex1,
- const ::basegfx::polygon::B2DPolygon& rCandidate2, sal_uInt32 nIndex2,
- CutFlagValue aCutFlags,
- double* pCut1, double* pCut2)
- {
- CutFlagValue aRetval(CUTFLAG_NONE);
- const sal_uInt32 nPointCount1(rCandidate1.count());
- const sal_uInt32 nPointCount2(rCandidate2.count());
+ return aRetval;
+ }
- if(nIndex1 < nPointCount1 && nIndex2 < nPointCount2)
- {
- sal_uInt32 nEnd1(getIndexOfSuccessor(nIndex1, rCandidate1));
- sal_uInt32 nEnd2(getIndexOfSuccessor(nIndex2, rCandidate2));
+ CutFlagValue findCut(
+ const ::basegfx::B2DPolygon& rCandidate1, sal_uInt32 nIndex1,
+ const ::basegfx::B2DPolygon& rCandidate2, sal_uInt32 nIndex2,
+ CutFlagValue aCutFlags,
+ double* pCut1, double* pCut2)
+ {
+ CutFlagValue aRetval(CUTFLAG_NONE);
+ const sal_uInt32 nPointCount1(rCandidate1.count());
+ const sal_uInt32 nPointCount2(rCandidate2.count());
- const ::basegfx::point::B2DPoint aStart1(rCandidate1.getB2DPoint(nIndex1));
- const ::basegfx::point::B2DPoint aEnd1(rCandidate1.getB2DPoint(nEnd1));
- const ::basegfx::vector::B2DVector aVector1(aEnd1 - aStart1);
+ if(nIndex1 < nPointCount1 && nIndex2 < nPointCount2)
+ {
+ sal_uInt32 nEnd1(getIndexOfSuccessor(nIndex1, rCandidate1));
+ sal_uInt32 nEnd2(getIndexOfSuccessor(nIndex2, rCandidate2));
- const ::basegfx::point::B2DPoint aStart2(rCandidate2.getB2DPoint(nIndex2));
- const ::basegfx::point::B2DPoint aEnd2(rCandidate2.getB2DPoint(nEnd2));
- const ::basegfx::vector::B2DVector aVector2(aEnd2 - aStart2);
+ const ::basegfx::B2DPoint aStart1(rCandidate1.getB2DPoint(nIndex1));
+ const ::basegfx::B2DPoint aEnd1(rCandidate1.getB2DPoint(nEnd1));
+ const ::basegfx::B2DVector aVector1(aEnd1 - aStart1);
- aRetval = findCut(
- aStart1, aVector1, aStart2, aVector2,
- aCutFlags, pCut1, pCut2);
- }
+ const ::basegfx::B2DPoint aStart2(rCandidate2.getB2DPoint(nIndex2));
+ const ::basegfx::B2DPoint aEnd2(rCandidate2.getB2DPoint(nEnd2));
+ const ::basegfx::B2DVector aVector2(aEnd2 - aStart2);
- return aRetval;
+ aRetval = findCut(
+ aStart1, aVector1, aStart2, aVector2,
+ aCutFlags, pCut1, pCut2);
}
- CutFlagValue findCut(
- const ::basegfx::point::B2DPoint& rEdge1Start, const ::basegfx::vector::B2DVector& rEdge1Delta,
- const ::basegfx::point::B2DPoint& rEdge2Start, const ::basegfx::vector::B2DVector& rEdge2Delta,
- CutFlagValue aCutFlags,
- double* pCut1, double* pCut2)
- {
- CutFlagValue aRetval(CUTFLAG_NONE);
- double fCut1(0.0);
- double fCut2(0.0);
- sal_Bool bFinished(!((sal_Bool)(aCutFlags & CUTFLAG_ALL)));
+ return aRetval;
+ }
- // test for same points?
- if(!bFinished
- && (aCutFlags & (CUTFLAG_START1|CUTFLAG_END1))
- && (aCutFlags & (CUTFLAG_START2|CUTFLAG_END2)))
+ CutFlagValue findCut(
+ const ::basegfx::B2DPoint& rEdge1Start, const ::basegfx::B2DVector& rEdge1Delta,
+ const ::basegfx::B2DPoint& rEdge2Start, const ::basegfx::B2DVector& rEdge2Delta,
+ CutFlagValue aCutFlags,
+ double* pCut1, double* pCut2)
+ {
+ CutFlagValue aRetval(CUTFLAG_NONE);
+ double fCut1(0.0);
+ double fCut2(0.0);
+ sal_Bool bFinished(!((sal_Bool)(aCutFlags & CUTFLAG_ALL)));
+
+ // test for same points?
+ if(!bFinished
+ && (aCutFlags & (CUTFLAG_START1|CUTFLAG_END1))
+ && (aCutFlags & (CUTFLAG_START2|CUTFLAG_END2)))
+ {
+ // same startpoint?
+ if(!bFinished && (aCutFlags & (CUTFLAG_START1|CUTFLAG_START2)) == (CUTFLAG_START1|CUTFLAG_START2))
{
- // same startpoint?
- if(!bFinished && (aCutFlags & (CUTFLAG_START1|CUTFLAG_START2)) == (CUTFLAG_START1|CUTFLAG_START2))
+ if(rEdge1Start.equal(rEdge2Start))
{
- if(rEdge1Start.equal(rEdge2Start))
- {
- bFinished = sal_True;
- aRetval = (CUTFLAG_START1|CUTFLAG_START2);
- }
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_START1|CUTFLAG_START2);
}
+ }
- // same endpoint?
- if(!bFinished && (aCutFlags & (CUTFLAG_END1|CUTFLAG_END2)) == (CUTFLAG_END1|CUTFLAG_END2))
- {
- const ::basegfx::point::B2DPoint aEnd1(rEdge1Start + rEdge1Delta);
- const ::basegfx::point::B2DPoint aEnd2(rEdge2Start + rEdge2Delta);
+ // same endpoint?
+ if(!bFinished && (aCutFlags & (CUTFLAG_END1|CUTFLAG_END2)) == (CUTFLAG_END1|CUTFLAG_END2))
+ {
+ const ::basegfx::B2DPoint aEnd1(rEdge1Start + rEdge1Delta);
+ const ::basegfx::B2DPoint aEnd2(rEdge2Start + rEdge2Delta);
- if(aEnd1.equal(aEnd2))
- {
- bFinished = sal_True;
- aRetval = (CUTFLAG_END1|CUTFLAG_END2);
- fCut1 = fCut2 = 1.0;
- }
+ if(aEnd1.equal(aEnd2))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_END1|CUTFLAG_END2);
+ fCut1 = fCut2 = 1.0;
}
+ }
- // startpoint1 == endpoint2?
- if(!bFinished && (aCutFlags & (CUTFLAG_START1|CUTFLAG_END2)) == (CUTFLAG_START1|CUTFLAG_END2))
- {
- const ::basegfx::point::B2DPoint aEnd2(rEdge2Start + rEdge2Delta);
+ // startpoint1 == endpoint2?
+ if(!bFinished && (aCutFlags & (CUTFLAG_START1|CUTFLAG_END2)) == (CUTFLAG_START1|CUTFLAG_END2))
+ {
+ const ::basegfx::B2DPoint aEnd2(rEdge2Start + rEdge2Delta);
- if(rEdge1Start.equal(aEnd2))
- {
- bFinished = sal_True;
- aRetval = (CUTFLAG_START1|CUTFLAG_END2);
- fCut1 = 0.0;
- fCut2 = 1.0;
- }
+ if(rEdge1Start.equal(aEnd2))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_START1|CUTFLAG_END2);
+ fCut1 = 0.0;
+ fCut2 = 1.0;
}
+ }
- // startpoint2 == endpoint1?
- if(!bFinished&& (aCutFlags & (CUTFLAG_START2|CUTFLAG_END1)) == (CUTFLAG_START2|CUTFLAG_END1))
- {
- const ::basegfx::point::B2DPoint aEnd1(rEdge1Start + rEdge1Delta);
+ // startpoint2 == endpoint1?
+ if(!bFinished&& (aCutFlags & (CUTFLAG_START2|CUTFLAG_END1)) == (CUTFLAG_START2|CUTFLAG_END1))
+ {
+ const ::basegfx::B2DPoint aEnd1(rEdge1Start + rEdge1Delta);
- if(rEdge2Start.equal(aEnd1))
- {
- bFinished = sal_True;
- aRetval = (CUTFLAG_START2|CUTFLAG_END1);
- fCut1 = 1.0;
- fCut2 = 0.0;
- }
+ if(rEdge2Start.equal(aEnd1))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_START2|CUTFLAG_END1);
+ fCut1 = 1.0;
+ fCut2 = 0.0;
}
}
+ }
- if(!bFinished && (aCutFlags & CUTFLAG_LINE))
+ if(!bFinished && (aCutFlags & CUTFLAG_LINE))
+ {
+ if(!bFinished && (aCutFlags & CUTFLAG_START1))
{
- if(!bFinished && (aCutFlags & CUTFLAG_START1))
+ // start1 on line 2 ?
+ if(isPointOnEdge(rEdge1Start, rEdge2Start, rEdge2Delta, &fCut2))
{
- // start1 on line 2 ?
- if(isPointOnEdge(rEdge1Start, rEdge2Start, rEdge2Delta, &fCut2))
- {
- bFinished = sal_True;
- aRetval = (CUTFLAG_LINE|CUTFLAG_START1);
- }
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_LINE|CUTFLAG_START1);
}
+ }
- if(!bFinished && (aCutFlags & CUTFLAG_START2))
+ if(!bFinished && (aCutFlags & CUTFLAG_START2))
+ {
+ // start2 on line 1 ?
+ if(isPointOnEdge(rEdge2Start, rEdge1Start, rEdge1Delta, &fCut1))
{
- // start2 on line 1 ?
- if(isPointOnEdge(rEdge2Start, rEdge1Start, rEdge1Delta, &fCut1))
- {
- bFinished = sal_True;
- aRetval = (CUTFLAG_LINE|CUTFLAG_START2);
- }
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_LINE|CUTFLAG_START2);
}
+ }
- if(!bFinished && (aCutFlags & CUTFLAG_END1))
- {
- // end1 on line 2 ?
- const ::basegfx::point::B2DPoint aEnd1(rEdge1Start + rEdge1Delta);
+ if(!bFinished && (aCutFlags & CUTFLAG_END1))
+ {
+ // end1 on line 2 ?
+ const ::basegfx::B2DPoint aEnd1(rEdge1Start + rEdge1Delta);
- if(isPointOnEdge(aEnd1, rEdge2Start, rEdge2Delta, &fCut2))
- {
- bFinished = sal_True;
- aRetval = (CUTFLAG_LINE|CUTFLAG_END1);
- }
+ if(isPointOnEdge(aEnd1, rEdge2Start, rEdge2Delta, &fCut2))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_LINE|CUTFLAG_END1);
}
+ }
- if(!bFinished && (aCutFlags & CUTFLAG_END2))
- {
- // end2 on line 1 ?
- const ::basegfx::point::B2DPoint aEnd2(rEdge2Start + rEdge2Delta);
+ if(!bFinished && (aCutFlags & CUTFLAG_END2))
+ {
+ // end2 on line 1 ?
+ const ::basegfx::B2DPoint aEnd2(rEdge2Start + rEdge2Delta);
- if(isPointOnEdge(aEnd2, rEdge1Start, rEdge1Delta, &fCut1))
- {
- bFinished = sal_True;
- aRetval = (CUTFLAG_LINE|CUTFLAG_END2);
- }
+ if(isPointOnEdge(aEnd2, rEdge1Start, rEdge1Delta, &fCut1))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_LINE|CUTFLAG_END2);
}
+ }
+
+ if(!bFinished)
+ {
+ // cut in line1, line2 ?
+ fCut1 = (rEdge1Delta.getX() * rEdge2Delta.getY()) - (rEdge1Delta.getY() * rEdge2Delta.getX());
- if(!bFinished)
+ if(!::basegfx::fTools::equalZero(fCut1))
{
- // cut in line1, line2 ?
- fCut1 = (rEdge1Delta.getX() * rEdge2Delta.getY()) - (rEdge1Delta.getY() * rEdge2Delta.getX());
+ fCut1 = (rEdge2Delta.getY() * (rEdge2Start.getX() - rEdge1Start.getX())
+ + rEdge2Delta.getX() * (rEdge1Start.getY() - rEdge2Start.getY())) / fCut1;
- if(!::basegfx::numeric::fTools::equalZero(fCut1))
- {
- fCut1 = (rEdge2Delta.getY() * (rEdge2Start.getX() - rEdge1Start.getX())
- + rEdge2Delta.getX() * (rEdge1Start.getY() - rEdge2Start.getY())) / fCut1;
+ const double fZero(0.0);
+ const double fOne(1.0);
- const double fZero(0.0);
- const double fOne(1.0);
+ // inside parameter range edge1 AND fCut2 is calcable
+ if(::basegfx::fTools::more(fCut1, fZero) && ::basegfx::fTools::less(fCut1, fOne)
+ && (!::basegfx::fTools::equalZero(rEdge2Delta.getX()) || !::basegfx::fTools::equalZero(rEdge2Delta.getY())))
+ {
+ // take the mopre precise calculation of the two possible
+ if(fabs(rEdge2Delta.getX()) > fabs(rEdge2Delta.getY()))
+ {
+ fCut2 = (rEdge1Start.getX() + fCut1
+ * rEdge1Delta.getX() - rEdge2Start.getX()) / rEdge2Delta.getX();
+ }
+ else
+ {
+ fCut2 = (rEdge1Start.getY() + fCut1
+ * rEdge1Delta.getY() - rEdge2Start.getY()) / rEdge2Delta.getY();
+ }
- // inside parameter range edge1 AND fCut2 is calcable
- if(::basegfx::numeric::fTools::more(fCut1, fZero) && ::basegfx::numeric::fTools::less(fCut1, fOne)
- && (!::basegfx::numeric::fTools::equalZero(rEdge2Delta.getX()) || !::basegfx::numeric::fTools::equalZero(rEdge2Delta.getY())))
+ // inside parameter range edge2, too
+ if(::basegfx::fTools::more(fCut2, fZero) && ::basegfx::fTools::less(fCut2, fOne))
{
- // take the mopre precise calculation of the two possible
- if(fabs(rEdge2Delta.getX()) > fabs(rEdge2Delta.getY()))
- {
- fCut2 = (rEdge1Start.getX() + fCut1
- * rEdge1Delta.getX() - rEdge2Start.getX()) / rEdge2Delta.getX();
- }
- else
- {
- fCut2 = (rEdge1Start.getY() + fCut1
- * rEdge1Delta.getY() - rEdge2Start.getY()) / rEdge2Delta.getY();
- }
-
- // inside parameter range edge2, too
- if(::basegfx::numeric::fTools::more(fCut2, fZero) && ::basegfx::numeric::fTools::less(fCut2, fOne))
- {
- bFinished = sal_True;
- aRetval = CUTFLAG_LINE;
- }
+ bFinished = sal_True;
+ aRetval = CUTFLAG_LINE;
}
}
}
}
+ }
- // copy values if wanted
- if(pCut1)
- {
- *pCut1 = fCut1;
- }
-
- if(pCut2)
- {
- *pCut2 = fCut2;
- }
-
- return aRetval;
+ // copy values if wanted
+ if(pCut1)
+ {
+ *pCut1 = fCut1;
}
- sal_Bool isPointOnEdge(
- const ::basegfx::point::B2DPoint& rPoint,
- const ::basegfx::point::B2DPoint& rEdgeStart,
- const ::basegfx::vector::B2DVector& rEdgeDelta,
- double* pCut)
+ if(pCut2)
{
- sal_Bool bDeltaXIsZero(::basegfx::numeric::fTools::equalZero(rEdgeDelta.getX()));
- sal_Bool bDeltaYIsZero(::basegfx::numeric::fTools::equalZero(rEdgeDelta.getY()));
- const double fZero(0.0);
- const double fOne(1.0);
+ *pCut2 = fCut2;
+ }
- if(bDeltaXIsZero && bDeltaYIsZero)
- {
- // no line, just a point
- return sal_False;
- }
- else if(bDeltaXIsZero)
+ return aRetval;
+ }
+
+ sal_Bool isPointOnEdge(
+ const ::basegfx::B2DPoint& rPoint,
+ const ::basegfx::B2DPoint& rEdgeStart,
+ const ::basegfx::B2DVector& rEdgeDelta,
+ double* pCut)
+ {
+ sal_Bool bDeltaXIsZero(::basegfx::fTools::equalZero(rEdgeDelta.getX()));
+ sal_Bool bDeltaYIsZero(::basegfx::fTools::equalZero(rEdgeDelta.getY()));
+ const double fZero(0.0);
+ const double fOne(1.0);
+
+ if(bDeltaXIsZero && bDeltaYIsZero)
+ {
+ // no line, just a point
+ return sal_False;
+ }
+ else if(bDeltaXIsZero)
+ {
+ // vertical line
+ if(::basegfx::fTools::equal(rPoint.getX(), rEdgeStart.getX()))
{
- // vertical line
- if(::basegfx::numeric::fTools::equal(rPoint.getX(), rEdgeStart.getX()))
- {
- double fValue = (rPoint.getY() - rEdgeStart.getY()) / rEdgeDelta.getY();
+ double fValue = (rPoint.getY() - rEdgeStart.getY()) / rEdgeDelta.getY();
- if(::basegfx::numeric::fTools::more(fValue, fZero) && ::basegfx::numeric::fTools::less(fValue, fOne))
+ if(::basegfx::fTools::more(fValue, fZero) && ::basegfx::fTools::less(fValue, fOne))
+ {
+ if(pCut)
{
- if(pCut)
- {
- *pCut = fValue;
- }
-
- return sal_True;
+ *pCut = fValue;
}
+
+ return sal_True;
}
}
- else if(bDeltaYIsZero)
+ }
+ else if(bDeltaYIsZero)
+ {
+ // horizontal line
+ if(::basegfx::fTools::equal(rPoint.getY(), rEdgeStart.getY()))
{
- // horizontal line
- if(::basegfx::numeric::fTools::equal(rPoint.getY(), rEdgeStart.getY()))
- {
- double fValue = (rPoint.getX() - rEdgeStart.getX()) / rEdgeDelta.getX();
+ double fValue = (rPoint.getX() - rEdgeStart.getX()) / rEdgeDelta.getX();
- if(::basegfx::numeric::fTools::more(fValue, fZero)
- && ::basegfx::numeric::fTools::less(fValue, fOne))
+ if(::basegfx::fTools::more(fValue, fZero)
+ && ::basegfx::fTools::less(fValue, fOne))
+ {
+ if(pCut)
{
- if(pCut)
- {
- *pCut = fValue;
- }
-
- return sal_True;
+ *pCut = fValue;
}
+
+ return sal_True;
}
}
- else
+ }
+ else
+ {
+ // any angle line
+ double fTOne = (rPoint.getX() - rEdgeStart.getX()) / rEdgeDelta.getX();
+ double fTTwo = (rPoint.getY() - rEdgeStart.getY()) / rEdgeDelta.getY();
+
+ if(::basegfx::fTools::equal(fTOne, fTTwo))
{
- // any angle line
- double fTOne = (rPoint.getX() - rEdgeStart.getX()) / rEdgeDelta.getX();
- double fTTwo = (rPoint.getY() - rEdgeStart.getY()) / rEdgeDelta.getY();
+ // same parameter representation, point is on line. Take
+ // middle value for better results
+ double fValue = (fTOne + fTTwo) / 2.0;
- if(::basegfx::numeric::fTools::equal(fTOne, fTTwo))
+ if(::basegfx::fTools::more(fValue, fZero) && ::basegfx::fTools::less(fValue, fOne))
{
- // same parameter representation, point is on line. Take
- // middle value for better results
- double fValue = (fTOne + fTTwo) / 2.0;
+ // point is inside line bounds, too
+ if(pCut)
+ {
+ *pCut = fValue;
+ }
+
+ return sal_True;
+ }
+ }
+ }
- if(::basegfx::numeric::fTools::more(fValue, fZero) && ::basegfx::numeric::fTools::less(fValue, fOne))
+ return sal_False;
+ }
+
+ ::basegfx::B2DPolyPolygon applyLineDashing(const ::basegfx::B2DPolygon& rCandidate, const ::std::vector<double>& raDashDotArray, double fFullDashDotLen)
+ {
+ ::basegfx::B2DPolyPolygon aRetval;
+
+ if(rCandidate.count() && fFullDashDotLen > 0.0)
+ {
+ const sal_uInt32 nCount(rCandidate.isClosed() ? rCandidate.count() : rCandidate.count() - 1L);
+ sal_uInt32 nDashDotIndex(0L);
+ double fDashDotLength(raDashDotArray[nDashDotIndex]);
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ const sal_uInt32 nNextIndex(getIndexOfSuccessor(a, rCandidate));
+ const ::basegfx::B2DPoint aStart(rCandidate.getB2DPoint(a));
+ const ::basegfx::B2DPoint aEnd(rCandidate.getB2DPoint(nNextIndex));
+ const ::basegfx::B2DVector aVector(aEnd - aStart);
+ double fLength(aVector.getLength());
+ double fPosOnVector(0.0);
+
+ while(fLength >= fDashDotLength)
+ {
+ // handle [fPosOnVector .. fPosOnVector+fDashDotLength]
+ if(nDashDotIndex % 2)
{
- // point is inside line bounds, too
- if(pCut)
+ ::basegfx::B2DPolygon aResult;
+
+ // add start point
+ if(fPosOnVector == 0.0)
+ {
+ aResult.append(aStart);
+ }
+ else
{
- *pCut = fValue;
+ aResult.append(aStart + (aVector * fPosOnVector));
}
- return sal_True;
+ // add end point
+ aResult.append(aStart + (aVector * (fPosOnVector + fDashDotLength)));
+
+ // add line to PolyPolygon
+ aRetval.append(aResult);
}
+
+ // consume from fDashDotLength
+ fPosOnVector += fDashDotLength;
+ fLength -= fDashDotLength;
+ nDashDotIndex = (nDashDotIndex + 1L) % raDashDotArray.size();
+ fDashDotLength = raDashDotArray[nDashDotIndex];
}
- }
- return sal_False;
+ // handle [fPosOnVector .. fPosOnVector+fLength (bzw. end)]
+ if((fLength > 0.0) && (nDashDotIndex % 2))
+ {
+ ::basegfx::B2DPolygon aResult;
+
+ // add start and end point
+ const ::basegfx::B2DPoint aPosA(aStart + (aVector * fPosOnVector));
+ aResult.append(aPosA);
+
+ // add line to PolyPolygon
+ aRetval.append(aResult);
+ }
+
+ // consume from fDashDotLength
+ fDashDotLength -= fLength;
+ }
}
- } // end of namespace tools
- } // end of namespace polygon
+
+ return aRetval;
+ }
+ } // end of namespace tools
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx
index 301d5a68edd8..f6fcbd9c0e55 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolypolygon.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:11 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,7 +81,7 @@
class ImplB2DPolyPolygon
{
- typedef ::std::vector< ::basegfx::polygon::B2DPolygon > PolygonVector;
+ typedef ::std::vector< ::basegfx::B2DPolygon > PolygonVector;
PolygonVector maPolygons;
sal_uInt32 mnRefCount;
@@ -127,17 +127,17 @@ public:
return sal_True;
}
- const ::basegfx::polygon::B2DPolygon& getB2DPolygon(sal_uInt32 nIndex) const
+ const ::basegfx::B2DPolygon& getB2DPolygon(sal_uInt32 nIndex) const
{
return maPolygons[nIndex];
}
- void setB2DPolygon(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rPolygon)
+ void setB2DPolygon(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rPolygon)
{
maPolygons[nIndex] = rPolygon;
}
- void insert(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rPolygon, sal_uInt32 nCount)
+ void insert(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rPolygon, sal_uInt32 nCount)
{
if(nCount)
{
@@ -148,7 +148,7 @@ public:
}
}
- void insert(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolyPolygon& rPolyPolygon)
+ void insert(sal_uInt32 nIndex, const ::basegfx::B2DPolyPolygon& rPolyPolygon)
{
const sal_uInt32 nCount = rPolyPolygon.count();
@@ -209,7 +209,7 @@ public:
}
}
- void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix)
+ void transform(const ::basegfx::B2DHomMatrix& rMatrix)
{
for(sal_uInt32 a(0L); a < maPolygons.size(); a++)
{
@@ -222,247 +222,244 @@ public:
namespace basegfx
{
- namespace polygon
- {
- // init static default Polygon
- static ImplB2DPolyPolygon maStaticDefaultPolyPolygon;
+ // init static default Polygon
+ static ImplB2DPolyPolygon maStaticDefaultPolyPolygon;
- void B2DPolyPolygon::implForceUniqueCopy()
+ void B2DPolyPolygon::implForceUniqueCopy()
+ {
+ if(mpPolyPolygon->getRefCount())
{
- if(mpPolyPolygon->getRefCount())
- {
- mpPolyPolygon->decRefCount();
- mpPolyPolygon = new ImplB2DPolyPolygon(*mpPolyPolygon);
- }
+ mpPolyPolygon->decRefCount();
+ mpPolyPolygon = new ImplB2DPolyPolygon(*mpPolyPolygon);
}
+ }
- B2DPolyPolygon::B2DPolyPolygon()
- : mpPolyPolygon(&maStaticDefaultPolyPolygon)
- {
- mpPolyPolygon->incRefCount();
- }
+ B2DPolyPolygon::B2DPolyPolygon()
+ : mpPolyPolygon(&maStaticDefaultPolyPolygon)
+ {
+ mpPolyPolygon->incRefCount();
+ }
- B2DPolyPolygon::B2DPolyPolygon(const B2DPolyPolygon& rPolyPolygon)
- : mpPolyPolygon(rPolyPolygon.mpPolyPolygon)
+ B2DPolyPolygon::B2DPolyPolygon(const B2DPolyPolygon& rPolyPolygon)
+ : mpPolyPolygon(rPolyPolygon.mpPolyPolygon)
+ {
+ mpPolyPolygon->incRefCount();
+ }
+
+ B2DPolyPolygon::~B2DPolyPolygon()
+ {
+ if(mpPolyPolygon->getRefCount())
{
- mpPolyPolygon->incRefCount();
+ mpPolyPolygon->decRefCount();
}
-
- B2DPolyPolygon::~B2DPolyPolygon()
+ else
{
- if(mpPolyPolygon->getRefCount())
- {
- mpPolyPolygon->decRefCount();
- }
- else
- {
- delete mpPolyPolygon;
- }
+ delete mpPolyPolygon;
}
+ }
- B2DPolyPolygon& B2DPolyPolygon::operator=(const B2DPolyPolygon& rPolyPolygon)
+ B2DPolyPolygon& B2DPolyPolygon::operator=(const B2DPolyPolygon& rPolyPolygon)
+ {
+ if(mpPolyPolygon->getRefCount())
{
- if(mpPolyPolygon->getRefCount())
- {
- mpPolyPolygon->decRefCount();
- }
- else
- {
- delete mpPolyPolygon;
- }
-
- mpPolyPolygon = rPolyPolygon.mpPolyPolygon;
- mpPolyPolygon->incRefCount();
-
- return *this;
+ mpPolyPolygon->decRefCount();
}
-
- sal_Bool B2DPolyPolygon::operator==(const B2DPolyPolygon& rPolyPolygon) const
+ else
{
- if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon)
- {
- return sal_True;
- }
-
- return mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon));
+ delete mpPolyPolygon;
}
- sal_Bool B2DPolyPolygon::operator!=(const B2DPolyPolygon& rPolyPolygon) const
- {
- if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon)
- {
- return sal_False;
- }
+ mpPolyPolygon = rPolyPolygon.mpPolyPolygon;
+ mpPolyPolygon->incRefCount();
- return !mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon));
- }
+ return *this;
+ }
- sal_uInt32 B2DPolyPolygon::count() const
+ sal_Bool B2DPolyPolygon::operator==(const B2DPolyPolygon& rPolyPolygon) const
+ {
+ if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon)
{
- return mpPolyPolygon->count();
+ return sal_True;
}
- B2DPolygon B2DPolyPolygon::getB2DPolygon(sal_uInt32 nIndex) const
- {
- OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)");
+ return mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon));
+ }
- return mpPolyPolygon->getB2DPolygon(nIndex);
+ sal_Bool B2DPolyPolygon::operator!=(const B2DPolyPolygon& rPolyPolygon) const
+ {
+ if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon)
+ {
+ return sal_False;
}
- void B2DPolyPolygon::setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon)
- {
- OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)");
+ return !mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon));
+ }
- if(mpPolyPolygon->getB2DPolygon(nIndex) != rPolygon)
- {
- implForceUniqueCopy();
- mpPolyPolygon->setB2DPolygon(nIndex, rPolygon);
- }
- }
+ sal_uInt32 B2DPolyPolygon::count() const
+ {
+ return mpPolyPolygon->count();
+ }
- sal_Bool B2DPolyPolygon::areControlPointsUsed() const
- {
- for(sal_uInt32 a(0L); a < mpPolyPolygon->count(); a++)
- {
- const ::basegfx::polygon::B2DPolygon& rPolygon = mpPolyPolygon->getB2DPolygon(a);
+ B2DPolygon B2DPolyPolygon::getB2DPolygon(sal_uInt32 nIndex) const
+ {
+ OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)");
- if(rPolygon.areControlPointsUsed())
- {
- return sal_True;
- }
- }
+ return mpPolyPolygon->getB2DPolygon(nIndex);
+ }
- return sal_False;
+ void B2DPolyPolygon::setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon)
+ {
+ OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)");
+
+ if(mpPolyPolygon->getB2DPolygon(nIndex) != rPolygon)
+ {
+ implForceUniqueCopy();
+ mpPolyPolygon->setB2DPolygon(nIndex, rPolygon);
}
+ }
- void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount)
+ sal_Bool B2DPolyPolygon::areControlPointsUsed() const
+ {
+ for(sal_uInt32 a(0L); a < mpPolyPolygon->count(); a++)
{
- OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)");
+ const ::basegfx::B2DPolygon& rPolygon = mpPolyPolygon->getB2DPolygon(a);
- if(nCount)
+ if(rPolygon.areControlPointsUsed())
{
- implForceUniqueCopy();
- mpPolyPolygon->insert(nIndex, rPolygon, nCount);
+ return sal_True;
}
}
- void B2DPolyPolygon::append(const B2DPolygon& rPolygon, sal_uInt32 nCount)
+ return sal_False;
+ }
+
+ void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount)
+ {
+ OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)");
+
+ if(nCount)
{
- if(nCount)
- {
- implForceUniqueCopy();
- mpPolyPolygon->insert(mpPolyPolygon->count(), rPolygon, nCount);
- }
+ implForceUniqueCopy();
+ mpPolyPolygon->insert(nIndex, rPolygon, nCount);
}
+ }
- void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon)
+ void B2DPolyPolygon::append(const B2DPolygon& rPolygon, sal_uInt32 nCount)
+ {
+ if(nCount)
{
- OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)");
-
- if(rPolyPolygon.count())
- {
- implForceUniqueCopy();
- mpPolyPolygon->insert(nIndex, rPolyPolygon);
- }
+ implForceUniqueCopy();
+ mpPolyPolygon->insert(mpPolyPolygon->count(), rPolygon, nCount);
}
+ }
+
+ void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon)
+ {
+ OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)");
- void B2DPolyPolygon::append(const B2DPolyPolygon& rPolyPolygon)
+ if(rPolyPolygon.count())
{
- if(rPolyPolygon.count())
- {
- implForceUniqueCopy();
- mpPolyPolygon->insert(mpPolyPolygon->count(), rPolyPolygon);
- }
+ implForceUniqueCopy();
+ mpPolyPolygon->insert(nIndex, rPolyPolygon);
}
+ }
- void B2DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
+ void B2DPolyPolygon::append(const B2DPolyPolygon& rPolyPolygon)
+ {
+ if(rPolyPolygon.count())
{
- OSL_ENSURE(nIndex + nCount <= mpPolyPolygon->count(), "B2DPolyPolygon Remove outside range (!)");
-
- if(nCount)
- {
- implForceUniqueCopy();
- mpPolyPolygon->remove(nIndex, nCount);
- }
+ implForceUniqueCopy();
+ mpPolyPolygon->insert(mpPolyPolygon->count(), rPolyPolygon);
}
+ }
- void B2DPolyPolygon::clear()
- {
- if(mpPolyPolygon->getRefCount())
- {
- mpPolyPolygon->decRefCount();
- }
- else
- {
- delete mpPolyPolygon;
- }
+ void B2DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
+ {
+ OSL_ENSURE(nIndex + nCount <= mpPolyPolygon->count(), "B2DPolyPolygon Remove outside range (!)");
- mpPolyPolygon = &maStaticDefaultPolyPolygon;
- mpPolyPolygon->incRefCount();
+ if(nCount)
+ {
+ implForceUniqueCopy();
+ mpPolyPolygon->remove(nIndex, nCount);
}
+ }
- sal_Bool B2DPolyPolygon::isClosed() const
+ void B2DPolyPolygon::clear()
+ {
+ if(mpPolyPolygon->getRefCount())
+ {
+ mpPolyPolygon->decRefCount();
+ }
+ else
{
- sal_Bool bRetval(sal_True);
+ delete mpPolyPolygon;
+ }
- // PolyPOlygon is closed when all contained Polygons are closed or
- // no Polygon exists.
- for(sal_uInt32 a(0L); bRetval && a < mpPolyPolygon->count(); a++)
- {
- if(!(mpPolyPolygon->getB2DPolygon(a)).isClosed())
- {
- bRetval = sal_False;
- }
- }
+ mpPolyPolygon = &maStaticDefaultPolyPolygon;
+ mpPolyPolygon->incRefCount();
+ }
- return bRetval;
- }
+ sal_Bool B2DPolyPolygon::isClosed() const
+ {
+ sal_Bool bRetval(sal_True);
- void B2DPolyPolygon::setClosed(sal_Bool bNew)
+ // PolyPOlygon is closed when all contained Polygons are closed or
+ // no Polygon exists.
+ for(sal_uInt32 a(0L); bRetval && a < mpPolyPolygon->count(); a++)
{
- if(bNew != isClosed())
+ if(!(mpPolyPolygon->getB2DPolygon(a)).isClosed())
{
- implForceUniqueCopy();
- mpPolyPolygon->setClosed(bNew);
+ bRetval = sal_False;
}
}
- void B2DPolyPolygon::flip()
+ return bRetval;
+ }
+
+ void B2DPolyPolygon::setClosed(sal_Bool bNew)
+ {
+ if(bNew != isClosed())
{
implForceUniqueCopy();
- mpPolyPolygon->flip();
+ mpPolyPolygon->setClosed(bNew);
}
+ }
- sal_Bool B2DPolyPolygon::hasDoublePoints() const
- {
- sal_Bool bRetval(sal_False);
-
- for(sal_uInt32 a(0L); !bRetval && a < mpPolyPolygon->count(); a++)
- {
- if((mpPolyPolygon->getB2DPolygon(a)).hasDoublePoints())
- {
- bRetval = sal_True;
- }
- }
+ void B2DPolyPolygon::flip()
+ {
+ implForceUniqueCopy();
+ mpPolyPolygon->flip();
+ }
- return bRetval;
- }
+ sal_Bool B2DPolyPolygon::hasDoublePoints() const
+ {
+ sal_Bool bRetval(sal_False);
- void B2DPolyPolygon::removeDoublePoints()
+ for(sal_uInt32 a(0L); !bRetval && a < mpPolyPolygon->count(); a++)
{
- if(hasDoublePoints())
+ if((mpPolyPolygon->getB2DPolygon(a)).hasDoublePoints())
{
- implForceUniqueCopy();
- mpPolyPolygon->removeDoublePoints();
+ bRetval = sal_True;
}
}
- void B2DPolyPolygon::transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix)
+ return bRetval;
+ }
+
+ void B2DPolyPolygon::removeDoublePoints()
+ {
+ if(hasDoublePoints())
{
implForceUniqueCopy();
- mpPolyPolygon->transform(rMatrix);
+ mpPolyPolygon->removeDoublePoints();
}
- } // end of namespace polygon
+ }
+
+ void B2DPolyPolygon::transform(const ::basegfx::B2DHomMatrix& rMatrix)
+ {
+ implForceUniqueCopy();
+ mpPolyPolygon->transform(rMatrix);
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
index a86bfce3d937..17d1c476acbf 100644
--- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx
+++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolypolygoncutter.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:12 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -88,231 +88,228 @@
namespace basegfx
{
- namespace polygon
+ B2DPolygonNode::B2DPolygonNode(const ::basegfx::B2DPoint& rPosition, B2DPolygonNode* pPrevious)
+ : maPosition(rPosition)
{
- B2DPolygonNode::B2DPolygonNode(const ::basegfx::point::B2DPoint& rPosition, B2DPolygonNode* pPrevious)
- : maPosition(rPosition)
- {
- mpListPrevious = this;
- mpListNext = this;
+ mpListPrevious = this;
+ mpListNext = this;
- if(pPrevious)
- {
- mpNext = pPrevious->getNext();
- mpPrevious = pPrevious;
- mpNext->mpPrevious = this;
- mpPrevious->mpNext = this;
- }
- else
- {
- mpPrevious = mpNext = this;
- }
+ if(pPrevious)
+ {
+ mpNext = pPrevious->getNext();
+ mpPrevious = pPrevious;
+ mpNext->mpPrevious = this;
+ mpPrevious->mpNext = this;
}
-
- B2DPolygonNode::~B2DPolygonNode()
+ else
{
- if(mpNext != this)
- {
- mpPrevious->mpNext = mpNext;
- mpNext->mpPrevious = mpPrevious;
- }
+ mpPrevious = mpNext = this;
}
+ }
- void B2DPolygonNode::calcMinMaxX(double& fMaxAX, double& fMinAX) const
+ B2DPolygonNode::~B2DPolygonNode()
+ {
+ if(mpNext != this)
{
- if(maPosition.getX() > mpNext->maPosition.getX())
- {
- fMaxAX = maPosition.getX();
- fMinAX = mpNext->maPosition.getX();
- }
- else
- {
- fMaxAX = mpNext->maPosition.getX();
- fMinAX = maPosition.getX();
- }
+ mpPrevious->mpNext = mpNext;
+ mpNext->mpPrevious = mpPrevious;
}
+ }
- void B2DPolygonNode::calcMinMaxY(double& fMaxAY, double& fMinAY) const
+ void B2DPolygonNode::calcMinMaxX(double& fMaxAX, double& fMinAX) const
+ {
+ if(maPosition.getX() > mpNext->maPosition.getX())
{
- if(maPosition.getY() > mpNext->maPosition.getY())
- {
- fMaxAY = maPosition.getY();
- fMinAY = mpNext->maPosition.getY();
- }
- else
- {
- fMaxAY = mpNext->maPosition.getY();
- fMinAY = maPosition.getY();
- }
+ fMaxAX = maPosition.getX();
+ fMinAX = mpNext->maPosition.getX();
+ }
+ else
+ {
+ fMaxAX = mpNext->maPosition.getX();
+ fMinAX = maPosition.getX();
}
+ }
- void B2DPolygonNode::swapNextPointers(B2DPolygonNode* pCand)
+ void B2DPolygonNode::calcMinMaxY(double& fMaxAY, double& fMinAY) const
+ {
+ if(maPosition.getY() > mpNext->maPosition.getY())
{
- B2DPolygonNode* pTemporary = mpNext;
- mpNext = pCand->mpNext;
- pCand->mpNext = pTemporary;
- mpNext->mpPrevious = this;
- pCand->mpNext->mpPrevious = pCand;
+ fMaxAY = maPosition.getY();
+ fMinAY = mpNext->maPosition.getY();
+ }
+ else
+ {
+ fMaxAY = mpNext->maPosition.getY();
+ fMinAY = maPosition.getY();
}
+ }
- void B2DPolygonNode::addToList(B2DPolygonNode*& rpList)
+ void B2DPolygonNode::swapNextPointers(B2DPolygonNode* pCand)
+ {
+ B2DPolygonNode* pTemporary = mpNext;
+ mpNext = pCand->mpNext;
+ pCand->mpNext = pTemporary;
+ mpNext->mpPrevious = this;
+ pCand->mpNext->mpPrevious = pCand;
+ }
+
+ void B2DPolygonNode::addToList(B2DPolygonNode*& rpList)
+ {
+ if(rpList)
{
- if(rpList)
- {
- mpListNext = rpList->mpListNext;
- rpList->mpListNext = this;
- mpListPrevious = rpList;
- mpListNext->mpListPrevious = this;
- }
- else
- {
- rpList = this;
- }
+ mpListNext = rpList->mpListNext;
+ rpList->mpListNext = this;
+ mpListPrevious = rpList;
+ mpListNext->mpListPrevious = this;
+ }
+ else
+ {
+ rpList = this;
}
+ }
- void B2DPolygonNode::remFromList(B2DPolygonNode*& rpList)
+ void B2DPolygonNode::remFromList(B2DPolygonNode*& rpList)
+ {
+ if(mpListNext != this)
{
- if(mpListNext != this)
+ if(rpList == this)
{
- if(rpList == this)
- {
- rpList = mpListPrevious;
- }
-
- mpListPrevious->mpListNext = mpListNext;
- mpListNext->mpListPrevious = mpListPrevious;
- mpListNext = mpListPrevious = this;
+ rpList = mpListPrevious;
}
- else
+
+ mpListPrevious->mpListNext = mpListNext;
+ mpListNext->mpListPrevious = mpListPrevious;
+ mpListNext = mpListPrevious = this;
+ }
+ else
+ {
+ if(rpList == this)
{
- if(rpList == this)
- {
- rpList = 0L;
- }
+ rpList = 0L;
}
}
+ }
- sal_Bool B2DPolygonNode::getOrientation() const
- {
- const B2DPolygonNode* pOutmost = this;
- const B2DPolygonNode* pCurrent = this->getNext();
+ sal_Bool B2DPolygonNode::getOrientation() const
+ {
+ const B2DPolygonNode* pOutmost = this;
+ const B2DPolygonNode* pCurrent = this->getNext();
- while(pCurrent != this)
+ while(pCurrent != this)
+ {
+ if(::basegfx::fTools::more(pOutmost->getPosition().getX(), pCurrent->getPosition().getX()))
{
- if(::basegfx::numeric::fTools::more(pOutmost->getPosition().getX(), pCurrent->getPosition().getX()))
+ if(pCurrent->getPosition().getX() < pOutmost->getPosition().getX())
+ {
+ pOutmost = pCurrent;
+ }
+ else
{
- if(pCurrent->getPosition().getX() < pOutmost->getPosition().getX())
+ if(pCurrent->getPosition().getY() < pOutmost->getPosition().getY())
{
pOutmost = pCurrent;
}
- else
- {
- if(pCurrent->getPosition().getY() < pOutmost->getPosition().getY())
- {
- pOutmost = pCurrent;
- }
- }
}
-
- // next node
- pCurrent = pCurrent->getNext();
}
- ::basegfx::vector::B2DVector aVec1(pOutmost->getPrevious()->getPosition() - pOutmost->getPosition());
- ::basegfx::vector::B2DVector aVec2(pOutmost->getNext()->getPosition() - pOutmost->getPosition());
- return sal_Bool(::basegfx::numeric::fTools::more(aVec1.getX() * aVec2.getY(), aVec1.getY() * aVec2.getX()));
+ // next node
+ pCurrent = pCurrent->getNext();
}
- void B2DPolygonNode::swapOrientation()
- {
- B2DPolygonNode* pCurrent = this;
+ ::basegfx::B2DVector aVec1(pOutmost->getPrevious()->getPosition() - pOutmost->getPosition());
+ ::basegfx::B2DVector aVec2(pOutmost->getNext()->getPosition() - pOutmost->getPosition());
+ return sal_Bool(::basegfx::fTools::more(aVec1.getX() * aVec2.getY(), aVec1.getY() * aVec2.getX()));
+ }
- do {
- pCurrent->swapPreviousNext();
- pCurrent = pCurrent->getPrevious();
- } while(pCurrent != this);
- }
+ void B2DPolygonNode::swapOrientation()
+ {
+ B2DPolygonNode* pCurrent = this;
- ::basegfx::range::B2DRange B2DPolygonNode::getRange() const
- {
- ::basegfx::range::B2DRange aRetval;
- const B2DPolygonNode* pCurrent = this;
+ do {
+ pCurrent->swapPreviousNext();
+ pCurrent = pCurrent->getPrevious();
+ } while(pCurrent != this);
+ }
- do {
- aRetval.expand(pCurrent->getPosition());
- pCurrent = pCurrent->getPrevious();
- } while(pCurrent != this);
+ ::basegfx::B2DRange B2DPolygonNode::getRange() const
+ {
+ ::basegfx::B2DRange aRetval;
+ const B2DPolygonNode* pCurrent = this;
- return aRetval;
- }
+ do {
+ aRetval.expand(pCurrent->getPosition());
+ pCurrent = pCurrent->getPrevious();
+ } while(pCurrent != this);
- sal_Bool B2DPolygonNode::isInside(const ::basegfx::point::B2DPoint& rPoint, sal_Bool bWithBorder) const
+ return aRetval;
+ }
+
+ sal_Bool B2DPolygonNode::isInside(const ::basegfx::B2DPoint& rPoint, sal_Bool bWithBorder) const
+ {
+ sal_Bool bInside(sal_False);
+ const B2DPolygonNode* pCurrent = this;
+
+ do
{
- sal_Bool bInside(sal_False);
- const B2DPolygonNode* pCurrent = this;
+ if(bWithBorder && pCurrent->getPosition().equal(rPoint))
+ {
+ return sal_True;
+ }
+
+ B2DPolygonNode* pNext = pCurrent->getNext();
+ const sal_Bool bCompYA(::basegfx::fTools::more(pCurrent->getPosition().getY(), rPoint.getY()));
+ const sal_Bool bCompYB(::basegfx::fTools::more(pNext->getPosition().getY(), rPoint.getY()));
- do
+ if(bCompYA != bCompYB)
{
- if(bWithBorder && pCurrent->getPosition().equal(rPoint))
+ const sal_Bool bCompXA(::basegfx::fTools::more(pCurrent->getPosition().getX(), rPoint.getX()));
+ const sal_Bool bCompXB(::basegfx::fTools::more(pNext->getPosition().getX(), rPoint.getX()));
+
+ if(bCompXA == bCompXB)
{
- return sal_True;
+ if(bCompXA)
+ {
+ bInside = !bInside;
+ }
}
-
- B2DPolygonNode* pNext = pCurrent->getNext();
- const sal_Bool bCompYA(::basegfx::numeric::fTools::more(pCurrent->getPosition().getY(), rPoint.getY()));
- const sal_Bool bCompYB(::basegfx::numeric::fTools::more(pNext->getPosition().getY(), rPoint.getY()));
-
- if(bCompYA != bCompYB)
+ else
{
- const sal_Bool bCompXA(::basegfx::numeric::fTools::more(pCurrent->getPosition().getX(), rPoint.getX()));
- const sal_Bool bCompXB(::basegfx::numeric::fTools::more(pNext->getPosition().getX(), rPoint.getX()));
+ double fCmp =
+ pNext->getPosition().getX() - (pNext->getPosition().getY() - rPoint.getY()) *
+ (pCurrent->getPosition().getX() - pNext->getPosition().getX()) /
+ (pCurrent->getPosition().getY() - pNext->getPosition().getY());
- if(bCompXA == bCompXB)
+ if(bWithBorder && ::basegfx::fTools::more(fCmp, rPoint.getX()))
{
- if(bCompXA)
- {
- bInside = !bInside;
- }
+ bInside = !bInside;
}
- else
+ else if(::basegfx::fTools::moreOrEqual(fCmp, rPoint.getX()))
{
- double fCmp =
- pNext->getPosition().getX() - (pNext->getPosition().getY() - rPoint.getY()) *
- (pCurrent->getPosition().getX() - pNext->getPosition().getX()) /
- (pCurrent->getPosition().getY() - pNext->getPosition().getY());
-
- if(bWithBorder && ::basegfx::numeric::fTools::more(fCmp, rPoint.getX()))
- {
- bInside = !bInside;
- }
- else if(::basegfx::numeric::fTools::moreOrEqual(fCmp, rPoint.getX()))
- {
- bInside = !bInside;
- }
+ bInside = !bInside;
}
}
+ }
- // next edge
- pCurrent = pNext;
+ // next edge
+ pCurrent = pNext;
- } while(pCurrent != this);
+ } while(pCurrent != this);
- return bInside;
- }
+ return bInside;
+ }
- sal_Bool B2DPolygonNode::isPolygonInside(B2DPolygonNode* pPoly, sal_Bool bWithBorder) const
- {
- B2DPolygonNode* pTest = pPoly;
- sal_Bool bAllAInside(sal_True);
+ sal_Bool B2DPolygonNode::isPolygonInside(B2DPolygonNode* pPoly, sal_Bool bWithBorder) const
+ {
+ B2DPolygonNode* pTest = pPoly;
+ sal_Bool bAllAInside(sal_True);
- do {
- bAllAInside = isInside(pTest->getPosition(), bWithBorder);
- pTest = pTest->getNext();
- } while(bAllAInside && pTest != pPoly);
+ do {
+ bAllAInside = isInside(pTest->getPosition(), bWithBorder);
+ pTest = pTest->getNext();
+ } while(bAllAInside && pTest != pPoly);
- return bAllAInside;
- }
- } // end of namespace polygon
+ return bAllAInside;
+ }
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
@@ -320,26 +317,23 @@ namespace basegfx
namespace basegfx
{
- namespace polygon
+ void B2DSimpleCut::solve()
{
- void B2DSimpleCut::solve()
- {
- mpLeft->swapNextPointers(mpRight);
+ mpLeft->swapNextPointers(mpRight);
- if(mbCorrectOrientation)
+ if(mbCorrectOrientation)
+ {
+ if(mpLeft->getOrientation() != mbOrientation)
{
- if(mpLeft->getOrientation() != mbOrientation)
- {
- mpLeft->swapOrientation();
- }
+ mpLeft->swapOrientation();
+ }
- if(mpRight->getOrientation() != mbOrientation)
- {
- mpRight->swapOrientation();
- }
+ if(mpRight->getOrientation() != mbOrientation)
+ {
+ mpRight->swapOrientation();
}
}
- } // end of namespace polygon
+ }
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
@@ -347,27 +341,24 @@ namespace basegfx
namespace basegfx
{
- namespace polygon
+ void B2DClipExtraPolygonInfo::init(B2DPolygonNode* pNew)
{
- void B2DClipExtraPolygonInfo::init(B2DPolygonNode* pNew)
+ maRange = pNew->getRange();
+ mbOrientation = pNew->getOrientation();
+ mnDepth = (mbOrientation) ? 0L : -1L;
+ }
+
+ void B2DClipExtraPolygonInfo::changeDepth(sal_Bool bOrientation)
+ {
+ if(bOrientation)
{
- maRange = pNew->getRange();
- mbOrientation = pNew->getOrientation();
- mnDepth = (mbOrientation) ? 0L : -1L;
+ mnDepth++;
}
-
- void B2DClipExtraPolygonInfo::changeDepth(sal_Bool bOrientation)
+ else
{
- if(bOrientation)
- {
- mnDepth++;
- }
- else
- {
- mnDepth--;
- }
+ mnDepth--;
}
- } // end of namespace polygon
+ }
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
@@ -375,772 +366,769 @@ namespace basegfx
namespace basegfx
{
- namespace polygon
+ B2DPolyPolygonCutter::~B2DPolyPolygonCutter()
{
- B2DPolyPolygonCutter::~B2DPolyPolygonCutter()
+ for(sal_uInt32 a(0L); a < maPolygonList.size(); a++)
{
- for(sal_uInt32 a(0L); a < maPolygonList.size(); a++)
- {
- delete maPolygonList[a];
- }
-
- maPolygonList.clear();
+ delete maPolygonList[a];
}
- void B2DPolyPolygonCutter::removeIncludedPolygons(sal_Bool bUseOr)
+ maPolygonList.clear();
+ }
+
+ void B2DPolyPolygonCutter::removeIncludedPolygons(sal_Bool bUseOr)
+ {
+ const sal_uInt32 aCount(maPolygonList.size());
+ B2DClipExtraPolygonInfo* pInfos = new B2DClipExtraPolygonInfo[aCount];
+ sal_uInt32 a, b;
+
+ // fill infos
+ for(a = 0L; a < aCount; a++)
{
- const sal_uInt32 aCount(maPolygonList.size());
- B2DClipExtraPolygonInfo* pInfos = new B2DClipExtraPolygonInfo[aCount];
- sal_uInt32 a, b;
+ pInfos[a].init(maPolygonList[a]);
+ }
- // fill infos
- for(a = 0L; a < aCount; a++)
- {
- pInfos[a].init(maPolygonList[a]);
- }
+ // get all includes
+ for(a = 0L; a < aCount; a++)
+ {
+ B2DClipExtraPolygonInfo& rInfoA = pInfos[a];
- // get all includes
- for(a = 0L; a < aCount; a++)
+ for(b = 0L; b < aCount; b++)
{
- B2DClipExtraPolygonInfo& rInfoA = pInfos[a];
+ B2DClipExtraPolygonInfo& rInfoB = pInfos[b];
- for(b = 0L; b < aCount; b++)
+ if(a != b && doRangesInclude(rInfoA.getRange(), rInfoB.getRange()))
{
- B2DClipExtraPolygonInfo& rInfoB = pInfos[b];
-
- if(a != b && doRangesInclude(rInfoA.getRange(), rInfoB.getRange()))
+ // volume B in A, test pA, pB for inclusion, with border
+ if(maPolygonList[a]->isPolygonInside(maPolygonList[b], sal_True))
{
- // volume B in A, test pA, pB for inclusion, with border
- if(maPolygonList[a]->isPolygonInside(maPolygonList[b], sal_True))
- {
- // pB is inside pA
- rInfoB.changeDepth(rInfoA.getOrientation());
- }
+ // pB is inside pA
+ rInfoB.changeDepth(rInfoA.getOrientation());
}
}
}
+ }
- // delete removable
- for(a = 0L, b = 0L; a < aCount; a++)
- {
- B2DClipExtraPolygonInfo& rInfo = pInfos[a];
+ // delete removable
+ for(a = 0L, b = 0L; a < aCount; a++)
+ {
+ B2DClipExtraPolygonInfo& rInfo = pInfos[a];
- if((bUseOr && rInfo.getDepth() != 0L) || (!bUseOr && rInfo.getDepth() < 1L))
- {
- B2DPolygonNodeVector::iterator aPosition(maPolygonList.begin() + b);
- B2DPolygonNode* pCandidate = *aPosition;
- maPolygonList.erase(aPosition);
- deletePolygon(pCandidate);
- }
- else
- {
- b++;
- }
+ if((bUseOr && rInfo.getDepth() != 0L) || (!bUseOr && rInfo.getDepth() < 1L))
+ {
+ B2DPolygonNodeVector::iterator aPosition(maPolygonList.begin() + b);
+ B2DPolygonNode* pCandidate = *aPosition;
+ maPolygonList.erase(aPosition);
+ deletePolygon(pCandidate);
+ }
+ else
+ {
+ b++;
}
-
- // delete infos
- delete[] pInfos;
}
- void B2DPolyPolygonCutter::solveAllCuts(B2DSimpleCutVector& rCuts)
- {
- B2DPolygonNode* pNewList = 0L;
-
- // add all nodes of polys to list
- polysToList(pNewList);
+ // delete infos
+ delete[] pInfos;
+ }
- // solve cuts
- B2DSimpleCutVector::iterator aCandidate(rCuts.begin());
+ void B2DPolyPolygonCutter::solveAllCuts(B2DSimpleCutVector& rCuts)
+ {
+ B2DPolygonNode* pNewList = 0L;
- for(; aCandidate < rCuts.end(); aCandidate++)
- {
- B2DSimpleCut* pCut = *aCandidate;
- pCut->solve();
- delete pCut;
- }
+ // add all nodes of polys to list
+ polysToList(pNewList);
- rCuts.clear();
+ // solve cuts
+ B2DSimpleCutVector::iterator aCandidate(rCuts.begin());
- // extract polys
- listToPolys(pNewList);
+ for(; aCandidate < rCuts.end(); aCandidate++)
+ {
+ B2DSimpleCut* pCut = *aCandidate;
+ pCut->solve();
+ delete pCut;
}
- void B2DPolyPolygonCutter::polysToList(B2DPolygonNode*& rpList)
- {
- B2DPolygonNodeVector::iterator aCandidate(maPolygonList.begin());
+ rCuts.clear();
- for(; aCandidate != maPolygonList.end(); aCandidate++)
- {
- addAllNodes(*aCandidate, rpList);
- }
+ // extract polys
+ listToPolys(pNewList);
+ }
- maPolygonList.clear();
- }
+ void B2DPolyPolygonCutter::polysToList(B2DPolygonNode*& rpList)
+ {
+ B2DPolygonNodeVector::iterator aCandidate(maPolygonList.begin());
- void B2DPolyPolygonCutter::listToPolys(B2DPolygonNode*& rpList)
+ for(; aCandidate != maPolygonList.end(); aCandidate++)
{
- while(rpList)
- {
- // get one
- B2DPolygonNode* pNew = extractNextPolygon(rpList);
-
- if(pNew)
- {
- maPolygonList.push_back(pNew);
- }
- }
+ addAllNodes(*aCandidate, rpList);
}
- B2DPolygonNode* B2DPolyPolygonCutter::createNewPolygon(const B2DPolygon& rPolygon)
+ maPolygonList.clear();
+ }
+
+ void B2DPolyPolygonCutter::listToPolys(B2DPolygonNode*& rpList)
+ {
+ while(rpList)
{
- B2DPolygonNode* pRetval = NULL;
+ // get one
+ B2DPolygonNode* pNew = extractNextPolygon(rpList);
- for(sal_uInt32 a(0L); a < rPolygon.count(); a++)
+ if(pNew)
{
- ::basegfx::point::B2DPoint aPoint(rPolygon.getB2DPoint(a));
- pRetval = new B2DPolygonNode(aPoint, pRetval);
+ maPolygonList.push_back(pNew);
}
-
- return pRetval;
}
+ }
+
+ B2DPolygonNode* B2DPolyPolygonCutter::createNewPolygon(const B2DPolygon& rPolygon)
+ {
+ B2DPolygonNode* pRetval = NULL;
- void B2DPolyPolygonCutter::deletePolygon(B2DPolygonNode* pCand)
+ for(sal_uInt32 a(0L); a < rPolygon.count(); a++)
{
- B2DPolygonNode* pPoly = pCand;
+ ::basegfx::B2DPoint aPoint(rPolygon.getB2DPoint(a));
+ pRetval = new B2DPolygonNode(aPoint, pRetval);
+ }
- while(pPoly)
- {
- B2DPolygonNode* pNext = pPoly->getNext();
+ return pRetval;
+ }
- if(pNext == pPoly)
- {
- pNext = 0L;
- }
+ void B2DPolyPolygonCutter::deletePolygon(B2DPolygonNode* pCand)
+ {
+ B2DPolygonNode* pPoly = pCand;
+
+ while(pPoly)
+ {
+ B2DPolygonNode* pNext = pPoly->getNext();
- delete pPoly;
- pPoly = pNext;
+ if(pNext == pPoly)
+ {
+ pNext = 0L;
}
+
+ delete pPoly;
+ pPoly = pNext;
}
+ }
- void B2DPolyPolygonCutter::addAllNodes(B2DPolygonNode* pPolygon, B2DPolygonNode*& rpList)
- {
- B2DPolygonNode* pAct = pPolygon;
+ void B2DPolyPolygonCutter::addAllNodes(B2DPolygonNode* pPolygon, B2DPolygonNode*& rpList)
+ {
+ B2DPolygonNode* pAct = pPolygon;
- do {
- pAct->addToList(rpList);
- pAct = pAct->getNext();
- } while(pAct != pPolygon);
- }
+ do {
+ pAct->addToList(rpList);
+ pAct = pAct->getNext();
+ } while(pAct != pPolygon);
+ }
- void B2DPolyPolygonCutter::addPolyPolygon(const B2DPolyPolygon& rPolyPolygon, sal_Bool bForceOrientation)
+ void B2DPolyPolygonCutter::addPolyPolygon(const B2DPolyPolygon& rPolyPolygon, sal_Bool bForceOrientation)
+ {
+ for(sal_uInt32 a(0L); a < rPolyPolygon.count(); a++)
{
- for(sal_uInt32 a(0L); a < rPolyPolygon.count(); a++)
- {
- B2DPolygon aCandidate = rPolyPolygon.getB2DPolygon(a);
- aCandidate.removeDoublePoints();
+ B2DPolygon aCandidate = rPolyPolygon.getB2DPolygon(a);
+ aCandidate.removeDoublePoints();
- if(!aCandidate.isClosed() || aCandidate.count() < 3)
- {
- maNotClosedPolygons.append(aCandidate);
- }
- else
+ if(!aCandidate.isClosed() || aCandidate.count() < 3)
+ {
+ maNotClosedPolygons.append(aCandidate);
+ }
+ else
+ {
+ if(bForceOrientation)
{
- if(bForceOrientation)
- {
- ::basegfx::vector::B2DVectorOrientation aOrientation =
- ::basegfx::polygon::tools::getOrientation(aCandidate);
+ ::basegfx::B2DVectorOrientation aOrientation =
+ ::basegfx::tools::getOrientation(aCandidate);
- if(::basegfx::vector::ORIENTATION_POSITIVE != aOrientation)
- {
- aCandidate.flip();
- }
+ if(::basegfx::ORIENTATION_POSITIVE != aOrientation)
+ {
+ aCandidate.flip();
}
-
- B2DPolygonNode* pNew = createNewPolygon(aCandidate);
- maPolygonList.push_back(pNew);
}
+
+ B2DPolygonNode* pNew = createNewPolygon(aCandidate);
+ maPolygonList.push_back(pNew);
}
}
+ }
+
+ void B2DPolyPolygonCutter::getPolyPolygon(B2DPolyPolygon& rPolyPolygon)
+ {
+ B2DPolygonNodeVector::iterator aCandidate(maPolygonList.begin());
- void B2DPolyPolygonCutter::getPolyPolygon(B2DPolyPolygon& rPolyPolygon)
+ for(; aCandidate < maPolygonList.end(); aCandidate++)
{
- B2DPolygonNodeVector::iterator aCandidate(maPolygonList.begin());
+ B2DPolygonNode* pCand = *aCandidate;
+ B2DPolygonNode* pAct = pCand;
+ sal_uInt32 nCount(0L);
+
+ do {
+ nCount++;
+ pAct = pAct->getNext();
+ } while(pAct != pCand);
- for(; aCandidate < maPolygonList.end(); aCandidate++)
+ if(nCount > 2L)
{
- B2DPolygonNode* pCand = *aCandidate;
- B2DPolygonNode* pAct = pCand;
- sal_uInt32 nCount(0L);
+ B2DPolygon aNewPolygon;
do {
- nCount++;
+ aNewPolygon.append(pAct->getPosition());
pAct = pAct->getNext();
} while(pAct != pCand);
- if(nCount > 2L)
- {
- B2DPolygon aNewPolygon;
+ aNewPolygon.setClosed(sal_True);
+ rPolyPolygon.append(aNewPolygon);
+ }
- do {
- aNewPolygon.append(pAct->getPosition());
- pAct = pAct->getNext();
- } while(pAct != pCand);
+ deletePolygon(pCand);
+ }
- aNewPolygon.setClosed(sal_True);
- rPolyPolygon.append(aNewPolygon);
- }
+ maPolygonList.clear();
- deletePolygon(pCand);
- }
+ while(maNotClosedPolygons.count())
+ {
+ rPolyPolygon.append(maNotClosedPolygons.getB2DPolygon(0L));
+ maNotClosedPolygons.remove(0L);
+ }
+ }
- maPolygonList.clear();
+ B2DSimpleCut* B2DPolyPolygonCutter::getExistingCut(B2DSimpleCutVector& rTmpCuts, B2DPolygonNode* pA, B2DPolygonNode* pB)
+ {
+ for(sal_uInt32 a(0L); a < rTmpCuts.size(); a++)
+ {
+ B2DSimpleCut* pCand = rTmpCuts[a];
- while(maNotClosedPolygons.count())
+ if(pCand->isSameCut(pA, pB))
{
- rPolyPolygon.append(maNotClosedPolygons.getB2DPolygon(0L));
- maNotClosedPolygons.remove(0L);
+ return pCand;
}
}
- B2DSimpleCut* B2DPolyPolygonCutter::getExistingCut(B2DSimpleCutVector& rTmpCuts, B2DPolygonNode* pA, B2DPolygonNode* pB)
- {
- for(sal_uInt32 a(0L); a < rTmpCuts.size(); a++)
- {
- B2DSimpleCut* pCand = rTmpCuts[a];
+ return 0L;
+ }
- if(pCand->isSameCut(pA, pB))
- {
- return pCand;
- }
- }
+ B2DPolygonNode* B2DPolyPolygonCutter::extractNextPolygon(B2DPolygonNode*& rpList)
+ {
+ B2DPolygonNode* pStart = rpList;
+
+ // remove all nodes of this poly from list
+ B2DPolygonNode* pAct = pStart;
+ sal_uInt32 nNumNodes(0L);
+
+ do {
+ pAct->remFromList(rpList);
+ pAct = pAct->getNext();
+ nNumNodes++;
+ } while(pAct != pStart);
+ if(nNumNodes < 3L)
+ {
+ deletePolygon(pStart);
return 0L;
}
-
- B2DPolygonNode* B2DPolyPolygonCutter::extractNextPolygon(B2DPolygonNode*& rpList)
+ else
{
- B2DPolygonNode* pStart = rpList;
-
- // remove all nodes of this poly from list
- B2DPolygonNode* pAct = pStart;
- sal_uInt32 nNumNodes(0L);
-
- do {
- pAct->remFromList(rpList);
- pAct = pAct->getNext();
- nNumNodes++;
- } while(pAct != pStart);
-
- if(nNumNodes < 3L)
- {
- deletePolygon(pStart);
- return 0L;
- }
- else
- {
- return pStart;
- }
+ return pStart;
}
+ }
- void B2DPolyPolygonCutter::removeSelfIntersections()
+ void B2DPolyPolygonCutter::removeSelfIntersections()
+ {
+ B2DSimpleCutVector aCuts;
+ B2DSimpleCutVector aNewCuts;
+ B2DPolygonNode* pCand;
+ B2DPolygonNode* pA;
+ B2DPolygonNode* pB;
+ double fMaxAX, fMinAX, fMaxAY, fMinAY;
+ double fMaxBX, fMinBX, fMaxBY, fMinBY;
+ double fCut;
+
+ // first job: Find all cuts and add points there
+ for(sal_uInt32 a(0L); a < maPolygonList.size(); a++)
{
- B2DSimpleCutVector aCuts;
- B2DSimpleCutVector aNewCuts;
- B2DPolygonNode* pCand;
- B2DPolygonNode* pA;
- B2DPolygonNode* pB;
- double fMaxAX, fMinAX, fMaxAY, fMinAY;
- double fMaxBX, fMinBX, fMaxBY, fMinBY;
- double fCut;
-
- // first job: Find all cuts and add points there
- for(sal_uInt32 a(0L); a < maPolygonList.size(); a++)
- {
- pCand = maPolygonList[a];
- pA = pCand;
+ pCand = maPolygonList[a];
+ pA = pCand;
+
+ // one run to find same start positions (so there is no need to
+ // search for existing cuts in main loop)
+ do {
+ pB = pA->getNext();
- // one run to find same start positions (so there is no need to
- // search for existing cuts in main loop)
do {
- pB = pA->getNext();
+ if(isSamePos(pA->getPosition(), pB->getPosition()))
+ {
+ aNewCuts.push_back(new B2DSimpleCut(pA, pB, sal_True, pCand->getOrientation()));
+ }
- do {
- if(isSamePos(pA->getPosition(), pB->getPosition()))
- {
- aNewCuts.push_back(new B2DSimpleCut(pA, pB, sal_True, pCand->getOrientation()));
- }
+ // next B
+ pB = pB->getNext();
+ } while(pB != pCand);
- // next B
- pB = pB->getNext();
- } while(pB != pCand);
+ // next A
+ pA = pA->getNext();
+ } while(pA->getNext() != pCand);
- // next A
- pA = pA->getNext();
- } while(pA->getNext() != pCand);
+ // second run to find real cuts
+ pA = pCand;
- // second run to find real cuts
- pA = pCand;
+ do {
+ // get bounds for this edge in poly
+ pA->calcMinMaxX(fMaxAX, fMinAX);
+ pA->calcMinMaxY(fMaxAY, fMinAY);
+ pB = pA->getNext();
do {
- // get bounds for this edge in poly
- pA->calcMinMaxX(fMaxAX, fMinAX);
- pA->calcMinMaxY(fMaxAY, fMinAY);
- pB = pA->getNext();
+ pB->calcMinMaxX(fMaxBX, fMinBX);
- do {
- pB->calcMinMaxX(fMaxBX, fMinBX);
+ if(::basegfx::fTools::more(fMaxBX, fMinAX)
+ && ::basegfx::fTools::more(fMaxAX, fMinBX))
+ {
+ pB->calcMinMaxY(fMaxBY, fMinBY);
- if(::basegfx::numeric::fTools::more(fMaxBX, fMinAX)
- && ::basegfx::numeric::fTools::more(fMaxAX, fMinBX))
+ if(::basegfx::fTools::more(fMaxBY, fMinAY)
+ && ::basegfx::fTools::more(fMaxAY, fMinBY))
{
- pB->calcMinMaxY(fMaxBY, fMinBY);
-
- if(::basegfx::numeric::fTools::more(fMaxBY, fMinAY)
- && ::basegfx::numeric::fTools::more(fMaxAY, fMinBY))
+ if(!isSamePos(pA->getPosition(), pB->getPosition()))
{
- if(!isSamePos(pA->getPosition(), pB->getPosition()))
- {
- const ::basegfx::vector::B2DVector aVectorA(pA->getNext()->getPosition() - pA->getPosition());
- const ::basegfx::vector::B2DVector aVectorB(pB->getNext()->getPosition() - pB->getPosition());
+ const ::basegfx::B2DVector aVectorA(pA->getNext()->getPosition() - pA->getPosition());
+ const ::basegfx::B2DVector aVectorB(pB->getNext()->getPosition() - pB->getPosition());
- if(::basegfx::polygon::tools::findCut(pA->getPosition(), aVectorA, pB->getPosition(), aVectorB, CUTFLAG_LINE, &fCut))
+ if(::basegfx::tools::findCut(pA->getPosition(), aVectorA, pB->getPosition(), aVectorB, CUTFLAG_LINE, &fCut))
+ {
+ // crossover, two new points
+ ::basegfx::B2DPoint aNewPos(::basegfx::interpolate(pA->getPosition(), pA->getNext()->getPosition(), fCut));
+ B2DPolygonNode* pCutLo = new B2DPolygonNode(aNewPos, pA);
+ B2DPolygonNode* pCutHi = new B2DPolygonNode(aNewPos, pB);
+ aNewCuts.push_back(new B2DSimpleCut(pCutLo, pCutHi, sal_True, pCand->getOrientation()));
+ pA->calcMinMaxX(fMaxAX, fMinAX);
+ pA->calcMinMaxY(fMaxAY, fMinAY);
+ }
+ else
+ {
+ if(::basegfx::tools::isPointOnEdge(pA->getPosition(), pB->getPosition(), aVectorB, &fCut))
{
- // crossover, two new points
- ::basegfx::point::B2DPoint aNewPos(::basegfx::tuple::interpolate(pA->getPosition(), pA->getNext()->getPosition(), fCut));
- B2DPolygonNode* pCutLo = new B2DPolygonNode(aNewPos, pA);
- B2DPolygonNode* pCutHi = new B2DPolygonNode(aNewPos, pB);
- aNewCuts.push_back(new B2DSimpleCut(pCutLo, pCutHi, sal_True, pCand->getOrientation()));
- pA->calcMinMaxX(fMaxAX, fMinAX);
- pA->calcMinMaxY(fMaxAY, fMinAY);
+ // startpoint A at edge B, one new point
+ B2DPolygonNode* pCutHi = new B2DPolygonNode(pA->getPosition(), pB);
+ aNewCuts.push_back(new B2DSimpleCut(pA, pCutHi, sal_True, pCand->getOrientation()));
}
- else
+ else if(::basegfx::tools::isPointOnEdge(pB->getPosition(), pA->getPosition(), aVectorA, &fCut))
{
- if(::basegfx::polygon::tools::isPointOnEdge(pA->getPosition(), pB->getPosition(), aVectorB, &fCut))
- {
- // startpoint A at edge B, one new point
- B2DPolygonNode* pCutHi = new B2DPolygonNode(pA->getPosition(), pB);
- aNewCuts.push_back(new B2DSimpleCut(pA, pCutHi, sal_True, pCand->getOrientation()));
- }
- else if(::basegfx::polygon::tools::isPointOnEdge(pB->getPosition(), pA->getPosition(), aVectorA, &fCut))
- {
- // startpoint B at edge A, one new point
- B2DPolygonNode* pCutLo = new B2DPolygonNode(pB->getPosition(), pA);
- aNewCuts.push_back(new B2DSimpleCut(pCutLo, pB, sal_True, pCand->getOrientation()));
- pA->calcMinMaxX(fMaxAX, fMinAX);
- pA->calcMinMaxY(fMaxAY, fMinAY);
- }
+ // startpoint B at edge A, one new point
+ B2DPolygonNode* pCutLo = new B2DPolygonNode(pB->getPosition(), pA);
+ aNewCuts.push_back(new B2DSimpleCut(pCutLo, pB, sal_True, pCand->getOrientation()));
+ pA->calcMinMaxX(fMaxAX, fMinAX);
+ pA->calcMinMaxY(fMaxAY, fMinAY);
}
}
}
}
+ }
- // next B
- pB = pB->getNext();
- } while(pB != pCand);
+ // next B
+ pB = pB->getNext();
+ } while(pB != pCand);
- // next A
- pA = pA->getNext();
- } while(pA->getNext() != pCand);
+ // next A
+ pA = pA->getNext();
+ } while(pA->getNext() != pCand);
- // copy new cuts to cuts
- aCuts.insert(aCuts.begin(), aNewCuts.begin(), aNewCuts.end());
- aNewCuts.clear();
- }
+ // copy new cuts to cuts
+ aCuts.insert(aCuts.begin(), aNewCuts.begin(), aNewCuts.end());
+ aNewCuts.clear();
+ }
- // second job: if there were cuts, split polys
- if(aCuts.size())
- {
- solveAllCuts(aCuts);
- }
+ // second job: if there were cuts, split polys
+ if(aCuts.size())
+ {
+ solveAllCuts(aCuts);
}
+ }
- sal_Bool B2DPolyPolygonCutter::isCrossover(B2DPolygonNode* pA, B2DPolygonNode* pB)
+ sal_Bool B2DPolyPolygonCutter::isCrossover(B2DPolygonNode* pA, B2DPolygonNode* pB)
+ {
+ // build entering vectors
+ ::basegfx::B2DVector aVecA(pA->getPrevious()->getPosition() - pA->getPosition());
+ ::basegfx::B2DVector aVecB(pB->getPrevious()->getPosition() - pA->getPosition());
+ aVecA.normalize();
+ aVecB.normalize();
+ double fDegreeA2 = atan2(aVecA.getY(), aVecA.getX());
+ double fDegreeB2 = atan2(aVecB.getY(), aVecB.getX());
+
+ // build leaving vectors
+ aVecA = pA->getNext()->getPosition() - pA->getPosition();
+ aVecB = pB->getNext()->getPosition() - pA->getPosition();
+ aVecA.normalize();
+ aVecB.normalize();
+ double fDegreeA1 = atan2(aVecA.getY(), aVecA.getX());
+ double fDegreeB1 = atan2(aVecB.getY(), aVecB.getX());
+
+ // compare
+ if(fDegreeA1 > fDegreeA2)
{
- // build entering vectors
- ::basegfx::vector::B2DVector aVecA(pA->getPrevious()->getPosition() - pA->getPosition());
- ::basegfx::vector::B2DVector aVecB(pB->getPrevious()->getPosition() - pA->getPosition());
- aVecA.normalize();
- aVecB.normalize();
- double fDegreeA2 = atan2(aVecA.getY(), aVecA.getX());
- double fDegreeB2 = atan2(aVecB.getY(), aVecB.getX());
-
- // build leaving vectors
- aVecA = pA->getNext()->getPosition() - pA->getPosition();
- aVecB = pB->getNext()->getPosition() - pA->getPosition();
- aVecA.normalize();
- aVecB.normalize();
- double fDegreeA1 = atan2(aVecA.getY(), aVecA.getX());
- double fDegreeB1 = atan2(aVecB.getY(), aVecB.getX());
-
- // compare
- if(fDegreeA1 > fDegreeA2)
- {
- double fTemp = fDegreeA2;
- fDegreeA2 = fDegreeA1;
- fDegreeA1 = fTemp;
- }
+ double fTemp = fDegreeA2;
+ fDegreeA2 = fDegreeA1;
+ fDegreeA1 = fTemp;
+ }
- sal_Bool bB1Inside(::basegfx::numeric::fTools::more(fDegreeB1, fDegreeA1)
- && ::basegfx::numeric::fTools::more(fDegreeA2, fDegreeB1));
- sal_Bool bB2Inside(::basegfx::numeric::fTools::more(fDegreeB2, fDegreeA1)
- && ::basegfx::numeric::fTools::more(fDegreeA2, fDegreeB2));
+ sal_Bool bB1Inside(::basegfx::fTools::more(fDegreeB1, fDegreeA1)
+ && ::basegfx::fTools::more(fDegreeA2, fDegreeB1));
+ sal_Bool bB2Inside(::basegfx::fTools::more(fDegreeB2, fDegreeA1)
+ && ::basegfx::fTools::more(fDegreeA2, fDegreeB2));
- if(bB1Inside && bB2Inside)
- {
- return sal_False;
- }
+ if(bB1Inside && bB2Inside)
+ {
+ return sal_False;
+ }
+
+ sal_Bool bB1Outside(::basegfx::fTools::more(fDegreeA1, fDegreeB1)
+ || ::basegfx::fTools::more(fDegreeB1, fDegreeA2));
+ sal_Bool bB2Outside(::basegfx::fTools::more(fDegreeA1, fDegreeB2)
+ || ::basegfx::fTools::more(fDegreeB2, fDegreeA2));
- sal_Bool bB1Outside(::basegfx::numeric::fTools::more(fDegreeA1, fDegreeB1)
- || ::basegfx::numeric::fTools::more(fDegreeB1, fDegreeA2));
- sal_Bool bB2Outside(::basegfx::numeric::fTools::more(fDegreeA1, fDegreeB2)
- || ::basegfx::numeric::fTools::more(fDegreeB2, fDegreeA2));
+ return !(bB1Outside && bB2Outside);
+ }
- return !(bB1Outside && bB2Outside);
+ sal_Bool B2DPolyPolygonCutter::isCrossover(B2DSimpleCut* pEnter, B2DSimpleCut* pLeave)
+ {
+ // build entering vectors
+ ::basegfx::B2DVector aVecJ(pEnter->getLeft()->getNext()->getPosition() - pEnter->getLeft()->getPosition());
+ ::basegfx::B2DVector aVecA(pEnter->getLeft()->getPrevious()->getPosition() - pEnter->getLeft()->getPosition());
+ ::basegfx::B2DVector aVecB(pEnter->getRight()->getPrevious()->getPosition() - pEnter->getLeft()->getPosition());
+ aVecJ.normalize();
+ aVecA.normalize();
+ aVecB.normalize();
+ double fDegreeJo = atan2(aVecJ.getY(), aVecJ.getX());
+ double fDegreeA2 = atan2(aVecA.getY(), aVecA.getX()) - fDegreeJo;
+ double fDegreeB2 = atan2(aVecB.getY(), aVecB.getX()) - fDegreeJo;
+
+ // move to range [0..2PI[
+ while(fDegreeA2 < 0.0)
+ {
+ fDegreeA2 += (2.0 * F_PI);
}
- sal_Bool B2DPolyPolygonCutter::isCrossover(B2DSimpleCut* pEnter, B2DSimpleCut* pLeave)
+ while(fDegreeA2 >= (2.0 * F_PI))
{
- // build entering vectors
- ::basegfx::vector::B2DVector aVecJ(pEnter->getLeft()->getNext()->getPosition() - pEnter->getLeft()->getPosition());
- ::basegfx::vector::B2DVector aVecA(pEnter->getLeft()->getPrevious()->getPosition() - pEnter->getLeft()->getPosition());
- ::basegfx::vector::B2DVector aVecB(pEnter->getRight()->getPrevious()->getPosition() - pEnter->getLeft()->getPosition());
- aVecJ.normalize();
- aVecA.normalize();
- aVecB.normalize();
- double fDegreeJo = atan2(aVecJ.getY(), aVecJ.getX());
- double fDegreeA2 = atan2(aVecA.getY(), aVecA.getX()) - fDegreeJo;
- double fDegreeB2 = atan2(aVecB.getY(), aVecB.getX()) - fDegreeJo;
-
- // move to range [0..2PI[
- while(fDegreeA2 < 0.0)
- {
- fDegreeA2 += (2.0 * F_PI);
- }
+ fDegreeA2 -= (2.0 * F_PI);
+ }
- while(fDegreeA2 >= (2.0 * F_PI))
- {
- fDegreeA2 -= (2.0 * F_PI);
- }
+ // move to range [0..2PI[
+ while(fDegreeB2 < 0.0)
+ {
+ fDegreeB2 += (2.0 * F_PI);
+ }
- // move to range [0..2PI[
- while(fDegreeB2 < 0.0)
- {
- fDegreeB2 += (2.0 * F_PI);
- }
+ while(fDegreeB2 >= (2.0 * F_PI))
+ {
+ fDegreeB2 -= (2.0 * F_PI);
+ }
- while(fDegreeB2 >= (2.0 * F_PI))
- {
- fDegreeB2 -= (2.0 * F_PI);
- }
+ sal_Bool bA2BiggerB2(::basegfx::fTools::more(fDegreeA2, fDegreeB2));
+
+ // build leaving vectors
+ aVecJ = pLeave->getLeft()->getPrevious()->getPosition() - pLeave->getLeft()->getPosition();
+ aVecA = pLeave->getLeft()->getNext()->getPosition() - pLeave->getLeft()->getPosition();
+ aVecB = pLeave->getRight()->getNext()->getPosition() - pLeave->getLeft()->getPosition();
+ aVecJ.normalize();
+ aVecA.normalize();
+ aVecB.normalize();
+ fDegreeJo = atan2(aVecJ.getY(), aVecJ.getX());
+ double fDegreeA1 = atan2(aVecA.getY(), aVecA.getX()) - fDegreeJo;
+ double fDegreeB1 = atan2(aVecB.getY(), aVecB.getX()) - fDegreeJo;
+
+ // move to range [0..2PI[
+ while(fDegreeA1 < 0.0)
+ {
+ fDegreeA1 += (2.0 * F_PI);
+ }
- sal_Bool bA2BiggerB2(::basegfx::numeric::fTools::more(fDegreeA2, fDegreeB2));
-
- // build leaving vectors
- aVecJ = pLeave->getLeft()->getPrevious()->getPosition() - pLeave->getLeft()->getPosition();
- aVecA = pLeave->getLeft()->getNext()->getPosition() - pLeave->getLeft()->getPosition();
- aVecB = pLeave->getRight()->getNext()->getPosition() - pLeave->getLeft()->getPosition();
- aVecJ.normalize();
- aVecA.normalize();
- aVecB.normalize();
- fDegreeJo = atan2(aVecJ.getY(), aVecJ.getX());
- double fDegreeA1 = atan2(aVecA.getY(), aVecA.getX()) - fDegreeJo;
- double fDegreeB1 = atan2(aVecB.getY(), aVecB.getX()) - fDegreeJo;
-
- // move to range [0..2PI[
- while(fDegreeA1 < 0.0)
- {
- fDegreeA1 += (2.0 * F_PI);
- }
+ while(fDegreeA1 >= (2.0 * F_PI))
+ {
+ fDegreeA1 -= (2.0 * F_PI);
+ }
- while(fDegreeA1 >= (2.0 * F_PI))
- {
- fDegreeA1 -= (2.0 * F_PI);
- }
+ // move to range [0..2PI[
+ while(fDegreeB1 < 0)
+ {
+ fDegreeB1 += (2.0 * F_PI);
+ }
- // move to range [0..2PI[
- while(fDegreeB1 < 0)
- {
- fDegreeB1 += (2.0 * F_PI);
- }
+ while(fDegreeB1 >= (2.0 * F_PI))
+ {
+ fDegreeB1 -= (2.0 * F_PI);
+ }
- while(fDegreeB1 >= (2.0 * F_PI))
- {
- fDegreeB1 -= (2.0 * F_PI);
- }
+ sal_Bool bA1BiggerB1(::basegfx::fTools::more(fDegreeA1, fDegreeB1));
- sal_Bool bA1BiggerB1(::basegfx::numeric::fTools::more(fDegreeA1, fDegreeB1));
+ // compare
+ return (bA1BiggerB1 == bA2BiggerB2);
+ }
- // compare
- return (bA1BiggerB1 == bA2BiggerB2);
+ void B2DPolyPolygonCutter::removeDoubleIntersections()
+ {
+ double fMaxAX, fMinAX, fMaxAY, fMinAY;
+ double fMaxBX, fMinBX, fMaxBY, fMinBY;
+ double fCut;
+ B2DSimpleCutVector aCuts;
+ B2DSimpleCutVector aTmpCuts;
+ B2DSimpleCutVector aNewCuts;
+ B2DPolygonNode* pCandA;
+ B2DPolygonNode* pCandB;
+ B2DPolygonNode* pA;
+ B2DPolygonNode* pB;
+ sal_uInt32 a;
+
+ // create volume list for all polys for faster compares
+ ::basegfx::B2DRange* pVolumes = new ::basegfx::B2DRange[maPolygonList.size()];
+
+ for(a = 0L; a < maPolygonList.size(); a++)
+ {
+ pVolumes[a] = maPolygonList[a]->getRange();
}
- void B2DPolyPolygonCutter::removeDoubleIntersections()
+ // register cuts (and add points for them) between pCandA and pCandB
+ for(a = 0L; a + 1L < maPolygonList.size(); a++)
{
- double fMaxAX, fMinAX, fMaxAY, fMinAY;
- double fMaxBX, fMinBX, fMaxBY, fMinBY;
- double fCut;
- B2DSimpleCutVector aCuts;
- B2DSimpleCutVector aTmpCuts;
- B2DSimpleCutVector aNewCuts;
- B2DPolygonNode* pCandA;
- B2DPolygonNode* pCandB;
- B2DPolygonNode* pA;
- B2DPolygonNode* pB;
- sal_uInt32 a;
-
- // create volume list for all polys for faster compares
- ::basegfx::range::B2DRange* pVolumes = new ::basegfx::range::B2DRange[maPolygonList.size()];
-
- for(a = 0L; a < maPolygonList.size(); a++)
- {
- pVolumes[a] = maPolygonList[a]->getRange();
- }
+ pCandA = maPolygonList[a];
- // register cuts (and add points for them) between pCandA and pCandB
- for(a = 0L; a + 1L < maPolygonList.size(); a++)
+ for(sal_uInt32 b = a + 1L; b < maPolygonList.size(); b++)
{
- pCandA = maPolygonList[a];
-
- for(sal_uInt32 b = a + 1L; b < maPolygonList.size(); b++)
+ if(doRangesIntersect(pVolumes[a], pVolumes[b]))
{
- if(doRangesIntersect(pVolumes[a], pVolumes[b]))
- {
- pCandB = maPolygonList[b];
- pA = pCandA;
+ pCandB = maPolygonList[b];
+ pA = pCandA;
+
+ // one run to find same start positions (so there is no need to
+ // search for existing cuts in main loop)
+ do {
+ pB = pCandB;
- // one run to find same start positions (so there is no need to
- // search for existing cuts in main loop)
do {
- pB = pCandB;
+ if(isSamePos(pA->getPosition(), pB->getPosition()))
+ {
+ aTmpCuts.push_back(new B2DSimpleCut(pA, pB));
+ }
- do {
- if(isSamePos(pA->getPosition(), pB->getPosition()))
- {
- aTmpCuts.push_back(new B2DSimpleCut(pA, pB));
- }
+ // next B
+ pB = pB->getNext();
+ } while(pB != pCandB);
- // next B
- pB = pB->getNext();
- } while(pB != pCandB);
+ // next A
+ pA = pA->getNext();
+ } while(pA != pCandA);
- // next A
- pA = pA->getNext();
- } while(pA != pCandA);
+ // second run to find real cuts
+ pA = pCandA;
- // second run to find real cuts
- pA = pCandA;
+ do {
+ // get bounds for this edge in poly
+ pA->calcMinMaxX(fMaxAX, fMinAX);
+ pA->calcMinMaxY(fMaxAY, fMinAY);
+ pB = pCandB;
do {
- // get bounds for this edge in poly
- pA->calcMinMaxX(fMaxAX, fMinAX);
- pA->calcMinMaxY(fMaxAY, fMinAY);
- pB = pCandB;
+ pB->calcMinMaxX(fMaxBX, fMinBX);
- do {
- pB->calcMinMaxX(fMaxBX, fMinBX);
+ if(::basegfx::fTools::more(fMaxBX, fMinAX)
+ && ::basegfx::fTools::more(fMaxAX, fMinBX))
+ {
+ pB->calcMinMaxY(fMaxBY, fMinBY);
- if(::basegfx::numeric::fTools::more(fMaxBX, fMinAX)
- && ::basegfx::numeric::fTools::more(fMaxAX, fMinBX))
+ if(::basegfx::fTools::more(fMaxBY, fMinAY)
+ && ::basegfx::fTools::more(fMaxAY, fMinBY))
{
- pB->calcMinMaxY(fMaxBY, fMinBY);
-
- if(::basegfx::numeric::fTools::more(fMaxBY, fMinAY)
- && ::basegfx::numeric::fTools::more(fMaxAY, fMinBY))
+ if(!isSamePos(pA->getPosition(), pB->getPosition()))
{
- if(!isSamePos(pA->getPosition(), pB->getPosition()))
- {
- const ::basegfx::vector::B2DVector aVectorA(pA->getNext()->getPosition() - pA->getPosition());
- const ::basegfx::vector::B2DVector aVectorB(pB->getNext()->getPosition() - pB->getPosition());
+ const ::basegfx::B2DVector aVectorA(pA->getNext()->getPosition() - pA->getPosition());
+ const ::basegfx::B2DVector aVectorB(pB->getNext()->getPosition() - pB->getPosition());
- if(::basegfx::polygon::tools::findCut(pA->getPosition(), aVectorA, pB->getPosition(), aVectorB, CUTFLAG_LINE, &fCut))
+ if(::basegfx::tools::findCut(pA->getPosition(), aVectorA, pB->getPosition(), aVectorB, CUTFLAG_LINE, &fCut))
+ {
+ // crossover, two new points, use as cutpoint
+ ::basegfx::B2DPoint aNewPos(::basegfx::interpolate(pA->getPosition(), pA->getNext()->getPosition(), fCut));
+ B2DPolygonNode* pCutLo = new B2DPolygonNode(aNewPos, pA);
+ B2DPolygonNode* pCutHi = new B2DPolygonNode(aNewPos, pB);
+ aNewCuts.push_back(new B2DSimpleCut(pCutLo, pCutHi));
+ pA->calcMinMaxX(fMaxAX, fMinAX);
+ pA->calcMinMaxY(fMaxAY, fMinAY);
+ }
+ else
+ {
+ if(::basegfx::tools::isPointOnEdge(pA->getPosition(), pB->getPosition(), aVectorB, &fCut))
{
- // crossover, two new points, use as cutpoint
- ::basegfx::point::B2DPoint aNewPos(::basegfx::tuple::interpolate(pA->getPosition(), pA->getNext()->getPosition(), fCut));
- B2DPolygonNode* pCutLo = new B2DPolygonNode(aNewPos, pA);
- B2DPolygonNode* pCutHi = new B2DPolygonNode(aNewPos, pB);
- aNewCuts.push_back(new B2DSimpleCut(pCutLo, pCutHi));
- pA->calcMinMaxX(fMaxAX, fMinAX);
- pA->calcMinMaxY(fMaxAY, fMinAY);
+ // startpoint A at edge B, one new point
+ // leaves or enters common section
+ B2DPolygonNode* pCutHi = new B2DPolygonNode(pA->getPosition(), pB);
+ aTmpCuts.push_back(new B2DSimpleCut(pA, pCutHi));
}
- else
+ else if(::basegfx::tools::isPointOnEdge(pB->getPosition(), pA->getPosition(), aVectorA, &fCut))
{
- if(::basegfx::polygon::tools::isPointOnEdge(pA->getPosition(), pB->getPosition(), aVectorB, &fCut))
- {
- // startpoint A at edge B, one new point
- // leaves or enters common section
- B2DPolygonNode* pCutHi = new B2DPolygonNode(pA->getPosition(), pB);
- aTmpCuts.push_back(new B2DSimpleCut(pA, pCutHi));
- }
- else if(::basegfx::polygon::tools::isPointOnEdge(pB->getPosition(), pA->getPosition(), aVectorA, &fCut))
- {
- // startpoint B at edge A, one new point
- // leaves or enters common section
- B2DPolygonNode* pCutLo = new B2DPolygonNode(pB->getPosition(), pA);
- aTmpCuts.push_back(new B2DSimpleCut(pCutLo, pB));
- pA->calcMinMaxX(fMaxAX, fMinAX);
- pA->calcMinMaxY(fMaxAY, fMinAY);
- }
+ // startpoint B at edge A, one new point
+ // leaves or enters common section
+ B2DPolygonNode* pCutLo = new B2DPolygonNode(pB->getPosition(), pA);
+ aTmpCuts.push_back(new B2DSimpleCut(pCutLo, pB));
+ pA->calcMinMaxX(fMaxAX, fMinAX);
+ pA->calcMinMaxY(fMaxAY, fMinAY);
}
}
}
}
+ }
- // next B
- pB = pB->getNext();
- } while(pB != pCandB);
-
- // next A
- pA = pA->getNext();
- } while(pA != pCandA);
+ // next B
+ pB = pB->getNext();
+ } while(pB != pCandB);
- // test all temporary cuts for simple criteria
- for(sal_uInt32 c(0L); c < aTmpCuts.size();)
- {
- B2DSimpleCut* pCand = aTmpCuts[c];
- sal_Bool bPrevSamePos(isPrevSamePos(pCand->getLeft(), pCand->getRight()));
- sal_Bool bNextSamePos(isNextSamePos(pCand->getLeft(), pCand->getRight()));
- sal_Bool bDelete(sal_False);
- sal_Bool bIncC(sal_True);
+ // next A
+ pA = pA->getNext();
+ } while(pA != pCandA);
- if(bPrevSamePos && bNextSamePos)
- {
- // single point inside continued same direction section
- bDelete = sal_True;
- }
- else if(!bPrevSamePos && !bNextSamePos)
- {
- // this is no same direction section, test for real cut
- if(isCrossover(pCand->getLeft(), pCand->getRight()))
- {
- // real cut, move to real cutlist
- aNewCuts.push_back(pCand);
- aTmpCuts.erase(aTmpCuts.begin() + c);
- bIncC = sal_False;
- }
- else
- {
- // no cut, just a touch in one point
- bDelete = sal_True;
- }
- }
+ // test all temporary cuts for simple criteria
+ for(sal_uInt32 c(0L); c < aTmpCuts.size();)
+ {
+ B2DSimpleCut* pCand = aTmpCuts[c];
+ sal_Bool bPrevSamePos(isPrevSamePos(pCand->getLeft(), pCand->getRight()));
+ sal_Bool bNextSamePos(isNextSamePos(pCand->getLeft(), pCand->getRight()));
+ sal_Bool bDelete(sal_False);
+ sal_Bool bIncC(sal_True);
- // delete if wanted
- if(bDelete)
+ if(bPrevSamePos && bNextSamePos)
+ {
+ // single point inside continued same direction section
+ bDelete = sal_True;
+ }
+ else if(!bPrevSamePos && !bNextSamePos)
+ {
+ // this is no same direction section, test for real cut
+ if(isCrossover(pCand->getLeft(), pCand->getRight()))
{
- delete pCand;
+ // real cut, move to real cutlist
+ aNewCuts.push_back(pCand);
aTmpCuts.erase(aTmpCuts.begin() + c);
bIncC = sal_False;
}
+ else
+ {
+ // no cut, just a touch in one point
+ bDelete = sal_True;
+ }
+ }
- // next candidate
- if(bIncC)
- c++;
+ // delete if wanted
+ if(bDelete)
+ {
+ delete pCand;
+ aTmpCuts.erase(aTmpCuts.begin() + c);
+ bIncC = sal_False;
}
- // are there entering/leaving same direction sections?
- while(aTmpCuts.size())
+ // next candidate
+ if(bIncC)
+ c++;
+ }
+
+ // are there entering/leaving same direction sections?
+ while(aTmpCuts.size())
+ {
+ // this cuts enter/leave a common same-direction section between
+ // polygons pCandA, pCandB. If it is a real crossover, a cutpoint
+ // for it is needed, else it can be ignored.
+ B2DSimpleCut* pCutA = aTmpCuts[0L];
+ aTmpCuts.erase(aTmpCuts.begin());
+ B2DPolygonNode* pActA = pCutA->getLeft();
+ B2DPolygonNode* pActB = pCutA->getRight();
+ sal_Bool bPrevSamePos(isPrevSamePos(pActA, pActB));
+ sal_Bool bNextSamePos(isNextSamePos(pActA, pActB));
+
+ if(aTmpCuts.size())
{
- // this cuts enter/leave a common same-direction section between
- // polygons pCandA, pCandB. If it is a real crossover, a cutpoint
- // for it is needed, else it can be ignored.
- B2DSimpleCut* pCutA = aTmpCuts[0L];
- aTmpCuts.erase(aTmpCuts.begin());
- B2DPolygonNode* pActA = pCutA->getLeft();
- B2DPolygonNode* pActB = pCutA->getRight();
- sal_Bool bPrevSamePos(isPrevSamePos(pActA, pActB));
- sal_Bool bNextSamePos(isNextSamePos(pActA, pActB));
-
- if(aTmpCuts.size())
+ B2DSimpleCut* pCutB = 0L;
+
+ if(isNextSamePos(pCutA->getLeft(), pCutA->getRight()))
{
- B2DSimpleCut* pCutB = 0L;
+ // this is a start node
+ B2DPolygonNode* pActA = pCutA->getLeft()->getNext();
+ B2DPolygonNode* pActB = pCutA->getRight()->getNext();
- if(isNextSamePos(pCutA->getLeft(), pCutA->getRight()))
+ while(!pCutB && pActA != pCutA->getLeft())
{
- // this is a start node
- B2DPolygonNode* pActA = pCutA->getLeft()->getNext();
- B2DPolygonNode* pActB = pCutA->getRight()->getNext();
-
- while(!pCutB && pActA != pCutA->getLeft())
+ if(!isNextSamePos(pActA, pActB))
{
- if(!isNextSamePos(pActA, pActB))
- {
- pCutB = getExistingCut(aTmpCuts, pActA, pActB);
- }
-
- pActA = pActA->getNext();
- pActB = pActB->getNext();
+ pCutB = getExistingCut(aTmpCuts, pActA, pActB);
}
- if(pCutB)
+ pActA = pActA->getNext();
+ pActB = pActB->getNext();
+ }
+
+ if(pCutB)
+ {
+ const B2DSimpleCutVector::iterator aFindResult = ::std::find(aTmpCuts.begin(), aTmpCuts.end(), pCutB);
+ aTmpCuts.erase(aFindResult);
+
+ if(isCrossover(pCutA, pCutB))
+ {
+ aNewCuts.push_back(pCutB);
+ }
+ else
{
- const B2DSimpleCutVector::iterator aFindResult = ::std::find(aTmpCuts.begin(), aTmpCuts.end(), pCutB);
- aTmpCuts.erase(aFindResult);
+ delete pCutB;
+ }
+ }
+ }
+ else
+ {
+ // this is a end node
+ B2DPolygonNode* pActA = pCutA->getLeft()->getPrevious();
+ B2DPolygonNode* pActB = pCutA->getRight()->getPrevious();
- if(isCrossover(pCutA, pCutB))
- {
- aNewCuts.push_back(pCutB);
- }
- else
- {
- delete pCutB;
- }
+ while(!pCutB && pActA != pCutA->getLeft())
+ {
+ if(!isPrevSamePos(pActA, pActB))
+ {
+ pCutB = getExistingCut(aTmpCuts, pActA, pActB);
}
+
+ pActA = pActA->getPrevious();
+ pActB = pActB->getPrevious();
}
- else
+
+ if(pCutB)
{
- // this is a end node
- B2DPolygonNode* pActA = pCutA->getLeft()->getPrevious();
- B2DPolygonNode* pActB = pCutA->getRight()->getPrevious();
+ const B2DSimpleCutVector::iterator aFindResult = ::std::find(aTmpCuts.begin(), aTmpCuts.end(), pCutB);
+ aTmpCuts.erase(aFindResult);
- while(!pCutB && pActA != pCutA->getLeft())
+ if(isCrossover(pCutB, pCutA))
{
- if(!isPrevSamePos(pActA, pActB))
- {
- pCutB = getExistingCut(aTmpCuts, pActA, pActB);
- }
-
- pActA = pActA->getPrevious();
- pActB = pActB->getPrevious();
+ aNewCuts.push_back(pCutB);
}
-
- if(pCutB)
+ else
{
- const B2DSimpleCutVector::iterator aFindResult = ::std::find(aTmpCuts.begin(), aTmpCuts.end(), pCutB);
- aTmpCuts.erase(aFindResult);
-
- if(isCrossover(pCutB, pCutA))
- {
- aNewCuts.push_back(pCutB);
- }
- else
- {
- delete pCutB;
- }
+ delete pCutB;
}
}
}
-
- // delete cut in EVERY case
- delete pCutA;
}
- // copy new cuts to all cuts
- aCuts.insert(aCuts.begin(), aNewCuts.begin(), aNewCuts.end());
- aNewCuts.clear();
+ // delete cut in EVERY case
+ delete pCutA;
}
+
+ // copy new cuts to all cuts
+ aCuts.insert(aCuts.begin(), aNewCuts.begin(), aNewCuts.end());
+ aNewCuts.clear();
}
}
+ }
- // delete volume list again
- delete[] pVolumes;
+ // delete volume list again
+ delete[] pVolumes;
- // are there cuts to solve? Solve them all in one run
- if(aCuts.size())
- {
- solveAllCuts(aCuts);
- }
+ // are there cuts to solve? Solve them all in one run
+ if(aCuts.size())
+ {
+ solveAllCuts(aCuts);
}
- } // end of namespace polygon
+ }
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx b/basegfx/source/polygon/b2dpolypolygontools.cxx
index 3ddb6f11a0a3..60f61b347135 100644
--- a/basegfx/source/polygon/b2dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolypolygontools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolypolygontools.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:12 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,153 +87,164 @@
namespace basegfx
{
- namespace polygon
+ namespace tools
{
- namespace tools
+ // B2DPolyPolygon tools
+
+ void correctOrientations(::basegfx::B2DPolyPolygon& rCandidate)
{
- // B2DPolyPolygon tools
+ const sal_uInt32 nPolygonCount(rCandidate.count());
+ sal_uInt32 nIndexOfOutmostPolygon(0L);
+ sal_Bool bIndexOfOutmostPolygonSet(sal_False);
- void correctOrientations(::basegfx::polygon::B2DPolyPolygon& rCandidate)
+ for(sal_uInt32 a(0L); a < nPolygonCount; a++)
{
- const sal_uInt32 nPolygonCount(rCandidate.count());
- sal_uInt32 nIndexOfOutmostPolygon(0L);
- sal_Bool bIndexOfOutmostPolygonSet(sal_False);
+ ::basegfx::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a);
- for(sal_uInt32 a(0L); a < nPolygonCount; a++)
+ if(aCandidate.count() > 2L)
{
- ::basegfx::polygon::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a);
-
- if(aCandidate.count() > 2L)
+ ::basegfx::B2DVectorOrientation aOrientation =
+ ::basegfx::tools::getOrientation(aCandidate);
+ sal_Bool bDoFlip(::basegfx::ORIENTATION_POSITIVE != aOrientation);
+
+ // init values for depth and compare point for
+ // inside test. Since the ordering makes only sense when assuming
+ // that there are no intersections, the inside test is done with
+ // any point of the candidate, so teke the first one.
+ sal_uInt32 nDepth(0L);
+ const ::basegfx::B2DPoint aTestPoint(aCandidate.getB2DPoint(0L));
+
+ // loop over other polygons and calculate depth
+ for(sal_uInt32 b(0L); b < nPolygonCount; b++)
{
- ::basegfx::vector::B2DVectorOrientation aOrientation =
- ::basegfx::polygon::tools::getOrientation(aCandidate);
- sal_Bool bDoFlip(::basegfx::vector::ORIENTATION_POSITIVE != aOrientation);
-
- // init values for depth and compare point for
- // inside test. Since the ordering makes only sense when assuming
- // that there are no intersections, the inside test is done with
- // any point of the candidate, so teke the first one.
- sal_uInt32 nDepth(0L);
- const ::basegfx::point::B2DPoint aTestPoint(aCandidate.getB2DPoint(0L));
-
- // loop over other polygons and calculate depth
- for(sal_uInt32 b(0L); b < nPolygonCount; b++)
+ if(b != a)
{
- if(b != a)
- {
- ::basegfx::polygon::B2DPolygon aComparePolygon = rCandidate.getB2DPolygon(b);
+ ::basegfx::B2DPolygon aComparePolygon = rCandidate.getB2DPolygon(b);
- if(::basegfx::polygon::tools::isInside(aComparePolygon, aTestPoint))
- {
- nDepth++;
- }
+ if(::basegfx::tools::isInside(aComparePolygon, aTestPoint))
+ {
+ nDepth++;
}
}
+ }
- // if nDepth is odd it is a hole
- sal_Bool bIsHole(1L == (nDepth & 0x00000001));
+ // if nDepth is odd it is a hole
+ sal_Bool bIsHole(1L == (nDepth & 0x00000001));
- // does polygon need to be flipped?
- if((bDoFlip && !bIsHole) || (!bDoFlip && bIsHole))
- {
- aCandidate.flip();
-
- // write back changed polygon
- rCandidate.setB2DPolygon(a, aCandidate);
- }
+ // does polygon need to be flipped?
+ if((bDoFlip && !bIsHole) || (!bDoFlip && bIsHole))
+ {
+ aCandidate.flip();
- // remember the index if it's the outmost polygon
- if(!bIndexOfOutmostPolygonSet && 0L == nDepth)
- {
- bIndexOfOutmostPolygonSet = sal_True;
- nIndexOfOutmostPolygon = a;
- }
+ // write back changed polygon
+ rCandidate.setB2DPolygon(a, aCandidate);
}
- }
- // if the outmost polygon is not the first, move it in front
- if(bIndexOfOutmostPolygonSet && nIndexOfOutmostPolygon > 0L)
- {
- ::basegfx::polygon::B2DPolygon aOutmostPolygon = rCandidate.getB2DPolygon(nIndexOfOutmostPolygon);
- rCandidate.remove(nIndexOfOutmostPolygon);
- rCandidate.insert(0L, aOutmostPolygon);
+ // remember the index if it's the outmost polygon
+ if(!bIndexOfOutmostPolygonSet && 0L == nDepth)
+ {
+ bIndexOfOutmostPolygonSet = sal_True;
+ nIndexOfOutmostPolygon = a;
+ }
}
}
- void removeIntersections(::basegfx::polygon::B2DPolyPolygon& rCandidate,
- sal_Bool bForceOrientation, sal_Bool bInvertRemove)
+ // if the outmost polygon is not the first, move it in front
+ if(bIndexOfOutmostPolygonSet && nIndexOfOutmostPolygon > 0L)
{
- ::basegfx::polygon::B2DPolyPolygonCutter aCutter;
-
- aCutter.addPolyPolygon(rCandidate, bForceOrientation);
- aCutter.removeSelfIntersections();
- aCutter.removeDoubleIntersections();
- aCutter.removeIncludedPolygons(!bInvertRemove);
- rCandidate.clear();
- aCutter.getPolyPolygon(rCandidate);
+ ::basegfx::B2DPolygon aOutmostPolygon = rCandidate.getB2DPolygon(nIndexOfOutmostPolygon);
+ rCandidate.remove(nIndexOfOutmostPolygon);
+ rCandidate.insert(0L, aOutmostPolygon);
}
+ }
+
+ void removeIntersections(::basegfx::B2DPolyPolygon& rCandidate,
+ sal_Bool bForceOrientation, sal_Bool bInvertRemove)
+ {
+ ::basegfx::B2DPolyPolygonCutter aCutter;
+
+ aCutter.addPolyPolygon(rCandidate, bForceOrientation);
+ aCutter.removeSelfIntersections();
+ aCutter.removeDoubleIntersections();
+ aCutter.removeIncludedPolygons(!bInvertRemove);
+ rCandidate.clear();
+ aCutter.getPolyPolygon(rCandidate);
+ }
- ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivideByDistance(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fDistanceBound)
+ ::basegfx::B2DPolyPolygon adaptiveSubdivideByDistance(const ::basegfx::B2DPolyPolygon& rCandidate, double fDistanceBound)
+ {
+ ::basegfx::B2DPolyPolygon aRetval(rCandidate);
+
+ if(aRetval.areControlPointsUsed())
{
- ::basegfx::polygon::B2DPolyPolygon aRetval(rCandidate);
+ const sal_uInt32 nPolygonCount(aRetval.count());
- if(aRetval.areControlPointsUsed())
+ for(sal_uInt32 a(0L); aRetval.areControlPointsUsed() && a < nPolygonCount; a++)
{
- const sal_uInt32 nPolygonCount(aRetval.count());
+ ::basegfx::B2DPolygon aCandidate = aRetval.getB2DPolygon(a);
- for(sal_uInt32 a(0L); aRetval.areControlPointsUsed() && a < nPolygonCount; a++)
+ if(aCandidate.areControlPointsUsed())
{
- ::basegfx::polygon::B2DPolygon aCandidate = aRetval.getB2DPolygon(a);
-
- if(aCandidate.areControlPointsUsed())
- {
- aCandidate = ::basegfx::polygon::tools::adaptiveSubdivideByDistance(aCandidate, fDistanceBound);
- aRetval.setB2DPolygon(a, aCandidate);
- }
+ aCandidate = ::basegfx::tools::adaptiveSubdivideByDistance(aCandidate, fDistanceBound);
+ aRetval.setB2DPolygon(a, aCandidate);
}
}
-
- return aRetval;
}
- ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivideByAngle(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fAngleBound)
+ return aRetval;
+ }
+
+ ::basegfx::B2DPolyPolygon adaptiveSubdivideByAngle(const ::basegfx::B2DPolyPolygon& rCandidate, double fAngleBound)
+ {
+ ::basegfx::B2DPolyPolygon aRetval(rCandidate);
+
+ if(aRetval.areControlPointsUsed())
{
- ::basegfx::polygon::B2DPolyPolygon aRetval(rCandidate);
+ const sal_uInt32 nPolygonCount(aRetval.count());
- if(aRetval.areControlPointsUsed())
+ for(sal_uInt32 a(0L); aRetval.areControlPointsUsed() && a < nPolygonCount; a++)
{
- const sal_uInt32 nPolygonCount(aRetval.count());
+ ::basegfx::B2DPolygon aCandidate = aRetval.getB2DPolygon(a);
- for(sal_uInt32 a(0L); aRetval.areControlPointsUsed() && a < nPolygonCount; a++)
+ if(aCandidate.areControlPointsUsed())
{
- ::basegfx::polygon::B2DPolygon aCandidate = aRetval.getB2DPolygon(a);
-
- if(aCandidate.areControlPointsUsed())
- {
- aCandidate = ::basegfx::polygon::tools::adaptiveSubdivideByAngle(aCandidate, fAngleBound);
- aRetval.setB2DPolygon(a, aCandidate);
- }
+ aCandidate = ::basegfx::tools::adaptiveSubdivideByAngle(aCandidate, fAngleBound);
+ aRetval.setB2DPolygon(a, aCandidate);
}
}
-
- return aRetval;
}
- ::basegfx::range::B2DRange getRange(const ::basegfx::polygon::B2DPolyPolygon& rCandidate)
+ return aRetval;
+ }
+
+ ::basegfx::B2DRange getRange(const ::basegfx::B2DPolyPolygon& rCandidate)
+ {
+ ::basegfx::B2DRange aRetval;
+ const sal_uInt32 nPolygonCount(rCandidate.count());
+
+ for(sal_uInt32 a(0L); a < nPolygonCount; a++)
{
- ::basegfx::range::B2DRange aRetval;
- const sal_uInt32 nPolygonCount(rCandidate.count());
+ ::basegfx::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a);
+ aRetval.expand(::basegfx::tools::getRange(aCandidate));
+ }
- for(sal_uInt32 a(0L); a < nPolygonCount; a++)
- {
- ::basegfx::polygon::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a);
- aRetval.expand(::basegfx::polygon::tools::getRange(aCandidate));
- }
+ return aRetval;
+ }
+
+ ::basegfx::B2DPolyPolygon applyLineDashing(const ::basegfx::B2DPolyPolygon& rCandidate, const ::std::vector<double>& raDashDotArray, double fFullDashDotLen)
+ {
+ ::basegfx::B2DPolyPolygon aRetval;
+ const sal_uInt32 nPolygonCount(rCandidate.count());
- return aRetval;
+ for(sal_uInt32 a(0L); a < nPolygonCount; a++)
+ {
+ ::basegfx::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a);
+ aRetval.append(applyLineDashing(aCandidate, raDashDotArray, fFullDashDotLen));
}
- } // end of namespace tools
- } // end of namespace polygon
+
+ return aRetval;
+ }
+ } // end of namespace tools
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
diff --git a/basegfx/source/polygon/b3dpolygon.cxx b/basegfx/source/polygon/b3dpolygon.cxx
index df2672d6bbf4..0d488c04bf2c 100644
--- a/basegfx/source/polygon/b3dpolygon.cxx
+++ b/basegfx/source/polygon/b3dpolygon.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dpolygon.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:31:36 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -82,17 +82,17 @@
class CoordinateData3D
{
- ::basegfx::point::B3DPoint maPoint;
+ ::basegfx::B3DPoint maPoint;
public:
CoordinateData3D() {}
- CoordinateData3D(const ::basegfx::point::B3DPoint& rData) : maPoint(rData) {}
+ CoordinateData3D(const ::basegfx::B3DPoint& rData) : maPoint(rData) {}
~CoordinateData3D() {}
- const ::basegfx::point::B3DPoint& getCoordinate() const { return maPoint; }
- void setCoordinate(const ::basegfx::point::B3DPoint& rValue) { if(rValue != maPoint) maPoint = rValue; }
+ const ::basegfx::B3DPoint& getCoordinate() const { return maPoint; }
+ void setCoordinate(const ::basegfx::B3DPoint& rValue) { if(rValue != maPoint) maPoint = rValue; }
sal_Bool operator==(const CoordinateData3D& rData ) const { return (maPoint == rData.getCoordinate()); }
- void transform(const ::basegfx::matrix::B3DHomMatrix& rMatrix) { maPoint *= rMatrix; }
+ void transform(const ::basegfx::B3DHomMatrix& rMatrix) { maPoint *= rMatrix; }
};
//////////////////////////////////////////////////////////////////////////////
@@ -133,12 +133,12 @@ public:
return (maVector == rCandidate.maVector);
}
- const ::basegfx::point::B3DPoint& getCoordinate(sal_uInt32 nIndex) const
+ const ::basegfx::B3DPoint& getCoordinate(sal_uInt32 nIndex) const
{
return maVector[nIndex].getCoordinate();
}
- void setCoordinate(sal_uInt32 nIndex, const ::basegfx::point::B3DPoint& rValue)
+ void setCoordinate(sal_uInt32 nIndex, const ::basegfx::B3DPoint& rValue)
{
maVector[nIndex].setCoordinate(rValue);
}
@@ -229,7 +229,7 @@ public:
}
}
- void transform(const ::basegfx::matrix::B3DHomMatrix& rMatrix)
+ void transform(const ::basegfx::B3DHomMatrix& rMatrix)
{
CoordinateData3DVector::iterator aStart(maVector.begin());
CoordinateData3DVector::iterator aEnd(maVector.end());
@@ -333,17 +333,17 @@ public:
return sal_False;
}
- const ::basegfx::point::B3DPoint& getPoint(sal_uInt32 nIndex) const
+ const ::basegfx::B3DPoint& getPoint(sal_uInt32 nIndex) const
{
return maPoints.getCoordinate(nIndex);
}
- void setPoint(sal_uInt32 nIndex, const ::basegfx::point::B3DPoint& rValue)
+ void setPoint(sal_uInt32 nIndex, const ::basegfx::B3DPoint& rValue)
{
maPoints.setCoordinate(nIndex, rValue);
}
- void insert(sal_uInt32 nIndex, const ::basegfx::point::B3DPoint& rPoint, sal_uInt32 nCount)
+ void insert(sal_uInt32 nIndex, const ::basegfx::B3DPoint& rPoint, sal_uInt32 nCount)
{
if(nCount)
{
@@ -417,7 +417,7 @@ public:
maPoints.removeDoublePointsWholeTrack();
}
- void transform(const ::basegfx::matrix::B3DHomMatrix& rMatrix)
+ void transform(const ::basegfx::B3DHomMatrix& rMatrix)
{
maPoints.transform(rMatrix);
}
@@ -427,253 +427,250 @@ public:
namespace basegfx
{
- namespace polygon
- {
- // init static default Polygon
- static ImplB3DPolygon maStaticDefaultPolygon;
+ // init static default Polygon
+ static ImplB3DPolygon maStaticDefaultPolygon;
- void B3DPolygon::implForceUniqueCopy()
+ void B3DPolygon::implForceUniqueCopy()
+ {
+ if(mpPolygon->getRefCount())
{
- if(mpPolygon->getRefCount())
- {
- mpPolygon->decRefCount();
- mpPolygon = new ImplB3DPolygon(*mpPolygon);
- }
+ mpPolygon->decRefCount();
+ mpPolygon = new ImplB3DPolygon(*mpPolygon);
}
+ }
+
+ B3DPolygon::B3DPolygon()
+ : mpPolygon(&maStaticDefaultPolygon)
+ {
+ mpPolygon->incRefCount();
+ }
- B3DPolygon::B3DPolygon()
- : mpPolygon(&maStaticDefaultPolygon)
+ B3DPolygon::B3DPolygon(const B3DPolygon& rPolygon)
+ : mpPolygon(rPolygon.mpPolygon)
+ {
+ mpPolygon->incRefCount();
+ }
+
+ B3DPolygon::B3DPolygon(const B3DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 nCount)
+ : mpPolygon(new ImplB3DPolygon(*rPolygon.mpPolygon, nIndex, nCount))
+ {
+ OSL_ENSURE(nIndex + nCount > rPolygon.mpPolygon->count(), "B3DPolygon constructor outside range (!)");
+ }
+
+ B3DPolygon::~B3DPolygon()
+ {
+ if(mpPolygon->getRefCount())
{
- mpPolygon->incRefCount();
+ mpPolygon->decRefCount();
}
-
- B3DPolygon::B3DPolygon(const B3DPolygon& rPolygon)
- : mpPolygon(rPolygon.mpPolygon)
+ else
{
- mpPolygon->incRefCount();
+ delete mpPolygon;
}
+ }
- B3DPolygon::B3DPolygon(const B3DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 nCount)
- : mpPolygon(new ImplB3DPolygon(*rPolygon.mpPolygon, nIndex, nCount))
+ B3DPolygon& B3DPolygon::operator=(const B3DPolygon& rPolygon)
+ {
+ if(mpPolygon->getRefCount())
{
- OSL_ENSURE(nIndex + nCount > rPolygon.mpPolygon->count(), "B3DPolygon constructor outside range (!)");
+ mpPolygon->decRefCount();
}
-
- B3DPolygon::~B3DPolygon()
+ else
{
- if(mpPolygon->getRefCount())
- {
- mpPolygon->decRefCount();
- }
- else
- {
- delete mpPolygon;
- }
+ delete mpPolygon;
}
- B3DPolygon& B3DPolygon::operator=(const B3DPolygon& rPolygon)
- {
- if(mpPolygon->getRefCount())
- {
- mpPolygon->decRefCount();
- }
- else
- {
- delete mpPolygon;
- }
+ mpPolygon = rPolygon.mpPolygon;
+ mpPolygon->incRefCount();
- mpPolygon = rPolygon.mpPolygon;
- mpPolygon->incRefCount();
+ return *this;
+ }
- return *this;
+ sal_Bool B3DPolygon::operator==(const B3DPolygon& rPolygon) const
+ {
+ if(mpPolygon == rPolygon.mpPolygon)
+ {
+ return sal_True;
}
- sal_Bool B3DPolygon::operator==(const B3DPolygon& rPolygon) const
- {
- if(mpPolygon == rPolygon.mpPolygon)
- {
- return sal_True;
- }
+ return mpPolygon->isEqual(*(rPolygon.mpPolygon));
+ }
- return mpPolygon->isEqual(*(rPolygon.mpPolygon));
+ sal_Bool B3DPolygon::operator!=(const B3DPolygon& rPolygon) const
+ {
+ if(mpPolygon == rPolygon.mpPolygon)
+ {
+ return sal_False;
}
- sal_Bool B3DPolygon::operator!=(const B3DPolygon& rPolygon) const
- {
- if(mpPolygon == rPolygon.mpPolygon)
- {
- return sal_False;
- }
+ return !mpPolygon->isEqual(*(rPolygon.mpPolygon));
+ }
- return !mpPolygon->isEqual(*(rPolygon.mpPolygon));
- }
+ sal_uInt32 B3DPolygon::count() const
+ {
+ return mpPolygon->count();
+ }
- sal_uInt32 B3DPolygon::count() const
- {
- return mpPolygon->count();
- }
+ ::basegfx::B3DPoint B3DPolygon::getB3DPoint(sal_uInt32 nIndex) const
+ {
+ OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)");
- ::basegfx::point::B3DPoint B3DPolygon::getB3DPoint(sal_uInt32 nIndex) const
- {
- OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)");
+ return mpPolygon->getPoint(nIndex);
+ }
- return mpPolygon->getPoint(nIndex);
- }
+ void B3DPolygon::setB3DPoint(sal_uInt32 nIndex, const ::basegfx::B3DPoint& rValue)
+ {
+ OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)");
- void B3DPolygon::setB3DPoint(sal_uInt32 nIndex, const ::basegfx::point::B3DPoint& rValue)
+ if(mpPolygon->getPoint(nIndex) != rValue)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)");
-
- if(mpPolygon->getPoint(nIndex) != rValue)
- {
- implForceUniqueCopy();
- mpPolygon->setPoint(nIndex, rValue);
- }
+ implForceUniqueCopy();
+ mpPolygon->setPoint(nIndex, rValue);
}
+ }
- void B3DPolygon::insert(sal_uInt32 nIndex, const ::basegfx::point::B3DPoint& rPoint, sal_uInt32 nCount)
- {
- OSL_ENSURE(nIndex <= mpPolygon->count(), "B3DPolygon Insert outside range (!)");
+ void B3DPolygon::insert(sal_uInt32 nIndex, const ::basegfx::B3DPoint& rPoint, sal_uInt32 nCount)
+ {
+ OSL_ENSURE(nIndex <= mpPolygon->count(), "B3DPolygon Insert outside range (!)");
- if(nCount)
- {
- implForceUniqueCopy();
- mpPolygon->insert(nIndex, rPoint, nCount);
- }
+ if(nCount)
+ {
+ implForceUniqueCopy();
+ mpPolygon->insert(nIndex, rPoint, nCount);
}
+ }
- void B3DPolygon::append(const ::basegfx::point::B3DPoint& rPoint, sal_uInt32 nCount)
+ void B3DPolygon::append(const ::basegfx::B3DPoint& rPoint, sal_uInt32 nCount)
+ {
+ if(nCount)
{
- if(nCount)
- {
- implForceUniqueCopy();
- mpPolygon->insert(mpPolygon->count(), rPoint, nCount);
- }
+ implForceUniqueCopy();
+ mpPolygon->insert(mpPolygon->count(), rPoint, nCount);
}
+ }
+
+ void B3DPolygon::insert(sal_uInt32 nIndex, const B3DPolygon& rPoly, sal_uInt32 nIndex2, sal_uInt32 nCount)
+ {
+ OSL_ENSURE(nIndex <= mpPolygon->count(), "B3DPolygon Insert outside range (!)");
- void B3DPolygon::insert(sal_uInt32 nIndex, const B3DPolygon& rPoly, sal_uInt32 nIndex2, sal_uInt32 nCount)
+ if(rPoly.count())
{
- OSL_ENSURE(nIndex <= mpPolygon->count(), "B3DPolygon Insert outside range (!)");
+ implForceUniqueCopy();
- if(rPoly.count())
+ if(!nCount)
{
- implForceUniqueCopy();
-
- if(!nCount)
- {
- nCount = rPoly.count();
- }
-
- if(0L == nIndex2 && nCount == rPoly.count())
- {
- mpPolygon->insert(nIndex, *rPoly.mpPolygon);
- }
- else
- {
- OSL_ENSURE(nIndex2 + nCount > rPoly.mpPolygon->count(), "B3DPolygon Insert outside range (!)");
- ImplB3DPolygon aTempPoly(*rPoly.mpPolygon, nIndex2, nCount);
- mpPolygon->insert(nIndex, aTempPoly);
- }
+ nCount = rPoly.count();
}
- }
- void B3DPolygon::append(const B3DPolygon& rPoly, sal_uInt32 nIndex, sal_uInt32 nCount)
- {
- if(rPoly.count())
+ if(0L == nIndex2 && nCount == rPoly.count())
{
- implForceUniqueCopy();
-
- if(!nCount)
- {
- nCount = rPoly.count();
- }
-
- if(0L == nIndex && nCount == rPoly.count())
- {
- mpPolygon->insert(mpPolygon->count(), *rPoly.mpPolygon);
- }
- else
- {
- OSL_ENSURE(nIndex + nCount > rPoly.mpPolygon->count(), "B3DPolygon Append outside range (!)");
- ImplB3DPolygon aTempPoly(*rPoly.mpPolygon, nIndex, nCount);
- mpPolygon->insert(mpPolygon->count(), aTempPoly);
- }
+ mpPolygon->insert(nIndex, *rPoly.mpPolygon);
+ }
+ else
+ {
+ OSL_ENSURE(nIndex2 + nCount > rPoly.mpPolygon->count(), "B3DPolygon Insert outside range (!)");
+ ImplB3DPolygon aTempPoly(*rPoly.mpPolygon, nIndex2, nCount);
+ mpPolygon->insert(nIndex, aTempPoly);
}
}
+ }
- void B3DPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
+ void B3DPolygon::append(const B3DPolygon& rPoly, sal_uInt32 nIndex, sal_uInt32 nCount)
+ {
+ if(rPoly.count())
{
- OSL_ENSURE(nIndex + nCount <= mpPolygon->count(), "B3DPolygon Remove outside range (!)");
+ implForceUniqueCopy();
- if(nCount)
+ if(!nCount)
{
- implForceUniqueCopy();
- mpPolygon->remove(nIndex, nCount);
+ nCount = rPoly.count();
}
- }
- void B3DPolygon::clear()
- {
- if(mpPolygon->getRefCount())
+ if(0L == nIndex && nCount == rPoly.count())
{
- mpPolygon->decRefCount();
+ mpPolygon->insert(mpPolygon->count(), *rPoly.mpPolygon);
}
else
{
- delete mpPolygon;
+ OSL_ENSURE(nIndex + nCount > rPoly.mpPolygon->count(), "B3DPolygon Append outside range (!)");
+ ImplB3DPolygon aTempPoly(*rPoly.mpPolygon, nIndex, nCount);
+ mpPolygon->insert(mpPolygon->count(), aTempPoly);
}
-
- mpPolygon = &maStaticDefaultPolygon;
- mpPolygon->incRefCount();
}
+ }
- sal_Bool B3DPolygon::isClosed() const
+ void B3DPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
+ {
+ OSL_ENSURE(nIndex + nCount <= mpPolygon->count(), "B3DPolygon Remove outside range (!)");
+
+ if(nCount)
{
- return mpPolygon->isClosed();
+ implForceUniqueCopy();
+ mpPolygon->remove(nIndex, nCount);
}
+ }
- void B3DPolygon::setClosed(sal_Bool bNew)
+ void B3DPolygon::clear()
+ {
+ if(mpPolygon->getRefCount())
{
- if(mpPolygon->isClosed() != bNew)
- {
- implForceUniqueCopy();
- mpPolygon->setClosed(bNew);
- }
+ mpPolygon->decRefCount();
}
+ else
+ {
+ delete mpPolygon;
+ }
+
+ mpPolygon = &maStaticDefaultPolygon;
+ mpPolygon->incRefCount();
+ }
+
+ sal_Bool B3DPolygon::isClosed() const
+ {
+ return mpPolygon->isClosed();
+ }
- void B3DPolygon::flip()
+ void B3DPolygon::setClosed(sal_Bool bNew)
+ {
+ if(mpPolygon->isClosed() != bNew)
{
- if(mpPolygon->count() > 1)
- {
- implForceUniqueCopy();
- mpPolygon->flip();
- }
+ implForceUniqueCopy();
+ mpPolygon->setClosed(bNew);
}
+ }
- sal_Bool B3DPolygon::hasDoublePoints() const
+ void B3DPolygon::flip()
+ {
+ if(mpPolygon->count() > 1)
{
- return mpPolygon->hasDoublePoints();
+ implForceUniqueCopy();
+ mpPolygon->flip();
}
+ }
- void B3DPolygon::removeDoublePoints()
+ sal_Bool B3DPolygon::hasDoublePoints() const
+ {
+ return mpPolygon->hasDoublePoints();
+ }
+
+ void B3DPolygon::removeDoublePoints()
+ {
+ if(mpPolygon->count() > 1)
{
- if(mpPolygon->count() > 1)
- {
- implForceUniqueCopy();
- mpPolygon->removeDoublePointsAtBeginEnd();
- mpPolygon->removeDoublePointsWholeTrack();
- }
+ implForceUniqueCopy();
+ mpPolygon->removeDoublePointsAtBeginEnd();
+ mpPolygon->removeDoublePointsWholeTrack();
}
+ }
- void B3DPolygon::transform(const ::basegfx::matrix::B3DHomMatrix& rMatrix)
+ void B3DPolygon::transform(const ::basegfx::B3DHomMatrix& rMatrix)
+ {
+ if(mpPolygon->count())
{
- if(mpPolygon->count())
- {
- implForceUniqueCopy();
- mpPolygon->transform(rMatrix);
- }
+ implForceUniqueCopy();
+ mpPolygon->transform(rMatrix);
}
- } // end of namespace polygon
+ }
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
diff --git a/basegfx/source/polygon/b3dpolygontools.cxx b/basegfx/source/polygon/b3dpolygontools.cxx
index 473aa6baef45..9784ae5930a9 100644
--- a/basegfx/source/polygon/b3dpolygontools.cxx
+++ b/basegfx/source/polygon/b3dpolygontools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dpolygontools.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:31:39 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,275 +83,344 @@
namespace basegfx
{
- namespace polygon
+ namespace tools
{
- namespace tools
+ // B3DPolygon tools
+ void checkClosed(B3DPolygon& rCandidate)
{
- // B3DPolygon tools
- void checkClosed(polygon::B3DPolygon& rCandidate)
+ while(rCandidate.count() > 1L
+ && rCandidate.getB3DPoint(0L).equal(rCandidate.getB3DPoint(rCandidate.count() - 1L)))
{
- while(rCandidate.count() > 1L
- && rCandidate.getB3DPoint(0L).equal(rCandidate.getB3DPoint(rCandidate.count() - 1L)))
- {
- rCandidate.setClosed(sal_True);
- rCandidate.remove(rCandidate.count() - 1L);
- }
+ rCandidate.setClosed(sal_True);
+ rCandidate.remove(rCandidate.count() - 1L);
}
+ }
+
+ // 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)
+ {
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
- // 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)
+ if(nIndex)
+ {
+ return nIndex - 1L;
+ }
+ else if(rCandidate.count())
+ {
+ return rCandidate.count() - 1L;
+ }
+ else
{
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+ return nIndex;
+ }
+ }
- if(nIndex)
- {
- return nIndex - 1L;
- }
- else if(rCandidate.count())
- {
- return rCandidate.count() - 1L;
- }
- else
- {
- return nIndex;
- }
+ sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::B3DPolygon& rCandidate)
+ {
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+
+ if(nIndex + 1L < rCandidate.count())
+ {
+ return nIndex + 1L;
}
+ else
+ {
+ return 0L;
+ }
+ }
+
+ sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::B3DPolygon& rCandidate)
+ {
+ sal_uInt32 nNewIndex(nIndex);
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
- sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B3DPolygon& rCandidate)
+ if(rCandidate.count() > 1)
{
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+ nNewIndex = getIndexOfPredecessor(nIndex, rCandidate);
+ ::basegfx::B3DPoint aPoint(rCandidate.getB3DPoint(nIndex));
- if(nIndex + 1L < rCandidate.count())
- {
- return nIndex + 1L;
- }
- else
+ while(nNewIndex != nIndex
+ && aPoint.equal(rCandidate.getB3DPoint(nNewIndex)))
{
- return 0L;
+ nNewIndex = getIndexOfPredecessor(nNewIndex, rCandidate);
}
}
- sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B3DPolygon& rCandidate)
+ return nNewIndex;
+ }
+
+ sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::B3DPolygon& rCandidate)
+ {
+ sal_uInt32 nNewIndex(nIndex);
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+
+ if(rCandidate.count() > 1)
{
- sal_uInt32 nNewIndex(nIndex);
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+ nNewIndex = getIndexOfSuccessor(nIndex, rCandidate);
+ ::basegfx::B3DPoint aPoint(rCandidate.getB3DPoint(nIndex));
- if(rCandidate.count() > 1)
+ while(nNewIndex != nIndex
+ && aPoint.equal(rCandidate.getB3DPoint(nNewIndex)))
{
- nNewIndex = getIndexOfPredecessor(nIndex, rCandidate);
- ::basegfx::point::B3DPoint aPoint(rCandidate.getB3DPoint(nIndex));
-
- while(nNewIndex != nIndex
- && aPoint.equal(rCandidate.getB3DPoint(nNewIndex)))
- {
- nNewIndex = getIndexOfPredecessor(nNewIndex, rCandidate);
- }
+ nNewIndex = getIndexOfSuccessor(nNewIndex, rCandidate);
}
-
- return nNewIndex;
}
- sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B3DPolygon& rCandidate)
- {
- sal_uInt32 nNewIndex(nIndex);
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+ return nNewIndex;
+ }
- if(rCandidate.count() > 1)
- {
- nNewIndex = getIndexOfSuccessor(nIndex, rCandidate);
- ::basegfx::point::B3DPoint aPoint(rCandidate.getB3DPoint(nIndex));
-
- while(nNewIndex != nIndex
- && aPoint.equal(rCandidate.getB3DPoint(nNewIndex)))
- {
- nNewIndex = getIndexOfSuccessor(nNewIndex, rCandidate);
- }
- }
+ ::basegfx::B3DRange getRange(const ::basegfx::B3DPolygon& rCandidate)
+ {
+ ::basegfx::B3DRange aRetval;
+ const sal_uInt32 nPointCount(rCandidate.count());
- return nNewIndex;
+ for(sal_uInt32 a(0L); a < nPointCount; a++)
+ {
+ const ::basegfx::B3DPoint aTestPoint(rCandidate.getB3DPoint(a));
+ aRetval.expand(aTestPoint);
}
- ::basegfx::range::B3DRange getRange(const ::basegfx::polygon::B3DPolygon& rCandidate)
- {
- ::basegfx::range::B3DRange aRetval;
- const sal_uInt32 nPointCount(rCandidate.count());
+ return aRetval;
+ }
+
+ double getEdgeLength(const ::basegfx::B3DPolygon& rCandidate, sal_uInt32 nIndex)
+ {
+ OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+ double fRetval(0.0);
+ const sal_uInt32 nPointCount(rCandidate.count());
- for(sal_uInt32 a(0L); a < nPointCount; a++)
+ if(nIndex < nPointCount)
+ {
+ if(rCandidate.isClosed() || nIndex + 1 != nPointCount)
{
- const ::basegfx::point::B3DPoint aTestPoint(rCandidate.getB3DPoint(a));
- aRetval.expand(aTestPoint);
+ const sal_uInt32 nNextIndex(nIndex + 1 == nPointCount ? 0L : nIndex + 1L);
+ const ::basegfx::B3DPoint aCurrentPoint(rCandidate.getB3DPoint(nIndex));
+ const ::basegfx::B3DPoint aNextPoint(rCandidate.getB3DPoint(nNextIndex));
+ const ::basegfx::B3DVector aVector(aNextPoint - aCurrentPoint);
+ fRetval = aVector.getLength();
}
+ }
- return aRetval;
+ return fRetval;
+ }
+
+ double getLength(const ::basegfx::B3DPolygon& rCandidate)
+ {
+ // This method may also be implemented using a loop over getEdgeLength, but
+ // since this would cause a lot of sqare roots to be solved it is much better
+ // to sum up the quadrats first and then use a singe suare root (if necessary)
+ double fRetval(0.0);
+ const sal_uInt32 nPointCount(rCandidate.count());
+ const sal_uInt32 nLoopCount(rCandidate.isClosed() ? nPointCount : nPointCount - 1L);
+
+ for(sal_uInt32 a(0L); a < nLoopCount; a++)
+ {
+ const sal_uInt32 nNextIndex(a + 1 == nPointCount ? 0L : a + 1L);
+ const ::basegfx::B3DPoint aCurrentPoint(rCandidate.getB3DPoint(a));
+ const ::basegfx::B3DPoint aNextPoint(rCandidate.getB3DPoint(nNextIndex));
+ const ::basegfx::B3DVector aVector(aNextPoint - aCurrentPoint);
+ fRetval += aVector.scalar(aVector);
}
- double getEdgeLength(const ::basegfx::polygon::B3DPolygon& rCandidate, sal_uInt32 nIndex)
+ if(!::basegfx::fTools::equalZero(fRetval))
{
- OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
- double fRetval(0.0);
- const sal_uInt32 nPointCount(rCandidate.count());
+ const double fOne(1.0);
- if(nIndex < nPointCount)
+ if(!::basegfx::fTools::equal(fOne, fRetval))
{
- if(rCandidate.isClosed() || nIndex + 1 != nPointCount)
- {
- const sal_uInt32 nNextIndex(nIndex + 1 == nPointCount ? 0L : nIndex + 1L);
- const ::basegfx::point::B3DPoint aCurrentPoint(rCandidate.getB3DPoint(nIndex));
- const ::basegfx::point::B3DPoint aNextPoint(rCandidate.getB3DPoint(nNextIndex));
- const ::basegfx::vector::B3DVector aVector(aNextPoint - aCurrentPoint);
- fRetval = aVector.getLength();
- }
+ fRetval = sqrt(fRetval);
}
-
- return fRetval;
}
- double getLength(const ::basegfx::polygon::B3DPolygon& rCandidate)
+ return fRetval;
+ }
+
+ ::basegfx::B3DPoint getPositionAbsolute(const ::basegfx::B3DPolygon& rCandidate, double fDistance, double fLength)
+ {
+ ::basegfx::B3DPoint aRetval;
+ const sal_uInt32 nPointCount(rCandidate.count());
+
+ if(nPointCount > 1L)
{
- // This method may also be implemented using a loop over getEdgeLength, but
- // since this would cause a lot of sqare roots to be solved it is much better
- // to sum up the quadrats first and then use a singe suare root (if necessary)
- double fRetval(0.0);
- const sal_uInt32 nPointCount(rCandidate.count());
- const sal_uInt32 nLoopCount(rCandidate.isClosed() ? nPointCount : nPointCount - 1L);
-
- for(sal_uInt32 a(0L); a < nLoopCount; a++)
+ sal_uInt32 nIndex(0L);
+ sal_Bool bIndexDone(sal_False);
+ const double fZero(0.0);
+ double fEdgeLength(fZero);
+
+ // get length if not given
+ if(::basegfx::fTools::equalZero(fLength))
{
- const sal_uInt32 nNextIndex(a + 1 == nPointCount ? 0L : a + 1L);
- const ::basegfx::point::B3DPoint aCurrentPoint(rCandidate.getB3DPoint(a));
- const ::basegfx::point::B3DPoint aNextPoint(rCandidate.getB3DPoint(nNextIndex));
- const ::basegfx::vector::B3DVector aVector(aNextPoint - aCurrentPoint);
- fRetval += aVector.scalar(aVector);
+ fLength = getLength(rCandidate);
}
- if(!::basegfx::numeric::fTools::equalZero(fRetval))
+ // handle fDistance < 0.0
+ if(::basegfx::fTools::less(fDistance, fZero))
{
- const double fOne(1.0);
-
- if(!::basegfx::numeric::fTools::equal(fOne, fRetval))
+ if(rCandidate.isClosed())
+ {
+ // if fDistance < 0.0 increment with multiple of fLength
+ sal_uInt32 nCount(sal_uInt32(-fDistance / fLength));
+ fDistance += double(nCount + 1L) * fLength;
+ }
+ else
{
- fRetval = sqrt(fRetval);
+ // crop to polygon start
+ fDistance = fZero;
+ bIndexDone = sal_True;
}
}
- return fRetval;
- }
-
- ::basegfx::point::B3DPoint getPositionAbsolute(const ::basegfx::polygon::B3DPolygon& rCandidate, double fDistance, double fLength)
- {
- ::basegfx::point::B3DPoint aRetval;
- const sal_uInt32 nPointCount(rCandidate.count());
-
- if(nPointCount > 1L)
+ // handle fDistance >= fLength
+ if(::basegfx::fTools::moreOrEqual(fDistance, fLength))
{
- sal_uInt32 nIndex(0L);
- sal_Bool bIndexDone(sal_False);
- const double fZero(0.0);
- double fEdgeLength(fZero);
-
- // get length if not given
- if(::basegfx::numeric::fTools::equalZero(fLength))
+ if(rCandidate.isClosed())
{
- fLength = getLength(rCandidate);
+ // if fDistance >= fLength decrement with multiple of fLength
+ sal_uInt32 nCount(sal_uInt32(fDistance / fLength));
+ fDistance -= (double)(nCount) * fLength;
}
-
- // handle fDistance < 0.0
- if(::basegfx::numeric::fTools::less(fDistance, fZero))
+ else
{
- if(rCandidate.isClosed())
- {
- // if fDistance < 0.0 increment with multiple of fLength
- sal_uInt32 nCount(sal_uInt32(-fDistance / fLength));
- fDistance += double(nCount + 1L) * fLength;
- }
- else
- {
- // crop to polygon start
- fDistance = fZero;
- bIndexDone = sal_True;
- }
+ // crop to polygon end
+ fDistance = fZero;
+ nIndex = nPointCount - 1L;
+ bIndexDone = sal_True;
}
+ }
- // handle fDistance >= fLength
- if(::basegfx::numeric::fTools::moreOrEqual(fDistance, fLength))
+ // look for correct index. fDistance is now [0.0 .. fLength[
+ if(!bIndexDone)
+ {
+ do
{
- if(rCandidate.isClosed())
+ // get length of next edge
+ fEdgeLength = getEdgeLength(rCandidate, nIndex);
+
+ if(::basegfx::fTools::moreOrEqual(fDistance, fEdgeLength))
{
- // if fDistance >= fLength decrement with multiple of fLength
- sal_uInt32 nCount(sal_uInt32(fDistance / fLength));
- fDistance -= (double)(nCount) * fLength;
+ // go to next edge
+ fDistance -= fEdgeLength;
+ nIndex++;
}
else
{
- // crop to polygon end
- fDistance = fZero;
- nIndex = nPointCount - 1L;
+ // it's on this edge, stop
bIndexDone = sal_True;
}
+ } while (!bIndexDone);
+ }
+
+ // get the point using nIndex
+ aRetval = rCandidate.getB3DPoint(nIndex);
+
+ // if fDistance != 0.0, move that length on the edge. The edge
+ // length is in fEdgeLength.
+ if(!::basegfx::fTools::equalZero(fDistance))
+ {
+ sal_uInt32 nNextIndex(getIndexOfSuccessor(nIndex, rCandidate));
+ const ::basegfx::B3DPoint aNextPoint(rCandidate.getB3DPoint(nNextIndex));
+ double fRelative(fZero);
+
+ if(!::basegfx::fTools::equalZero(fEdgeLength))
+ {
+ fRelative = fDistance / fEdgeLength;
}
- // look for correct index. fDistance is now [0.0 .. fLength[
- if(!bIndexDone)
+ // add calculated average value to the return value
+ aRetval += ::basegfx::average(aRetval, aNextPoint, fRelative);
+ }
+ }
+
+ return aRetval;
+ }
+
+ ::basegfx::B3DPoint getPositionRelative(const ::basegfx::B3DPolygon& rCandidate, double fDistance, double fLength)
+ {
+ // get length if not given
+ if(::basegfx::fTools::equalZero(fLength))
+ {
+ fLength = getLength(rCandidate);
+ }
+
+ // multiply fDistance with real length to get absolute position and
+ // use getPositionAbsolute
+ return getPositionAbsolute(rCandidate, fDistance * fLength, fLength);
+ }
+
+ ::basegfx::B3DPolyPolygon applyLineDashing(const ::basegfx::B3DPolygon& rCandidate, const ::std::vector<double>& raDashDotArray, double fFullDashDotLen)
+ {
+ ::basegfx::B3DPolyPolygon aRetval;
+
+ if(rCandidate.count() && fFullDashDotLen > 0.0)
+ {
+ const sal_uInt32 nCount(rCandidate.isClosed() ? rCandidate.count() : rCandidate.count() - 1L);
+ sal_uInt32 nDashDotIndex(0L);
+ double fDashDotLength(raDashDotArray[nDashDotIndex]);
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ const sal_uInt32 nNextIndex(getIndexOfSuccessor(a, rCandidate));
+ const ::basegfx::B3DPoint aStart(rCandidate.getB3DPoint(a));
+ const ::basegfx::B3DPoint aEnd(rCandidate.getB3DPoint(nNextIndex));
+ ::basegfx::B3DVector aVector(aEnd - aStart);
+ double fLength(aVector.getLength());
+ double fPosOnVector(0.0);
+ aVector.normalize();
+
+ while(fLength >= fDashDotLength)
{
- do
+ // handle [fPosOnVector .. fPosOnVector+fDashDotLength]
+ if(nDashDotIndex % 2)
{
- // get length of next edge
- fEdgeLength = getEdgeLength(rCandidate, nIndex);
+ ::basegfx::B3DPolygon aResult;
- if(::basegfx::numeric::fTools::moreOrEqual(fDistance, fEdgeLength))
+ // add start point
+ if(fPosOnVector == 0.0)
{
- // go to next edge
- fDistance -= fEdgeLength;
- nIndex++;
+ aResult.append(aStart);
}
else
{
- // it's on this edge, stop
- bIndexDone = sal_True;
+ aResult.append(aStart + (aVector * fPosOnVector));
}
- } while (!bIndexDone);
- }
- // get the point using nIndex
- aRetval = rCandidate.getB3DPoint(nIndex);
+ // add end point
+ aResult.append(aStart + (aVector * (fPosOnVector + fDashDotLength)));
- // if fDistance != 0.0, move that length on the edge. The edge
- // length is in fEdgeLength.
- if(!::basegfx::numeric::fTools::equalZero(fDistance))
- {
- sal_uInt32 nNextIndex(getIndexOfSuccessor(nIndex, rCandidate));
- const ::basegfx::point::B3DPoint aNextPoint(rCandidate.getB3DPoint(nNextIndex));
- double fRelative(fZero);
-
- if(!::basegfx::numeric::fTools::equalZero(fEdgeLength))
- {
- fRelative = fDistance / fEdgeLength;
+ // add line to PolyPolygon
+ aRetval.append(aResult);
}
- // add calculated average value to the return value
- aRetval += ::basegfx::tuple::average(aRetval, aNextPoint, fRelative);
+ // consume from fDashDotLength
+ fPosOnVector += fDashDotLength;
+ fLength -= fDashDotLength;
+ nDashDotIndex = (nDashDotIndex + 1L) % raDashDotArray.size();
+ fDashDotLength = raDashDotArray[nDashDotIndex];
}
- }
- return aRetval;
- }
+ // handle [fPosOnVector .. fPosOnVector+fLength (bzw. end)]
+ if((fLength > 0.0) && (nDashDotIndex % 2))
+ {
+ ::basegfx::B3DPolygon aResult;
- ::basegfx::point::B3DPoint getPositionRelative(const ::basegfx::polygon::B3DPolygon& rCandidate, double fDistance, double fLength)
- {
- // get length if not given
- if(::basegfx::numeric::fTools::equalZero(fLength))
- {
- fLength = getLength(rCandidate);
- }
+ // add start and end point
+ const ::basegfx::B3DPoint aPosA(aStart + (aVector * fPosOnVector));
+ aResult.append(aPosA);
+ aResult.append(aEnd);
- // multiply fDistance with real length to get absolute position and
- // use getPositionAbsolute
- return getPositionAbsolute(rCandidate, fDistance * fLength, fLength);
+ // add line to PolyPolygon
+ aRetval.append(aResult);
+ }
+
+ // consume from fDashDotLength
+ fDashDotLength -= fLength;
+ }
}
- } // end of namespace tools
- } // end of namespace polygon
+ return aRetval;
+ }
+ } // end of namespace tools
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
diff --git a/basegfx/source/polygon/b3dpolypolygon.cxx b/basegfx/source/polygon/b3dpolypolygon.cxx
index 28e43316f369..bb78552b24e5 100644
--- a/basegfx/source/polygon/b3dpolypolygon.cxx
+++ b/basegfx/source/polygon/b3dpolypolygon.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dpolypolygon.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:31:37 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -77,7 +77,7 @@
class ImplB3DPolyPolygon
{
- typedef ::std::vector< ::basegfx::polygon::B3DPolygon > PolygonVector;
+ typedef ::std::vector< ::basegfx::B3DPolygon > PolygonVector;
PolygonVector maPolygons;
sal_uInt32 mnRefCount;
@@ -123,17 +123,17 @@ public:
return sal_True;
}
- const ::basegfx::polygon::B3DPolygon& getB3DPolygon(sal_uInt32 nIndex) const
+ const ::basegfx::B3DPolygon& getB3DPolygon(sal_uInt32 nIndex) const
{
return maPolygons[nIndex];
}
- void setB3DPolygon(sal_uInt32 nIndex, const ::basegfx::polygon::B3DPolygon& rPolygon)
+ void setB3DPolygon(sal_uInt32 nIndex, const ::basegfx::B3DPolygon& rPolygon)
{
maPolygons[nIndex] = rPolygon;
}
- void insert(sal_uInt32 nIndex, const ::basegfx::polygon::B3DPolygon& rPolygon, sal_uInt32 nCount)
+ void insert(sal_uInt32 nIndex, const ::basegfx::B3DPolygon& rPolygon, sal_uInt32 nCount)
{
if(nCount)
{
@@ -144,7 +144,7 @@ public:
}
}
- void insert(sal_uInt32 nIndex, const ::basegfx::polygon::B3DPolyPolygon& rPolyPolygon)
+ void insert(sal_uInt32 nIndex, const ::basegfx::B3DPolyPolygon& rPolyPolygon)
{
const sal_uInt32 nCount = rPolyPolygon.count();
@@ -205,7 +205,7 @@ public:
}
}
- void transform(const ::basegfx::matrix::B3DHomMatrix& rMatrix)
+ void transform(const ::basegfx::B3DHomMatrix& rMatrix)
{
for(sal_uInt32 a(0L); a < maPolygons.size(); a++)
{
@@ -218,232 +218,229 @@ public:
namespace basegfx
{
- namespace polygon
- {
- // init static default Polygon
- static ImplB3DPolyPolygon maStaticDefaultPolyPolygon;
+ // init static default Polygon
+ static ImplB3DPolyPolygon maStaticDefaultPolyPolygon;
- void B3DPolyPolygon::implForceUniqueCopy()
+ void B3DPolyPolygon::implForceUniqueCopy()
+ {
+ if(mpPolyPolygon->getRefCount())
{
- if(mpPolyPolygon->getRefCount())
- {
- mpPolyPolygon->decRefCount();
- mpPolyPolygon = new ImplB3DPolyPolygon(*mpPolyPolygon);
- }
+ mpPolyPolygon->decRefCount();
+ mpPolyPolygon = new ImplB3DPolyPolygon(*mpPolyPolygon);
}
+ }
+
+ B3DPolyPolygon::B3DPolyPolygon()
+ : mpPolyPolygon(&maStaticDefaultPolyPolygon)
+ {
+ mpPolyPolygon->incRefCount();
+ }
- B3DPolyPolygon::B3DPolyPolygon()
- : mpPolyPolygon(&maStaticDefaultPolyPolygon)
+ B3DPolyPolygon::B3DPolyPolygon(const B3DPolyPolygon& rPolyPolygon)
+ : mpPolyPolygon(rPolyPolygon.mpPolyPolygon)
+ {
+ mpPolyPolygon->incRefCount();
+ }
+
+ B3DPolyPolygon::~B3DPolyPolygon()
+ {
+ if(mpPolyPolygon->getRefCount())
{
- mpPolyPolygon->incRefCount();
+ mpPolyPolygon->decRefCount();
}
-
- B3DPolyPolygon::B3DPolyPolygon(const B3DPolyPolygon& rPolyPolygon)
- : mpPolyPolygon(rPolyPolygon.mpPolyPolygon)
+ else
{
- mpPolyPolygon->incRefCount();
+ delete mpPolyPolygon;
}
+ }
- B3DPolyPolygon::~B3DPolyPolygon()
+ B3DPolyPolygon& B3DPolyPolygon::operator=(const B3DPolyPolygon& rPolyPolygon)
+ {
+ if(mpPolyPolygon->getRefCount())
{
- if(mpPolyPolygon->getRefCount())
- {
- mpPolyPolygon->decRefCount();
- }
- else
- {
- delete mpPolyPolygon;
- }
+ mpPolyPolygon->decRefCount();
}
-
- B3DPolyPolygon& B3DPolyPolygon::operator=(const B3DPolyPolygon& rPolyPolygon)
+ else
{
- if(mpPolyPolygon->getRefCount())
- {
- mpPolyPolygon->decRefCount();
- }
- else
- {
- delete mpPolyPolygon;
- }
-
- mpPolyPolygon = rPolyPolygon.mpPolyPolygon;
- mpPolyPolygon->incRefCount();
-
- return *this;
+ delete mpPolyPolygon;
}
- sal_Bool B3DPolyPolygon::operator==(const B3DPolyPolygon& rPolyPolygon) const
- {
- if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon)
- {
- return sal_True;
- }
+ mpPolyPolygon = rPolyPolygon.mpPolyPolygon;
+ mpPolyPolygon->incRefCount();
- return mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon));
- }
+ return *this;
+ }
- sal_Bool B3DPolyPolygon::operator!=(const B3DPolyPolygon& rPolyPolygon) const
+ sal_Bool B3DPolyPolygon::operator==(const B3DPolyPolygon& rPolyPolygon) const
+ {
+ if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon)
{
- if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon)
- {
- return sal_False;
- }
-
- return !mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon));
+ return sal_True;
}
- sal_uInt32 B3DPolyPolygon::count() const
+ return mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon));
+ }
+
+ sal_Bool B3DPolyPolygon::operator!=(const B3DPolyPolygon& rPolyPolygon) const
+ {
+ if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon)
{
- return mpPolyPolygon->count();
+ return sal_False;
}
- B3DPolygon B3DPolyPolygon::getB3DPolygon(sal_uInt32 nIndex) const
- {
- OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B3DPolyPolygon access outside range (!)");
+ return !mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon));
+ }
- return mpPolyPolygon->getB3DPolygon(nIndex);
- }
+ sal_uInt32 B3DPolyPolygon::count() const
+ {
+ return mpPolyPolygon->count();
+ }
- void B3DPolyPolygon::setB3DPolygon(sal_uInt32 nIndex, const B3DPolygon& rPolygon)
- {
- OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B3DPolyPolygon access outside range (!)");
+ B3DPolygon B3DPolyPolygon::getB3DPolygon(sal_uInt32 nIndex) const
+ {
+ OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B3DPolyPolygon access outside range (!)");
- if(mpPolyPolygon->getB3DPolygon(nIndex) != rPolygon)
- {
- implForceUniqueCopy();
- mpPolyPolygon->setB3DPolygon(nIndex, rPolygon);
- }
- }
+ return mpPolyPolygon->getB3DPolygon(nIndex);
+ }
- void B3DPolyPolygon::insert(sal_uInt32 nIndex, const B3DPolygon& rPolygon, sal_uInt32 nCount)
- {
- OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B3DPolyPolygon Insert outside range (!)");
+ void B3DPolyPolygon::setB3DPolygon(sal_uInt32 nIndex, const B3DPolygon& rPolygon)
+ {
+ OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B3DPolyPolygon access outside range (!)");
- if(nCount)
- {
- implForceUniqueCopy();
- mpPolyPolygon->insert(nIndex, rPolygon, nCount);
- }
+ if(mpPolyPolygon->getB3DPolygon(nIndex) != rPolygon)
+ {
+ implForceUniqueCopy();
+ mpPolyPolygon->setB3DPolygon(nIndex, rPolygon);
}
+ }
- void B3DPolyPolygon::append(const B3DPolygon& rPolygon, sal_uInt32 nCount)
+ void B3DPolyPolygon::insert(sal_uInt32 nIndex, const B3DPolygon& rPolygon, sal_uInt32 nCount)
+ {
+ OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B3DPolyPolygon Insert outside range (!)");
+
+ if(nCount)
{
- if(nCount)
- {
- implForceUniqueCopy();
- mpPolyPolygon->insert(mpPolyPolygon->count(), rPolygon, nCount);
- }
+ implForceUniqueCopy();
+ mpPolyPolygon->insert(nIndex, rPolygon, nCount);
}
+ }
- void B3DPolyPolygon::insert(sal_uInt32 nIndex, const B3DPolyPolygon& rPolyPolygon)
+ void B3DPolyPolygon::append(const B3DPolygon& rPolygon, sal_uInt32 nCount)
+ {
+ if(nCount)
{
- OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B3DPolyPolygon Insert outside range (!)");
-
- if(rPolyPolygon.count())
- {
- implForceUniqueCopy();
- mpPolyPolygon->insert(nIndex, rPolyPolygon);
- }
+ implForceUniqueCopy();
+ mpPolyPolygon->insert(mpPolyPolygon->count(), rPolygon, nCount);
}
+ }
+
+ void B3DPolyPolygon::insert(sal_uInt32 nIndex, const B3DPolyPolygon& rPolyPolygon)
+ {
+ OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B3DPolyPolygon Insert outside range (!)");
- void B3DPolyPolygon::append(const B3DPolyPolygon& rPolyPolygon)
+ if(rPolyPolygon.count())
{
- if(rPolyPolygon.count())
- {
- implForceUniqueCopy();
- mpPolyPolygon->insert(mpPolyPolygon->count(), rPolyPolygon);
- }
+ implForceUniqueCopy();
+ mpPolyPolygon->insert(nIndex, rPolyPolygon);
}
+ }
- void B3DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
+ void B3DPolyPolygon::append(const B3DPolyPolygon& rPolyPolygon)
+ {
+ if(rPolyPolygon.count())
{
- OSL_ENSURE(nIndex + nCount <= mpPolyPolygon->count(), "B3DPolyPolygon Remove outside range (!)");
-
- if(nCount)
- {
- implForceUniqueCopy();
- mpPolyPolygon->remove(nIndex, nCount);
- }
+ implForceUniqueCopy();
+ mpPolyPolygon->insert(mpPolyPolygon->count(), rPolyPolygon);
}
+ }
- void B3DPolyPolygon::clear()
- {
- if(mpPolyPolygon->getRefCount())
- {
- mpPolyPolygon->decRefCount();
- }
- else
- {
- delete mpPolyPolygon;
- }
+ void B3DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
+ {
+ OSL_ENSURE(nIndex + nCount <= mpPolyPolygon->count(), "B3DPolyPolygon Remove outside range (!)");
- mpPolyPolygon = &maStaticDefaultPolyPolygon;
- mpPolyPolygon->incRefCount();
+ if(nCount)
+ {
+ implForceUniqueCopy();
+ mpPolyPolygon->remove(nIndex, nCount);
}
+ }
- sal_Bool B3DPolyPolygon::isClosed() const
+ void B3DPolyPolygon::clear()
+ {
+ if(mpPolyPolygon->getRefCount())
+ {
+ mpPolyPolygon->decRefCount();
+ }
+ else
{
- sal_Bool bRetval(sal_True);
+ delete mpPolyPolygon;
+ }
- // PolyPOlygon is closed when all contained Polygons are closed or
- // no Polygon exists.
- for(sal_uInt32 a(0L); bRetval && a < mpPolyPolygon->count(); a++)
- {
- if(!(mpPolyPolygon->getB3DPolygon(a)).isClosed())
- {
- bRetval = sal_False;
- }
- }
+ mpPolyPolygon = &maStaticDefaultPolyPolygon;
+ mpPolyPolygon->incRefCount();
+ }
- return bRetval;
- }
+ sal_Bool B3DPolyPolygon::isClosed() const
+ {
+ sal_Bool bRetval(sal_True);
- void B3DPolyPolygon::setClosed(sal_Bool bNew)
+ // PolyPOlygon is closed when all contained Polygons are closed or
+ // no Polygon exists.
+ for(sal_uInt32 a(0L); bRetval && a < mpPolyPolygon->count(); a++)
{
- if(bNew != isClosed())
+ if(!(mpPolyPolygon->getB3DPolygon(a)).isClosed())
{
- implForceUniqueCopy();
- mpPolyPolygon->setClosed(bNew);
+ bRetval = sal_False;
}
}
- void B3DPolyPolygon::flip()
+ return bRetval;
+ }
+
+ void B3DPolyPolygon::setClosed(sal_Bool bNew)
+ {
+ if(bNew != isClosed())
{
implForceUniqueCopy();
- mpPolyPolygon->flip();
+ mpPolyPolygon->setClosed(bNew);
}
+ }
- sal_Bool B3DPolyPolygon::hasDoublePoints() const
- {
- sal_Bool bRetval(sal_False);
-
- for(sal_uInt32 a(0L); !bRetval && a < mpPolyPolygon->count(); a++)
- {
- if((mpPolyPolygon->getB3DPolygon(a)).hasDoublePoints())
- {
- bRetval = sal_True;
- }
- }
+ void B3DPolyPolygon::flip()
+ {
+ implForceUniqueCopy();
+ mpPolyPolygon->flip();
+ }
- return bRetval;
- }
+ sal_Bool B3DPolyPolygon::hasDoublePoints() const
+ {
+ sal_Bool bRetval(sal_False);
- void B3DPolyPolygon::removeDoublePoints()
+ for(sal_uInt32 a(0L); !bRetval && a < mpPolyPolygon->count(); a++)
{
- if(hasDoublePoints())
+ if((mpPolyPolygon->getB3DPolygon(a)).hasDoublePoints())
{
- implForceUniqueCopy();
- mpPolyPolygon->removeDoublePoints();
+ bRetval = sal_True;
}
}
- void B3DPolyPolygon::transform(const ::basegfx::matrix::B3DHomMatrix& rMatrix)
+ return bRetval;
+ }
+
+ void B3DPolyPolygon::removeDoublePoints()
+ {
+ if(hasDoublePoints())
{
implForceUniqueCopy();
- mpPolyPolygon->transform(rMatrix);
+ mpPolyPolygon->removeDoublePoints();
}
- } // end of namespace polygon
+ }
+
+ void B3DPolyPolygon::transform(const ::basegfx::B3DHomMatrix& rMatrix)
+ {
+ implForceUniqueCopy();
+ mpPolyPolygon->transform(rMatrix);
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/polygon/b3dpolypolygontools.cxx b/basegfx/source/polygon/b3dpolypolygontools.cxx
index 3b540b258653..4a4e5a3eab2e 100644
--- a/basegfx/source/polygon/b3dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b3dpolypolygontools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dpolypolygontools.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:31:41 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,26 +87,37 @@
namespace basegfx
{
- namespace polygon
+ namespace tools
{
- namespace tools
+ // B3DPolyPolygon tools
+ ::basegfx::B3DRange getRange(const ::basegfx::B3DPolyPolygon& rCandidate)
{
- // B3DPolyPolygon tools
- ::basegfx::range::B3DRange getRange(const ::basegfx::polygon::B3DPolyPolygon& rCandidate)
+ ::basegfx::B3DRange aRetval;
+ const sal_uInt32 nPolygonCount(rCandidate.count());
+
+ for(sal_uInt32 a(0L); a < nPolygonCount; a++)
{
- ::basegfx::range::B3DRange aRetval;
- const sal_uInt32 nPolygonCount(rCandidate.count());
+ ::basegfx::B3DPolygon aCandidate = rCandidate.getB3DPolygon(a);
+ aRetval.expand(::basegfx::tools::getRange(aCandidate));
+ }
+
+ return aRetval;
+ }
- for(sal_uInt32 a(0L); a < nPolygonCount; a++)
- {
- ::basegfx::polygon::B3DPolygon aCandidate = rCandidate.getB3DPolygon(a);
- aRetval.expand(::basegfx::polygon::tools::getRange(aCandidate));
- }
+ ::basegfx::B3DPolyPolygon applyLineDashing(const ::basegfx::B3DPolyPolygon& rCandidate, const ::std::vector<double>& raDashDotArray, double fFullDashDotLen)
+ {
+ ::basegfx::B3DPolyPolygon aRetval;
+ const sal_uInt32 nPolygonCount(rCandidate.count());
- return aRetval;
+ for(sal_uInt32 a(0L); a < nPolygonCount; a++)
+ {
+ ::basegfx::B3DPolygon aCandidate = rCandidate.getB3DPolygon(a);
+ aRetval.append(applyLineDashing(aCandidate, raDashDotArray, fFullDashDotLen));
}
- } // end of namespace tools
- } // end of namespace polygon
+
+ return aRetval;
+ }
+ } // end of namespace tools
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
diff --git a/basegfx/source/range/b1drange.cxx b/basegfx/source/range/b1drange.cxx
index 48271c90e1ac..faf5c89b7a66 100644
--- a/basegfx/source/range/b1drange.cxx
+++ b/basegfx/source/range/b1drange.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b1drange.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-10-31 10:13:59 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,9 +65,6 @@
namespace basegfx
{
- namespace range
- {
- } // end of namespace range
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/range/b2drange.cxx b/basegfx/source/range/b2drange.cxx
index f4e7ec28973e..a5c6122c460e 100644
--- a/basegfx/source/range/b2drange.cxx
+++ b/basegfx/source/range/b2drange.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2drange.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-10-31 10:13:59 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,9 +65,6 @@
namespace basegfx
{
- namespace range
- {
- } // end of namespace range
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/range/b3drange.cxx b/basegfx/source/range/b3drange.cxx
index c67b87994fcb..714efb85a562 100644
--- a/basegfx/source/range/b3drange.cxx
+++ b/basegfx/source/range/b3drange.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3drange.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-10-31 10:13:59 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,9 +65,6 @@
namespace basegfx
{
- namespace range
- {
- } // end of namespace range
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/tuple/b2dtuple.cxx b/basegfx/source/tuple/b2dtuple.cxx
index a8cdfa54d663..1565fe3ea0d2 100644
--- a/basegfx/source/tuple/b2dtuple.cxx
+++ b/basegfx/source/tuple/b2dtuple.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dtuple.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: aw $ $Date: 2003-11-10 11:45:51 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -69,65 +69,62 @@
namespace basegfx
{
- namespace tuple
- {
- // initialize static member
- ::basegfx::tuple::B2DTuple B2DTuple::maEmptyTuple(0.0, 0.0);
+ // initialize static member
+ ::basegfx::B2DTuple B2DTuple::maEmptyTuple(0.0, 0.0);
- sal_Bool B2DTuple::equalZero() const
- {
- return (this == &maEmptyTuple ||
- (::basegfx::numeric::fTools::equalZero(mfX) && ::basegfx::numeric::fTools::equalZero(mfY)));
- }
+ sal_Bool B2DTuple::equalZero() const
+ {
+ return (this == &maEmptyTuple ||
+ (::basegfx::fTools::equalZero(mfX) && ::basegfx::fTools::equalZero(mfY)));
+ }
- sal_Bool B2DTuple::equalZero(const double& rfSmallValue) const
- {
- return (this == &maEmptyTuple ||
- (::basegfx::numeric::fTools::equalZero(mfX, rfSmallValue) && ::basegfx::numeric::fTools::equalZero(mfY, rfSmallValue)));
- }
+ sal_Bool B2DTuple::equalZero(const double& rfSmallValue) const
+ {
+ return (this == &maEmptyTuple ||
+ (::basegfx::fTools::equalZero(mfX, rfSmallValue) && ::basegfx::fTools::equalZero(mfY, rfSmallValue)));
+ }
- sal_Bool B2DTuple::equal(const B2DTuple& rTup) const
- {
- return (
- ::basegfx::numeric::fTools::equal(mfX, rTup.mfX) &&
- ::basegfx::numeric::fTools::equal(mfY, rTup.mfY));
- }
+ sal_Bool B2DTuple::equal(const B2DTuple& rTup) const
+ {
+ return (
+ ::basegfx::fTools::equal(mfX, rTup.mfX) &&
+ ::basegfx::fTools::equal(mfY, rTup.mfY));
+ }
- sal_Bool B2DTuple::equal(const B2DTuple& rTup, const double& rfSmallValue) const
- {
- return (
- ::basegfx::numeric::fTools::equal(mfX, rTup.mfX, rfSmallValue) &&
- ::basegfx::numeric::fTools::equal(mfY, rTup.mfY, rfSmallValue));
- }
+ sal_Bool B2DTuple::equal(const B2DTuple& rTup, const double& rfSmallValue) const
+ {
+ return (
+ ::basegfx::fTools::equal(mfX, rTup.mfX, rfSmallValue) &&
+ ::basegfx::fTools::equal(mfY, rTup.mfY, rfSmallValue));
+ }
- void B2DTuple::correctValues(const double fCompareValue)
+ void B2DTuple::correctValues(const double fCompareValue)
+ {
+ if(0.0 == fCompareValue)
{
- if(0.0 == fCompareValue)
+ if(::basegfx::fTools::equalZero(mfX))
{
- if(::basegfx::numeric::fTools::equalZero(mfX))
- {
- mfX = 0.0;
- }
+ mfX = 0.0;
+ }
- if(::basegfx::numeric::fTools::equalZero(mfY))
- {
- mfY = 0.0;
- }
+ if(::basegfx::fTools::equalZero(mfY))
+ {
+ mfY = 0.0;
}
- else
+ }
+ else
+ {
+ if(::basegfx::fTools::equal(mfX, fCompareValue))
{
- if(::basegfx::numeric::fTools::equal(mfX, fCompareValue))
- {
- mfX = fCompareValue;
- }
+ mfX = fCompareValue;
+ }
- if(::basegfx::numeric::fTools::equal(mfY, fCompareValue))
- {
- mfY = fCompareValue;
- }
+ if(::basegfx::fTools::equal(mfY, fCompareValue))
+ {
+ mfY = fCompareValue;
}
}
- } // end of namespace tuple
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/tuple/b3dtuple.cxx b/basegfx/source/tuple/b3dtuple.cxx
index f1e7691adfb3..718903f0864f 100644
--- a/basegfx/source/tuple/b3dtuple.cxx
+++ b/basegfx/source/tuple/b3dtuple.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dtuple.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-10 11:45:51 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,11 +65,8 @@
namespace basegfx
{
- namespace tuple
- {
- // initialize static member
- ::basegfx::tuple::B3DTuple B3DTuple::maEmptyTuple(0.0, 0.0, 0.0);
- } // end of namespace tuple
+ // initialize static member
+ ::basegfx::B3DTuple B3DTuple::maEmptyTuple(0.0, 0.0, 0.0);
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/vector/b2dvector.cxx b/basegfx/source/vector/b2dvector.cxx
index ed0325b446a5..d9c46044211c 100644
--- a/basegfx/source/vector/b2dvector.cxx
+++ b/basegfx/source/vector/b2dvector.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dvector.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: thb $ $Date: 2003-11-12 12:11:24 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,163 +73,160 @@
namespace basegfx
{
- namespace vector
+ B2DVector& B2DVector::normalize()
{
- B2DVector& B2DVector::normalize()
+ double fLen(scalar(*this));
+
+ if(!::basegfx::fTools::equalZero(fLen))
{
- double fLen(scalar(*this));
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equalZero(fLen))
+ if(!::basegfx::fTools::equal(fOne, fLen))
{
- const double fOne(1.0);
+ fLen = sqrt(fLen);
- if(!::basegfx::numeric::fTools::equal(fOne, fLen))
+ if(!::basegfx::fTools::equalZero(fLen))
{
- fLen = sqrt(fLen);
-
- if(!::basegfx::numeric::fTools::equalZero(fLen))
- {
- mfX /= fLen;
- mfY /= fLen;
- }
+ mfX /= fLen;
+ mfY /= fLen;
}
}
-
- return *this;
- }
-
- B2DVector& B2DVector::operator=( const ::basegfx::tuple::B2DTuple& rVec )
- {
- mfX = rVec.getX();
- mfY = rVec.getY();
- return *this;
}
+ return *this;
+ }
- double B2DVector::getLength() const
- {
- return hypot( mfX, mfY );
- }
-
- double B2DVector::scalar( const B2DVector& rVec ) const
- {
- return((mfX * rVec.mfX) + (mfY * rVec.mfY));
- }
+ B2DVector& B2DVector::operator=( const ::basegfx::B2DTuple& rVec )
+ {
+ mfX = rVec.getX();
+ mfY = rVec.getY();
+ return *this;
+ }
- double B2DVector::cross( const B2DVector& rVec ) const
- {
- return(mfX * rVec.getY() - mfY * rVec.getX());
- }
- double B2DVector::angle( const B2DVector& rVec ) const
- {
- return atan2(mfX * rVec.getY() - mfY * rVec.getX(),
- mfX * rVec.getX() + mfY * rVec.getY());
- }
+ double B2DVector::getLength() const
+ {
+ return hypot( mfX, mfY );
+ }
- const B2DVector& B2DVector::getEmptyVector()
- {
- return (const B2DVector&) ::basegfx::tuple::B2DTuple::getEmptyTuple();
- }
+ double B2DVector::scalar( const B2DVector& rVec ) const
+ {
+ return((mfX * rVec.mfX) + (mfY * rVec.mfY));
+ }
- B2DVector& B2DVector::operator*=( const matrix::B2DHomMatrix& rMat )
- {
- const double fTempX( rMat.get(0,0)*mfX +
- rMat.get(0,1)*mfY );
- const double fTempY( rMat.get(1,0)*mfX +
- rMat.get(1,1)*mfY );
- mfX = fTempX;
- mfY = fTempY;
-
- return *this;
- }
+ double B2DVector::cross( const B2DVector& rVec ) const
+ {
+ return(mfX * rVec.getY() - mfY * rVec.getX());
+ }
- B2DVector& B2DVector::setLength(double fLen)
- {
- double fLenNow(scalar(*this));
+ double B2DVector::angle( const B2DVector& rVec ) const
+ {
+ return atan2(mfX * rVec.getY() - mfY * rVec.getX(),
+ mfX * rVec.getX() + mfY * rVec.getY());
+ }
- if(!::basegfx::numeric::fTools::equalZero(fLenNow))
- {
- const double fOne(10.0);
+ const B2DVector& B2DVector::getEmptyVector()
+ {
+ return (const B2DVector&) ::basegfx::B2DTuple::getEmptyTuple();
+ }
- if(!::basegfx::numeric::fTools::equal(fOne, fLenNow))
- {
- fLen /= sqrt(fLenNow);
- }
+ B2DVector& B2DVector::operator*=( const B2DHomMatrix& rMat )
+ {
+ const double fTempX( rMat.get(0,0)*mfX +
+ rMat.get(0,1)*mfY );
+ const double fTempY( rMat.get(1,0)*mfX +
+ rMat.get(1,1)*mfY );
+ mfX = fTempX;
+ mfY = fTempY;
- mfX *= fLen;
- mfY *= fLen;
- }
+ return *this;
+ }
- return *this;
- }
+ B2DVector& B2DVector::setLength(double fLen)
+ {
+ double fLenNow(scalar(*this));
- sal_Bool B2DVector::isNormalized() const
+ if(!::basegfx::fTools::equalZero(fLenNow))
{
- const double fOne(1.0);
- const double fScalar(scalar(*this));
+ const double fOne(10.0);
- return (::basegfx::numeric::fTools::equal(fOne, fScalar));
- }
+ if(!::basegfx::fTools::equal(fOne, fLenNow))
+ {
+ fLen /= sqrt(fLenNow);
+ }
- sal_Bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB )
- {
- double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
- return ::basegfx::numeric::fTools::equalZero(fVal);
+ mfX *= fLen;
+ mfY *= fLen;
}
- B2DVectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB )
- {
- double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
+ return *this;
+ }
- if(fVal > 0.0)
- {
- return ORIENTATION_POSITIVE;
- }
+ sal_Bool B2DVector::isNormalized() const
+ {
+ const double fOne(1.0);
+ const double fScalar(scalar(*this));
- if(fVal < 0.0)
- {
- return ORIENTATION_NEGATIVE;
- }
+ return (::basegfx::fTools::equal(fOne, fScalar));
+ }
- return ORIENTATION_NEUTRAL;
- }
+ sal_Bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB )
+ {
+ double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
+ return ::basegfx::fTools::equalZero(fVal);
+ }
+
+ B2DVectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB )
+ {
+ double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
- B2DVector getPerpendicular( const B2DVector& rNormalizedVec )
+ if(fVal > 0.0)
{
- B2DVector aPerpendicular(-rNormalizedVec.getY(), rNormalizedVec.getX());
- return aPerpendicular;
+ return ORIENTATION_POSITIVE;
}
- B2DVector operator*( const matrix::B2DHomMatrix& rMat, const B2DVector& rVec )
+ if(fVal < 0.0)
{
- B2DVector aRes( rVec );
- return aRes*=rMat;
+ return ORIENTATION_NEGATIVE;
}
- ::basegfx::vector::B2DVectorContinuity getContinuity(const B2DVector& rBackVector, const B2DVector& rForwardVector )
+ return ORIENTATION_NEUTRAL;
+ }
+
+ B2DVector getPerpendicular( const B2DVector& rNormalizedVec )
+ {
+ B2DVector aPerpendicular(-rNormalizedVec.getY(), rNormalizedVec.getX());
+ return aPerpendicular;
+ }
+
+ B2DVector operator*( const B2DHomMatrix& rMat, const B2DVector& rVec )
+ {
+ B2DVector aRes( rVec );
+ return aRes*=rMat;
+ }
+
+ ::basegfx::B2DVectorContinuity getContinuity(const B2DVector& rBackVector, const B2DVector& rForwardVector )
+ {
+ ::basegfx::B2DVectorContinuity eRetval(::basegfx::CONTINUITY_NONE);
+
+ if(!rBackVector.equalZero() && !rForwardVector.equalZero())
{
- ::basegfx::vector::B2DVectorContinuity eRetval(::basegfx::vector::CONTINUITY_NONE);
+ const B2DVector aInverseForwardVector(-rForwardVector.getX(), -rForwardVector.getY());
- if(!rBackVector.equalZero() && !rForwardVector.equalZero())
+ if(rBackVector.equal(aInverseForwardVector))
{
- const B2DVector aInverseForwardVector(-rForwardVector.getX(), -rForwardVector.getY());
-
- if(rBackVector.equal(aInverseForwardVector))
- {
- // same direction and same length -> C2
- eRetval = ::basegfx::vector::CONTINUITY_C2;
- }
- else if(areParallel(rBackVector, aInverseForwardVector))
- {
- // same direction -> C1
- eRetval = ::basegfx::vector::CONTINUITY_C1;
- }
+ // same direction and same length -> C2
+ eRetval = ::basegfx::CONTINUITY_C2;
+ }
+ else if(areParallel(rBackVector, aInverseForwardVector))
+ {
+ // same direction -> C1
+ eRetval = ::basegfx::CONTINUITY_C1;
}
-
- return eRetval;
}
- } // end of namespace vector
+
+ return eRetval;
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/vector/b3dvector.cxx b/basegfx/source/vector/b3dvector.cxx
index 45c8b3d58fa8..6e08ea0fffa7 100644
--- a/basegfx/source/vector/b3dvector.cxx
+++ b/basegfx/source/vector/b3dvector.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dvector.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:16 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -69,71 +69,68 @@
namespace basegfx
{
- namespace vector
+ B3DVector& B3DVector::normalize()
{
- B3DVector& B3DVector::normalize()
+ double fLen(scalar(*this));
+
+ if(!::basegfx::fTools::equalZero(fLen))
{
- double fLen(scalar(*this));
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equalZero(fLen))
+ if(!::basegfx::fTools::equal(fOne, fLen))
{
- const double fOne(1.0);
+ fLen = sqrt(fLen);
- if(!::basegfx::numeric::fTools::equal(fOne, fLen))
+ if(!::basegfx::fTools::equalZero(fLen))
{
- fLen = sqrt(fLen);
-
- if(!::basegfx::numeric::fTools::equalZero(fLen))
- {
- mfX /= fLen;
- mfY /= fLen;
- mfZ /= fLen;
- }
+ mfX /= fLen;
+ mfY /= fLen;
+ mfZ /= fLen;
}
}
-
- return *this;
}
- B3DVector B3DVector::getPerpendicular(const B3DVector& rNormalizedVec) const
- {
- B3DVector aNew(*this);
- aNew = cross(aNew, rNormalizedVec);
- aNew.normalize();
- return aNew;
- }
+ return *this;
+ }
- B3DVector B3DVector::getProjectionOnPlane(const B3DVector& rNormalizedPlane) const
- {
- B3DVector aNew(*this);
- aNew = cross(aNew, rNormalizedPlane);
- aNew = cross(aNew, rNormalizedPlane);
+ B3DVector B3DVector::getPerpendicular(const B3DVector& rNormalizedVec) const
+ {
+ B3DVector aNew(*this);
+ aNew = cross(aNew, rNormalizedVec);
+ aNew.normalize();
+ return aNew;
+ }
+
+ B3DVector B3DVector::getProjectionOnPlane(const B3DVector& rNormalizedPlane) const
+ {
+ B3DVector aNew(*this);
+ aNew = cross(aNew, rNormalizedPlane);
+ aNew = cross(aNew, rNormalizedPlane);
- aNew.mfX = mfX - aNew.mfX;
- aNew.mfY = mfY - aNew.mfY;
- aNew.mfZ = mfZ - aNew.mfZ;
+ aNew.mfX = mfX - aNew.mfX;
+ aNew.mfY = mfY - aNew.mfY;
+ aNew.mfZ = mfZ - aNew.mfZ;
- return aNew;
- }
+ return aNew;
+ }
- B3DVector& B3DVector::operator*=( const matrix::B3DHomMatrix& rMat )
- {
- const double fTempX( rMat.get(0,0)*mfX + rMat.get(0,1)*mfY + rMat.get(0,2)*mfZ );
- const double fTempY( rMat.get(1,0)*mfX + rMat.get(1,1)*mfY + rMat.get(1,2)*mfZ );
- const double fTempZ( rMat.get(2,0)*mfX + rMat.get(2,1)*mfY + rMat.get(2,2)*mfZ );
- mfX = fTempX;
- mfY = fTempY;
- mfZ = fTempZ;
+ B3DVector& B3DVector::operator*=( const B3DHomMatrix& rMat )
+ {
+ const double fTempX( rMat.get(0,0)*mfX + rMat.get(0,1)*mfY + rMat.get(0,2)*mfZ );
+ const double fTempY( rMat.get(1,0)*mfX + rMat.get(1,1)*mfY + rMat.get(1,2)*mfZ );
+ const double fTempZ( rMat.get(2,0)*mfX + rMat.get(2,1)*mfY + rMat.get(2,2)*mfZ );
+ mfX = fTempX;
+ mfY = fTempY;
+ mfZ = fTempZ;
- return *this;
- }
+ return *this;
+ }
- B3DVector operator*( const matrix::B3DHomMatrix& rMat, const B3DVector& rVec )
- {
- B3DVector aRes( rVec );
- return aRes*=rMat;
- }
- } // end of namespace vector
+ B3DVector operator*( const B3DHomMatrix& rMat, const B3DVector& rVec )
+ {
+ B3DVector aRes( rVec );
+ return aRes*=rMat;
+ }
} // end of namespace basegfx
// eof