示例#1
0
        /// <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);
        }
示例#2
0
 /// <summary>
 /// Add seed point as id/distance pair
 /// </summary>
 public void AddSeed(int id, float seed_dist)
 {
     if (SparseNodes != null) {
         GraphNode g = get_node(id);
         Debug.Assert(SparseQueue.Contains(g) == false);
         SparseQueue.Enqueue(g, seed_dist);
     } else {
         Debug.Assert(DenseQueue.Contains(id) == false);
         enqueue_node_dense(id, seed_dist, -1);
     }
     Seeds.Add(id);
 }