From 56f2ab808ec8b0ce9aed1acd042123b87006ad60 Mon Sep 17 00:00:00 2001 From: Armin Weiss Date: Wed, 26 Nov 2003 13:40:18 +0000 Subject: Added support for B3DPolyPOlygon, moved BDRange from source/inc to range namespace and the directories --- basegfx/inc/basegfx/numeric/ftools.hxx | 32 +++++- basegfx/inc/basegfx/point/b2dpoint.hxx | 22 ++++- basegfx/inc/basegfx/point/b3dpoint.hxx | 37 ++++++- basegfx/inc/basegfx/polygon/b2dpolygon.hxx | 12 ++- basegfx/inc/basegfx/polygon/b2dpolygontools.hxx | 18 ++-- basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx | 16 ++- .../inc/basegfx/polygon/b2dpolypolygontools.hxx | 24 +++-- basegfx/inc/basegfx/range/b1drange.hxx | 15 ++- basegfx/inc/basegfx/range/b2drange.hxx | 20 ++-- basegfx/inc/basegfx/range/b3drange.hxx | 23 +++-- basegfx/inc/basegfx/tuple/b3dtuple.hxx | 20 ++-- basegfx/inc/basegfx/vector/b2dvector.hxx | 22 ++++- basegfx/inc/basegfx/vector/b3dvector.hxx | 44 ++++++++- basegfx/prj/d.lst | 5 + basegfx/source/curve/b2dbeziertools.cxx | 35 ++++--- basegfx/source/curve/b2dcubicbezier.cxx | 8 +- basegfx/source/curve/b2dquadraticbezier.cxx | 8 +- basegfx/source/point/b3dpoint.cxx | 28 +++++- basegfx/source/polygon/b2dpolygon.cxx | 103 +++++++++++++++---- basegfx/source/polygon/b2dpolygontools.cxx | 109 ++++++++++++++++++--- basegfx/source/polygon/b2dpolypolygon.cxx | 58 ++++++----- basegfx/source/polygon/b2dpolypolygoncutter.cxx | 20 ++-- basegfx/source/polygon/b2dpolypolygontools.cxx | 56 +++++++++-- basegfx/source/polygon/makefile.mk | 10 +- basegfx/source/vector/b3dvector.cxx | 26 ++++- basegfx/util/makefile.mk | 5 +- 26 files changed, 611 insertions(+), 165 deletions(-) (limited to 'basegfx') diff --git a/basegfx/inc/basegfx/numeric/ftools.hxx b/basegfx/inc/basegfx/numeric/ftools.hxx index 9e657b91179f..4a8287ff164c 100644 --- a/basegfx/inc/basegfx/numeric/ftools.hxx +++ b/basegfx/inc/basegfx/numeric/ftools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ftools.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2003-11-05 12:25:38 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:39:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,6 +70,34 @@ #include #endif +////////////////////////////////////////////////////////////////////////////// +// standard PI defines from solar.h, but we do not want to link against tools + +#ifndef F_PI +#define F_PI 3.14159265358979323846 +#endif +#ifndef F_PI2 +#define F_PI2 1.57079632679489661923 +#endif +#ifndef F_PI4 +#define F_PI4 0.785398163397448309616 +#endif +#ifndef F_PI180 +#define F_PI180 0.01745329251994 +#endif +#ifndef F_PI1800 +#define F_PI1800 0.001745329251994 +#endif +#ifndef F_PI18000 +#define F_PI18000 0.0001745329251994 +#endif +#ifndef F_2PI +#define F_2PI 6.28318530717958647694 +#endif + +////////////////////////////////////////////////////////////////////////////// +// fTools defines + namespace basegfx { namespace numeric diff --git a/basegfx/inc/basegfx/point/b2dpoint.hxx b/basegfx/inc/basegfx/point/b2dpoint.hxx index 297bada3ba56..eb5f042f69e8 100644 --- a/basegfx/inc/basegfx/point/b2dpoint.hxx +++ b/basegfx/inc/basegfx/point/b2dpoint.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpoint.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2003-11-06 16:30:23 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:39:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -130,6 +130,24 @@ namespace basegfx ~B2DPoint() {} + /** *=operator to allow usage from B2DPoint, too + */ + B2DPoint& operator*=( const B2DPoint& rPnt ) + { + mfX *= rPnt.mfX; + mfY *= rPnt.mfY; + return *this; + } + + /** *=operator to allow usage from B2DPoint, too + */ + B2DPoint& operator*=(double t) + { + mfX *= t; + mfY *= t; + return *this; + } + /** assignment operator to allow assigning the results of B2DTuple calculations */ diff --git a/basegfx/inc/basegfx/point/b3dpoint.hxx b/basegfx/inc/basegfx/point/b3dpoint.hxx index 65047e6c26cf..7f444b850234 100644 --- a/basegfx/inc/basegfx/point/b3dpoint.hxx +++ b/basegfx/inc/basegfx/point/b3dpoint.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dpoint.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2003-11-06 16:30:24 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:39:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,6 +68,12 @@ namespace basegfx { + namespace matrix + { + // predeclaration + class B3DHomMatrix; + } // end of namespace matrix; + namespace point { /** Base Point class with three double values @@ -128,6 +134,26 @@ namespace basegfx ~B3DPoint() {} + /** *=operator to allow usage from B3DPoint, too + */ + B3DPoint& operator*=( const B3DPoint& rPnt ) + { + mfX *= rPnt.mfX; + mfY *= rPnt.mfY; + mfZ *= rPnt.mfZ; + return *this; + } + + /** *=operator to allow usage from B3DPoint, too + */ + B3DPoint& operator*=(double t) + { + mfX *= t; + mfY *= t; + mfZ *= t; + return *this; + } + /** assignment operator to allow assigning the results of B3DTuple calculations */ @@ -139,6 +165,13 @@ namespace basegfx return *this; } + /** Transform point by given transformation matrix. + + The translational components of the matrix are, in + contrast to B3DVector, applied. + */ + B3DPoint& operator*=( const ::basegfx::matrix::B3DHomMatrix& rMat ); + static const B3DPoint& getEmptyPoint() { return (const B3DPoint&) ::basegfx::tuple::B3DTuple::getEmptyTuple(); diff --git a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx index 3ce8fff7bf8c..c58be040d447 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolygon.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-10 11:45:47 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:39:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -86,6 +86,11 @@ namespace basegfx { class B2DVector; } // end of namespace vector + + namespace matrix + { + class B2DHomMatrix; + } // end of namespace matrix } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// @@ -157,6 +162,9 @@ namespace basegfx // remove double points, at the begin/end and follow-ups, too void removeDoublePoints(); + + // apply transformation given in matrix form to the polygon + void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix); }; } // end of namespace polygon } // end of namespace basegfx diff --git a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx index efc77e678d21..b2fc5f9c16e5 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolygontools.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-11-11 09:48:12 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:39:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,20 +70,17 @@ #include #endif -#ifndef _TOOLS_DEBUG_HXX -#include -#endif - ////////////////////////////////////////////////////////////////////////////// namespace basegfx { + // predefinitions namespace polygon { - // predefinitions class B2DPolygon; } // end of namespace polygon + // predefinitions namespace range { class B2DRange; @@ -125,7 +122,7 @@ namespace basegfx sal_Bool isInside(const ::basegfx::polygon::B2DPolygon& rCandidate, const ::basegfx::point::B2DPoint& rPoint, sal_Bool bWithBorder = sal_False); sal_Bool isInside(const ::basegfx::polygon::B2DPolygon& rCandidate, const ::basegfx::polygon::B2DPolygon& rPolygon, sal_Bool bWithBorder = sal_False); - // get size of polygon + // get size of polygon. Control vectors are included in that ranges. ::basegfx::range::B2DRange getRange(const ::basegfx::polygon::B2DPolygon& rCandidate); // get area of polygon @@ -154,7 +151,10 @@ namespace basegfx ::basegfx::vector::B2DVectorContinuity getContinuityInPoint(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex); // Subdivide all contained curves. Use distanceBound value if given. - ::basegfx::polygon::B2DPolygon adaptiveSubdivide(const ::basegfx::polygon::B2DPolygon& rCandidate, double fDistanceBound = 0.0); + ::basegfx::polygon::B2DPolygon adaptiveSubdivideByDistance(const ::basegfx::polygon::B2DPolygon& rCandidate, double fDistanceBound = 0.0); + + // Subdivide all contained curves. Use distanceBound value if given. + ::basegfx::polygon::B2DPolygon adaptiveSubdivideByAngle(const ::basegfx::polygon::B2DPolygon& rCandidate, double fAngleBound = 5.0); // Definitions for the cut flags used from the findCut methods typedef sal_uInt16 CutFlagValue; diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx index acd385099ebe..89e6b68b4072 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygon.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-10 11:45:48 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:39:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,6 +75,11 @@ namespace basegfx { class B2DPolygon; } // end of namespace polygon + + namespace matrix + { + class B2DHomMatrix; + } // end of namespace matrix } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// @@ -107,8 +112,8 @@ namespace basegfx // polygon interface sal_uInt32 count() const; - B2DPolygon getPolygon(sal_uInt32 nIndex) const; - void setPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon); + B2DPolygon getB2DPolygon(sal_uInt32 nIndex) const; + void setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon); // test for curve sal_Bool areControlPointsUsed() const; @@ -139,6 +144,9 @@ namespace basegfx // remove double points, at the begin/end and follow-ups, too void removeDoublePoints(); + + // apply transformation given in matrix form to the polygon + void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix); }; } // end of namespace polygon } // end of namespace basegfx diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx index 926fa918035a..5165ef6a37ed 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygontools.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-11 09:48:13 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:39:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,20 +70,22 @@ #include #endif -#ifndef _TOOLS_DEBUG_HXX -#include -#endif - ////////////////////////////////////////////////////////////////////////////// namespace basegfx { + // predefinitions namespace polygon { - // predefinitions class B2DPolyPolygon; } // end of namespace polygon + // predefinitions + namespace range + { + class B2DRange; + } // end of namespace range + namespace polygon { namespace tools @@ -108,7 +110,13 @@ namespace basegfx sal_Bool bForceOrientation = sal_True, sal_Bool bInvertRemove = sal_False); // Subdivide all contained curves. Use distanceBound value if given. - ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivide(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fDistanceBound = 0.0); + ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivideByDistance(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fDistanceBound = 0.0); + + // Subdivide all contained curves. Use distanceBound value if given. + ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivideByAngle(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fAngleBound = 5.0); + + // get size of PolyPolygon. Control vectors are included in that ranges. + ::basegfx::range::B2DRange getRange(const ::basegfx::polygon::B2DPolyPolygon& rCandidate); } // end of namespace tools } // end of namespace polygon diff --git a/basegfx/inc/basegfx/range/b1drange.hxx b/basegfx/inc/basegfx/range/b1drange.hxx index 3acab7da4a20..e2fd154b5e11 100644 --- a/basegfx/inc/basegfx/range/b1drange.hxx +++ b/basegfx/inc/basegfx/range/b1drange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b1drange.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-06 16:30:25 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,8 +62,8 @@ #ifndef _BGFX_RANGE_B1DRANGE_HXX #define _BGFX_RANGE_B1DRANGE_HXX -#ifndef _BDRANGE_HXX -#include +#ifndef _BGFX_RANGE_BASICRANGE_HXX +#include #endif namespace basegfx @@ -72,7 +72,7 @@ namespace basegfx { class B1DRange { - BDRange maRange; + ::basegfx::range::BasicRange maRange; public: B1DRange() @@ -119,6 +119,11 @@ namespace basegfx return maRange.getRange(); } + double getCenter() const + { + return maRange.getCenter(); + } + sal_Bool isInside(double fValue) const { return maRange.isInside(fValue); diff --git a/basegfx/inc/basegfx/range/b2drange.hxx b/basegfx/inc/basegfx/range/b2drange.hxx index 85002f6c8956..10f14abe9fd7 100644 --- a/basegfx/inc/basegfx/range/b2drange.hxx +++ b/basegfx/inc/basegfx/range/b2drange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2drange.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-06 16:30:26 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,8 +66,8 @@ #include #endif -#ifndef _BDRANGE_HXX -#include +#ifndef _BGFX_RANGE_BASICRANGE_HXX +#include #endif namespace basegfx @@ -76,8 +76,8 @@ namespace basegfx { class B2DRange { - BDRange maRangeX; - BDRange maRangeY; + ::basegfx::range::BasicRange maRangeX; + ::basegfx::range::BasicRange maRangeY; public: B2DRange() @@ -140,6 +140,14 @@ namespace basegfx ); } + tuple::B2DTuple getCenter() const + { + return tuple::B2DTuple( + maRangeX.getCenter(), + maRangeY.getCenter() + ); + } + sal_Bool isInside(const tuple::B2DTuple& rTuple) const { return ( diff --git a/basegfx/inc/basegfx/range/b3drange.hxx b/basegfx/inc/basegfx/range/b3drange.hxx index 2da5e2c3e1af..3d6c3c958d1a 100644 --- a/basegfx/inc/basegfx/range/b3drange.hxx +++ b/basegfx/inc/basegfx/range/b3drange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3drange.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-06 16:30:26 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,8 +66,8 @@ #include #endif -#ifndef _BDRANGE_HXX -#include +#ifndef _BGFX_RANGE_BASICRANGE_HXX +#include #endif namespace basegfx @@ -76,9 +76,9 @@ namespace basegfx { class B3DRange { - BDRange maRangeX; - BDRange maRangeY; - BDRange maRangeZ; + ::basegfx::range::BasicRange maRangeX; + ::basegfx::range::BasicRange maRangeY; + ::basegfx::range::BasicRange maRangeZ; public: B3DRange() @@ -149,6 +149,15 @@ namespace basegfx ); } + tuple::B3DTuple getCenter() const + { + return tuple::B3DTuple( + maRangeX.getCenter(), + maRangeY.getCenter(), + maRangeZ.getCenter() + ); + } + sal_Bool isInside(const tuple::B3DTuple& rTuple) const { return ( diff --git a/basegfx/inc/basegfx/tuple/b3dtuple.hxx b/basegfx/inc/basegfx/tuple/b3dtuple.hxx index 24ab97aad569..48f1fde48a24 100644 --- a/basegfx/inc/basegfx/tuple/b3dtuple.hxx +++ b/basegfx/inc/basegfx/tuple/b3dtuple.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dtuple.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-10 11:45:49 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -192,13 +192,15 @@ namespace basegfx // comparators with tolerance ////////////////////////////////////////////////////////////////////// - sal_Bool EqualZero() const + sal_Bool equalZero() const { return (this == &maEmptyTuple || - (::basegfx::numeric::fTools::equalZero(mfX) && ::basegfx::numeric::fTools::equalZero(mfY) && ::basegfx::numeric::fTools::equalZero(mfZ))); + (::basegfx::numeric::fTools::equalZero(mfX) + && ::basegfx::numeric::fTools::equalZero(mfY) + && ::basegfx::numeric::fTools::equalZero(mfZ))); } - sal_Bool EqualZero(const double& rfSmallValue) const + sal_Bool equalZero(const double& rfSmallValue) const { return (this == &maEmptyTuple || (::basegfx::numeric::fTools::equalZero(mfX, rfSmallValue) @@ -206,7 +208,7 @@ namespace basegfx && ::basegfx::numeric::fTools::equalZero(mfZ, rfSmallValue))); } - sal_Bool Equal(const B3DTuple& rTup) const + sal_Bool equal(const B3DTuple& rTup) const { return ( ::basegfx::numeric::fTools::equal(mfX, rTup.mfX) && @@ -214,7 +216,7 @@ namespace basegfx ::basegfx::numeric::fTools::equal(mfZ, rTup.mfZ)); } - sal_Bool Equal(const B3DTuple& rTup, const double& rfSmallValue) const + sal_Bool equal(const B3DTuple& rTup, const double& rfSmallValue) const { return ( ::basegfx::numeric::fTools::equal(mfX, rTup.mfX, rfSmallValue) && @@ -281,12 +283,12 @@ namespace basegfx sal_Bool operator==( const B3DTuple& rTup ) const { - return Equal(rTup); + return equal(rTup); } sal_Bool operator!=( const B3DTuple& rTup ) const { - return !Equal(rTup); + return !equal(rTup); } B3DTuple& operator=( const B3DTuple& rTup ) diff --git a/basegfx/inc/basegfx/vector/b2dvector.hxx b/basegfx/inc/basegfx/vector/b2dvector.hxx index 0a3a896733a0..f35c38bb3236 100644 --- a/basegfx/inc/basegfx/vector/b2dvector.hxx +++ b/basegfx/inc/basegfx/vector/b2dvector.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dvector.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: thb $ $Date: 2003-11-12 12:09:51 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -158,6 +158,24 @@ namespace basegfx ~B2DVector() {} + /** *=operator to allow usage from B2DVector, too + */ + B2DVector& operator*=( const B2DVector& rPnt ) + { + mfX *= rPnt.mfX; + mfY *= rPnt.mfY; + return *this; + } + + /** *=operator to allow usage from B2DVector, too + */ + B2DVector& operator*=(double t) + { + mfX *= t; + mfY *= t; + return *this; + } + /** assignment operator to allow assigning the results of B2DTuple calculations */ diff --git a/basegfx/inc/basegfx/vector/b3dvector.hxx b/basegfx/inc/basegfx/vector/b3dvector.hxx index bd118592ec96..855abb7f71e8 100644 --- a/basegfx/inc/basegfx/vector/b3dvector.hxx +++ b/basegfx/inc/basegfx/vector/b3dvector.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dvector.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-06 16:30:26 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,6 +68,12 @@ namespace basegfx { + namespace matrix + { + // predeclaration + class B3DHomMatrix; + } // end of namespace matrix; + namespace vector { /** Base Point class with three double values @@ -128,6 +134,26 @@ namespace basegfx ~B3DVector() {} + /** *=operator to allow usage from B3DVector, too + */ + B3DVector& operator*=( const B3DVector& rPnt ) + { + mfX *= rPnt.mfX; + mfY *= rPnt.mfY; + mfZ *= rPnt.mfZ; + return *this; + } + + /** *=operator to allow usage from B3DVector, too + */ + B3DVector& operator*=(double t) + { + mfX *= t; + mfY *= t; + mfZ *= t; + return *this; + } + /** assignment operator to allow assigning the results of B3DTuple calculations */ @@ -275,6 +301,13 @@ namespace basegfx return ((mfX * rVec.mfX) + (mfY * rVec.mfY) + (mfZ * rVec.mfZ)); } + /** Transform vector by given transformation matrix. + + Since this is a vector, translational components of the + matrix are disregarded. + */ + B3DVector& operator*=( const matrix::B3DHomMatrix& rMat ); + static const B3DVector& getEmptyVector() { return (const B3DVector&) ::basegfx::tuple::B3DTuple::getEmptyTuple(); @@ -301,6 +334,13 @@ namespace basegfx return aPerpendicular; } + /** Transform vector by given transformation matrix. + + Since this is a vector, translational components of the + matrix are disregarded. + */ + B3DVector operator*( const matrix::B3DHomMatrix& rMat, const B3DVector& rVec ); + /** Calculate the Cross Product of two 3D Vectors @param rVecA diff --git a/basegfx/prj/d.lst b/basegfx/prj/d.lst index 54fb7f67a511..ac3edb8a1314 100644 --- a/basegfx/prj/d.lst +++ b/basegfx/prj/d.lst @@ -19,6 +19,7 @@ mkdir: %_DEST%\inc%_EXT%\basegfx\point ..\inc\basegfx\point\b3dhompoint.hxx %_DEST%\inc%_EXT%\basegfx\point\b3dhompoint.hxx mkdir: %_DEST%\inc%_EXT%\basegfx\range +..\inc\basegfx\range\basicrange.hxx %_DEST%\inc%_EXT%\basegfx\range\basicrange.hxx ..\inc\basegfx\range\b1drange.hxx %_DEST%\inc%_EXT%\basegfx\range\b1drange.hxx ..\inc\basegfx\range\b2drange.hxx %_DEST%\inc%_EXT%\basegfx\range\b2drange.hxx ..\inc\basegfx\range\b3drange.hxx %_DEST%\inc%_EXT%\basegfx\range\b3drange.hxx @@ -38,6 +39,10 @@ mkdir: %_DEST%\inc%_EXT%\basegfx\polygon ..\inc\basegfx\polygon\b2dpolypolygon.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b2dpolypolygon.hxx ..\inc\basegfx\polygon\b2dpolygontools.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b2dpolygontools.hxx ..\inc\basegfx\polygon\b2dpolypolygontools.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b2dpolypolygontools.hxx +..\inc\basegfx\polygon\b3dpolygon.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b3dpolygon.hxx +..\inc\basegfx\polygon\b3dpolypolygon.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b3dpolypolygon.hxx +..\inc\basegfx\polygon\b3dpolygontools.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b3dpolygontools.hxx +..\inc\basegfx\polygon\b3dpolypolygontools.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b3dpolypolygontools.hxx mkdir: %_DEST%\inc%_EXT%\basegfx\tuple ..\inc\basegfx\tuple\b2dtuple.hxx %_DEST%\inc%_EXT%\basegfx\tuple\b2dtuple.hxx diff --git a/basegfx/source/curve/b2dbeziertools.cxx b/basegfx/source/curve/b2dbeziertools.cxx index 0e6e24a071da..3512b87ca992 100644 --- a/basegfx/source/curve/b2dbeziertools.cxx +++ b/basegfx/source/curve/b2dbeziertools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dbeziertools.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: thb $ $Date: 2003-11-12 12:09:52 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,10 @@ #include #include +#ifndef _SOLAR_H +#include +#endif + #include #ifndef _BGFX_CURVE_B2DCUBICBEZIER_HXX @@ -148,7 +152,7 @@ namespace basegfx { public: AngleErrorFunctor( const double& angleBounds ) : - mfTanAngle( tan( angleBounds ) ), + mfTanAngle( angleBounds * F_PI180 ), mfLastTanAngle( ::std::numeric_limits::max() ) { } @@ -213,14 +217,21 @@ namespace basegfx double fCurrAngle( ::std::numeric_limits::max() ); - if( !numeric::fTools::equalZero( scalarVecADDB ) ) - fCurrAngle = fabs( crossVecADDB / scalarVecADDB ); - - if( !numeric::fTools::equalZero( scalarVecStartTangentAD ) ) - fCurrAngle = ::std::min( fCurrAngle, fabs( crossVecStartTangentAD / scalarVecStartTangentAD ) ); - - if( !numeric::fTools::equalZero( scalarVecDBEndTangent ) ) - fCurrAngle = ::std::min( fCurrAngle, fabs( crossVecDBEndTangent / scalarVecDBEndTangent ) ); + // 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 ) + { + 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. @@ -261,7 +272,7 @@ namespace basegfx prevent endless looping. */ template < class ErrorFunctor > int ImplAdaptiveSubdivide( polygon::B2DPolygon& rPoly, - const ErrorFunctor& rErrorFunctor, + ErrorFunctor rErrorFunctor, const double P1x, const double P1y, const double P2x, const double P2y, const double P3x, const double P3y, diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index 19eadc8dab49..9633aa6b5130 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dcubicbezier.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-06 16:30:27 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,10 +63,6 @@ #include #endif -#ifndef _TOOLS_DEBUG_HXX -#include -#endif - ////////////////////////////////////////////////////////////////////////////// namespace basegfx diff --git a/basegfx/source/curve/b2dquadraticbezier.cxx b/basegfx/source/curve/b2dquadraticbezier.cxx index 5db6c1d42775..607d10b4a7bc 100644 --- a/basegfx/source/curve/b2dquadraticbezier.cxx +++ b/basegfx/source/curve/b2dquadraticbezier.cxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dquadraticbezier.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-06 16:30:27 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,10 +63,6 @@ #include #endif -#ifndef _TOOLS_DEBUG_HXX -#include -#endif - #ifndef _BGFX_NUMERIC_FTOOLS_HXX #include #endif diff --git a/basegfx/source/point/b3dpoint.cxx b/basegfx/source/point/b3dpoint.cxx index 357b2ae0f33c..6d6471ffa07d 100644 --- a/basegfx/source/point/b3dpoint.cxx +++ b/basegfx/source/point/b3dpoint.cxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dpoint.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-26 14:40:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,10 +63,34 @@ #include #endif +#ifndef _BGFX_MATRIX_B3DHOMMATRIX_HXX +#include +#endif + namespace basegfx { namespace point { + 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; + + return *this; + } } // end of namespace point } // end of namespace basegfx diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index 09d4429aa181..7a9b477081f5 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolygon.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-11-10 11:45:50 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,12 +59,12 @@ * ************************************************************************/ -#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX -#include +#ifndef _OSL_DIAGNOSE_H_ +#include #endif -#ifndef _TOOLS_DEBUG_HXX -#include +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include #endif #ifndef _BGFX_POINT_B2DPOINT_HXX @@ -75,6 +75,10 @@ #include #endif +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include +#endif + #include #include @@ -92,6 +96,7 @@ public: const ::basegfx::point::B2DPoint& getCoordinate() const { return maPoint; } void setCoordinate(const ::basegfx::point::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; } }; ////////////////////////////////////////////////////////////////////////////// @@ -227,6 +232,17 @@ public: } } } + + void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix) + { + CoordinateData2DVector::iterator aStart(maVector.begin()); + CoordinateData2DVector::iterator aEnd(maVector.end()); + + for(; aStart != aEnd; aStart++) + { + aStart->transform(rMatrix); + } + } }; ////////////////////////////////////////////////////////////////////////////// @@ -922,6 +938,48 @@ public: maPoints.removeDoublePointsWholeTrack(); } } + + void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix) + { + if(mpControlVector) + { + for(sal_uInt32 a(0L); a < maPoints.count(); a++) + { + ::basegfx::point::B2DPoint aCandidate = maPoints.getCoordinate(a); + + if(mpControlVector->isUsed()) + { + const ::basegfx::vector::B2DVector& rVectorA(mpControlVector->getVectorA(a)); + const ::basegfx::vector::B2DVector& rVectorB(mpControlVector->getVectorB(a)); + + if(!rVectorA.equalZero()) + { + ::basegfx::vector::B2DVector aVectorA(rMatrix * rVectorA); + mpControlVector->setVectorA(a, aVectorA); + } + + if(!rVectorB.equalZero()) + { + ::basegfx::vector::B2DVector aVectorB(rMatrix * rVectorB); + mpControlVector->setVectorB(a, aVectorB); + } + } + + aCandidate *= rMatrix; + maPoints.setCoordinate(a, aCandidate); + } + + if(!mpControlVector->isUsed()) + { + delete mpControlVector; + mpControlVector = 0L; + } + } + else + { + maPoints.transform(rMatrix); + } + } }; ////////////////////////////////////////////////////////////////////////////// @@ -957,7 +1015,7 @@ namespace basegfx B2DPolygon::B2DPolygon(const B2DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 nCount) : mpPolygon(new ImplB2DPolygon(*rPolygon.mpPolygon, nIndex, nCount)) { - DBG_ASSERT(nIndex + nCount > rPolygon.mpPolygon->count(), "B2DPolygon constructor outside range (!)"); + OSL_ENSURE(nIndex + nCount > rPolygon.mpPolygon->count(), "B2DPolygon constructor outside range (!)"); } B2DPolygon::~B2DPolygon() @@ -1016,14 +1074,14 @@ namespace basegfx ::basegfx::point::B2DPoint B2DPolygon::getB2DPoint(sal_uInt32 nIndex) const { - DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); + OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); return mpPolygon->getPoint(nIndex); } void B2DPolygon::setB2DPoint(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rValue) { - DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); + OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); if(mpPolygon->getPoint(nIndex) != rValue) { @@ -1034,7 +1092,7 @@ namespace basegfx void B2DPolygon::insert(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount) { - DBG_ASSERT(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)"); + OSL_ENSURE(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)"); if(nCount) { @@ -1054,14 +1112,14 @@ namespace basegfx ::basegfx::vector::B2DVector B2DPolygon::getControlVectorA(sal_uInt32 nIndex) const { - DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); + OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); return mpPolygon->getControlVectorA(nIndex); } void B2DPolygon::setControlVectorA(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue) { - DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); + OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); if(mpPolygon->getControlVectorA(nIndex) != rValue) { @@ -1072,14 +1130,14 @@ namespace basegfx ::basegfx::vector::B2DVector B2DPolygon::getControlVectorB(sal_uInt32 nIndex) const { - DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); + OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); return mpPolygon->getControlVectorB(nIndex); } void B2DPolygon::setControlVectorB(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue) { - DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); + OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); if(mpPolygon->getControlVectorB(nIndex) != rValue) { @@ -1095,7 +1153,7 @@ namespace basegfx void B2DPolygon::insert(sal_uInt32 nIndex, const B2DPolygon& rPoly, sal_uInt32 nIndex2, sal_uInt32 nCount) { - DBG_ASSERT(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)"); + OSL_ENSURE(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)"); if(rPoly.count()) { @@ -1112,7 +1170,7 @@ namespace basegfx } else { - DBG_ASSERT(nIndex2 + nCount > rPoly.mpPolygon->count(), "B2DPolygon Insert outside range (!)"); + OSL_ENSURE(nIndex2 + nCount > rPoly.mpPolygon->count(), "B2DPolygon Insert outside range (!)"); ImplB2DPolygon aTempPoly(*rPoly.mpPolygon, nIndex2, nCount); mpPolygon->insert(nIndex, aTempPoly); } @@ -1136,7 +1194,7 @@ namespace basegfx } else { - DBG_ASSERT(nIndex + nCount > rPoly.mpPolygon->count(), "B2DPolygon Append outside range (!)"); + OSL_ENSURE(nIndex + nCount > rPoly.mpPolygon->count(), "B2DPolygon Append outside range (!)"); ImplB2DPolygon aTempPoly(*rPoly.mpPolygon, nIndex, nCount); mpPolygon->insert(mpPolygon->count(), aTempPoly); } @@ -1145,7 +1203,7 @@ namespace basegfx void B2DPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount) { - DBG_ASSERT(nIndex + nCount <= mpPolygon->count(), "B2DPolygon Remove outside range (!)"); + OSL_ENSURE(nIndex + nCount <= mpPolygon->count(), "B2DPolygon Remove outside range (!)"); if(nCount) { @@ -1206,6 +1264,15 @@ namespace basegfx mpPolygon->removeDoublePointsWholeTrack(); } } + + void B2DPolygon::transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix) + { + if(mpPolygon->count()) + { + 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 28aa2bd7aeab..c2a6faf8909a 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolygontools.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: thb $ $Date: 2003-11-12 12:09:52 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,6 +59,10 @@ * ************************************************************************/ +#ifndef _OSL_DIAGNOSE_H_ +#include +#endif + #ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX #include #endif @@ -138,7 +142,7 @@ namespace basegfx // is none. Same for successor. sal_uInt32 getIndexOfPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate) { - DBG_ASSERT(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); + OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); if(nIndex) { @@ -156,7 +160,7 @@ namespace basegfx sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate) { - DBG_ASSERT(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); + OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); if(nIndex + 1L < rCandidate.count()) { @@ -171,7 +175,7 @@ namespace basegfx sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate) { sal_uInt32 nNewIndex(nIndex); - DBG_ASSERT(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); + OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); if(rCandidate.count() > 1) { @@ -191,7 +195,7 @@ namespace basegfx sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate) { sal_uInt32 nNewIndex(nIndex); - DBG_ASSERT(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); + OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); if(rCandidate.count() > 1) { @@ -223,7 +227,7 @@ namespace basegfx ::basegfx::vector::B2DVectorContinuity getContinuityInPoint(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex) { - DBG_ASSERT(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); + OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); ::basegfx::vector::B2DVectorContinuity eRetval(::basegfx::vector::CONTINUITY_NONE); if(rCandidate.count() > 1L && rCandidate.areControlPointsUsed()) @@ -238,7 +242,7 @@ namespace basegfx return eRetval; } - ::basegfx::polygon::B2DPolygon adaptiveSubdivide(const ::basegfx::polygon::B2DPolygon& rCandidate, double fDistanceBound) + ::basegfx::polygon::B2DPolygon adaptiveSubdivideByDistance(const ::basegfx::polygon::B2DPolygon& rCandidate, double fDistanceBound) { ::basegfx::polygon::B2DPolygon aRetval(rCandidate); @@ -312,6 +316,60 @@ namespace basegfx return aRetval; } + ::basegfx::polygon::B2DPolygon adaptiveSubdivideByAngle(const ::basegfx::polygon::B2DPolygon& rCandidate, double fAngleBound) + { + ::basegfx::polygon::B2DPolygon aRetval(rCandidate); + + if(aRetval.areControlPointsUsed()) + { + const sal_uInt32 nPointCount(rCandidate.isClosed() ? rCandidate.count() : rCandidate.count() - 1L); + aRetval.clear(); + + for(sal_uInt32 a(0L); a < nPointCount; a++) + { + 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 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 + { + // no vectors used, add point + aRetval.append(rCandidate.getB2DPoint(a)); + } + } + + // check closed flag, aRetval was cleared and thus it may be invalid. + if(aRetval.isClosed() != rCandidate.isClosed()) + { + aRetval.setClosed(rCandidate.isClosed()); + } + } + + return aRetval; + } + sal_Bool isInside(const ::basegfx::polygon::B2DPolygon& rCandidate, const ::basegfx::point::B2DPoint& rPoint, sal_Bool bWithBorder) { sal_Bool bRetval(sal_False); @@ -387,10 +445,35 @@ namespace basegfx ::basegfx::range::B2DRange aRetval; const sal_uInt32 nPointCount(rCandidate.count()); - for(sal_uInt32 a(0L); a < nPointCount; a++) + if(rCandidate.areControlPointsUsed()) { - const ::basegfx::point::B2DPoint aTestPoint(rCandidate.getB2DPoint(a)); - aRetval.expand(aTestPoint); + 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); + + 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); + } + } + } + else + { + for(sal_uInt32 a(0L); a < nPointCount; a++) + { + const ::basegfx::point::B2DPoint aTestPoint(rCandidate.getB2DPoint(a)); + aRetval.expand(aTestPoint); + } } return aRetval; @@ -427,7 +510,7 @@ namespace basegfx double getEdgeLength(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex) { - DBG_ASSERT(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); + OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); double fRetval(0.0); const sal_uInt32 nPointCount(rCandidate.count()); @@ -591,7 +674,7 @@ namespace basegfx ::basegfx::vector::B2DVectorOrientation getPointOrientation(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex) { - DBG_ASSERT(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); + OSL_ENSURE(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)"); ::basegfx::vector::B2DVectorOrientation eRetval(::basegfx::vector::ORIENTATION_NEUTRAL); if(rCandidate.count() > 2) diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index fdd1e30276d3..301d5a68edd8 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygon.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-11-10 11:45:50 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,6 +59,10 @@ * ************************************************************************/ +#ifndef _OSL_DIAGNOSE_H_ +#include +#endif + #ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX #include #endif @@ -67,10 +71,6 @@ #include #endif -#ifndef _TOOLS_DEBUG_HXX -#include -#endif - #ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX #include #endif @@ -127,12 +127,12 @@ public: return sal_True; } - const ::basegfx::polygon::B2DPolygon& getPolygon(sal_uInt32 nIndex) const + const ::basegfx::polygon::B2DPolygon& getB2DPolygon(sal_uInt32 nIndex) const { return maPolygons[nIndex]; } - void setPolygon(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rPolygon) + void setB2DPolygon(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rPolygon) { maPolygons[nIndex] = rPolygon; } @@ -161,7 +161,7 @@ public: for(sal_uInt32 a(0L); a < nCount; a++) { - maPolygons.insert(aIndex, rPolyPolygon.getPolygon(a)); + maPolygons.insert(aIndex, rPolyPolygon.getB2DPolygon(a)); aIndex++; } } @@ -208,6 +208,14 @@ public: maPolygons[a].removeDoublePoints(); } } + + void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix) + { + for(sal_uInt32 a(0L); a < maPolygons.size(); a++) + { + maPolygons[a].transform(rMatrix); + } + } }; ////////////////////////////////////////////////////////////////////////////// @@ -294,21 +302,21 @@ namespace basegfx return mpPolyPolygon->count(); } - B2DPolygon B2DPolyPolygon::getPolygon(sal_uInt32 nIndex) const + B2DPolygon B2DPolyPolygon::getB2DPolygon(sal_uInt32 nIndex) const { - DBG_ASSERT(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)"); + OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)"); - return mpPolyPolygon->getPolygon(nIndex); + return mpPolyPolygon->getB2DPolygon(nIndex); } - void B2DPolyPolygon::setPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon) + void B2DPolyPolygon::setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon) { - DBG_ASSERT(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)"); + OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)"); - if(mpPolyPolygon->getPolygon(nIndex) != rPolygon) + if(mpPolyPolygon->getB2DPolygon(nIndex) != rPolygon) { implForceUniqueCopy(); - mpPolyPolygon->setPolygon(nIndex, rPolygon); + mpPolyPolygon->setB2DPolygon(nIndex, rPolygon); } } @@ -316,7 +324,7 @@ namespace basegfx { for(sal_uInt32 a(0L); a < mpPolyPolygon->count(); a++) { - const ::basegfx::polygon::B2DPolygon& rPolygon = mpPolyPolygon->getPolygon(a); + const ::basegfx::polygon::B2DPolygon& rPolygon = mpPolyPolygon->getB2DPolygon(a); if(rPolygon.areControlPointsUsed()) { @@ -329,7 +337,7 @@ namespace basegfx void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount) { - DBG_ASSERT(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)"); + OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)"); if(nCount) { @@ -349,7 +357,7 @@ namespace basegfx void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon) { - DBG_ASSERT(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)"); + OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)"); if(rPolyPolygon.count()) { @@ -369,7 +377,7 @@ namespace basegfx void B2DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount) { - DBG_ASSERT(nIndex + nCount <= mpPolyPolygon->count(), "B2DPolyPolygon Remove outside range (!)"); + OSL_ENSURE(nIndex + nCount <= mpPolyPolygon->count(), "B2DPolyPolygon Remove outside range (!)"); if(nCount) { @@ -401,7 +409,7 @@ namespace basegfx // no Polygon exists. for(sal_uInt32 a(0L); bRetval && a < mpPolyPolygon->count(); a++) { - if(!(mpPolyPolygon->getPolygon(a)).isClosed()) + if(!(mpPolyPolygon->getB2DPolygon(a)).isClosed()) { bRetval = sal_False; } @@ -431,7 +439,7 @@ namespace basegfx for(sal_uInt32 a(0L); !bRetval && a < mpPolyPolygon->count(); a++) { - if((mpPolyPolygon->getPolygon(a)).hasDoublePoints()) + if((mpPolyPolygon->getB2DPolygon(a)).hasDoublePoints()) { bRetval = sal_True; } @@ -448,6 +456,12 @@ namespace basegfx mpPolyPolygon->removeDoublePoints(); } } + + void B2DPolyPolygon::transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix) + { + implForceUniqueCopy(); + mpPolyPolygon->transform(rMatrix); + } } // end of namespace polygon } // end of namespace basegfx diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx b/basegfx/source/polygon/b2dpolypolygoncutter.cxx index 31df5fee4628..a86bfce3d937 100644 --- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx +++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygoncutter.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2003-11-10 11:45:51 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,12 +59,16 @@ * ************************************************************************/ -#ifndef _BGFX_POLYGON_B2DPOLYPOLYGONCUTTER_HXX -#include +#ifndef _OSL_DIAGNOSE_H_ +#include +#endif + +#ifndef _BGFX_NUMERIC_FTOOLS_HXX +#include #endif -#ifndef _TOOLS_DEBUG_HXX -#include +#ifndef _BGFX_POLYGON_B2DPOLYPOLYGONCUTTER_HXX +#include #endif #ifndef _BGFX_NUMERIC_FTOOLS_HXX @@ -532,7 +536,7 @@ namespace basegfx { for(sal_uInt32 a(0L); a < rPolyPolygon.count(); a++) { - B2DPolygon aCandidate = rPolyPolygon.getPolygon(a); + B2DPolygon aCandidate = rPolyPolygon.getB2DPolygon(a); aCandidate.removeDoublePoints(); if(!aCandidate.isClosed() || aCandidate.count() < 3) @@ -593,7 +597,7 @@ namespace basegfx while(maNotClosedPolygons.count()) { - rPolyPolygon.append(maNotClosedPolygons.getPolygon(0L)); + rPolyPolygon.append(maNotClosedPolygons.getB2DPolygon(0L)); maNotClosedPolygons.remove(0L); } } diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx b/basegfx/source/polygon/b2dpolypolygontools.cxx index bd5b03a3549b..3ddb6f11a0a3 100644 --- a/basegfx/source/polygon/b2dpolypolygontools.cxx +++ b/basegfx/source/polygon/b2dpolypolygontools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygontools.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-11 09:48:14 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,7 +101,7 @@ namespace basegfx for(sal_uInt32 a(0L); a < nPolygonCount; a++) { - ::basegfx::polygon::B2DPolygon aCandidate = rCandidate.getPolygon(a); + ::basegfx::polygon::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a); if(aCandidate.count() > 2L) { @@ -121,7 +121,7 @@ namespace basegfx { if(b != a) { - ::basegfx::polygon::B2DPolygon aComparePolygon = rCandidate.getPolygon(b); + ::basegfx::polygon::B2DPolygon aComparePolygon = rCandidate.getB2DPolygon(b); if(::basegfx::polygon::tools::isInside(aComparePolygon, aTestPoint)) { @@ -139,7 +139,7 @@ namespace basegfx aCandidate.flip(); // write back changed polygon - rCandidate.setPolygon(a, aCandidate); + rCandidate.setB2DPolygon(a, aCandidate); } // remember the index if it's the outmost polygon @@ -154,7 +154,7 @@ namespace basegfx // if the outmost polygon is not the first, move it in front if(bIndexOfOutmostPolygonSet && nIndexOfOutmostPolygon > 0L) { - ::basegfx::polygon::B2DPolygon aOutmostPolygon = rCandidate.getPolygon(nIndexOfOutmostPolygon); + ::basegfx::polygon::B2DPolygon aOutmostPolygon = rCandidate.getB2DPolygon(nIndexOfOutmostPolygon); rCandidate.remove(nIndexOfOutmostPolygon); rCandidate.insert(0L, aOutmostPolygon); } @@ -173,7 +173,7 @@ namespace basegfx aCutter.getPolyPolygon(rCandidate); } - ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivide(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fDistanceBound) + ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivideByDistance(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fDistanceBound) { ::basegfx::polygon::B2DPolyPolygon aRetval(rCandidate); @@ -183,12 +183,12 @@ namespace basegfx for(sal_uInt32 a(0L); aRetval.areControlPointsUsed() && a < nPolygonCount; a++) { - ::basegfx::polygon::B2DPolygon aCandidate = aRetval.getPolygon(a); + ::basegfx::polygon::B2DPolygon aCandidate = aRetval.getB2DPolygon(a); if(aCandidate.areControlPointsUsed()) { - aCandidate = ::basegfx::polygon::tools::adaptiveSubdivide(aCandidate, fDistanceBound); - aRetval.setPolygon(a, aCandidate); + aCandidate = ::basegfx::polygon::tools::adaptiveSubdivideByDistance(aCandidate, fDistanceBound); + aRetval.setB2DPolygon(a, aCandidate); } } } @@ -196,6 +196,42 @@ namespace basegfx return aRetval; } + ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivideByAngle(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fAngleBound) + { + ::basegfx::polygon::B2DPolyPolygon aRetval(rCandidate); + + if(aRetval.areControlPointsUsed()) + { + const sal_uInt32 nPolygonCount(aRetval.count()); + + for(sal_uInt32 a(0L); aRetval.areControlPointsUsed() && a < nPolygonCount; a++) + { + ::basegfx::polygon::B2DPolygon aCandidate = aRetval.getB2DPolygon(a); + + if(aCandidate.areControlPointsUsed()) + { + aCandidate = ::basegfx::polygon::tools::adaptiveSubdivideByAngle(aCandidate, fAngleBound); + aRetval.setB2DPolygon(a, aCandidate); + } + } + } + + return aRetval; + } + + ::basegfx::range::B2DRange getRange(const ::basegfx::polygon::B2DPolyPolygon& rCandidate) + { + ::basegfx::range::B2DRange aRetval; + const sal_uInt32 nPolygonCount(rCandidate.count()); + + for(sal_uInt32 a(0L); a < nPolygonCount; a++) + { + ::basegfx::polygon::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a); + aRetval.expand(::basegfx::polygon::tools::getRange(aCandidate)); + } + + return aRetval; + } } // end of namespace tools } // end of namespace polygon } // end of namespace basegfx diff --git a/basegfx/source/polygon/makefile.mk b/basegfx/source/polygon/makefile.mk index 6cf70f361d67..e9ddc11a9e38 100644 --- a/basegfx/source/polygon/makefile.mk +++ b/basegfx/source/polygon/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.3 $ +# $Revision: 1.4 $ # -# last change: $Author: aw $ $Date: 2003-11-06 16:30:29 $ +# last change: $Author: aw $ $Date: 2003-11-26 14:40:13 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -79,7 +79,11 @@ SLOFILES= \ $(SLO)$/b2dpolygontools.obj \ $(SLO)$/b2dpolypolygon.obj \ $(SLO)$/b2dpolypolygontools.obj \ - $(SLO)$/b2dpolypolygoncutter.obj + $(SLO)$/b2dpolypolygoncutter.obj \ + $(SLO)$/b3dpolygon.obj \ + $(SLO)$/b3dpolygontools.obj \ + $(SLO)$/b3dpolypolygon.obj \ + $(SLO)$/b3dpolypolygontools.obj # --- Targets ---------------------------------- diff --git a/basegfx/source/vector/b3dvector.cxx b/basegfx/source/vector/b3dvector.cxx index 96c1ee387ae5..45c8b3d58fa8 100644 --- a/basegfx/source/vector/b3dvector.cxx +++ b/basegfx/source/vector/b3dvector.cxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dvector.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2003-10-31 10:14:00 $ + * last change: $Author: aw $ $Date: 2003-11-26 14:40:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,6 +63,10 @@ #include #endif +#ifndef _BGFX_MATRIX_B3DHOMMATRIX_HXX +#include +#endif + namespace basegfx { namespace vector @@ -111,6 +115,24 @@ namespace basegfx 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; + + return *this; + } + + B3DVector operator*( const matrix::B3DHomMatrix& rMat, const B3DVector& rVec ) + { + B3DVector aRes( rVec ); + return aRes*=rMat; + } } // end of namespace vector } // end of namespace basegfx diff --git a/basegfx/util/makefile.mk b/basegfx/util/makefile.mk index fe7f06a45b05..e2a55db15595 100644 --- a/basegfx/util/makefile.mk +++ b/basegfx/util/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.5 $ +# $Revision: 1.6 $ # -# last change: $Author: aw $ $Date: 2003-10-28 11:15:10 $ +# last change: $Author: aw $ $Date: 2003-11-26 14:40:18 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -86,7 +86,6 @@ SHL1TARGET= basegfx$(UPD)$(DLLPOSTFIX) SHL1IMPLIB= ibasegfx SHL1STDLIBS=\ - $(TOOLSLIB) \ $(SALLIB) \ $(VOSLIB) \ $(CPPUHELPERLIB) \ -- cgit v1.2.3