1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
#ifndef __FTContour__
#define __FTContour__
#include "FTPoint.h"
#include "FTVector.h"
#include "FTGL.h"
struct ContourPoint
{
ContourPoint(){}
ContourPoint( FTPoint p, char t)
: point(p),
tag(t)
{}
FTPoint point;
char tag;
};
/**
* FTContour class is a container of points that describe a vector font
* outline. It is used as a container for the output of the bezier curve
* evaluator in FTVectoriser.
*
* @see FTOutlineGlyph
* @see FTPolyGlyph
* @see FTPoint
*/
class FTGL_EXPORT FTContour
{
public:
/**
* Constructor
*
* @param contour
* @param pointTags
* @param numberOfPoints
*/
FTContour( FT_Vector* contour, char* pointTags, unsigned int numberOfPoints);
/**
* Destructor
*/
~FTContour()
{
pointList.clear();
}
/**
* How many points define this contour
*
* @return the number of points in this contour
*/
size_t size() const { return pointList.size();}
/**
* How many points define this contour
*
* @return the number of points in this contour
*/
size_t Points() const { return size();}
// FIXME make private
/**
* The list of points in this contour
*/
typedef FTVector<FTPoint> PointVector;
PointVector pointList;
private:
/**
* Add a point to this contour. This function tests for duplicate
* points.
*
* @param point The point to be added to the contour.
*/
void AddPoint( FTPoint point);
/**
* Process a conic (second order) bezier curve.
*
* @param index
* @param pointList
*/
void EvaluateConicCurve( const int index, const FTVector<ContourPoint>& pointList);
/**
* Process a cubic (third order) bezier curve.
*
* @param index
* @param pointList
*/
void EvaluateCubicCurve( const int index, const FTVector<ContourPoint>& pointList);
/**
* De Casteljau (bezier) algorithm contributed by Jed Soane
*
* @param t
* @param curveOrder The order of the curve to be evaluated.
* <code>2</code> equals conic (quadratic) and <code>3</code> equals cubic
*/
void deCasteljau( const float t, const int curveOrder);
/**
* De Casteljau (bezier) algorithm contributed by Jed Soane
*
* @param curveOrder The order of the curve to be evaluated.
* <code>2</code> equals conic (quadratic) and <code>3</code> equals cubic
*/
void evaluateCurve( const int curveOrder);
/**
*/
// Magic numbers -- #define MAX_DEG 4
float bValues[4][4][2]; //3D array storing values of de Casteljau algorithm.
float ctrlPtArray[4][2]; // Magic numbers
/**
* Parameterisation step size for De Casteljau algorithm
*/
const float kBSTEPSIZE;
};
#endif // __FTContour__