Simplified polygon base template (PolygonPointList), changed some include statements to work with big and small letters.
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: PolygonPoint.hxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: aw $ $Date: 2003-02-27 15:42:05 $
|
||||
* last change: $Author: aw $ $Date: 2003-03-14 11:47:03 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -66,17 +66,17 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template < class Point, class Vector > class SimplePolygonPoint
|
||||
template < class Point > class SimplePointEntry
|
||||
{
|
||||
Point maPoint;
|
||||
|
||||
public:
|
||||
SimplePolygonPoint()
|
||||
: maPoint()
|
||||
SimplePointEntry()
|
||||
: maPoint(Point::GetEmptyPoint())
|
||||
{
|
||||
}
|
||||
|
||||
SimplePolygonPoint(const Point& rInitPoint)
|
||||
SimplePointEntry(const Point& rInitPoint)
|
||||
: maPoint(rInitPoint)
|
||||
{
|
||||
}
|
||||
@@ -91,60 +91,32 @@ public:
|
||||
maPoint = rValue;
|
||||
}
|
||||
|
||||
const Vector& GetBackwardVector() const
|
||||
sal_Bool operator==(const SimplePointEntry& rEntry) const
|
||||
{
|
||||
return Vector::GetEmptyVector();
|
||||
}
|
||||
|
||||
void SetBackwardVector(const Vector& rValue)
|
||||
{
|
||||
DBG_ASSERT(Vector::GetEmptyVector() == rValue, "Setting backward vector different from zero vector not allowed at SimpleNode (!)");
|
||||
}
|
||||
|
||||
const Vector& GetForwardVector() const
|
||||
{
|
||||
return Vector::GetEmptyVector();
|
||||
}
|
||||
|
||||
void SetForwardVector(const Vector& rValue)
|
||||
{
|
||||
DBG_ASSERT(Vector::GetEmptyVector() == rValue, "Setting forward vector different from zero vector not allowed at SimpleNode (!)");
|
||||
return (maPoint == rEntry.maPoint);
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template < class Point, class Vector > class BezierPolygonPoint
|
||||
template < class Vector > class SimpleBezierEntry
|
||||
{
|
||||
Point maPoint;
|
||||
Vector maBackward;
|
||||
Vector maForward;
|
||||
|
||||
public:
|
||||
BezierPolygonPoint()
|
||||
: maPoint(),
|
||||
maBackward(),
|
||||
maForward()
|
||||
SimpleBezierEntry()
|
||||
: maBackward(Vector::GetEmptyVector()),
|
||||
maForward(Vector::GetEmptyVector())
|
||||
{
|
||||
}
|
||||
|
||||
BezierPolygonPoint(const Point& rInitPoint)
|
||||
: maPoint(rInitPoint),
|
||||
maBackward(),
|
||||
maForward()
|
||||
SimpleBezierEntry(const Vector& rInitBackward, const Vector& rInitForward)
|
||||
: maBackward(rInitBackward),
|
||||
maForward(rInitForward)
|
||||
{
|
||||
}
|
||||
|
||||
const Point& GetPoint() const
|
||||
{
|
||||
return maPoint;
|
||||
}
|
||||
|
||||
void SetPoint(const Point& rValue)
|
||||
{
|
||||
maPoint = rValue;
|
||||
}
|
||||
|
||||
const Vector& GetBackwardVector() const
|
||||
{
|
||||
return maBackward;
|
||||
@@ -171,100 +143,34 @@ public:
|
||||
return sal_True;
|
||||
return sal_False;
|
||||
}
|
||||
|
||||
sal_Bool operator==(const SimpleBezierEntry& rEntry) const
|
||||
{
|
||||
return ((maBackward == rEntry.maBackward) && (maForward == rEntry.maForward));
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template < class Point, class Vector > class PolygonPointList
|
||||
{
|
||||
typedef SimplePolygonPoint< Point, Vector > LocalSimplePolygonPoint;
|
||||
typedef BezierPolygonPoint< Point, Vector > LocalBezierPolygonPoint;
|
||||
typedef ::std::vector< LocalSimplePolygonPoint > SimplePolygonVector;
|
||||
typedef ::std::vector< LocalBezierPolygonPoint > BezierPolygonVector;
|
||||
typedef SimplePointEntry< Point > LocalSimplePointEntry;
|
||||
typedef SimpleBezierEntry< Vector > LocalSimpleBezierEntry;
|
||||
typedef ::std::vector< LocalSimplePointEntry > SimplePointVector;
|
||||
typedef ::std::vector< LocalSimpleBezierEntry > SimpleBezierVector;
|
||||
|
||||
sal_uInt32 mnCount;
|
||||
sal_uInt32 mnBezierCount;
|
||||
SimplePointVector maPoints;
|
||||
SimpleBezierVector* mpVectors;
|
||||
|
||||
union
|
||||
{
|
||||
SimplePolygonVector* mpSimple;
|
||||
BezierPolygonVector* mpBezier;
|
||||
}
|
||||
maList;
|
||||
|
||||
unsigned mbBezierFormat : 1;
|
||||
unsigned mbIsClosed : 1;
|
||||
|
||||
void ImplCopyToBezierVector(BezierPolygonVector* pBezier, SimplePolygonVector* pSimple)
|
||||
{
|
||||
SimplePolygonVector::iterator aSimpleIter(pSimple->begin());
|
||||
const SimplePolygonVector::iterator aSimpleEnd(pSimple->end());
|
||||
BezierPolygonVector::iterator aBezierIter(pBezier->begin());
|
||||
|
||||
for( ; aSimpleIter != aSimpleEnd; ++aSimpleIter , ++aBezierIter)
|
||||
{
|
||||
aBezierIter->SetPoint(aSimpleIter->GetPoint());
|
||||
}
|
||||
}
|
||||
|
||||
void ImplForceToBezier()
|
||||
{
|
||||
if(!mbBezierFormat)
|
||||
{
|
||||
SimplePolygonVector* pOldSimple = maList.mpSimple;
|
||||
|
||||
if(mnCount)
|
||||
{
|
||||
maList.mpBezier = new BezierPolygonVector(mnCount);
|
||||
ImplCopyToBezierVector(maList.mpBezier, pOldSimple);
|
||||
}
|
||||
|
||||
delete pOldSimple;
|
||||
mbBezierFormat = sal_True;
|
||||
}
|
||||
}
|
||||
|
||||
sal_Bool ImplCompareDifferentFormats(SimplePolygonVector* pSimple, BezierPolygonVector* pBezier) const
|
||||
{
|
||||
SimplePolygonVector::iterator aSimpleIter(pSimple->begin());
|
||||
const SimplePolygonVector::iterator aSimpleEnd(pSimple->end());
|
||||
BezierPolygonVector::iterator aBezierIter(pBezier->begin());
|
||||
|
||||
for( ; aSimpleIter != aSimpleEnd; ++aSimpleIter , ++aBezierIter)
|
||||
{
|
||||
if(aBezierIter->GetPoint() != aSimpleIter->GetPoint())
|
||||
return sal_False;
|
||||
}
|
||||
|
||||
return sal_True;
|
||||
}
|
||||
|
||||
void ImplCopyToSimpleVector(SimplePolygonVector* pSimple, BezierPolygonVector* pBezier)
|
||||
{
|
||||
BezierPolygonVector::iterator aBezierIter(pBezier->begin());
|
||||
const BezierPolygonVector::iterator aBezierEnd(pBezier->end());
|
||||
SimplePolygonVector::iterator aSimpleIter(pSimple->begin());
|
||||
|
||||
for( ; aBezierIter != aBezierEnd; ++aBezierIter , ++aSimpleIter)
|
||||
{
|
||||
aSimpleIter->SetPoint(aBezierIter->GetPoint());
|
||||
}
|
||||
}
|
||||
|
||||
void ImplTryToChangeToSimple()
|
||||
{
|
||||
if(mbBezierFormat && !mnBezierCount)
|
||||
if(!mnBezierCount && mpVectors)
|
||||
{
|
||||
BezierPolygonVector* pOldBezier = maList.mpBezier;
|
||||
|
||||
if(mnCount)
|
||||
{
|
||||
maList.mpSimple = new SimplePolygonVector(mnCount);
|
||||
ImplCopyToSimpleVector(maList.mpSimple, pOldBezier);
|
||||
}
|
||||
|
||||
delete pOldBezier;
|
||||
mbBezierFormat = sal_False;
|
||||
delete mpVectors;
|
||||
mpVectors = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,72 +190,60 @@ public:
|
||||
mbIsClosed = bNew;
|
||||
}
|
||||
|
||||
sal_uInt32 GetPointCount() const
|
||||
sal_uInt32 Count() const
|
||||
{
|
||||
return mnCount;
|
||||
return maPoints.size();
|
||||
}
|
||||
|
||||
PolygonPointList(sal_Bool bBezier)
|
||||
: mnCount(0L),
|
||||
mnBezierCount(0L),
|
||||
mbBezierFormat(bBezier),
|
||||
PolygonPointList()
|
||||
: mnBezierCount(0L),
|
||||
mpVectors(0L),
|
||||
mbIsClosed(sal_False)
|
||||
{
|
||||
// complete initialization with defaults
|
||||
maList.mpSimple = 0L;
|
||||
}
|
||||
|
||||
PolygonPointList(const PolygonPointList& rSource)
|
||||
: mnCount(rSource.mnCount),
|
||||
mnBezierCount(rSource.mnBezierCount),
|
||||
mbBezierFormat(rSource.mbBezierFormat),
|
||||
mbIsClosed(sal_False)
|
||||
: mnBezierCount(0L),
|
||||
maPoints(rSource.maPoints),
|
||||
mpVectors(0L),
|
||||
mbIsClosed(rSource.mbIsClosed)
|
||||
{
|
||||
// complete initialization using copy
|
||||
maList.mpSimple = 0L;
|
||||
|
||||
if(mnCount)
|
||||
if(rSource.mpVectors && rSource.mnBezierCount)
|
||||
{
|
||||
if(mbBezierFormat)
|
||||
{
|
||||
if(mnBezierCount)
|
||||
{
|
||||
maList.mpBezier = new BezierPolygonVector(*rSource.maList.mpBezier);
|
||||
}
|
||||
else
|
||||
{
|
||||
// here, a reduction at copy time can be done
|
||||
maList.mpSimple = new SimplePolygonVector(mnCount);
|
||||
ImplCopyToSimpleVector(maList.mpSimple, rSource.maList.mpBezier);
|
||||
mbBezierFormat = sal_False;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
maList.mpSimple = new SimplePolygonVector(*rSource.maList.mpSimple);
|
||||
}
|
||||
mpVectors = new SimpleBezierVector(*rSource.mpVectors);
|
||||
mnBezierCount = rSource.mnBezierCount;
|
||||
}
|
||||
}
|
||||
|
||||
PolygonPointList(const PolygonPointList& rSource, sal_uInt32 nIndex, sal_uInt32 nCount)
|
||||
: mnCount(0L),
|
||||
mnBezierCount(0L),
|
||||
mbBezierFormat(rSource.mbBezierFormat),
|
||||
mbIsClosed(sal_False)
|
||||
: mnBezierCount(0L),
|
||||
maPoints(nCount),
|
||||
mpVectors(0L),
|
||||
mbIsClosed(rSource.mbIsClosed)
|
||||
{
|
||||
// complete initialization using partly copy
|
||||
maList.mpSimple = 0L;
|
||||
|
||||
if(nCount)
|
||||
{
|
||||
if(rSource.IsBezier())
|
||||
// copy point data
|
||||
{
|
||||
maList.mpBezier = new BezierPolygonVector();
|
||||
maList.mpBezier->reserve(nCount);
|
||||
|
||||
BezierPolygonVector::iterator aStart(rSource.maList.mpBezier->begin());
|
||||
SimplePointVector::const_iterator aStart(rSource.maPoints.begin());
|
||||
aStart += nIndex;
|
||||
BezierPolygonVector::iterator aEnd(aStart);
|
||||
SimplePointVector::const_iterator aEnd(aStart);
|
||||
aEnd += nCount;
|
||||
maPoints.insert(0L, aStart, aEnd);
|
||||
}
|
||||
|
||||
// copy bezier data
|
||||
if(rSource.mpVectors && rSource.mnBezierCount)
|
||||
{
|
||||
mpVectors = new SimpleBezierVector();
|
||||
mpVectors->reserve(nCount);
|
||||
|
||||
SimpleBezierVector::iterator aStart(mpVectors->begin());
|
||||
aStart += nIndex;
|
||||
SimpleBezierVector::iterator aEnd(aStart);
|
||||
aEnd += nCount;
|
||||
|
||||
for( ; aStart != aEnd; ++aStart )
|
||||
@@ -359,119 +253,77 @@ public:
|
||||
mnBezierCount++;
|
||||
}
|
||||
|
||||
maList.mpBezier->push_back(*aStart);
|
||||
mpVectors->push_back(*aStart);
|
||||
}
|
||||
|
||||
// maybe 0L == mbBezierCount, try to reduce
|
||||
mnCount = nCount;
|
||||
ImplTryToChangeToSimple();
|
||||
}
|
||||
else
|
||||
{
|
||||
maList.mpSimple = new SimplePolygonVector();
|
||||
maList.mpSimple->reserve(nCount);
|
||||
|
||||
SimplePolygonVector::iterator aStart(rSource.maList.mpSimple->begin());
|
||||
aStart += nIndex;
|
||||
SimplePolygonVector::iterator aEnd(aStart);
|
||||
aEnd += nCount;
|
||||
|
||||
maList.mpSimple->insert(0L, aStart, aEnd);
|
||||
mnCount = nCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~PolygonPointList()
|
||||
{
|
||||
if(mbBezierFormat)
|
||||
if(mpVectors)
|
||||
{
|
||||
if(maList.mpBezier)
|
||||
{
|
||||
delete maList.mpBezier;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(maList.mpSimple)
|
||||
{
|
||||
delete maList.mpSimple;
|
||||
}
|
||||
delete mpVectors;
|
||||
}
|
||||
}
|
||||
|
||||
sal_Bool IsEqual(const PolygonPointList& rPointList) const
|
||||
{
|
||||
// same point count?
|
||||
if(mnCount != rPointList.mnCount)
|
||||
if(maPoints.size() != rPointList.maPoints.size())
|
||||
return sal_False;
|
||||
|
||||
// if zero points the polys are equal
|
||||
if(!mnCount)
|
||||
if(!maPoints.size())
|
||||
return sal_True;
|
||||
|
||||
// if bezier count used it needs to be equal
|
||||
if(mnBezierCount != rPointList.mnBezierCount)
|
||||
return sal_False;
|
||||
|
||||
// compare content if same format
|
||||
if(mbBezierFormat && rPointList.mbBezierFormat)
|
||||
return (maList.mpBezier == rPointList.maList.mpBezier);
|
||||
// compare point content
|
||||
if(maPoints != rPointList.maPoints)
|
||||
return sal_False;
|
||||
|
||||
if(!mbBezierFormat && !rPointList.mbBezierFormat)
|
||||
return (maList.mpSimple == rPointList.maList.mpSimple);
|
||||
// beziercounts are equal: if it's zero, we are done
|
||||
if(!mnBezierCount)
|
||||
return sal_True;
|
||||
|
||||
// here we have a combination of bezier and simple. Thus, mnBezierCount
|
||||
// needs to be zero, else we have an error here.
|
||||
DBG_ASSERT(0L == mnBezierCount, "Error: Bezier count needs to be zero here (!)");
|
||||
// beziercounts are equal and not zero; compare them
|
||||
DBG_ASSERT(0L != mpVectors, "Error: Bezier list needs to exist here(!)");
|
||||
DBG_ASSERT(0L != rPointList.mpVectors, "Error: Bezier list needs to exist here(!)");
|
||||
|
||||
if(mbBezierFormat)
|
||||
{
|
||||
// Hint: here would be another chance for reduction, but this method should stay const
|
||||
return ImplCompareDifferentFormats(rPointList.maList.mpSimple, maList.mpBezier);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ImplCompareDifferentFormats(maList.mpSimple, rPointList.maList.mpBezier);
|
||||
}
|
||||
return (*mpVectors == *rPointList.mpVectors);
|
||||
}
|
||||
|
||||
const Point& GetPoint(sal_uInt32 nIndex) const
|
||||
{
|
||||
if(mbBezierFormat)
|
||||
return ((*maList.mpBezier)[nIndex]).GetPoint();
|
||||
else
|
||||
return ((*maList.mpSimple)[nIndex]).GetPoint();
|
||||
return maPoints[nIndex].GetPoint();
|
||||
}
|
||||
|
||||
void SetPoint(sal_uInt32 nIndex, const Point& rValue)
|
||||
{
|
||||
if(mbBezierFormat)
|
||||
((*maList.mpBezier)[nIndex]).SetPoint(rValue);
|
||||
else
|
||||
((*maList.mpSimple)[nIndex]).SetPoint(rValue);
|
||||
maPoints[nIndex].SetPoint(rValue);
|
||||
}
|
||||
|
||||
const Vector& GetBackwardVector(sal_uInt32 nIndex) const
|
||||
{
|
||||
if(mbBezierFormat)
|
||||
return ((*maList.mpBezier)[nIndex]).GetBackwardVector();
|
||||
if(mpVectors)
|
||||
return ((*mpVectors)[nIndex]).GetBackwardVector();
|
||||
else
|
||||
return Vector::GetEmptyVector();
|
||||
}
|
||||
|
||||
void SetBackwardVector(sal_uInt32 nIndex, const Vector& rValue)
|
||||
{
|
||||
if(!mbBezierFormat && rValue != Vector::GetEmptyVector())
|
||||
ImplForceToBezier();
|
||||
|
||||
if(mbBezierFormat)
|
||||
if(mpVectors)
|
||||
{
|
||||
LocalBezierPolygonPoint& rDest = (*maList.mpBezier)[nIndex];
|
||||
LocalSimpleBezierEntry& rDest = (*mpVectors)[nIndex];
|
||||
sal_Bool bBezierNeededBefore(rDest.IsBezierNeeded());
|
||||
|
||||
rDest.SetBackwardVector(rValue);
|
||||
|
||||
((*mpVectors)[nIndex]).SetBackwardVector(rValue);
|
||||
sal_Bool bBezierNeededAfter(rDest.IsBezierNeeded());
|
||||
|
||||
if(bBezierNeededBefore != bBezierNeededAfter)
|
||||
@@ -482,28 +334,34 @@ public:
|
||||
mnBezierCount--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sal_Bool bEmptyVector(rValue == Vector::GetEmptyVector());
|
||||
|
||||
if(bEmptyVector)
|
||||
return;
|
||||
|
||||
mpVectors = new SimpleBezierVector(maPoints.size());
|
||||
((*mpVectors)[nIndex]).SetBackwardVector(rValue);
|
||||
mnBezierCount++;
|
||||
}
|
||||
}
|
||||
|
||||
const Vector& GetForwardVector(sal_uInt32 nIndex) const
|
||||
{
|
||||
if(mbBezierFormat)
|
||||
return ((*maList.mpBezier)[nIndex]).GetForwardVector();
|
||||
if(mpVectors)
|
||||
return ((*mpVectors)[nIndex]).GetForwardVector();
|
||||
else
|
||||
return Vector::GetEmptyVector();
|
||||
}
|
||||
|
||||
void SetForwardVector(sal_uInt32 nIndex, const Vector& rValue)
|
||||
{
|
||||
if(!mbBezierFormat && rValue != Vector::GetEmptyVector())
|
||||
ImplForceToBezier();
|
||||
|
||||
if(mbBezierFormat)
|
||||
if(mpVectors)
|
||||
{
|
||||
LocalBezierPolygonPoint& rDest = (*maList.mpBezier)[nIndex];
|
||||
LocalSimpleBezierEntry& rDest = (*mpVectors)[nIndex];
|
||||
sal_Bool bBezierNeededBefore(rDest.IsBezierNeeded());
|
||||
|
||||
rDest.SetForwardVector(rValue);
|
||||
|
||||
((*mpVectors)[nIndex]).SetForwardVector(rValue);
|
||||
sal_Bool bBezierNeededAfter(rDest.IsBezierNeeded());
|
||||
|
||||
if(bBezierNeededBefore != bBezierNeededAfter)
|
||||
@@ -514,125 +372,94 @@ public:
|
||||
mnBezierCount--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sal_Bool bEmptyVector(rValue == Vector::GetEmptyVector());
|
||||
|
||||
if(bEmptyVector)
|
||||
return;
|
||||
|
||||
mpVectors = new SimpleBezierVector(maPoints.size());
|
||||
((*mpVectors)[nIndex]).SetForwardVector(rValue);
|
||||
mnBezierCount++;
|
||||
}
|
||||
}
|
||||
|
||||
void Insert(sal_uInt32 nIndex, const Point& rPoint, sal_uInt32 nCount)
|
||||
{
|
||||
if(nCount)
|
||||
{
|
||||
// before inserting, eventually reduce memory usage
|
||||
// maybe 0L == mbBezierCount, try to reduce
|
||||
ImplTryToChangeToSimple();
|
||||
|
||||
if(mbBezierFormat)
|
||||
// add nCount copies of rPoint
|
||||
{
|
||||
LocalBezierPolygonPoint aNode(rPoint);
|
||||
|
||||
if(!maList.mpBezier)
|
||||
{
|
||||
maList.mpBezier = new BezierPolygonVector(mnCount, aNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
BezierPolygonVector::iterator aIndex(maList.mpBezier->begin());
|
||||
aIndex += nIndex;
|
||||
maList.mpBezier->insert(aIndex, nCount, aNode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LocalSimplePolygonPoint aNode(rPoint);
|
||||
|
||||
if(!maList.mpSimple)
|
||||
{
|
||||
maList.mpSimple = new SimplePolygonVector(mnCount, aNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
SimplePolygonVector::iterator aIndex(maList.mpSimple->begin());
|
||||
aIndex += nIndex;
|
||||
maList.mpSimple->insert(aIndex, nCount, aNode);
|
||||
}
|
||||
LocalSimplePointEntry aNode(rPoint);
|
||||
SimplePointVector::iterator aIndex(maPoints.begin());
|
||||
aIndex += nIndex;
|
||||
maPoints.insert(aIndex, nCount, aNode);
|
||||
}
|
||||
|
||||
mnCount += nCount;
|
||||
// add nCount empty entries to keep indices synchronized
|
||||
if(mpVectors)
|
||||
{
|
||||
LocalSimpleBezierEntry aNode;
|
||||
SimpleBezierVector::iterator aIndex(mpVectors->begin());
|
||||
aIndex += nIndex;
|
||||
mpVectors->insert(aIndex, nCount, aNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Insert(sal_uInt32 nIndex, const PolygonPointList& rSource)
|
||||
{
|
||||
const sal_uInt32 nCount(rSource.mnCount);
|
||||
const sal_uInt32 nCount(rSource.maPoints.size());
|
||||
|
||||
if(nCount)
|
||||
{
|
||||
if(rSource.IsBezier())
|
||||
// instert point data
|
||||
{
|
||||
ImplForceToBezier();
|
||||
SimplePointVector::iterator aIndex(maPoints.begin());
|
||||
aIndex += nIndex;
|
||||
|
||||
if(!maList.mpBezier)
|
||||
SimplePointVector::const_iterator aStart(rSource.maPoints.begin());
|
||||
SimplePointVector::const_iterator aEnd(rSource.maPoints.end());
|
||||
|
||||
maPoints.insert(aIndex, aStart, aEnd);
|
||||
}
|
||||
|
||||
// insert bezier data
|
||||
if(rSource.mpVectors && rSource.mnBezierCount)
|
||||
{
|
||||
SimpleBezierVector::iterator aIndex(mpVectors->begin());
|
||||
aIndex += nIndex;
|
||||
|
||||
SimpleBezierVector::iterator aStart(rSource.mpVectors->begin());
|
||||
SimpleBezierVector::iterator aEnd(rSource.mpVectors->end());
|
||||
|
||||
if(!mpVectors)
|
||||
{
|
||||
// copy other bezier
|
||||
maList.mpBezier = new BezierPolygonVector(*rSource.maList.mpBezier);
|
||||
mnBezierCount = rSource.mnBezierCount;
|
||||
mpVectors = new SimpleBezierVector(maPoints.size() - nCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
// insert bezier into bezier
|
||||
BezierPolygonVector::iterator aIndex(maList.mpBezier->begin());
|
||||
aIndex += nIndex;
|
||||
|
||||
BezierPolygonVector::iterator aStart(rSource.maList.mpBezier->begin());
|
||||
BezierPolygonVector::iterator aEnd(rSource.maList.mpBezier->end());
|
||||
mpVectors->insert(aIndex, aStart, aEnd);
|
||||
|
||||
maList.mpBezier->insert(aIndex, aStart, aEnd);
|
||||
mnBezierCount += rSource.mnBezierCount;
|
||||
}
|
||||
mnBezierCount += rSource.mnBezierCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
// before inserting, eventually reduce memory usage
|
||||
// maybe 0L == mbBezierCount, try to reduce
|
||||
ImplTryToChangeToSimple();
|
||||
|
||||
if(mnBezierCount)
|
||||
// add nCount empty entries to keep indices synchronized
|
||||
if(mpVectors)
|
||||
{
|
||||
// local is still bezier, source is simple. Insert
|
||||
// simple into bezier.
|
||||
LocalBezierPolygonPoint aNode(Point::GetEmptyPoint());
|
||||
BezierPolygonVector::iterator aIndex(maList.mpBezier->begin());
|
||||
LocalSimpleBezierEntry aNode;
|
||||
SimpleBezierVector::iterator aIndex(mpVectors->begin());
|
||||
aIndex += nIndex;
|
||||
|
||||
// insert nCount empty elements
|
||||
maList.mpBezier->insert(aIndex, nCount, aNode);
|
||||
|
||||
// copy coordinate data to new locations
|
||||
SimplePolygonVector::iterator aSimpleIter(rSource.maList.mpSimple->begin());
|
||||
const SimplePolygonVector::iterator aSimpleEnd(rSource.maList.mpSimple->end());
|
||||
|
||||
for( ; aSimpleIter != aSimpleEnd; ++aSimpleIter , ++aIndex)
|
||||
{
|
||||
aIndex->SetPoint(aSimpleIter->GetPoint());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// insert simple into simple
|
||||
if(!maList.mpSimple)
|
||||
{
|
||||
maList.mpSimple = new SimplePolygonVector(*rSource.maList.mpSimple);
|
||||
}
|
||||
else
|
||||
{
|
||||
SimplePolygonVector::iterator aIndex(maList.mpSimple->begin());
|
||||
aIndex += nIndex;
|
||||
|
||||
SimplePolygonVector::iterator aStart(rSource.maList.mpSimple->begin());
|
||||
SimplePolygonVector::iterator aEnd(rSource.maList.mpSimple->end());
|
||||
|
||||
maList.mpSimple->insert(aIndex, aStart, aEnd);
|
||||
}
|
||||
mpVectors->insert(aIndex, nCount, aNode);
|
||||
}
|
||||
}
|
||||
|
||||
mnCount += nCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -640,16 +467,29 @@ public:
|
||||
{
|
||||
if(nCount)
|
||||
{
|
||||
if(mbBezierFormat)
|
||||
// maybe 0L == mbBezierCount, try to reduce
|
||||
ImplTryToChangeToSimple();
|
||||
|
||||
// remove point data
|
||||
{
|
||||
BezierPolygonVector::iterator aStart(maList.mpBezier->begin());
|
||||
SimplePointVector::iterator aStart(maPoints.begin());
|
||||
aStart += nIndex;
|
||||
const BezierPolygonVector::iterator aEnd(aStart + nCount);
|
||||
const SimplePointVector::iterator aEnd(aStart + nCount);
|
||||
|
||||
maPoints.erase(aStart, aEnd);
|
||||
}
|
||||
|
||||
// remove bezier data
|
||||
if(mpVectors)
|
||||
{
|
||||
SimpleBezierVector::iterator aStart(mpVectors->begin());
|
||||
aStart += nIndex;
|
||||
const SimpleBezierVector::iterator aEnd(aStart + nCount);
|
||||
|
||||
// take care for correct mnBezierCount BEFORE erase
|
||||
if(mnBezierCount)
|
||||
{
|
||||
BezierPolygonVector::iterator aTestIter(aStart);
|
||||
SimpleBezierVector::iterator aTestIter(aStart);
|
||||
|
||||
for( ; mnBezierCount && aTestIter != aEnd; ++aTestIter)
|
||||
{
|
||||
@@ -658,22 +498,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// erase nodes
|
||||
maList.mpBezier->erase(aStart, aEnd);
|
||||
|
||||
// try to reduce, maybe 0L == mnBezierCount
|
||||
ImplTryToChangeToSimple();
|
||||
if(mnBezierCount)
|
||||
{
|
||||
// erase nodes
|
||||
mpVectors->erase(aStart, aEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// try to reduce, maybe 0L == mnBezierCount
|
||||
ImplTryToChangeToSimple();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SimplePolygonVector::iterator aStart(maList.mpSimple->begin());
|
||||
aStart += nIndex;
|
||||
const SimplePolygonVector::iterator aEnd(aStart + nCount);
|
||||
|
||||
maList.mpSimple->erase(aStart, aEnd);
|
||||
}
|
||||
|
||||
mnCount -= nCount;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user