コード例 #1
0
        public static RepresentableGraph CreateVisibilityGraph(
            List <DSGeom.Polygon> boundary,
            List <DSGeom.Polygon> obstructions)
        {
            var graph    = BaseGraph.ByBoundaryAndInternalPolygons(boundary, obstructions);
            var visGraph = RepresentableGraph.ByBaseGraph(graph);

            return(visGraph);
        }
コード例 #2
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 RepresentableGraph ByBaseGraph(BaseGraph baseGraph, bool reduced = true)
        {
            if (baseGraph == null)
            {
                throw new ArgumentNullException("graph");
            }
            var visGraph        = new VisibilityGraph(baseGraph.graph, reduced, true);
            var visibilityGraph = new RepresentableGraph()
            {
                graph = visGraph
            };

            return(visibilityGraph);
        }
コード例 #3
0
 public void Tessellate(
     IRenderPackage package,
     TessellationParameters parameters)
 {
     if (this.GetType() == typeof(RepresentableGraph))
     {
         RepresentableGraph visGraph = this as RepresentableGraph;
         if (visGraph.Factors != null && visGraph.colorRange != null)
         {
             visGraph.TessellateVisibilityGraph(package, parameters);
         }
         else
         {
             TesselateBaseGraph(package, parameters);
         }
     }
     else
     {
         TesselateBaseGraph(package, parameters);
     }
 }
コード例 #4
0
        public static Dictionary <string, object> Connectivity(
            RepresentableGraph visGraph,
            [DefaultArgument("null")] List <DSCore.Color> colours,
            [DefaultArgument("null")] List <double> indices)
        {
            if (visGraph == null)
            {
                throw new ArgumentNullException("visGraph");
            }

            VisibilityGraph visibilityGraph = visGraph.graph as VisibilityGraph;

            RepresentableGraph graph = new RepresentableGraph()
            {
                graph   = visibilityGraph,
                Factors = visibilityGraph.ConnectivityFactor()
            };

            if (colours != null && indices != null && colours.Count == indices.Count)
            {
                graph.colorRange = new Dictionary <double, DSCore.Color>();
                // Create KeyValuePairs and sort them by index in case unordered.
                var pairs = indices.Zip(colours, (i, c) => new KeyValuePair <double, DSCore.Color>(i, c)).OrderBy(kv => kv.Key);

                // Adding values to colorRange dictionary
                foreach (KeyValuePair <double, DSCore.Color> kv in pairs)
                {
                    graph.colorRange.Add(kv.Key, kv.Value);
                }
            }

            return(new Dictionary <string, object>()
            {
                { graphOutput, graph },
                { factorsOutput, graph.Factors }
            });
        }