public Node2List(Node2List L) { m_nodes = new List <Node2>(); m_sort = NodeListSort.none; m_nodes.Capacity = L.m_nodes.Count; m_sort = L.m_sort; int num = L.m_nodes.Count - 1; for (int i = 0; i <= num; i++) { if (L.m_nodes[i] == null) { m_nodes.Add(null); } else { m_nodes.Add(new Node2(L.m_nodes[i])); } } }
public Node2Tree(Node2List owner) { this.m_list = owner; }
/// <summary>Builds a subtree from a Node list.</summary> /// <param name="nodes">All the nodes that are supposed to be included in this tree.</param> /// <param name="index_subset">A subset of nodes on which to perform the subdivision. Pass a null-pointer to use ALL nodes. /// If the list is not null, used indices will be extracted from the list, in order to reduce the number of pointless inclusion tests.</param> /// <param name="group_limit">The number of allowed Nodes per Leaf. If a Leaf contains more than N nodes, it will subdivide.</param> public void SubDivide(Node2List nodes, List <int> index_subset, int group_limit) { this.m_nodes = new List <int>(nodes.Count); this.m_A = (Node2Leaf)null; this.m_B = (Node2Leaf)null; this.m_C = (Node2Leaf)null; this.m_D = (Node2Leaf)null; if (index_subset == null) { int num = nodes.Count - 1; for (int index = 0; index <= num; ++index) { this.m_nodes.Add(index); } } else { int num1 = index_subset.Count - 1; int index1 = 0; int num2 = num1; for (int index2 = 0; index2 <= num2; ++index2) { int index3 = index_subset[index2]; Node2 node = nodes[index3]; if (node != null) { if (this.Contains(node.x, node.y)) { this.m_nodes.Add(index3); } else { index_subset[index1] = index3; ++index1; } } } if (index1 < index_subset.Count) { if (index1 == 0) { index_subset.Clear(); } else { index_subset.RemoveRange(index1, index_subset.Count - index1); } } } double num3 = (this.m_x1 - this.m_x0) * (this.m_x1 - this.m_x0) + (this.m_y1 - this.m_y0) * (this.m_y1 - this.m_y0); if (this.m_nodes.Count > group_limit && num3 > 1E-08) { this.CreateSubLeafs(); this.m_A.SubDivide(nodes, this.m_nodes, group_limit); this.m_B.SubDivide(nodes, this.m_nodes, group_limit); this.m_C.SubDivide(nodes, this.m_nodes, group_limit); this.m_D.SubDivide(nodes, this.m_nodes, group_limit); this.TrimSubLeafs(); this.m_nodes = (List <int>)null; } else if (this.m_nodes.Count == 0) { this.m_nodes = (List <int>)null; } else { this.m_nodes.TrimExcess(); } }
/// <summary>Recursive method that solves a proximity search.</summary> /// <param name="nodes">Node set to search</param> /// <param name="prox">Proximity object to search with</param> public void SolveProximity(Node2List nodes, Node2Proximity prox) { double d0 = default(double); double d1 = default(double); prox.DistanceRange(ref d0, ref d1); double num1 = this.MinimumDistanceSquared(prox.Start.x, prox.Start.y); if (num1 >= d1 || num1 > prox.MaxSearchRadiusSquared || this.MaximumDistanceSquared(prox.Start.x, prox.Start.y) <= prox.MinSearchRadiusSquared) { return; } if (this.m_nodes == null) { Node2Leaf[] node2LeafArray; if (prox.Start.x < this.x_mid) { if (prox.Start.y < this.y_mid) { node2LeafArray = new Node2Leaf[4] { this.m_A, this.m_B, this.m_D, this.m_C } } ; else { node2LeafArray = new Node2Leaf[4] { this.m_D, this.m_A, this.m_C, this.m_B } }; } else if (prox.Start.y < this.y_mid) { node2LeafArray = new Node2Leaf[4] { this.m_B, this.m_A, this.m_C, this.m_D } } ; else { node2LeafArray = new Node2Leaf[4] { this.m_C, this.m_D, this.m_B, this.m_A } }; int num2 = node2LeafArray.Length - 1; for (int index = 0; index <= num2; ++index) { if (node2LeafArray[index] != null) { node2LeafArray[index].SolveProximity(nodes, prox); } } } else { if (this.m_nodes == null) { return; } int num2 = this.m_nodes.Count - 1; for (int index = 0; index <= num2; ++index) { prox.RegisterNode(nodes[this.m_nodes[index]], this.m_nodes[index]); } } }