public static Dictionary <string, object> FromOrigin( DSGeom.Point origin, List <DSGeom.Point> points, List <DSGeom.Polygon> boundary, [DefaultArgument("[]")] List <DSGeom.Polygon> obstacles) { DSGeom.Polygon isovist = IsovistPolygon(boundary, obstacles, origin); GTGeom.Polygon gPol = GTGeom.Polygon.ByVertices(isovist.Points.Select(p => GTGeom.Vertex.ByCoordinates(p.X, p.Y, p.Z)).ToList()); List <DSGeom.Point> visPoints = new List <DSGeom.Point>(); double totalPoints = points.Count; double visibilityAmount = 0; foreach (DSGeom.Point point in points) { GTGeom.Vertex vertex = GTGeom.Vertex.ByCoordinates(point.X, point.Y, point.Z); if (gPol.ContainsVertex(vertex)) { ++visibilityAmount; visPoints.Add(point); } } isovist.Dispose(); return(new Dictionary <string, object>() { { scoreOutputPort, (1 / totalPoints) * visibilityAmount }, { geometryOutputPort, visPoints } }); }
public static BaseGraph ByBoundaryAndInternalPolygons( List <DSGeom.Polygon> boundaries, [DefaultArgument("[]")] List <DSGeom.Polygon> internals) { if (boundaries == null) { throw new NullReferenceException("boundaryPolygons"); } if (internals == null) { throw new NullReferenceException("internalPolygons"); } List <GTGeom.Polygon> input = new List <GTGeom.Polygon>(); foreach (DSGeom.Polygon pol in boundaries) { var vertices = pol.Points.Select(pt => GTGeom.Vertex.ByCoordinates(pt.X, pt.Y, pt.Z)).ToList(); GTGeom.Polygon gPol = GTGeom.Polygon.ByVertices(vertices, true); input.Add(gPol); } foreach (DSGeom.Polygon pol in internals) { var vertices = pol.Points.Select(pt => GTGeom.Vertex.ByCoordinates(pt.X, pt.Y, pt.Z)).ToList(); GTGeom.Polygon gPol = GTGeom.Polygon.ByVertices(vertices, false); input.Add(gPol); } return(new BaseGraph(input)); }
private static List <GTGeom.Polygon> FromDynamoPolygons(List <DSGeom.Polygon> polygons, bool external) { var gtPolygons = new List <GTGeom.Polygon>(); for (var i = 0; i < polygons.Count; i++) { var vertices = polygons[i].Points .Select(pt => GTGeom.Vertex.ByCoordinates(pt.X, pt.Y, pt.Z)) .ToList(); GTGeom.Polygon gPol = GTGeom.Polygon.ByVertices(vertices, external); gtPolygons.Add(gPol); } return(gtPolygons); }
public static Dictionary <string, object> OfPointsFromOrigin( Point origin, List <Point> points, List <Polygon> boundary, [DefaultArgument("[]")] List <Polygon> obstructions = null) { if (origin is null) { throw new ArgumentNullException(nameof(origin)); } if (points is null || points.Count == 0) { throw new ArgumentNullException(nameof(points)); } if (obstructions == null) { obstructions = new List <Polygon>(); } Polygon isovist = IsovistPolygon(origin, obstructions, boundary); GTGeom.Polygon isovistPolygon = GTGeom.Polygon.ByVertices(isovist.Points.Select(p => GTGeom.Vertex.ByCoordinates(p.X, p.Y, p.Z)).ToList()); var visiblePoints = new List <Point>(); double totalPoints = points.Count; double visibilityAmount = 0; for (var i = 0; i < points.Count; i++) { var point = points[i]; GTGeom.Vertex vertex = GTGeom.Vertex.ByCoordinates(point.X, point.Y, point.Z); if (isovistPolygon.ContainsVertex(vertex)) { ++visibilityAmount; visiblePoints.Add(point); } } isovist.Dispose(); var visibilityPercentageScore = (1 / totalPoints) * visibilityAmount * 100; return(new Dictionary <string, object>() { { percentageVisibleOutputPort, visibilityPercentageScore }, { visibleItemsOutputPort, visiblePoints } }); }
public static BaseGraph ByPolygons(List <DSGeom.Polygon> polygons) { if (polygons == null) { throw new NullReferenceException("polygons"); } List <GTGeom.Polygon> input = new List <GTGeom.Polygon>(); foreach (DSGeom.Polygon pol in polygons) { var vertices = pol.Points.Select(pt => GTGeom.Vertex.ByCoordinates(pt.X, pt.Y, pt.Z)).ToList(); GTGeom.Polygon gPol = GTGeom.Polygon.ByVertices(vertices, false); input.Add(gPol); } return(new BaseGraph(input)); }