protected void Compute_Sparse() { while (SparseQueue.Count > 0) { GraphNode g = SparseQueue.Dequeue(); max_value = Math.Max(g.priority, max_value); g.frozen = true; update_neighbours_sparse(g); } }
/// <summary> /// Compute distances that are less/equal to fMaxDistance from the seeds /// Terminates early, so Queue may not be empty /// </summary> public void ComputeToMaxDistance(Frame3f seedFrame, Index3i seedNbrs, float fMaxGraphDistance) { SeedFrame = seedFrame; for (int j = 0; j < 3; ++j) { int vid = seedNbrs[j]; GraphNode g = get_node(vid); g.uv = compute_local_uv(ref SeedFrame, PositionF(vid)); g.graph_distance = g.uv.Length; g.frozen = true; Debug.Assert(SparseQueue.Contains(g) == false); SparseQueue.Enqueue(g, g.graph_distance); } while (SparseQueue.Count > 0) { GraphNode g = SparseQueue.Dequeue(); max_graph_distance = Math.Max(g.graph_distance, max_graph_distance); if (max_graph_distance > fMaxGraphDistance) { return; } if (g.parent != null) { switch (UVMode) { case UVModes.ExponentialMap: update_uv_expmap(g); break; case UVModes.ExponentialMap_UpwindAvg: update_uv_upwind_expmap(g); break; case UVModes.PlanarProjection: update_uv_planar(g); break; } } float uv_dist_sqr = g.uv.LengthSquared; if (uv_dist_sqr > max_uv_distance) { max_uv_distance = uv_dist_sqr; } g.frozen = true; update_neighbours_sparse(g); } max_uv_distance = (float)Math.Sqrt(max_uv_distance); }