changed ftPoint to use doubles and inlined a lot of stuff
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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
diff --git a/include/FTVectoriser.h b/include/FTVectoriser.h
index 6091af2..2ae1ee9 100644
--- a/include/FTVectoriser.h
+++ b/include/FTVectoriser.h
@@ -1,14 +1,14 @@
#ifndef __FTVectoriser__
#define __FTVectoriser__
-#include "FTGL.h"
-
#include <vector>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
+#include "FTGL.h"
+
#include "FTGlyph.h"
using namespace std;
@@ -42,7 +42,7 @@ class FTGL_EXPORT ftPoint
* @param Y
* @param Z
*/
- ftPoint( const float X, const float Y, const float Z)
+ ftPoint( const double X, const double Y, const double Z)
: x(X), y(Y), z(Z)
{}
@@ -53,10 +53,7 @@ class FTGL_EXPORT ftPoint
* @param b
* @return
*/
- friend bool operator == ( const ftPoint &a, const ftPoint &b)
- {
- return((a.x == b.x) && (a.y == b.y) && (a.z == b.z));
- }
+ friend bool operator == ( const ftPoint &a, const ftPoint &b);
/**
* Operator != Tests for non equality
@@ -65,10 +62,7 @@ class FTGL_EXPORT ftPoint
* @param b
* @return
*/
- friend bool operator != ( const ftPoint &a, const ftPoint &b)
- {
- return((a.x != b.x) || (a.y != b.y) || (a.z != b.z));
- }
+ friend bool operator != ( const ftPoint &a, const ftPoint &b);
/**
* The point data
@@ -79,52 +73,6 @@ class FTGL_EXPORT ftPoint
};
-class FTGL_EXPORT FTTesselation
-{
- public:
- FTTesselation();
- ~FTTesselation();
-
- void AddPoint( const float x, const float y, const float z);
-
- int size() const { return pointList.size();}
-
- GLenum meshType;
- vector<ftPoint> pointList;
- private:
-};
-
-
-class FTGL_EXPORT FTMesh
-{
- public:
- FTMesh();
- ~FTMesh();
-
- void AddPoint( const float x, const float y, const float z);
- void Begin( GLenum m);
- void End();
-
- double* Point();
- int size() const;
-
- void Error( GLenum e) { err = e;}
- GLenum Error() const { return err;}
-
- /**
- * The list of points in this mesh
- */
- vector< FTTesselation*> tess;
- vector< ftPoint> tempPool;
- protected:
-
- private:
- FTTesselation* tempTess;
- GLenum err;
-
-};
-
-
/**
* FTContour class is a container of points that describe an outline
* point data.
@@ -140,13 +88,20 @@ class FTGL_EXPORT FTContour
/**
* Default constructor
*/
- FTContour();
+ FTContour()
+ : kMAXPOINTS( 1000)
+ {
+ pointList.reserve( kMAXPOINTS);
+ }
/**
* Destructor
*/
- ~FTContour();
-
+ ~FTContour()
+ {
+ pointList.clear();
+ }
+
/**
* Add a point to the end of this contour.
*
@@ -156,8 +111,17 @@ class FTGL_EXPORT FTContour
* @param x The X component of the point
* @param y The Y component of the point
*/
- void AddPoint( const float x, const float y);
-
+ void AddPoint( const double x, const double y)
+ {
+ ftPoint point( x, y, 0.0);
+
+ // Eliminate duplicate points.
+ if( pointList.empty() || ( pointList[pointList.size() - 1] != point && pointList[0] != point))
+ {
+ pointList.push_back( point);
+ }
+ }
+
/**
* How many points define this contour
*
@@ -180,6 +144,65 @@ class FTGL_EXPORT FTContour
};
+class FTGL_EXPORT FTTesselation
+{
+ public:
+ FTTesselation()
+ {
+ pointList.reserve( 128);
+ }
+
+ ~FTTesselation()
+ {
+ pointList.clear();
+ }
+
+
+ void AddPoint( const double x, const double y, const double z)
+ {
+ pointList.push_back( ftPoint( x, y, z));
+ }
+
+
+ int size() const { return pointList.size();}
+
+ GLenum meshType;
+ vector<ftPoint> pointList;
+ private:
+
+};
+
+
+class FTGL_EXPORT FTMesh
+{
+ public:
+ FTMesh();
+ ~FTMesh();
+
+ void AddPoint( const double x, const double y, const double z);
+ void Begin( GLenum m);
+ void End();
+
+ double* Point();
+ int size() const;
+
+ void Error( GLenum e) { err = e;}
+ GLenum Error() const { return err;}
+
+ vector< ftPoint> tempPool;
+ vector< FTTesselation*> tess;
+ protected:
+
+ private:
+ /**
+ * The list of points in this mesh
+ */
+ FTTesselation* tempTess;
+ GLenum err;
+
+};
+
+
/**
* FTVectoriser class is a helper class that converts font outlines into
* point data. It includes a bezier curve evaluator
@@ -214,18 +237,31 @@ class FTGL_EXPORT FTVectoriser
/**
* Copy the outline data into a block of <code>doubles</code>
- * @param d
+ *
+ * @param d a pointer to the memory to copy the data into.
*/
- void MakeOutline( double* d);
+ void GetOutline( double* d);
/**
- * Build a mesh from the outline and copy the vertx data into a
+ * Build a mesh from the outline and copy the vertex data into a
* block of <code>doubles</code>
- * @param d
+ *
+ * @param zNormal The direction of the z axis of the normal
+ * for this mesh
+ */
+ void MakeMesh( int zNormal = 1.0);
+
+ /**
+ * Copy the tesselation data into a block of <code>doubles</code>
+ *
+ * @param d a pointer to the memory to copy the data into.
*/
- void MakeMesh();
void GetMesh( double* d);
+ /** Get the number of points in the tesselation
+ *
+ * @return the number of points.
+ */
int MeshPoints() const { return mesh->size();}
/**
@@ -293,12 +329,6 @@ class FTGL_EXPORT FTVectoriser
*/
void evaluateCurve( const int n);
-
-
-//void CALLBACK ftglVertex( void* data);
-
-
-
/**
* The list of contours in this outline
*/