Exemple #1
0
 internal List<Point> FindAllCenters(Voronoi voronoi, VoronoiSettings settings)
 {
     var realCells = voronoi.Cells
         // filter the "real" cells
         .Where(c => c.Site.RealPoint).ToList();
     var centerOfRealCells = realCells
         // find center for points
         .Select(c =>
         {
             var centerPointOfPoints = GetCenterPointOfPoints(c.Vertices, settings.Width * 2, settings.Height);
             // account for cells having their center shifted to the other side
             if (centerPointOfPoints.X > ((double)settings.Width / 2d) * 3d)
             {
                 centerPointOfPoints = new Point(centerPointOfPoints.X - settings.Width, centerPointOfPoints.Y);
             }
             else if (centerPointOfPoints.X < ((double)settings.Width / 2))
             {
                 centerPointOfPoints = new Point(centerPointOfPoints.X + settings.Width, centerPointOfPoints.Y);
             }
             // fix points to be real again
             var point = new Point(centerPointOfPoints.X - settings.Width / 2, centerPointOfPoints.Y, c.Site.Name);
             if (_mapHelper.IsOutOfMap(point, settings.Width * 2, settings.Height))
             {
                 return c.Site;
             }
             return point;
         }).ToList();
     return centerOfRealCells;
 }
 internal void FixFaultyEdges(Voronoi voronoi, VoronoiSettings settings)
 {
     var semiEdges =
         voronoi.Edges.Where(
             e => (_mapHelper.IsOutOfMap(e.Start, settings.Width * 2, settings.Height)
                   && !_mapHelper.IsOutOfMap(e.End, settings.Width * 2, settings.Height))
                  || (!_mapHelper.IsOutOfMap(e.Start, settings.Width * 2, settings.Height)
                      && _mapHelper.IsOutOfMap(e.End, settings.Width * 2, settings.Height)));
     foreach (var semiEdge in semiEdges)
     {
         FixFaultyEdge(semiEdge, settings.Width * 2, settings.Height);
     }
 }
Exemple #3
0
        private void DefaultSettings(VoronoiSettings vs)
        {
            if (vs == null)
            {
                return;
            }

            NumberOfGenerators     = vs.NumberOfGenerators;
            NumberOfSamplingPoints = vs.NumberOfSamplingPoints;
            foreach (var item in vs.SamplingMethods)
            {
                SamplingMethods.Add(item);
            }
            SelectedSamplingMethod = vs.SelectedSamplingMethod.ToString();
        }
 public SettingsDataService()
 {
     VoronoiSettings = new VoronoiSettings();
 }