private void StartButton_Click(object sender, RoutedEventArgs e) { MCSelected = false; SRXSelected = false; DisableMC(); DisableCAStructureChanges(); previousScope = null; currentScope = null; SetUpProperties(); previousScope = StructureHelpers.InitCAStructure(properties, random); 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 GenerateSubstructure(List <Dictionary <Point, Grain> > remainingGrains, SimulationProperties properties) { // prepare base scope with remaining grains remainingIds = new List <int>(); var scope = new Scope(baseScope.Width, baseScope.Height); foreach (var grain in remainingGrains) { foreach (var g in grain) { scope.StructureArray[g.Key.X, g.Key.Y] = g.Value; if (remainingIds.IndexOf(g.Value.Id) == -1) { remainingIds.Add(g.Value.Id); } } } Scope prevScope = StructureHelpers.InitCAStructure(properties, random, scope, remainingIds); 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, remainingIds); // prevScope = newScope; // } //} //else //{ // CA while (newScope == null || !newScope.IsFull) { newScope = CA.Grow(prevScope, properties.NeighbourhoodType, properties.GrowthProbability, remainingIds); prevScope = newScope; } //} newScope.IsFull = true; StructureHelpers.UpdateBitmap(newScope); return(newScope); }