summaryrefslogtreecommitdiff
path: root/basegfx/source
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx/source')
-rw-r--r--basegfx/source/point/b2dhompoint.cxx8
-rw-r--r--basegfx/source/polygon/b2dpolygon.cxx16
-rw-r--r--basegfx/source/polygon/b2dpolygontools.cxx72
-rw-r--r--basegfx/source/polygon/b2dpolypolygon.cxx21
-rw-r--r--basegfx/source/polygon/b2dpolypolygoncutter.cxx38
-rw-r--r--basegfx/source/tuple/b2dtuple.cxx6
-rw-r--r--basegfx/source/tuple/b3dtuple.cxx6
-rw-r--r--basegfx/source/vector/b2dvector.cxx31
8 files changed, 143 insertions, 55 deletions
diff --git a/basegfx/source/point/b2dhompoint.cxx b/basegfx/source/point/b2dhompoint.cxx
index 75a5b5f0e782..575657491120 100644
--- a/basegfx/source/point/b2dhompoint.cxx
+++ b/basegfx/source/point/b2dhompoint.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dhompoint.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:53 $
+ * last change: $Author: aw $ $Date: 2003-11-10 11:45:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -228,8 +228,8 @@ namespace basegfx
B2DHomPoint interpolate(B2DHomPoint& rOld1, B2DHomPoint& rOld2, double t)
{
B2DHomPoint aInt(
- ((rOld2.getX() - rOld1.getX()) + t) + rOld1.getX(),
- ((rOld2.getY() - rOld1.getY()) + t) + rOld1.getY());
+ ((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
+ ((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY());
return aInt;
}
diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index e5bcd66a2e04..09d4429aa181 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolygon.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: aw $ $Date: 2003-11-06 16:30:29 $
+ * last change: $Author: aw $ $Date: 2003-11-10 11:45:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -118,6 +118,10 @@ public:
{
}
+ ~CoordinateDataArray2D()
+ {
+ }
+
sal_uInt32 count() const
{
return maVector.size();
@@ -182,7 +186,7 @@ public:
{
const sal_uInt32 nHalfSize(maVector.size() >> 1L);
CoordinateData2DVector::iterator aStart(maVector.begin());
- CoordinateData2DVector::iterator aEnd(maVector.end());
+ CoordinateData2DVector::iterator aEnd(maVector.end() - 1L);
for(sal_uInt32 a(0); a < nHalfSize; a++)
{
@@ -290,6 +294,10 @@ public:
}
}
+ ~ControlVectorArray2D()
+ {
+ }
+
sal_uInt32 count() const
{
return maVector.size();
@@ -1137,7 +1145,7 @@ namespace basegfx
void B2DPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
{
- DBG_ASSERT(nIndex + nCount > mpPolygon->count(), "B2DPolygon Remove outside range (!)");
+ DBG_ASSERT(nIndex + nCount <= mpPolygon->count(), "B2DPolygon Remove outside range (!)");
if(nCount)
{
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index c7211c12bd07..5061acfbfae4 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolygontools.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: aw $ $Date: 2003-11-06 16:30:29 $
+ * last change: $Author: aw $ $Date: 2003-11-10 11:45:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -86,15 +86,11 @@ namespace basegfx
// B2DPolygon tools
void checkClosed(polygon::B2DPolygon& rCandidate)
{
- while(rCandidate.count() > 1L)
+ while(rCandidate.count() > 1L
+ && rCandidate.getB2DPoint(0L).equal(rCandidate.getB2DPoint(rCandidate.count() - 1L)))
{
- sal_Bool bFirstLastPointEqual(rCandidate.getB2DPoint(0L).equal(rCandidate.getB2DPoint(rCandidate.count() - 1L)));
-
- if(bFirstLastPointEqual)
- {
- rCandidate.setClosed(sal_True);
- rCandidate.remove(rCandidate.count() - 1L);
- }
+ rCandidate.setClosed(sal_True);
+ rCandidate.remove(rCandidate.count() - 1L);
}
}
@@ -134,6 +130,8 @@ 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 (!)");
+
if(nIndex)
{
return nIndex - 1L;
@@ -150,6 +148,8 @@ 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 (!)");
+
if(nIndex + 1L < rCandidate.count())
{
return nIndex + 1L;
@@ -162,9 +162,12 @@ 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 (!)");
+
if(rCandidate.count() > 1)
{
- sal_uInt32 nNewIndex = getIndexOfPredecessor(nIndex, rCandidate);
+ nNewIndex = getIndexOfPredecessor(nIndex, rCandidate);
::basegfx::point::B2DPoint aPoint(rCandidate.getB2DPoint(nIndex));
while(nNewIndex != nIndex
@@ -174,14 +177,17 @@ namespace basegfx
}
}
- return nIndex;
+ return nNewIndex;
}
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 (!)");
+
if(rCandidate.count() > 1)
{
- sal_uInt32 nNewIndex = getIndexOfSuccessor(nIndex, rCandidate);
+ nNewIndex = getIndexOfSuccessor(nIndex, rCandidate);
::basegfx::point::B2DPoint aPoint(rCandidate.getB2DPoint(nIndex));
while(nNewIndex != nIndex
@@ -191,7 +197,7 @@ namespace basegfx
}
}
- return nIndex;
+ return nNewIndex;
}
::basegfx::vector::B2DVectorOrientation getOrientation(const ::basegfx::polygon::B2DPolygon& rCandidate)
@@ -207,7 +213,24 @@ namespace basegfx
return eRetval;
}
- sal_Bool isInside(const ::basegfx::polygon::B2DPolygon& rCandidate, const ::basegfx::point::B2DPoint& rPoint)
+ ::basegfx::vector::B2DVectorContinuity getContinuityInPoint(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex)
+ {
+ DBG_ASSERT(nIndex < rCandidate.count(), "getIndexOfPredecessor: Access to polygon out of range (!)");
+ ::basegfx::vector::B2DVectorContinuity eRetval(::basegfx::vector::CONTINUITY_NONE);
+
+ 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));
+
+ eRetval = ::basegfx::vector::getContinuity(aBackVector, aForwardVector);
+ }
+
+ return eRetval;
+ }
+
+ sal_Bool isInside(const ::basegfx::polygon::B2DPolygon& rCandidate, const ::basegfx::point::B2DPoint& rPoint, sal_Bool bWithBorder)
{
sal_Bool bRetval(sal_False);
const sal_uInt32 nPointCount(rCandidate.count());
@@ -215,9 +238,14 @@ namespace basegfx
for(sal_uInt32 a(0L); a < nPointCount; a++)
{
const ::basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
- const ::basegfx::point::B2DPoint aPreviousPoint(rCandidate.getB2DPoint((!a) ? nPointCount - 1L : a - 1L));
+
+ if(bWithBorder && aCurrentPoint.equal(rPoint))
+ {
+ return sal_True;
+ }
// 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()));
@@ -240,7 +268,11 @@ namespace basegfx
(aPreviousPoint.getX() - aCurrentPoint.getX()) /
(aPreviousPoint.getY() - aCurrentPoint.getY());
- if(::basegfx::numeric::fTools::more(fCompare, rPoint.getX()))
+ if(bWithBorder && ::basegfx::numeric::fTools::more(fCompare, rPoint.getX()))
+ {
+ bRetval = !bRetval;
+ }
+ else if(::basegfx::numeric::fTools::moreOrEqual(fCompare, rPoint.getX()))
{
bRetval = !bRetval;
}
@@ -251,7 +283,7 @@ namespace basegfx
return bRetval;
}
- sal_Bool isInside(const ::basegfx::polygon::B2DPolygon& rCandidate, const ::basegfx::polygon::B2DPolygon& rPolygon)
+ sal_Bool isInside(const ::basegfx::polygon::B2DPolygon& rCandidate, const ::basegfx::polygon::B2DPolygon& rPolygon, sal_Bool bWithBorder)
{
const sal_uInt32 nPointCount(rPolygon.count());
@@ -259,7 +291,7 @@ namespace basegfx
{
const ::basegfx::point::B2DPoint aTestPoint(rPolygon.getB2DPoint(a));
- if(!isInside(rCandidate, aTestPoint))
+ if(!isInside(rCandidate, aTestPoint, bWithBorder))
{
return sal_False;
}
@@ -313,6 +345,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 (!)");
double fRetval(0.0);
const sal_uInt32 nPointCount(rCandidate.count());
@@ -476,6 +509,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 (!)");
::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 7b15b1282a71..fdd1e30276d3 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolypolygon.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: aw $ $Date: 2003-11-06 16:30:29 $
+ * last change: $Author: aw $ $Date: 2003-11-10 11:45:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -312,6 +312,21 @@ namespace basegfx
}
}
+ sal_Bool B2DPolyPolygon::areControlPointsUsed() const
+ {
+ for(sal_uInt32 a(0L); a < mpPolyPolygon->count(); a++)
+ {
+ const ::basegfx::polygon::B2DPolygon& rPolygon = mpPolyPolygon->getPolygon(a);
+
+ if(rPolygon.areControlPointsUsed())
+ {
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+ }
+
void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount)
{
DBG_ASSERT(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)");
@@ -354,7 +369,7 @@ namespace basegfx
void B2DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
{
- DBG_ASSERT(nIndex + nCount > mpPolyPolygon->count(), "B2DPolyPolygon Remove outside range (!)");
+ DBG_ASSERT(nIndex + nCount <= mpPolyPolygon->count(), "B2DPolyPolygon Remove outside range (!)");
if(nCount)
{
diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
index 46b86ab10e40..31df5fee4628 100644
--- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx
+++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolypolygoncutter.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2003-11-06 16:29:33 $
+ * last change: $Author: aw $ $Date: 2003-11-10 11:45:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -242,21 +242,26 @@ namespace basegfx
return aRetval;
}
- sal_Bool B2DPolygonNode::isInside(const ::basegfx::point::B2DPoint& rPnt) const
+ sal_Bool B2DPolygonNode::isInside(const ::basegfx::point::B2DPoint& rPoint, sal_Bool bWithBorder) const
{
sal_Bool bInside(sal_False);
const B2DPolygonNode* pCurrent = this;
do
{
+ if(bWithBorder && pCurrent->getPosition().equal(rPoint))
+ {
+ return sal_True;
+ }
+
B2DPolygonNode* pNext = pCurrent->getNext();
- const sal_Bool bCompYA(::basegfx::numeric::fTools::more(pCurrent->getPosition().getY(), rPnt.getY()));
- const sal_Bool bCompYB(::basegfx::numeric::fTools::more(pNext->getPosition().getY(), rPnt.getY()));
+ 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)
{
- const sal_Bool bCompXA(::basegfx::numeric::fTools::more(pCurrent->getPosition().getX(), rPnt.getX()));
- const sal_Bool bCompXB(::basegfx::numeric::fTools::more(pNext->getPosition().getX(), rPnt.getX()));
+ 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()));
if(bCompXA == bCompXB)
{
@@ -268,11 +273,15 @@ namespace basegfx
else
{
double fCmp =
- pNext->getPosition().getX() - (pNext->getPosition().getY() - rPnt.getY()) *
+ pNext->getPosition().getX() - (pNext->getPosition().getY() - rPoint.getY()) *
(pCurrent->getPosition().getX() - pNext->getPosition().getX()) /
(pCurrent->getPosition().getY() - pNext->getPosition().getY());
- if(::basegfx::numeric::fTools::more(fCmp, rPnt.getX()))
+ if(bWithBorder && ::basegfx::numeric::fTools::more(fCmp, rPoint.getX()))
+ {
+ bInside = !bInside;
+ }
+ else if(::basegfx::numeric::fTools::moreOrEqual(fCmp, rPoint.getX()))
{
bInside = !bInside;
}
@@ -287,13 +296,13 @@ namespace basegfx
return bInside;
}
- sal_Bool B2DPolygonNode::isPolygonInside(B2DPolygonNode* pPoly) const
+ sal_Bool B2DPolygonNode::isPolygonInside(B2DPolygonNode* pPoly, sal_Bool bWithBorder) const
{
B2DPolygonNode* pTest = pPoly;
sal_Bool bAllAInside(sal_True);
do {
- bAllAInside = isInside(pTest->getPosition());
+ bAllAInside = isInside(pTest->getPosition(), bWithBorder);
pTest = pTest->getNext();
} while(bAllAInside && pTest != pPoly);
@@ -397,8 +406,8 @@ namespace basegfx
if(a != b && doRangesInclude(rInfoA.getRange(), rInfoB.getRange()))
{
- // volume B in A, test pA, pB for inclusion
- if(maPolygonList[a]->isPolygonInside(maPolygonList[b]))
+ // 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());
@@ -567,10 +576,9 @@ namespace basegfx
if(nCount > 2L)
{
B2DPolygon aNewPolygon;
- nCount = 0L;
do {
- aNewPolygon.setB2DPoint(nCount++, pAct->getPosition());
+ aNewPolygon.append(pAct->getPosition());
pAct = pAct->getNext();
} while(pAct != pCand);
diff --git a/basegfx/source/tuple/b2dtuple.cxx b/basegfx/source/tuple/b2dtuple.cxx
index 367ea17285dd..a8cdfa54d663 100644
--- a/basegfx/source/tuple/b2dtuple.cxx
+++ b/basegfx/source/tuple/b2dtuple.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dtuple.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:56 $
+ * last change: $Author: aw $ $Date: 2003-11-10 11:45:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,7 +72,7 @@ namespace basegfx
namespace tuple
{
// initialize static member
- B2DTuple B2DTuple::maEmptyTuple(0.0, 0.0);
+ ::basegfx::tuple::B2DTuple B2DTuple::maEmptyTuple(0.0, 0.0);
sal_Bool B2DTuple::equalZero() const
{
diff --git a/basegfx/source/tuple/b3dtuple.cxx b/basegfx/source/tuple/b3dtuple.cxx
index 3022d1fba2ac..f1e7691adfb3 100644
--- a/basegfx/source/tuple/b3dtuple.cxx
+++ b/basegfx/source/tuple/b3dtuple.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dtuple.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-10 11:45:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,7 +68,7 @@ namespace basegfx
namespace tuple
{
// initialize static member
- B3DTuple B3DTuple::maEmptyTuple(0.0, 0.0, 0.0);
+ ::basegfx::tuple::B3DTuple B3DTuple::maEmptyTuple(0.0, 0.0, 0.0);
} // end of namespace tuple
} // end of namespace basegfx
diff --git a/basegfx/source/vector/b2dvector.cxx b/basegfx/source/vector/b2dvector.cxx
index 92931c563125..1177396fefd1 100644
--- a/basegfx/source/vector/b2dvector.cxx
+++ b/basegfx/source/vector/b2dvector.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dvector.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: aw $ $Date: 2003-11-06 16:30:30 $
+ * last change: $Author: aw $ $Date: 2003-11-10 11:45:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -163,13 +163,13 @@ namespace basegfx
sal_Bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB )
{
- double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecA.getX());
+ double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
return ::basegfx::numeric::fTools::equalZero(fVal);
}
B2DVectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB )
{
- double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecA.getX());
+ double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
if(fVal > 0.0)
{
@@ -195,6 +195,29 @@ namespace basegfx
B2DVector aRes( rVec );
return aRes*=rMat;
}
+
+ ::basegfx::vector::B2DVectorContinuity getContinuity(const B2DVector& rBackVector, const B2DVector& rForwardVector )
+ {
+ ::basegfx::vector::B2DVectorContinuity eRetval(::basegfx::vector::CONTINUITY_NONE);
+
+ if(!rBackVector.equalZero() && !rForwardVector.equalZero())
+ {
+ 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;
+ }
+ }
+
+ return eRetval;
+ }
} // end of namespace vector
} // end of namespace basegfx