Example #1
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));
        }