예제 #1
0
        private static DSGeom.Polygon IsovistPolygon(
            List <DSGeom.Polygon> boundary,
            List <DSGeom.Polygon> obstacles,
            DSGeom.Point point)
        {
            BaseGraph baseGraph = BaseGraph.ByBoundaryAndInternalPolygons(boundary, obstacles);

            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);
            List <DSGeom.Point>  points   = vertices.Select(v => GTGeom.Points.ToPoint(v)).ToList();

            var polygon = DSGeom.Polygon.ByPoints(points);

            // if polygon is self intersecting, make new polygon
            if (polygon.SelfIntersections().Length > 0)
            {
                points.Add(point);
                polygon = DSGeom.Polygon.ByPoints(points);
            }
            return(polygon);
        }
예제 #2
0
        public static DSGeom.Surface FromPoint(
            List <DSGeom.Polygon> boundary,
            [DefaultArgument("[]")] List <DSGeom.Polygon> internals,
            DSGeom.Point point)
        {
            BaseGraph baseGraph = BaseGraph.ByBoundaryAndInternalPolygons(boundary, internals);

            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);
            List <DSGeom.Point>  points   = vertices.Select(v => GTGeom.Points.ToPoint(v)).ToList();

            var polygon = DSGeom.Polygon.ByPoints(points);

            // if polygon is self intersecting, make new polygon
            if (polygon.SelfIntersections().Length > 0)
            {
                points.Add(point);
                polygon = DSGeom.Polygon.ByPoints(points);
            }
            DSGeom.Surface surface = DSGeom.Surface.ByPatch(polygon);
            polygon.Dispose();
            points.ForEach(p => p.Dispose());

            return(surface);
        }
예제 #3
0
        private static Polygon IsovistPolygon(
            Point originPoint,
            List <Polygon> obstacles,
            List <Polygon> boundary)
        {
            if (obstacles is null)
            {
                throw new ArgumentNullException(nameof(obstacles));
            }
            if (boundary is null)
            {
                throw new ArgumentNullException(nameof(boundary));
            }

            var originVertex = GTGeom.Vertex.ByCoordinates(originPoint.X, originPoint.Y, originPoint.Z);
            var baseGraph    = BaseGraph.ByBoundaryAndInternalPolygons(boundary, obstacles);

            List <GTGeom.Vertex> vertices = Graphs.VisibilityGraph.VertexVisibility(originVertex, baseGraph.graph);
            List <DSGeom.Point>  points   = vertices.Select(v => GTGeom.Points.ToPoint(v)).ToList();

            var polygon = DSGeom.Polygon.ByPoints(points);

            // if polygon is self intersecting, make new polygon
            if (polygon.SelfIntersections().Length > 0)
            {
                points.Add(originPoint);
                polygon = DSGeom.Polygon.ByPoints(points);
            }
            points.ForEach(x => x.Dispose());

            return(polygon);
        }
예제 #4
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);
        }
예제 #5
0
        /// <summary>
        /// Returns a VisibilityGraph which is used as input for ShortestPath
        /// </summary>
        /// <param name="boundary"></param>
        /// <param name="internals"></param>
        /// <returns name = "visGraph">VisibilityGraph for use in ShortestPath</returns>
        public static Visibility CreateVisibilityGraph(
            List <DSGeom.Polygon> boundary,
            List <DSGeom.Polygon> internals)
        {
            var graph    = BaseGraph.ByBoundaryAndInternalPolygons(boundary, internals);
            var visGraph = Visibility.ByBaseGraph(graph);

            return(visGraph);
        }