summaryrefslogtreecommitdiff
path: root/basegfx/source
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx/source')
-rw-r--r--basegfx/source/curve/b2dbeziertools.cxx35
-rw-r--r--basegfx/source/curve/b2dcubicbezier.cxx8
-rw-r--r--basegfx/source/curve/b2dquadraticbezier.cxx8
-rw-r--r--basegfx/source/point/b3dpoint.cxx28
-rw-r--r--basegfx/source/polygon/b2dpolygon.cxx103
-rw-r--r--basegfx/source/polygon/b2dpolygontools.cxx109
-rw-r--r--basegfx/source/polygon/b2dpolypolygon.cxx58
-rw-r--r--basegfx/source/polygon/b2dpolypolygoncutter.cxx20
-rw-r--r--basegfx/source/polygon/b2dpolypolygontools.cxx56
-rw-r--r--basegfx/source/polygon/makefile.mk10
-rw-r--r--basegfx/source/vector/b3dvector.cxx26
11 files changed, 359 insertions, 102 deletions
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 <limits>
#include <algorithm>
+#ifndef _SOLAR_H
+#include <tools/solar.h>
+#endif
+
#include <basegfx/curve/b2dbeziertools.hxx>
#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<double>::max() )
{
}
@@ -213,14 +217,21 @@ namespace basegfx
double fCurrAngle( ::std::numeric_limits<double>::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 <basegfx/curve/b2dcubicbezier.hxx>
#endif
-#ifndef _TOOLS_DEBUG_HXX
-#include <tools/debug.hxx>
-#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 <basegfx/curve/b2dquadraticbezier.hxx>
#endif
-#ifndef _TOOLS_DEBUG_HXX
-#include <tools/debug.hxx>
-#endif
-
#ifndef _BGFX_NUMERIC_FTOOLS_HXX
#include <basegfx/numeric/ftools.hxx>
#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 <basegfx/point/b3dpoint.hxx>
#endif
+#ifndef _BGFX_MATRIX_B3DHOMMATRIX_HXX
+#include <basegfx/matrix/b3dhommatrix.hxx>
+#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 <basegfx/polygon/b2dpolygon.hxx>
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
#endif
-#ifndef _TOOLS_DEBUG_HXX
-#include <tools/debug.hxx>
+#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX
+#include <basegfx/polygon/b2dpolygon.hxx>
#endif
#ifndef _BGFX_POINT_B2DPOINT_HXX
@@ -75,6 +75,10 @@
#include <basegfx/vector/b2dvector.hxx>
#endif
+#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#endif
+
#include <vector>
#include <algorithm>
@@ -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 <osl/diagnose.h>
+#endif
+
#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX
#include <basegfx/polygon/b2dpolygontools.hxx>
#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 <osl/diagnose.h>
+#endif
+
#ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX
#include <basegfx/polygon/b2dpolypolygon.hxx>
#endif
@@ -67,10 +71,6 @@
#include <basegfx/polygon/b2dpolygon.hxx>
#endif
-#ifndef _TOOLS_DEBUG_HXX
-#include <tools/debug.hxx>
-#endif
-
#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#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 <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _BGFX_NUMERIC_FTOOLS_HXX
+#include <basegfx/numeric/ftools.hxx>
#endif
-#ifndef _TOOLS_DEBUG_HXX
-#include <tools/debug.hxx>
+#ifndef _BGFX_POLYGON_B2DPOLYPOLYGONCUTTER_HXX
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
#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 <basegfx/vector/b3dvector.hxx>
#endif
+#ifndef _BGFX_MATRIX_B3DHOMMATRIX_HXX
+#include <basegfx/matrix/b3dhommatrix.hxx>
+#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