/// <summary> /// Convert the Voronoi Diagram into a city with roads and building zones /// </summary> private void GenerateCity() { if (_voronoiDiagram == null) { //GenerateVoronoi(); return; } //Settings for generation _citySettings.DistrictSettings = DistrictSettings.ToList(); _citySettings.GenerateInnerRoads = GenerateInnerRoads; _citySettings.RoadSubdivision = RoadSubdivisions; _citySettings.DebugMode = DebugMode.Value; //generate city var timer = Stopwatch.StartNew(); _cityData = CityBuilder.GenerateCity(_citySettings, _voronoiDiagram); timer.Stop(); //update timer var time = timer.ElapsedMilliseconds / 1000.0; GenerationTimeText = $"City generated in {time} seconds."; //update canvas RefreshCanvas(); //InsetTesting var insetCells = new List <Cell>(); var points = new List <Point>(); foreach (var d in _cityData.Districts) { foreach (var c in d.Cells) { var cInset = c.Inset(20); insetCells.Add(cInset); //_drawService.DrawCell(c, Color.FromArgb(255, 120, 120, 120), true, true); points.AddRange(cInset.GenerateRandomPoints(9)); } } ////Draw foreach (var c in insetCells) { //_drawService.DrawCell(c, Color.FromArgb(255, 188, 188, 188), true, true); //Draw Triangulation var triangles = new BowyerWatsonGenerator().DelaunayTriangulation(c.Points); foreach (var t in triangles) { //_drawService.DrawTriangle(t, Colors.CornflowerBlue); } } foreach (var p in points) { _drawService.DrawPoint(p, 4, Colors.OrangeRed); } }