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; }
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); }
internal List<Point> GetPath(VisibilityVertex vs, VisibilityVertex vt, bool shrinkDistances) { var pathPoints = new List<Point>(); vs.IsShortestPathTerminal = vt.IsShortestPathTerminal = true; _visGraph.ClearPrevEdgesTable(); var router = new SingleSourceSingleTargetShortestPathOnVisibilityGraph(_visGraph, vs, vt) { 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; }
//internal Point TargetPoint { // get { // CurvePort tp = this.TargetPort as CurvePort; // if (tp != null) // return this.Target.BoundaryCurve[tp.Parameter]; // else // return (this.TargetPort as FloatingPort).Location; // } //} //internal Point SourcePoint { // get { // CurvePort sp = this.SourcePort as CurvePort; // if (sp != null) // return this.Source.BoundaryCurve[sp.Parameter]; // else // return (this.SourcePort as FloatingPort).Location; // } //} Polyline GetShortestPolyline(VisibilityVertex sourceVisVertex, VisibilityVertex _targetVisVertex) { CleanTheGraphForShortestPath(); var pathCalc = new SingleSourceSingleTargetShortestPathOnVisibilityGraph(this.visibilityGraph, sourceVisVertex, _targetVisVertex); IEnumerable<VisibilityVertex> path = pathCalc.GetPath(UseEdgeLengthMultiplier); if (path == null) { //ShowIsPassable(_sourceVisibilityVertex, _targetVisVertex); return null; } Debug.Assert(path.First() == sourceVisVertex && path.Last() == _targetVisVertex); var ret = new Polyline(); foreach (VisibilityVertex v in path) ret.AddPoint(v.Point); return RemoveCollinearVertices(ret); }