public static List <Line> Lines(BaseGraph path) { List <Line> lines = new List <Line>(); foreach (GTGeom.Edge edge in path.graph.edges) { var start = GTGeom.Points.ToPoint(edge.StartVertex); var end = GTGeom.Points.ToPoint(edge.EndVertex); lines.Add(Line.ByStartPointEndPoint(start, end)); } return(lines); }
public static Visibility ByBaseGraph(BaseGraph baseGraph, bool reduced = true) { if (baseGraph == null) { throw new ArgumentNullException("graph"); } var visGraph = new VisibilityGraph(baseGraph.graph, reduced, true); var visibilityGraph = new Visibility() { graph = visGraph }; return(visibilityGraph); }
public static BaseGraph ByLines(List <DSGeom.Line> lines) { if (lines is null || lines.Count == 0) { throw new ArgumentNullException(nameof(lines)); } var g = new BaseGraph(); for (var i = 0; i < lines.Count; i++) { var line = lines[i]; GTGeom.Vertex start = GTGeom.Points.ToVertex(line.StartPoint); GTGeom.Vertex end = GTGeom.Points.ToVertex(line.EndPoint); g.graph.AddEdge(GTGeom.Edge.ByStartVertexEndVertex(start, end)); } return(g); }
public static BaseGraph ByLines(List <DSGeom.Line> lines) { if (lines == null) { throw new NullReferenceException("lines"); } BaseGraph g = new BaseGraph() { graph = new Graph() }; foreach (DSGeom.Line line in lines) { GTGeom.Vertex start = GTGeom.Points.ToVertex(line.StartPoint); GTGeom.Vertex end = GTGeom.Points.ToVertex(line.EndPoint); g.graph.AddEdge(GTGeom.Edge.ByStartVertexEndVertex(start, end)); } return(g); }
public static Surface IsovistFromPoint( Point point, List <Polygon> boundary, [DefaultArgument("[]")] List <Polygon> obstructions) { var baseGraph = BaseGraph.ByBoundaryAndInternalPolygons(boundary, obstructions); if (baseGraph == null) { throw new ArgumentNullException("graph"); } if (point == null) { throw new ArgumentNullException("point"); } GTGeom.Vertex origin = GTGeom.Vertex.ByCoordinates(point.X, point.Y, point.Z); List <GTGeom.Vertex> vertices = VisibilityGraph.VertexVisibility(origin, baseGraph.graph); var points = vertices.Select(v => GTGeom.Points.ToPoint(v)).ToList(); var polygon = Polygon.ByPoints(points); // if polygon is self intersecting, make new polygon if (polygon.SelfIntersections().Length > 0) { points.Add(point); polygon = Polygon.ByPoints(points); } var surface = Surface.ByPatch(polygon); polygon.Dispose(); points.ForEach(p => p.Dispose()); return(surface); }
public static bool IsVisibilityGraph(BaseGraph graph) { return(graph.GetType() == typeof(Visibility)); }