/// <summary> /// Calculates the tangent visibility graph /// </summary> /// <param name="obstacles">a list of polylines representing obstacles</param> /// <returns></returns> public static VisibilityGraph FillVisibilityGraphForShortestPath(IEnumerable <Polyline> obstacles) { var holes = new List <Polyline>(OrientHolesClockwise(obstacles)); var visibilityGraph = CalculateGraphOfBoundaries(holes); var polygons = holes.Select(hole => new Polygon(hole)).ToList(); TangentVisibilityGraphCalculator.AddTangentVisibilityEdgesToGraph(polygons, visibilityGraph); return(visibilityGraph); }
/// <summary> /// /// </summary> /// <param name="pathStart"></param> /// <param name="pathEnd"></param> /// <param name="obstacles"></param> /// <param name="sourceVertex">graph vertex corresponding to the source</param> /// <param name="targetVertex">graph vertex corresponding to the target</param> /// <returns></returns> internal static VisibilityGraph GetVisibilityGraphForShortestPath(Point pathStart, Point pathEnd, IEnumerable <Polyline> obstacles, out VisibilityVertex sourceVertex, out VisibilityVertex targetVertex) { var holes = new List <Polyline>(OrientHolesClockwise(obstacles)); var visibilityGraph = CalculateGraphOfBoundaries(holes); var polygons = holes.Select(hole => new Polygon(hole)).ToList(); TangentVisibilityGraphCalculator.AddTangentVisibilityEdgesToGraph(polygons, visibilityGraph); PointVisibilityCalculator.CalculatePointVisibilityGraph(holes, visibilityGraph, pathStart, VisibilityKind.Tangent, out sourceVertex); PointVisibilityCalculator.CalculatePointVisibilityGraph(holes, visibilityGraph, pathEnd, VisibilityKind.Tangent, out targetVertex); return(visibilityGraph); }