internal void SetCellAsActive(int x, int y, int currentNucleonId) { CurrentGrid.Cells[x, y].ChangeState(1); CurrentGrid.Cells[x, y].Id = currentNucleonId; CurrentGrid.Cells[x, y].OriginPosition.Set(x, y); CurrentGrid.Cells[x, y].Time = 0; OriginGrains.Add(CurrentGrid.Cells[x, y].CurrentPosition); }
internal int AddRectangleCells(int numberOfActiveCells, double rotation, double firstRatio, double secondRatio) { List <Point> emptyCellPoints = new List <Point>(); emptyCellPoints = GetEmptyCells(); Random r = new Random(); emptyCellPoints = emptyCellPoints.OrderBy(e => r.Next()).Take(numberOfActiveCells).ToList(); foreach (Point p in emptyCellPoints) { SetCellAsActive(p.X, p.Y, OriginGrains.Count); CurrentGrid.Cells[p.X, p.Y].SetAsRectangleOrigin(rotation, firstRatio, secondRatio); OriginGrains.Add(CurrentGrid.Cells[p.X, p.Y].CurrentPosition); FrontalSolverEngine.FrontPoints.Add(p); } return(emptyCellPoints.Count); }
internal int AddCircleCells(int numberOfActiveCells, List <Point> emptyCellPoints = null) { if (emptyCellPoints == null) { emptyCellPoints = GetEmptyCells(); } Random r = new Random(); List <Point> cellPoints = emptyCellPoints.OrderBy(e => r.Next()).Take(numberOfActiveCells).ToList(); foreach (Point p in cellPoints) { SetCellAsActive(p.X, p.Y, OriginGrains.Count); CurrentGrid.Cells[p.X, p.Y].SetAsCircleOrigin(); OriginGrains.Add(CurrentGrid.Cells[p.X, p.Y].CurrentPosition); FrontalSolverEngine.FrontPoints.Add(p); emptyCellPoints.Remove(p); } return(cellPoints.Count); }
internal int AddRandomRectangleCells(int numberOfActiveCells, List <Point> emptyCellPoints = null) { if (emptyCellPoints == null) { emptyCellPoints = GetEmptyCells(); } Random r = new Random(); List <Point> cellPoints = emptyCellPoints.OrderBy(e => r.Next()).Take(numberOfActiveCells).ToList(); foreach (Point p in cellPoints) { var Rotation = r.NextDouble() * 90.0; var FirstRatio = r.NextDouble() * 10; var SecondRatio = r.NextDouble() * 10; SetCellAsActive(p.X, p.Y, OriginGrains.Count); CurrentGrid.Cells[p.X, p.Y].SetAsRectangleOrigin(Rotation, FirstRatio, SecondRatio); OriginGrains.Add(CurrentGrid.Cells[p.X, p.Y].CurrentPosition); FrontalSolverEngine.FrontPoints.Add(p); emptyCellPoints.Remove(p); } return(cellPoints.Count); }