static void AddSentinel( GLUtesselator *tess, GLdouble t ) /* * We add two sentinel edges above and below all other edges, * to avoid special cases at the top and bottom. */ { GLUhalfEdge *e; ActiveRegion *reg = (ActiveRegion *)memAlloc( sizeof( ActiveRegion )); if (reg == NULL) longjmp(tess->env,1); e = __gl_meshMakeEdge( tess->mesh ); if (e == NULL) longjmp(tess->env,1); e->Org->s = SENTINEL_COORD; e->Org->t = t; e->Dst->s = -SENTINEL_COORD; e->Dst->t = t; tess->event = e->Dst; /* initialize it */ reg->eUp = e; reg->windingNumber = 0; reg->inside = FALSE; reg->fixUpperEdge = FALSE; reg->sentinel = TRUE; reg->dirty = FALSE; reg->nodeUp = dictInsert( tess->dict, reg ); /* __gl_dictListInsertBefore */ if (reg->nodeUp == NULL) longjmp(tess->env,1); }
static int AddVertex(GLUtesselator* tess, GLfloat coords[3], void* data) { GLUhalfEdge* e=NULL; e=tess->lastEdge; if (e==NULL) { /* Make a self-loop (one vertex, one edge). */ e=__gl_meshMakeEdge(tess->mesh); if (e==NULL) { return 0; } if (!__gl_meshSplice(e, e->Sym)) { return 0; } } else { /* Create a new vertex and edge which immediately follow e * in the ordering around the left face. */ if (__gl_meshSplitEdge(e)==NULL) { return 0; } e=e->Lnext; } /* The new vertex is now e->Org. */ e->Org->data=data; e->Org->coords[0]=coords[0]; e->Org->coords[1]=coords[1]; e->Org->coords[2]=coords[2]; /* The winding of an edge says how the winding number changes as we * cross from the edge''s right face to its left face. We add the * vertices in such an order that a CCW contour will add +1 to * the winding number of the region inside the contour. */ e->winding=1; e->Sym->winding=-1; tess->lastEdge=e; return 1; }