// (Re)build the nodes private void buildnodesbutton_Click(object sender, EventArgs e) { General.Map.RebuildNodes(General.Map.ConfigSettings.NodebuilderSave, true); // Restart the mode so that the new structures are loaded in. // This will automatically close and re-open this window. General.Editing.CancelMode(); NodesViewerMode newmode = new NodesViewerMode(); General.Editing.ChangeMode(newmode); newmode.Form.showsegsvertices.Checked = this.showsegsvertices.Checked; }
// Constructor public NodesForm(NodesViewerMode mode) { InitializeComponent(); this.mode = mode; // Counts numsegs.Text = mode.Segs.Length.ToString(); numsplits.Text = mode.Nodes.Length.ToString(); numssectors.Text = mode.Subsectors.Length.ToString(); numvertices.Text = mode.Vertices.Length.ToString(); showsegsvertices.Text = "Show additional vertices (" + (mode.Vertices.Length - General.Map.Map.Vertices.Count) + " seg splits)"; // Create stats on the tree List <int> leafdepths = new List <int>(); DiveTree(mode.Nodes.Length - 1, 0, leafdepths); int maxdepth = 0, mindepth = int.MaxValue; foreach (int d in leafdepths) { if (d < mindepth) { mindepth = d; } if (d > maxdepth) { maxdepth = d; } } treedepth.Text = maxdepth.ToString(); // Calculate the tree balance. The balance is 100% when all leafs are equal depth and // 0% when 1 leaf equals peakdepth and the others are at level 1. int balance = (int)(((float)mindepth / maxdepth) * 100f); treebalance.Text = balance + "%"; // Start viewing root split splitindex.Maximum = mode.Nodes.Length - 1; splitindex.Value = mode.Nodes.Length - 1; splitindex_ValueChanged(null, EventArgs.Empty); // Viewing subsector ssectorindex.Maximum = mode.Subsectors.Length - 1; ssectorindex.Value = 0; ssectorindex_ValueChanged(null, EventArgs.Empty); segindex_ValueChanged(null, EventArgs.Empty); }