public Map(TruthTable truthT) { this.truthT = truthT; if (this.truthT.cantVars % 2 == 0) { renglones = columnas = Convert.ToInt32(Math.Sqrt(Math.Pow(2, this.truthT.cantVars))); } else { columnas = Convert.ToInt32(Math.Sqrt(Math.Pow(2, this.truthT.cantVars + 1))); renglones = columnas / 2; } matriz = Array.CreateInstance(typeof(bool), renglones, columnas); }
private void BTNresultado_Click(object sender, EventArgs e) { StyleMap(); // Map map = new Map(cantVars, TBXFunction.Text, GridValues, mapValues); comb = 0; table = new TruthTable(cantVars, TBXFunction.Text); table.Table = DGVTable; table.InsertValues(); map = new Map(table); map.DataMap = DGVMap; if (table.verif == true) { MessageBox.Show("Introduzca una funcion valida", "ERROR"); } else { Random Aleatorios = new Random(); Aleatorios = new Random(); int Red = Aleatorios.Next(250); int Blue = Aleatorios.Next(250); int Green = Aleatorios.Next(250); Color c = Color.FromArgb(Red, Green, Blue); table.c = c; map.c = c; table.CreateTable(); table.ClearMinTerms(); table.SelectMinTerms(); comb = Convert.ToInt32(Math.Pow(2, cantVars)); oNSet.Clear(); for (int i = 0; i < comb; i++) { if (Convert.ToInt32(table.Vars.GetValue(i, cantVars)) == 1) { oNSet.Add(long.Parse(i.ToString())); } } if (oNSet.Count == 0) { lblResult.Visible = false; map.FillMap(); map.CreateMap(); map.ClearMap(); map.MapColor(); InitForm(1); } else { lblResult.Visible = true; var kMap = new KMap(cantVars, oNSet, new HashSet <long>() { }); result = kMap.PrintCoverages(true); if (cantVars == 2 && oNSet.Count() == 4) { lblResult.Text = "1"; } else if (cantVars == 3 && oNSet.Count() == 8) { lblResult.Text = "1"; } else if (cantVars == 4 && oNSet.Count() == 16) { lblResult.Text = "1"; } else { lblResult.Text = result.Item2; } map.FillMap(); map.CreateMap(); map.ClearMap(); map.MapColor(); InitForm(1); } } }