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);
        }
Exemple #2
0
 internal void AddGrainOriginPoints(List <Point> pointsToDraw, int v)
 {
     OriginGrains.AddRange(pointsToDraw);
     foreach (Point p in pointsToDraw)
     {
         CurrentGrid.Cells[p.X, p.Y].Id = v;
         CurrentGrid.Cells[p.X, p.Y].ChangeState(1);
     }
     RecalculateOriginForGrid();
 }
 public void ClearGrid()
 {
     if (Running)
     {
         return;
     }
     CurrentGrid.Clear();
     Solver.Clear();
     OriginGrains.Clear();
     CurrentBitmap = new Bitmap(Grid.SizeX * Zoom, Grid.SizeY * Zoom, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
 }
Exemple #4
0
 public void ClearGrid()
 {
     if (Running)
     {
         return;
     }
     CurrentGrid.Clear();
     OriginGrains.Clear();
     NextGrid.Clear();
     Iteration = 1;
 }
Exemple #5
0
        public void ResizeGrid(int sizeX, int sizeY)
        {
            if (Running)
            {
                return;
            }

            CurrentGrid.Resize(sizeX, sizeY);
            OriginGrains.Clear();
            NextGrid.Resize(sizeX, sizeY);
        }
Exemple #6
0
 internal void RemoveGrainOriginPoints(List <Point> pointsToDraw)
 {
     foreach (Point p in pointsToDraw)
     {
         CurrentGrid.Cells[p.X, p.Y].ChangeState(0);
         OriginGrains.Remove(p);
     }
     if (OriginGrains.Count > 0)
     {
         RecalculateOriginForGrid();
     }
     else
     {
         CurrentGrid.Clear();
         Iteration = 1;
     }
 }
Exemple #7
0
        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);
        }
 internal void ResetCell(int x, int y)
 {
     CurrentGrid.Cells[x, y].Reset();
     OriginGrains.Remove(CurrentGrid.Cells[x, y].CurrentPosition);
 }