Beispiel #1
0
        internal void AssertEdgesPresentAndPassable(List <Point> path)
        {
            var vs = VisGraph.FindVertex(path[0]);

            Debug.Assert(vs != null);
            var vt = VisGraph.FindVertex(path[path.Count - 2]);

            Debug.Assert(vt != null);

            vs.IsShortestPathTerminal = vt.IsShortestPathTerminal = true;

            var router = new SingleSourceSingleTargetShortestPathOnVisibilityGraph(_visGraph, vs, vt)
            {
                LengthMultiplier         = 0.8,
                LengthMultiplierForAStar = 0.0
            };

            List <VisibilityEdge> pathEdges = new List <VisibilityEdge>();

            for (int i = 0; i < path.Count - 1; i++)
            {
                var edge = FindEdge(path[i], path[i + 1]);
                Debug.Assert(edge != null);
                pathEdges.Add(edge);
            }

            router.AssertEdgesPassable(pathEdges);

            vs.IsShortestPathTerminal = vt.IsShortestPathTerminal = false;
        }
Beispiel #2
0
        internal List <Point> GetPath(VisibilityVertex vs, VisibilityVertex vt,
                                      bool shrinkDistances, Tiling g)
        {
            var pathPoints = new List <Point>();

            vs.IsShortestPathTerminal = vt.IsShortestPathTerminal = true;
            _visGraph.ClearPrevEdgesTable();
            var router = new SingleSourceSingleTargetShortestPathOnVisibilityGraph(_visGraph, vs, vt, g)
            {
                LengthMultiplier         = 0.8,
                LengthMultiplierForAStar = 0.3
            };
            var vpath = router.GetPath(shrinkDistances);

            if (vpath == null)
            {
                Console.WriteLine("seeing a null path");
                vs.IsShortestPathTerminal = vt.IsShortestPathTerminal = false;
                return(pathPoints);
            }
            var path = vpath.ToList();

            for (int i = 0; i < path.Count(); i++)
            {
                pathPoints.Add(path[i].Point);
            }


            vs.IsShortestPathTerminal = vt.IsShortestPathTerminal = false;
            return(pathPoints);
        }
        Polyline GetShortestPolyline()
        {
            var pathCalc = new SingleSourceSingleTargetShortestPathOnVisibilityGraph(_visGraph, this.sourceVisibilityVertex,
                                                                                     TargetVisibilityVertex);
            var path = pathCalc.GetPath(false);
            var ret  = new Polyline();

            foreach (var v in path)
            {
                ret.AddPoint(v.Point);
            }
            return(RemoveCollinearPoint(ret));
        }