internal static void CalculatePointVisibilityGraph(IEnumerable<Polyline> listOfHoles,
                                                    VisibilityGraph visibilityGraph, Point point,
                                        VisibilityKind visibilityKind, out VisibilityVertex qVertex) {
     //maybe there is nothing to do
     var qv = visibilityGraph.FindVertex(point);
     if (qv != null){
         qVertex = qv;
         return;
     }
         
     var calculator = new PointVisibilityCalculator(listOfHoles, visibilityGraph, point, visibilityKind);
     calculator.FillGraph();
     qVertex = calculator.QVertex;
     Debug.Assert(qVertex != null);
 }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// We suppose that the holes are convex and oriented clockwis and are mutually disjoint
        /// </summary>
        /// <param name="listOfHoles"></param>
        /// <param name="visibilityGraph"></param>
        /// <param name="point">The point can belong to the boundary of one of the holes</param>
        /// <param name="visibilityKind">tangent or regural visibility</param>
        /// <param name="qVertex">the graph vertex corresponding to the pivot</param>
        /// <returns></returns>
        internal static VisibilityVertex CalculatePointVisibilityGraph(
            IEnumerable <Polyline> listOfHoles,
            VisibilityGraph visibilityGraph,
            Point point,
            VisibilityKind visibilityKind)
        {
            //maybe there is nothing to do
            var qv = visibilityGraph.FindVertex(point);

            if (qv != null)
            {
                return(qv);
            }

            var calculator = new PointVisibilityCalculator(listOfHoles, visibilityGraph, point, visibilityKind);

            calculator.FillGraph();
            return(calculator.QVertex);
        }
        internal static void CalculatePointVisibilityGraph(IEnumerable <Polyline> listOfHoles,
                                                           VisibilityGraph visibilityGraph, Point point,
                                                           VisibilityKind visibilityKind, out VisibilityVertex qVertex)
        {
            //maybe there is nothing to do
            var qv = visibilityGraph.FindVertex(point);

            if (qv != null)
            {
                qVertex = qv;
                return;
            }

            var calculator = new PointVisibilityCalculator(listOfHoles, visibilityGraph, point, visibilityKind);

            calculator.FillGraph();
            qVertex = calculator.QVertex;
            Debug.Assert(qVertex != null);
        }