Exemplo n.º 1
0
        private void draw(IsovistEscapeRoutes escapeRoutes)
        {
            this._escapeRoutes.Add(escapeRoutes);
            double        scale = this.getScaleFactor();
            Point         p1 = new Point(), p2 = new Point();
            DrawingVisual drawingVisual = new DrawingVisual();

            using (DrawingContext drawingContext = drawingVisual.RenderOpen())
            {
                Pen pen = new Pen(this._fillBrush, this._host.cellularFloor.CellSize);
                foreach (Cell item in escapeRoutes.EscapeRoutes)
                {
                    p1.X = item.U;
                    p1.Y = item.V + this._host.cellularFloor.CellSize / 2;
                    p2.X = item.U + this._host.cellularFloor.CellSize;
                    p2.Y = item.V + this._host.cellularFloor.CellSize / 2;
                    drawingContext.DrawLine(pen, p1, p2);
                }
                pen  = new Pen(this._centerBrush, this._host.cellularFloor.CellSize);
                p1.X = escapeRoutes.VantageCell.U;
                p1.Y = escapeRoutes.VantageCell.V + this._host.cellularFloor.CellSize / 2;
                p2.X = escapeRoutes.VantageCell.U + this._host.cellularFloor.CellSize;
                p2.Y = escapeRoutes.VantageCell.V + this._host.cellularFloor.CellSize / 2;
                drawingContext.DrawLine(pen, p1, p2);
            }
            drawingVisual.Drawing.Freeze();
            this._children.Add(drawingVisual);
        }
Exemplo n.º 2
0
        private void getEscapeRoute_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;
            }
            try
            {
                IsovistEscapeRoutes escapeRoutes = null;
                switch (this._escapeRouteType)
                {
                case EscapeRouteType.All:
                    escapeRoutes = CellularIsovistCalculator.GetAllEscapeRoute(p, this._host.IsovistDepth,
                                                                               this._host.IsovistBarrierType, this._host.cellularFloor);
                    this._children.Clear();
                    this._edges.Clear();
                    this._escapeRoutes.Clear();
                    this.draw(escapeRoutes);
                    break;

                case EscapeRouteType.WeightedAndSimplified:
                    escapeRoutes = CellularIsovistCalculator.GetWeightedSimplifiedEscapeRoute(p,
                                                                                              this._host.AgentIsovistExternalDepth,
                                                                                              this._host.IsovistBarrierType, this._host.cellularFloor, this._staticCosts,
                                                                                              this._host.MaximumNumberOfDestinations);
                    this._children.Clear();
                    this._edges.Clear();
                    this._escapeRoutes.Clear();
                    this.draw(escapeRoutes);
                    break;

                default:
                    break;
                }
            }
            catch (Exception error1)
            {
                this._host.IsovistInformation = null;
                MessageBox.Show(error1.Report());
            }
        }