Exemple #1
0
        /// <summary>
        /// Computes the isovist at the specified depth of view.
        /// </summary>
        /// <param name="depth">The depth of view.</param>
        /// <param name="typeOfBarrier">The type of barrier.</param>
        /// <param name="cellularFloor">The cellularFloor.</param>
        /// <param name="Tolerance">The tolerance.</param>
        public void Compute(double depth, BarrierType typeOfBarrier,
                            CellularFloor cellularFloor, double Tolerance = OSMDocument.AbsoluteTolerance)
        {
            var isovist = CellularIsovistCalculator.GetIsovist(this.VantageCell + new UV(cellularFloor.CellSize / 2, cellularFloor.CellSize / 2),
                                                               depth, typeOfBarrier, cellularFloor, Tolerance);

            this.VisibleCells = isovist.VisibleCells;
        }
Exemple #2
0
        private void drawInRevit()
        {
            this._host.Hide();
            UV   p    = this._host.OSM_to_BIM.PickPoint("Pick a vantage point to draw cellular Isovist");
            Cell cell = this._host.cellularFloor.FindCell(p);

            if (cell == null)
            {
                MessageBox.Show("Pick a point on the walkable field and try again!\n");
                return;
            }
            switch (this._host.IsovistBarrierType)
            {
            case BarrierType.Visual:
                if (cell.VisualOverlapState != OverlapState.Outside)
                {
                    MessageBox.Show("Pick a point outside visual barriers.\nTry again!");
                    this._host.ShowDialog();
                    return;
                }
                break;

            case BarrierType.Physical:
                if (cell.PhysicalOverlapState != OverlapState.Outside)
                {
                    MessageBox.Show("Pick a point outside physical barriers.\nTry again!");
                    this._host.ShowDialog();
                    return;
                }
                break;

            case BarrierType.Field:
                if (cell.FieldOverlapState != OverlapState.Inside)
                {
                    MessageBox.Show("Pick a point inside the walkable field.\nTry again!");
                    this._host.ShowDialog();
                    return;
                }
                break;

            case BarrierType.BarrierBuffer:
                if (cell.BarrierBufferOverlapState != OverlapState.Outside)
                {
                    MessageBox.Show("Pick a point outside barrier buffers.\nTry again!");
                    this._host.ShowDialog();
                    return;
                }
                break;

            default:
                break;
            }
            Isovist isovist = null;
            var     timer   = new System.Diagnostics.Stopwatch();

            try
            {
                timer.Start();
                isovist = CellularIsovistCalculator.GetIsovist(p, this._host.IsovistDepth, this._host.IsovistBarrierType, this._host.cellularFloor);
                timer.Stop();
                this._host.IsovistInformation = new IsovistInformation(IsovistInformation.IsovistType.Cellular,
                                                                       timer.Elapsed.TotalMilliseconds, isovist.GetArea(this._host.cellularFloor.CellSize), double.NaN);
            }
            catch (Exception error0)
            {
                this._host.IsovistInformation = null;
                MessageBox.Show(error0.Report());
            }
            timer = null;
            if (isovist != null)
            {
                try
                {
                    var    boundaries = isovist.GetBoundary(this._host.cellularFloor);
                    double elevation  = this._host.BIM_To_OSM.PlanElevation;
                    foreach (var item in boundaries)
                    {
                        this._host.OSM_to_BIM.VisualizePolygon(item.BoundaryPoints, elevation);
                    }
                }
                catch (Exception error1)
                {
                    MessageBox.Show(error1.Report());
                }
            }
            this._host.ShowDialog();
        }
