private void draw(Isovist isovist) { this._children.Clear(); this._edges.Clear(); this._escapeRoutes.Clear(); var boundaries = isovist.GetBoundary(this._host.cellularFloor); this._edges.Add(isovist.VantageCell, boundaries); double scale = this.getScaleFactor(); Point p1 = new Point(), p2 = new Point(); DrawingVisual drawingVisual = new DrawingVisual(); using (DrawingContext drawingContext = drawingVisual.RenderOpen()) { StreamGeometry sg = new StreamGeometry(); using (StreamGeometryContext sgc = sg.Open()) { foreach (BarrierPolygon item in boundaries) { sgc.BeginFigure(new Point(item.BoundaryPoints[0].U, item.BoundaryPoints[0].V), true, true); foreach (var uv in item.BoundaryPoints) { sgc.LineTo(new Point(uv.U, uv.V), true, true); } } } drawingContext.DrawGeometry(this._fillBrush, null, sg); Pen pen = new Pen(this._centerBrush, this._host.cellularFloor.CellSize); p1.X = isovist.VantageCell.U; p1.Y = isovist.VantageCell.V + this._host.cellularFloor.CellSize / 2; p2.X = isovist.VantageCell.U + this._host.cellularFloor.CellSize; p2.Y = isovist.VantageCell.V + this._host.cellularFloor.CellSize / 2; drawingContext.DrawLine(pen, p1, p2); } drawingVisual.Drawing.Freeze(); this._children.Add(drawingVisual); }
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(); }