Пример #1
0
        /// <summary>
        /// Computes the Visibility Graph from a base graph using Lee's algorithm.
        /// </summary>
        /// <param name="baseGraph">Base graph</param>
        /// <param name="reduced">Reduced graph returns edges where its vertices belong to different
        /// polygons and at least one is not convex/concave to its polygon.</param>
        /// <returns name="visGraph">Visibility graph</returns>
        public static VisibilityGraph ByBaseGraph(BaseGraph baseGraph, bool reduced = true)
        {
            if (baseGraph == null)
            {
                throw new ArgumentNullException("graph");
            }
            var visGraph = new Graphical.Graphs.VisibilityGraph(baseGraph.graph, reduced, true);

            var visibilityGraph = new VisibilityGraph()
            {
                graph = visGraph
            };

            return(visibilityGraph);
        }
Пример #2
0
        /// <summary>
        /// Creates a new Graph by a set of lines.
        /// </summary>
        /// <param name="lines">Lines</param>
        /// <returns name="baseGraph">Base Graph</returns>
        public static BaseGraph ByLines(List <Line> lines)
        {
            if (lines == null)
            {
                throw new NullReferenceException("lines");
            }
            BaseGraph g = new BaseGraph()
            {
                graph = new Graphical.Graphs.Graph()
            };

            foreach (Line line in lines)
            {
                gVertex start = Geometry.Points.ToVertex(line.StartPoint);
                gVertex end   = Geometry.Points.ToVertex(line.EndPoint);
                g.graph.AddEdge(gEdge.ByStartVertexEndVertex(start, end));
            }
            return(g);
        }
Пример #3
0
 public static bool IsVisibilityGraph(BaseGraph graph)
 {
     return(graph.GetType() == typeof(Graphical.Graphs.VisibilityGraph));
 }