void SetUpPriorityQueue() { triQueue = new FastPriorityQueue <TriangleNode>(triangles.Count); triNodes = new TriangleNode[triangles.Count]; foreach (Triangle t in triangles) { TriangleNode tNode = new TriangleNode(t); triNodes[t.index] = tNode; float shortestLength = LengthOfEdgePair(ShortestEdgeOfTriangle(t)); triQueue.Enqueue(tNode, shortestLength); } }
/// <summary> /// Take the next triangle off the priority queue and collapse its shortest edge. /// </summary> /// <returns></returns> bool CollapseShortestPQ() { if (triQueue.Count == 0) { return(false); } TriangleNode tNode = triQueue.Dequeue(); if (tNode.Collapsed) { return(true); } EdgePair shortestEdge = ShortestEdgeOfTriangle(tNode.triangle); CollapseEdge(shortestEdge); UpdatePQAroundMerged(shortestEdge.v1); return(true); }
void UpdatePQAroundVertex(int vertIndex) { Vertex vert = heMesh.Vertices[vertIndex]; HalfEdge start = vert.anyHalfEdge; HalfEdge he = vert.anyHalfEdge; // Iterate over all surrounding triangles. do { // Get the triangle node for this face. Face face = he.face; TriangleNode node = triNodes[face.Index]; // If the triangle is still valid, update its key to be its new shortest edge length. if (!node.Collapsed) { float shortest = LengthOfEdgePair(ShortestEdgeOfTriangle(node.triangle)); triQueue.UpdatePriority(node, shortest); } he = he.next; }while (he != start); }