Exemplo n.º 1
0
        /*
         * private void TestMinimal2Button_Click(object sender, EventArgs e)
         * {
         * MinimalEquation.Initialize();
         * Vector3D[] first = MinimalEquation.NextEquational(MinimalEquation.FirstSeedE);
         * }*/

        private void GeodesicAnalysisButton_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog sfd = new SaveFileDialog()
            {
                Filter = "*.csv|*.csv"
            })
            {
                if (sfd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                List <ScaledCenterlinePair> current = new List <ScaledCenterlinePair>();
                List <ScaledCenterlinePair> next    = new List <ScaledCenterlinePair>();

                MinimalEquation.Initialize();
                Vector2D seed = MinimalEquation.FirstSeed;

                ScaledCenterlinePair basicSet = new ScaledCenterlinePair();
                basicSet.primary = seed;
                basicSet.distanceToScaledCenterLine = 0;
                basicSet.primaryIndex = 1;

                current.Add(basicSet);

                List <string> lines  = new List <string>();
                string        header = "Count;Index;IndexBin;Distance;X;Y;";
                lines.Add(header);
                long i           = 1;
                long generations = Convert.ToInt32(GenerationBox.Text);

                for (int g = -1; g < generations; g++)
                {
                    foreach (ScaledCenterlinePair set in current)
                    {
                        string line = i.ToString() + ";";
                        i++;
                        line += set.primaryIndex.ToString() + ";";
                        line += Convert.ToString(set.primaryIndex, 2) + ";";
                        line += (-set.distanceToScaledCenterLine).ToString() + ";";
                        line += set.primary.x.ToString() + ";";
                        line += set.primary.y.ToString() + ";";
                        lines.Add(line);
                        line = "";

                        if (set.secondary != null)
                        {
                            line += i.ToString() + ";";
                            i++;
                            line += set.secondaryIndex.ToString() + ";";
                            line += Convert.ToString(set.secondaryIndex, 2) + ";";
                            line += set.distanceToScaledCenterLine.ToString() + ";";
                            line += set.secondary.x.ToString() + ";";
                            line += set.secondary.y.ToString() + ";";
                            lines.Add(line);
                        }

                        if (g < generations - 1)
                        {
                            next.Add(MinimalEquation.NextBasic(set.primary, set.primaryIndex));
                            if (set.secondary != null)
                            {
                                next.Add(MinimalEquation.NextBasic(set.secondary, set.secondaryIndex));
                            }
                        }
                    }
                    current = next;
                    next    = new List <ScaledCenterlinePair>();
                }
                File.WriteAllLines(sfd.FileName, lines);
            }
        }
Exemplo n.º 2
0
 private void TestMinimalButton_Click(object sender, EventArgs e)
 {
     MinimalEquation.Initialize();
     Vector2D[] first = MinimalEquation.Next1(MinimalEquation.FirstSeed);
 }