private void MCStartButton_Click(object sender, RoutedEventArgs e) { MCSelected = true; SRXSelected = false; DisableCA(); previousScope = null; currentScope = null; SetUpMCProperties(); this.MC = new MC(random, MCproperties); previousScope = StructureHelpers.GenerateEmptyStructure((int)StructureImage.Width, (int)StructureImage.Height); dispatcherTimer.Start(); }
private Scope GeterateDualphaseStructure(List <Dictionary <Point, Grain> > remainingGrains, SimulationProperties properties) { Scope prevScope; if (properties.AdvancedMethodType == AdvancedMethodType.AdvancedMC) { prevScope = StructureHelpers.GenerateEmptyStructure(properties.ScopeWidth, properties.ScopeHeight); } else { prevScope = StructureHelpers.InitCAStructure(properties, random); } var newScope = new Scope(prevScope.Width, prevScope.Height); if (properties.AdvancedMethodType == AdvancedMethodType.AdvancedMC) { // MC while (newScope == null || MC.ItertionsPerformed < MCProperties.NumberOfSteps) { newScope = MC.Grow(prevScope); prevScope = newScope; } } else { // CA while (newScope == null || !newScope.IsFull) { newScope = CA.Grow(prevScope, properties.NeighbourhoodType, properties.GrowthProbability); prevScope = newScope; } } // add second phase foreach (var grain in remainingGrains) { foreach (var g in grain) { newScope.StructureArray[g.Key.X, g.Key.Y] = g.Value; } } newScope.IsFull = true; StructureHelpers.UpdateBitmap(newScope); return(newScope); }
private Scope[] EnergyDistribution() { var baseScope = scope; var energyScope = StructureHelpers.GenerateEmptyStructure(scope.Width, scope.Height); for (int i = 1; i < scope.Width - 1; i++) { for (int j = 1; j < scope.Height - 1; j++) { if (scope.StructureArray[i, j].Id != Convert.ToInt32(SpecialIds.Border)) { baseScope.StructureArray[i, j].Energy = properties.GrainEnergy; energyScope.StructureArray[i, j].Id = Convert.ToInt32(SpecialIds.Energy); energyScope.StructureArray[i, j].Energy = properties.GrainEnergy; energyScope.StructureArray[i, j].Color = ChooseColor(properties.GrainEnergy); } else { baseScope.StructureArray[i, j] = scope.StructureArray[i, j]; energyScope.StructureArray[i, j] = scope.StructureArray[i, j]; } } } if (properties.EnergyDistributionType == EnergyDistributionType.Heterogenous) { UpdateBoundariesEnergy(scope, energyScope); for (int i = 1; i < energyScope.Height - 1; i++) { for (int j = 1; j < energyScope.Width - 1; j++) { baseScope.StructureArray[i, j].Energy = energyScope.StructureArray[i, j].Energy; } } } energyScope.IsFull = true; StructureHelpers.UpdateBitmap(energyScope); Scope[] scopes = new Scope[2] { energyScope, baseScope }; return(scopes); }