Exemplo n.º 1
0
        public static void SelectedBoundaries(List <Grain> grains, int width, int xNumOfCells, int yNumOfCells)
        {
            MainWindow.grain2Edge = getAllSelectedGrains(grains);
            List <Grain> grainsOnEdges = Inclusions.GrainOnEdges(MainWindow.grain2Edge, width, xNumOfCells, yNumOfCells);

            DrawEdges(grainsOnEdges);
        }
Exemplo n.º 2
0
 public static void DistributeEnergy(int EnergyDistribution, int EnergyOnEgdes, int EnergyInside)
 {
     if (EnergyDistribution == 0)
     {
         int energy = (EnergyOnEgdes + EnergyInside) / 2;
         foreach (Grain g in MainWindow.GrainTable)
         {
             g.EnergyColor = Color.FromRgb(255, (byte)(255 * energy / EnergyOnEgdes), 0);
             g.H           = energy;
         }
     }
     else
     {
         List <Grain> grainsOnEdges = Inclusions.GrainOnEdges(1, MainWindow.XNumOfCells, MainWindow.YNumOfCells);
         foreach (Grain g in MainWindow.GrainTable)
         {
             if (grainsOnEdges.Contains(g))
             {
                 g.EnergyColor = Color.FromRgb(255, (byte)(0), 0);
                 g.H           = EnergyOnEgdes;
             }
             else
             {
                 g.EnergyColor = Color.FromRgb(255, (byte)(255 - 255 * EnergyInside / EnergyOnEgdes), 0);
                 g.H           = EnergyInside;
             }
         }
     }
 }
Exemplo n.º 3
0
        public static void Nucleate(int number, int location)
        {
            Random rand = new Random();

            if (location == 0)
            {
                List <Grain> grainsOnEdges = Inclusions.GrainOnEdges(1, MainWindow.XNumOfCells, MainWindow.YNumOfCells);
                grainsOnEdges.RemoveAll(x => x.Recrystalized == true);

                for (int i = 0; i < number; i++)
                {
                    Grain g = grainsOnEdges.ElementAt(rand.Next(grainsOnEdges.Count));
                    g.Recrystalized = true;
                    Color color = Color.FromRgb((byte)(rand.Next(206) + 50), 0, 0);
                    g.Seed(color);
                    g.EnergyColor = Color.FromRgb(255, 255, 255);
                    g.H           = 0;
                    grainsOnEdges.Remove(g);
                }
            }
            else
            {
                for (int i = 0; i < number; i++)
                {
                    int x, y;
                    do
                    {
                        x = rand.Next(MainWindow.XNumOfCells);
                        y = rand.Next(MainWindow.YNumOfCells);
                    } while (MainWindow.GrainTable[x, y].Recrystalized);
                    MainWindow.GrainTable[x, y].Recrystalized = true;
                    Color color = Color.FromRgb((byte)(rand.Next(206) + 50), 0, 0);
                    MainWindow.GrainTable[x, y].Seed(color);
                    MainWindow.GrainTable[x, y].EnergyColor = Color.FromRgb(255, 255, 255);
                    MainWindow.GrainTable[x, y].H           = 0;
                }
            }
        }
Exemplo n.º 4
0
        public static void AllBoundaries(int width, int xNumOfCells, int yNumOfCells)
        {
            List <Grain> grainsOnEdges = Inclusions.GrainOnEdges(width, xNumOfCells, yNumOfCells);

            DrawEdges(grainsOnEdges);
        }