Exemple #3
0
        private void getCellularIsovist_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var  point = this._host.InverseRenderTransform.Transform(Mouse.GetPosition(this._host.FloorScene));
            UV   p     = new UV(point.X, point.Y);
            Cell cell  = this._host.cellularFloor.FindCell(p);

            if (cell == null)
            {
                MessageBox.Show("Pick a point on the walkable field and try again!\n");
                return;
            }
            switch (this._host.IsovistBarrierType)
            {
            case BarrierType.Visual:
                if (cell.VisualOverlapState != OverlapState.Outside)
                {
                    MessageBox.Show("Pick a point outside visual barriers.\nTry again!");
                    return;
                }
                break;

            case BarrierType.Physical:
                if (cell.PhysicalOverlapState != OverlapState.Outside)
                {
                    MessageBox.Show("Pick a point outside physical barriers.\nTry again!");
                    return;
                }
                break;

            case BarrierType.Field:
                if (cell.FieldOverlapState != OverlapState.Inside)
                {
                    MessageBox.Show("Pick a point inside the walkable field.\nTry again!");
                    return;
                }
                break;

            case BarrierType.BarrierBuffer:
                if (cell.BarrierBufferOverlapState != OverlapState.Outside)
                {
                    MessageBox.Show("Pick a point outside barrier buffers.\nTry again!");
                    return;
                }
                break;

            default:
                break;
            }
            var timer = new System.Diagnostics.Stopwatch();

            try
            {
                timer.Start();
                Isovist isovist = CellularIsovistCalculator.GetIsovist(p, this._host.IsovistDepth, this._host.IsovistBarrierType, this._host.cellularFloor);
                //Isovist isovist = CellularIsovistCalculator.GetIsovist(p,this._host.isoDepth, BarrierType.BarrierBuffer, this._host.cellularFloor);
                timer.Stop();
                this._host.IsovistInformation = new IsovistInformation(IsovistInformation.IsovistType.Cellular,
                                                                       timer.Elapsed.TotalMilliseconds, isovist.GetArea(this._host.cellularFloor.CellSize), double.NaN);
                this.draw(isovist);
            }
            catch (Exception error1)
            {
                this._host.IsovistInformation = null;
                MessageBox.Show(error1.Report());
            }
            timer = null;
        }
        private void endBtn_Click(object sender, RoutedEventArgs e)
        {
            this._host.CommandReset.Click  -= endBtn_Click;
            this._host.Menues.IsEnabled     = true;
            this._host.UIMessage.Visibility = Visibility.Hidden;
            //this.JGraphMode = false;
            this._host.Cursor = Cursors.Arrow;
            this._host.FloorScene.MouseLeftButtonDown -= FloorScene_MouseLeftButtonDown;
            try
            {
                #region Create Graph
                HashSet <UV>         pnts               = new HashSet <UV>();
                TriangleNet.Behavior behavior           = new Behavior();
                TriangleNet.Mesh     t_mesh             = new TriangleNet.Mesh();
                TriangleNet.Geometry.InputGeometry geom = new TriangleNet.Geometry.InputGeometry();
                foreach (Node node in JGNodes)
                {
                    TriangleNet.Data.Vertex vertex = new TriangleNet.Data.Vertex(node.Coordinates.U, node.Coordinates.V, 0);
                    geom.AddPoint(vertex);
                    pnts.Add(node.Coordinates);
                }
                t_mesh.Triangulate(geom);

                var graph = new JGGraph(pnts);
                foreach (var item in t_mesh.Triangles)
                {
                    UV  a    = null;
                    var vrtx = t_mesh.GetVertex(item.P0);
                    if (vrtx != null)
                    {
                        a = new UV(vrtx.X, vrtx.Y);
                    }
                    UV b = null;
                    vrtx = t_mesh.GetVertex(item.P1);
                    if (vrtx != null)
                    {
                        b = new UV(vrtx.X, vrtx.Y);
                    }
                    UV c = null;
                    vrtx = t_mesh.GetVertex(item.P2);
                    if (vrtx != null)
                    {
                        c = new UV(vrtx.X, vrtx.Y);
                    }
                    if (a != null && b != null)
                    {
                        graph.AddConnection(a, b);
                    }
                    if (a != null && c != null)
                    {
                        graph.AddConnection(a, c);
                    }
                    if (c != null && b != null)
                    {
                        graph.AddConnection(c, b);
                    }
                }
                #endregion
                #region Remove Edges with isovists at the ends that do not overlap
                this.edges = graph.ToEdges();
                Dictionary <int, Isovist> IsovistGuid = new Dictionary <int, Isovist>();
                foreach (JGVertex item in graph.Vertices)
                {
                    double x = double.NegativeInfinity;
                    foreach (JGVertex vertex in item.Connections)
                    {
                        var y = item.Point.DistanceTo(vertex.Point);
                        if (y > x)
                        {
                            x = y;
                        }
                    }
                    var isovist = CellularIsovistCalculator.GetIsovist(item.Point, x, BarrierType.Visual, this._host.cellularFloor);
                    IsovistGuid.Add(item.Point.GetHashCode(), isovist);
                }
                HashSet <JGEdge> visibleVertexes = new HashSet <JGEdge>();
                foreach (JGEdge item in this.edges)
                {
                    Isovist v1 = null;
                    IsovistGuid.TryGetValue(item.P1.GetHashCode(), out v1);
                    Isovist v2 = null;
                    IsovistGuid.TryGetValue(item.P2.GetHashCode(), out v2);
                    if (v1 != null && v2 != null)
                    {
                        if (v2.VisibleCells.Overlaps(v1.VisibleCells))
                        {
                            visibleVertexes.Add(item);
                        }
                    }
                }
                #endregion
                #region setting the edges
                JGEdge.LineToEdgeGuide.Clear();
                foreach (JGEdge edge in this.edges)
                {
                    edge.Clear();
                }
                this.edges = visibleVertexes.ToList <JGEdge>();
                foreach (JGEdge item in this.edges)
                {
                    item.Draw();
                }
                #endregion
                //cleaning up the used data
                t_mesh = null;
                graph  = null;
                geom.Clear();
                geom            = null;
                visibleVertexes = null;
                IsovistGuid     = null;
                //enabling edit mode
                this.EditGraph.IsEnabled      = true;
                this.DrawJG.IsEnabled         = true;
                this.Hide_show_Menu.IsEnabled = true;
                this.CreateCovexGraph.Header  = "Reset Convex Graph";
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Report());
            }
        }