257 :(NSArray *)dataArray outlineWidth:(float)outlineWidth
258{
259 NSParameterAssert(dataArray !=
nil);
260
261 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
262 GLUtesselator *tesselator = NULL;
263
265 memset(&polygonData, 0, sizeof polygonData);
266 polygonData.
OK = YES;
267#ifndef NDEBUG
269 if ([[NSUserDefaults standardUserDefaults] boolForKey:
@"polygon-sprite-dump-svg"])
SVGDumpBegin(&polygonData);
270#endif
271
272
274 {
276 goto END;
277 }
278
279 tesselator = gluNewTess();
280 if (tesselator == NULL)
281 {
283 goto END;
284 }
285
287
288
294
295 gluTessBeginPolygon(tesselator, &polygonData);
297
298 NSUInteger contourCount = [dataArray count], contourIndex;
299 for (contourIndex = 0; contourIndex < contourCount && polygonData.
OK; contourIndex++)
300 {
301 NSArray *contour = [dataArray oo_arrayAtIndex:contourIndex];
303 {
305 break;
306 }
307
309 }
310
311 gluTessEndPolygon(tesselator);
313
315 {
317
319 {
322 else
323 {
324
327 }
328 }
329 else
330 {
331
333 }
334 }
335 if (!polygonData.
OK)
goto END;
336
337
338 gluDeleteTess(tesselator);
339 tesselator = gluNewTess();
340 if (tesselator == NULL)
341 {
343 goto END;
344 }
345
346 polygonData.
count = 0;
349 {
351 goto END;
352 }
353#ifndef NDEBUG
355#endif
356
362 gluTessProperty(tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE);
363
364 gluTessBeginPolygon(tesselator, &polygonData);
366
367 outlineWidth *= 0.5f;
368 contourCount = [dataArray count];
369 for (contourIndex = 0; contourIndex < contourCount && polygonData.
OK; contourIndex++)
370 {
371 NSArray *contour = [dataArray oo_arrayAtIndex:contourIndex];
373 {
375 break;
376 }
377
380 }
381
382 gluTessEndPolygon(tesselator);
384
386 {
387 if (polygonData.
count != 0)
388 {
392 else
393 {
394
397 }
398 }
399 else
400 {
401
404 }
405 }
406
407END:
409 free(polygonData.
data);
410 gluDeleteTess(tesselator);
411 [pool release];
412#ifndef NDEBUG
414#endif
415 return polygonData.
OK;
416}
static void APIENTRY TessVertexCallback(void *vertexData, void *polygonData)
static void APIENTRY TessEndCallback(void *polygonData)
static void APIENTRY TessBeginCallback(GLenum type, void *polygonData)
static void SVGDumpBeginGroup(TessPolygonData *data, NSString *name)
static NSArray * DataArrayToPoints(TessPolygonData *data, NSArray *dataArray)
static void SubmitVertices(GLUtesselator *tesselator, TessPolygonData *polygonData, NSArray *contour)
static void APIENTRY ErrorCallback(GLenum error, void *polygonData)
static void APIENTRY TessCombineCallback(GLdouble coords[3], void *vertexData[4], GLfloat weight[4], void **outData, void *polygonData)
static NSArray * BuildOutlineContour(NSArray *dataArray, GLfloat width, BOOL inner)
static void SVGDumpBegin(TessPolygonData *data)
static void SVGDumpEndGroup(TessPolygonData *data)
static void SVGDumpEnd(TessPolygonData *data)
static BOOL GrowTessPolygonData(TessPolygonData *data, size_t capacityHint)
NSMutableString * debugSVG