public bool BuildKDTree_Stark(List <Vertex> target) { TimeCalc.ResetTime(); KdTree_Stark = KDTree_Stark.Build(target); TimeCalc.ShowLastTimeSpan("Build Tree Stark"); return(true); }
public void FindNearest_Points_Rednaxela(List <Vertex> vertices) { //float fThreshold = kdTreeNeighbourThreshold; List <Vertex> nearestNeighbours = new List <Vertex>(); for (int i = vertices.Count - 1; i >= 0; i--) { Vertex vToCheck = vertices[i]; // Perform a nearest neighbour search around that point. KDTreeRednaxela.NearestNeighbour <EllipseWrapper> pIter = null; KDTreeVertex kv = KDTreeVertex.Instance; pIter = kv.KdTree_Rednaxela.FindNearest_EuclidDistance(new double[] { vToCheck.Vector.X, vToCheck.Vector.Y, vToCheck.Vector.Z }, NumberOfNeighboursToSearch, -1); int neighboursFound = 0; while (pIter.MoveNext()) { EllipseWrapper wr = pIter.Current; Vertex vNeighbour = wr.Vertex; if (vToCheck != vNeighbour) { if (!vToCheck.IndexNeighbours.Contains(vNeighbour.IndexInModel)) { vToCheck.IndexNeighbours.Add(vNeighbour.IndexInModel); vToCheck.DistanceNeighbours.Add(pIter.CurrentDistance); } for (int j = vNeighbour.IndexNeighbours.Count - 1; j >= 0; j--) { if (vNeighbour.IndexNeighbours[j] == vToCheck.IndexInModel) { vNeighbour.IndexNeighbours.RemoveAt(j); vNeighbour.DistanceNeighbours.RemoveAt(j); } } neighboursFound = vToCheck.DistanceNeighbours.Count; //if (!vNeighbour.IndexNeighbours.Contains(vToCheck.IndexInModel)) //{ // vNeighbour.IndexNeighbours.Add(vToCheck.IndexInModel); // vNeighbour.DistanceNeighbours.Add(pIter.CurrentDistance); //} if ((neighboursFound) > NumberOfNeighboursToSearch) { break; } } } } TimeCalc.ShowLastTimeSpan("Find neighbours"); //RemoveAllVerticesBasedOnRadius(vertices); }
public bool BuildKDTree_Rednaxela(List <Vertex> vTarget) { TimeCalc.ResetTime(); try { KdTree_Rednaxela = new KDTreeRednaxela.KDTree_Rednaxela <EllipseWrapper>(3); for (int i = 0; i < vTarget.Count; ++i) { Vertex p = vTarget[i]; KdTree_Rednaxela.AddPoint(new double[] { p.Vector.X, p.Vector.Y, p.Vector.Z }, new EllipseWrapper(p)); } } catch (Exception err) { throw err; } TimeCalc.ShowLastTimeSpan("Build Tree Rednaxala"); return(true); }