X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fglyphpoints.cpp;fp=src%2Fglyphpoints.cpp;h=05edc828d791d44bba987e683b0ed935f1c1b858;hb=360d040a4727383cc8e78d0b8a3c8151c27d26fc;hp=e6dc52c11ca5ec7ffef3dad62ddcbef2fa1c0fe0;hpb=76edad3351932d31766083dd7a4e75e69d7b5671;p=ttedit diff --git a/src/glyphpoints.cpp b/src/glyphpoints.cpp index e6dc52c..05edc82 100755 --- a/src/glyphpoints.cpp +++ b/src/glyphpoints.cpp @@ -145,19 +145,6 @@ GlyphPoints& GlyphPoints::operator=(const GlyphPoints &c) if (this == &c) return *this; // Take care of self-assignment -#if 0 - if (x) - delete[] x; - - if (y) - delete[] y; - - if (onCurve) - delete[] onCurve; - - if (polyEnd) - delete[] polyEnd; -#endif FreeAllocatedMemory(); AllocateAndCopy(c.numPoints, c.numPolys, c.x, c.y, c.onCurve, c.polyEnd); @@ -454,6 +441,15 @@ IPoint GlyphPoints::GetPoint(uint16 poly, uint16 pt) } +IPoint GlyphPoints::GetPoint(uint16 pointNumber) +{ + if (pointNumber > numPoints) + throw GP_OUT_OF_RANGE; + + return IPoint(x[pointNumber], y[pointNumber]); +} + + bool GlyphPoints::GetOnCurve(uint16 poly, uint16 pt) { if (pt >= GetNumPoints(poly)) @@ -655,6 +651,7 @@ uint16 GlyphPoints::GetNext(uint16 poly, uint16 pt) } +#warning "!!! This function returns incorrect results !!!" uint16 GlyphPoints::GetPoly(uint16 pt) { if (pt >= numPoints) @@ -730,6 +727,40 @@ IPoint GlyphPoints::GetNextPoint(uint16 poly, uint16 pt) } +uint16 GlyphPoints::GetPolyForPoint(IPoint point) +{ + uint16 poly = 0; + + for(uint16 i=0; i polyEnd[poly]) + poly++; + + if (IPoint(x[i], y[i]) == point) + return poly; + } + + return 0xFFFF; +} + + +uint16 GlyphPoints::GetPolyForPointNumber(uint16 pointNumber) +{ + // If there's only one poly, we know where the point is... + if (numPolys <= 1) + return 0; + + // Otherwise, do a linear search through the polys to find the right one + for(uint16 i=0; i= GetPolyStart(i) && pointNumber <= polyEnd[i]) + return i; + } + + return 0xFFFF; +} + + // // Rotate a point by "angle" around point "center" //