public DijkstraGraphDistance(int nMaxNodes, int nMaxID,
                                     IEnumerable <int> nodeIDs,
                                     Func <int, int, float> nodeDistanceF,
                                     Func <int, IEnumerable <int> > neighboursF,
                                     IEnumerable <Vector2d> seeds = null // these are pairs (index, seedval)
                                     )
        {
            int initial_max = (nMaxNodes < 1024) ? nMaxNodes : nMaxNodes / 4;

            Queue = new FastPriorityQueue <GraphNode>(initial_max);

            NodeDistanceF = nodeDistanceF;
            NeighboursF   = neighboursF;

            Nodes = new SparseObjectList <GraphNode>(nMaxID, nMaxNodes);
            Seeds = new List <int>();

            max_value = float.MinValue;

            if (seeds != null)
            {
                foreach (var v in seeds)
                {
                    AddSeed((int)v.x, (float)v.y);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// nodeFilterF is used to restrict to valid nodes (eg if id space is sparse, or you only want a subset of possible nbrs)
        /// seeds list are pairs (id, seedvalue)
        /// </summary>
        public DijkstraGraphDistance(int nMaxID, bool bSparse,
                                     Func <int, bool> nodeFilterF,
                                     Func <int, int, float> nodeDistanceF,
                                     Func <int, IEnumerable <int> > neighboursF,
                                     IEnumerable <Vector2d> seeds = null // these are pairs (index, seedval)
                                     )
        {
            NodeFilterF   = nodeFilterF;
            NodeDistanceF = nodeDistanceF;
            NeighboursF   = neighboursF;


            if (bSparse)
            {
                SparseQueue    = new DynamicPriorityQueue <GraphNode>();
                SparseNodes    = new SparseObjectList <GraphNode>(nMaxID, 0);
                SparseNodePool = new MemoryPool <GraphNode>();
            }
            else
            {
                DenseQueue = new IndexPriorityQueue(nMaxID);
                DenseNodes = new GraphNodeStruct[nMaxID];
            }

            Seeds     = new List <int>();
            max_value = float.MinValue;
            if (seeds != null)
            {
                foreach (var v in seeds)
                {
                    AddSeed((int)v.x, (float)v.y);
                }
            }
        }
Пример #3
0
        public MeshLocalParam(int nMaxID,
                              Func <int, Vector3f> nodePositionF,
                              Func <int, Vector3f> nodeNormalF,
                              Func <int, IEnumerable <int> > neighboursF)
        {
            PositionF   = nodePositionF;
            NormalF     = nodeNormalF;
            NeighboursF = neighboursF;

            SparseQueue        = new DynamicPriorityQueue <GraphNode>();
            SparseNodes        = new SparseObjectList <GraphNode>(nMaxID, 0);
            SparseNodePool     = new MemoryPool <GraphNode>();
            max_graph_distance = float.MinValue;
            max_uv_distance    = float.MinValue;
        }