Made the FTPOINT type a struct of 3 floats rather than a PAIR<int, int> to make it compatible with gluTess. Made bValues[][] a private member rather than local to evaluateCurve()
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
diff --git a/include/FTVectoriser.h b/include/FTVectoriser.h
index 3c0d9d5..0d41d9a 100644
--- a/include/FTVectoriser.h
+++ b/include/FTVectoriser.h
@@ -22,7 +22,17 @@ class FTContour
// attributes
- typedef pair<int, int> ftPoint;
+// typedef pair<int, int> ftPoint;
+ struct ftPoint
+ {
+ float x, y, z;
+ ftPoint()
+ : x(0), y(0), z(0){}
+
+ ftPoint( float X, float Y, float Z)
+ : x(X), y(Y), z(Z){}
+ };
+
vector< ftPoint> pointList;
float ctrlPtArray[4][2];
private:
@@ -53,18 +63,20 @@ class FTVectoriser
// methods
int Conic( int index, int first, int last);
int Cubic( int index, int first, int last);
- void deCasteljau( GLfloat t, int n, GLfloat bValues[MAX_DEG][MAX_DEG][2]);
+ void deCasteljau( GLfloat t, int n);
void evaluateCurve( int n);
// attributes
-// typedef pair<int, int> ftPoint;
-// vector< FT_Vector> pointList;
vector< FTContour*> contourList;
float ctrlPtArray[4][2];
FTContour* contour;
FT_Outline ftOutline;
+
+ float bValues[MAX_DEG][MAX_DEG][2]; //3D array storing values
+ //of de Casteljau algorithm.
+
};
diff --git a/src/FTVectoriser.cpp b/src/FTVectoriser.cpp
index e21d20b..2e7e21a 100644
--- a/src/FTVectoriser.cpp
+++ b/src/FTVectoriser.cpp
@@ -18,18 +18,19 @@ FTContour::~FTContour()
void FTContour::AddPoint( int x, int y)
{
- float fx, fy;
+ float fx, fy, fz;
fx = static_cast<float>( x);
fy = static_cast<float>( y);
+ fy = 0;
- pointList.push_back( ftPoint( fx, fy));
+ pointList.push_back( ftPoint( fx, fy, fz));
}
// De Casteljau algorithm supplied by Jed Soane
-void FTVectoriser::deCasteljau( GLfloat t, int n, GLfloat bValues[MAX_DEG][MAX_DEG][2])
+void FTVectoriser::deCasteljau( float t, int n)
{
int i, k;
@@ -48,11 +49,9 @@ void FTVectoriser::deCasteljau( GLfloat t, int n, GLfloat bValues[MAX_DEG][MAX_D
void FTVectoriser::evaluateCurve( int n)
{
- GLint m, i; //loop counters
- GLfloat t; //parameter for curve point calc. [0.0, 1.0]
- GLfloat bValues[MAX_DEG][MAX_DEG][2]; //3D array storing values
- //of de Casteljau algorithm.
- GLfloat stepSize = 0.2;
+ int m, i; //loop counters
+ float t; //parameter for curve point calc. [0.0, 1.0]
+ float stepSize = 0.2;
// setting the b(0) equal to the control points
for (i = 0; i <= n; i++)
@@ -64,7 +63,7 @@ void FTVectoriser::evaluateCurve( int n)
for (m = 0; m <= (1 / stepSize); m++)
{
t = m * stepSize;
- deCasteljau( t, n, bValues); //calls to evaluate point on curve att.
+ deCasteljau( t, n); //calls to evaluate point on curve att.
} //end for(m...)
}
@@ -242,9 +241,10 @@ void FTVectoriser::Output( float* data)
for( int p = 0; p < contour->size(); ++p)
{
- data[i] = contour->pointList[p].first / 64.0f; // is 64 correct?
- data[i + 1] = contour->pointList[p].second / 64.0f;
- i += 2;
+ data[i] = contour->pointList[p].x / 64.0f; // is 64 correct?
+ data[i + 1] = contour->pointList[p].y / 64.0f;
+ data[i + 2] = contour->pointList[p].z / 64.0f;
+ i += 3;
}
}
}