private FaceCount MaximumFan(HalfEdge eOrig) { /* eOrig.Lface is the face we want to render. We want to find the size * of a maximal fan around eOrig.Org. To do this we just walk around * the origin vertex as far as possible in both directions. */ FaceCount newFace = new FaceCount(0, null, RenderFan); Face trail = null; HalfEdge e; for (e = eOrig; !e.leftFace.Marked(); e = e.nextEdgeCCWAroundOrigin) { Face.AddToTrail(ref e.leftFace, ref trail); ++newFace.size; } for (e = eOrig; !e.rightFace.Marked(); e = e.Oprev) { Face f = e.rightFace; Face.AddToTrail(ref f, ref trail); e.rightFace = f; ++newFace.size; } newFace.eStart = e; Face.FreeTrail(ref trail); return(newFace); }
private void RenderTriangle(Tesselator tess, HalfEdge e, int size) { /* Just add the triangle to a triangle list, so we can render all * the separate triangles at once. */ if (size != 1) { throw new Exception(); } Face.AddToTrail(ref e.leftFace, ref this.lonelyTriList); }
private FaceCount MaximumStrip(HalfEdge eOrig) { /* Here we are looking for a maximal strip that contains the vertices * eOrig.Org, eOrig.Dst, eOrig.Lnext.Dst (in that order or the * reverse, such that all triangles are oriented CCW). * * Again we walk forward and backward as far as possible. However for * strips there is a twist: to get CCW orientations, there must be * an *even* number of triangles in the strip on one side of eOrig. * We walk the strip starting on a side with an even number of triangles; * if both side have an odd number, we are forced to shorten one side. */ FaceCount newFace = new FaceCount(0, null, RenderStrip); int headSize = 0, tailSize = 0; Face trail = null; HalfEdge e, eTail, eHead; for (e = eOrig; !e.leftFace.Marked(); ++tailSize, e = e.nextEdgeCCWAroundOrigin) { Face.AddToTrail(ref e.leftFace, ref trail); ++tailSize; e = e.Dprev; if (e.leftFace.Marked()) { break; } Face.AddToTrail(ref e.leftFace, ref trail); } eTail = e; for (e = eOrig; !e.rightFace.Marked(); ++headSize, e = e.Dnext) { Face f = e.rightFace; Face.AddToTrail(ref f, ref trail); e.rightFace = f; ++headSize; e = e.Oprev; if (e.rightFace.Marked()) { break; } f = e.rightFace; Face.AddToTrail(ref f, ref trail); e.rightFace = f; } eHead = e; newFace.size = tailSize + headSize; if (IsEven(tailSize)) { newFace.eStart = eTail.otherHalfOfThisEdge; } else if (IsEven(headSize)) { newFace.eStart = eHead; } else { /* Both sides have odd length, we must shorten one of them. In fact, * we must start from eHead to guarantee inclusion of eOrig.Lface. */ --newFace.size; newFace.eStart = eHead.nextEdgeCCWAroundOrigin; } Face.FreeTrail(ref trail); return(newFace); }