#ifndef __GLYPHPOINTS_H__
#define __GLYPHPOINTS_H__
-#include "types.h"
+#include <stdint.h>
#include <stdio.h>
+#include "vector.h"
// "IPoint" is an Integer based Point
struct IPoint
{
- int32 x, y;
+ int32_t x, y;
bool onCurve;
- IPoint(int32 xx=0, int32 yy=0, bool oc=true): x(xx), y(yy), onCurve(oc) {}
+ IPoint(int32_t xx=0, int32_t yy=0, bool oc=true): x(xx), y(yy), onCurve(oc) {}
+ bool operator==(const IPoint & p) { return (p.x == x && p.y == y ? true: false); };
};
+
+struct GuideLine
+{
+ int32_t x, y;
+ double angle;
+};
+
+
// Throws the following exceptions:
#define GP_OUT_OF_RANGE 1
//Turns out the compiler barfs regardless...
//Turns out the problem was that the copy ctor wasn't declared as CONST...
GlyphPoints(int nPts = 0, int nPlys = 0, int * xa = NULL, int * ya = NULL,
- bool * oca = NULL, uint16 * pa = NULL);
+ bool * oca = NULL, uint16_t * pa = NULL);
// GlyphPoints(void);// And now *this* is needed... Bleah!
// GlyphPoints(int nPts, int nPlys = 0, int * xa = NULL, int * ya = NULL,
-// bool * oca = NULL, uint16 * pa = NULL);
+// bool * oca = NULL, uint16_t * pa = NULL);
GlyphPoints(int xx, int yy, bool oc);
// GlyphPoints(GlyphPoints &); // Copy constructor
GlyphPoints(const GlyphPoints &); // Copy constructor
GlyphPoints operator+(const IPoint &);
GlyphPoints& operator+=(const IPoint &);
void Clear(void);
- void InsertPoint(uint16, int, int, bool);
- void InsertPoint(uint16, const IPoint &);
- void DeletePoint(uint16);
- uint16 GetNumPoints(void);
- uint16 GetNumPoints(uint16 poly);
- uint16 GetNumPolys(void);
- int GetX(uint16);
- int GetY(uint16);
- bool GetOnCurve(uint16);
- int GetX(uint16, uint16);
- int GetNextX(uint16, uint16);
- int GetY(uint16, uint16);
- int GetNextY(uint16, uint16);
- IPoint GetPoint(uint16, uint16);
- bool GetOnCurve(uint16, uint16);
- bool GetPrevOnCurve(uint16, uint16);
- bool GetNextOnCurve(uint16, uint16);
- uint16 GetPolyStart(uint16);
- uint16 GetPolyEnd(uint16);
+ void InsertPoint(uint16_t, int, int, bool);
+ void InsertPoint(uint16_t, const IPoint &);
+ void DeletePoint(uint16_t);
+ uint16_t GetNumPoints(void);
+ uint16_t GetNumPoints(uint16_t poly);
+ uint16_t GetNumPolys(void);
+ int GetX(uint16_t);
+ int GetY(uint16_t);
+ Vector GetXY(uint16_t);
+ bool GetOnCurve(uint16_t);
+ int GetX(uint16_t, uint16_t);
+ int GetNextX(uint16_t, uint16_t);
+ int GetY(uint16_t, uint16_t);
+ int GetNextY(uint16_t, uint16_t);
+ IPoint GetPoint(uint16_t, uint16_t);
+ IPoint GetPoint(uint16_t);
+ bool GetOnCurve(uint16_t, uint16_t);
+ bool GetPrevOnCurve(uint16_t, uint16_t);
+ bool GetNextOnCurve(uint16_t, uint16_t);
+ uint16_t GetPolyStart(uint16_t);
+ uint16_t GetPolyEnd(uint16_t);
void OffsetPoints(int, int);
- void OffsetPoly(uint16, int32, int32);
+ void OffsetPoly(uint16_t, int32_t, int32_t);
void ScalePoints(float);
- void SetXY(uint16, int, int);
- void SetOnCurve(uint16, bool);
- uint16 GetPrev(uint16);
- uint16 GetNext(uint16);
- uint16 GetPrev(uint16, uint16);
- uint16 GetNext(uint16, uint16);
- uint16 GetPoly(uint16);
+ void SetXY(uint16_t, int, int);
+ void SetOnCurve(uint16_t, bool);
+ void SetPoint(const uint16_t pointNum, const IPoint point);
+ uint16_t GetPrev(uint16_t);
+ uint16_t GetNext(uint16_t);
+ uint16_t GetPrev(uint16_t, uint16_t);
+ uint16_t GetNext(uint16_t, uint16_t);
+ uint16_t GetPoly(uint16_t);
void AddNewPolyAtEnd(void);
- IPoint GetMidpointToPrev(uint16, uint16);
- IPoint GetMidpointToNext(uint16, uint16);
- IPoint GetPrevPoint(uint16, uint16);
- IPoint GetNextPoint(uint16, uint16);
+ IPoint GetMidpointToPrev(uint16_t, uint16_t);
+ IPoint GetMidpointToNext(uint16_t, uint16_t);
+ IPoint GetPrevPoint(uint16_t, uint16_t);
+ IPoint GetNextPoint(uint16_t, uint16_t);
+ uint16_t GetPolyForPoint(IPoint point);
+ uint16_t GetPolyForPointNumber(uint16_t pointNumber);
IPoint RotatePoint(const double angle, const IPoint point, const IPoint center);
void RotatePoints(const double angle, const IPoint point);
- IPoint GetPolyCentroid(const int16 poly);
- void RotatePolyAroundCentroid(const int16 poly, const double angle);
+ IPoint GetPolyCentroid(const int16_t poly);
+ void RotatePolyAroundCentroid(const int16_t poly, const double angle);
+ void InvertPolyDrawSequence(const uint16_t poly);
bool LoadGlyphFromFile(FILE *);
bool SaveGlyphToFile(FILE *);
private:
- void AllocateAndCopy(int, int, int *, int *, bool *, uint16 *);
+ void AllocateAndCopy(int, int, int *, int *, bool *, uint16_t *);
void FreeAllocatedMemory(void);
private:
int numPoints, numPolys;
int * x, * y;
bool * onCurve;
- uint16 * polyEnd;
- uint16 pointsAllocated, polysAllocated;
+ uint16_t * polyEnd;
+ uint16_t pointsAllocated, polysAllocated;
};
#endif // __GLYPHPOINTS_H__