/* * RunSimulation is used to setup the variables and call the various method to setup the simulation. * When the setup is complete it runs a for loop for the amount of Cycles calling the method RunCycle() in each iteration. */ public void RunSimulation(int Width, int Height, int Cycles, double FeedRate_A, double KillRate_B, ELaplacianFunctions laplacianEnum, EShadingAlgorthims shadingEnum, bool displayGrid) { this.Width = Width; this.Height = Height; this.Cycles = Cycles; this.FeedRate_A = FeedRate_A; this.KillRate_B = KillRate_B; this.laplacianEnum = laplacianEnum; //Data Fields are being set this.shadingEnum = shadingEnum; this.displayGrid = displayGrid; CurrentCycle = 0; progressbar.Maximum = Cycles; progressbar.Value = 0; SeedValue = 0.25; gridDrawer = new GridDrawer(canvas, Width, Height, shadingEnum); //Instance of GridDrawer is created which is later used to draw or save the grid. LapFactory = new LaplacianFactory(); LapFunction = LapFactory.CreateNewLaplacian(laplacianEnum); //LapFunction instance is created using the CreateNewLaplacian method from LapFactory. Diffusion_A = LapFunction.GetDiffusion_A(); //The Diffusion A and B differ depending upon what Lapacian function is used. Diffusion_B = LapFunction.GetDiffusion_B(); SetCellGrid(); //The CellGrid is set and filled up with a seed; SetCellNeighbours(); //In the entre grid all the cells are passed the Cells neighbouring them. Stop(); //Called so the canvas is cleared for (int cycleNum = 0; cycleNum < Cycles; cycleNum++) //Loops through the cycles calling RunCycle each time. { RunCycle(); } }
/* * CreateNewLaplacian takes in a enum representing the Laplacian Function which is wanted. * The switch then creates that Laplacian Function and returns it so the Manager class does not need to know how its created. */ public ILaplacian CreateNewLaplacian(ELaplacianFunctions lap) { ILaplacian newLaplacian = null; switch (lap) { case ELaplacianFunctions.CONVOLUTION: newLaplacian = new Laplacian_Convolution(); break; case ELaplacianFunctions.DELTA_MEANS: newLaplacian = new Laplacian_DeltaMeans(); break; case ELaplacianFunctions.PERPENDICULAR_NEIGHBOURS: newLaplacian = new Laplacian_PerpendicularNeighbours(); break; } return(newLaplacian); }