public void process_leaf_node_fixedball(SearchRecord sr) { float ballsize = sr.Radius; // bool rearrange = sr.rearrange; for (int i = IndexLeafVector; i <= endIndex; i++) { uint indexofi = this.Parent.Indices[i]; float distance; bool early_exit; if (rearrange) { early_exit = false; distance = 0.0F; for (int k = 0; k < 3; k++) { float f = this.Parent.TreeVectors[i].Vector[k] - sr.VectorTarget[k]; distance += f * f; if (distance > ballsize) { early_exit = true; break; } } if (early_exit) { continue; // next iteration of mainloop } // why do we do things like this? because if we take an early // exit (due to distance being too large) which is common, then // we need not read in the actual point index, thus saving main // memory bandwidth. If the distance to point is less than the // ballsize, though, then we need the index. // indexofi = this.Parent.Indices[i]; } else { // // but if we are not using the rearranged data, then // we must always indexofi = this.Parent.Indices[i]; early_exit = false; distance = 0.0F; for (int k = 0; k < 3; k++) { float f = this.Parent.TreeVectors[Convert.ToInt32(indexofi)].Vector[k] - sr.VectorTarget[k]; distance += f * f; if (distance > ballsize) { early_exit = true; break; } } if (early_exit) { continue; // next iteration of mainloop } } // end if rearrange. KDTreeResult e = new KDTreeResult(indexofi, distance); //sr.result.push_back(e); sr.SearchResult.Add(e); } }
public void process_leaf_node(SearchRecord sr) { float ballsize = sr.Radius; // bool rearrange = sr.rearrange; for (int i = IndexLeafVector; i <= endIndex; i++) { uint indexofi; // sr.ind[i]; float distance; if (rearrange) { if (CheckDistance(this.Parent.TreeVectors[i].Vector, sr.VectorTarget, ballsize, out distance)) { continue;// next iteration of mainloop } // why do we do things like this? because if we take an early // exit (due to distance being too large) which is common, then // we need not read in the actual point index, thus saving main // memory bandwidth. If the distance to point is less than the // ballsize, though, then we need the index. // indexofi = this.Parent.Indices[i]; } else { // // but if we are not using the rearranged data, then // we must always compare all indexofi = this.Parent.Indices[i]; if (CheckDistance(this.Parent.TreeVectors[Convert.ToInt32(indexofi)].Vector, sr.VectorTarget, ballsize, out distance)) { continue;// next iteration of mainloop } } // end if rearrange. // here the point must be added to the list. // // two choices for any point. The list so far is either // undersized, or it is not. // if (sr.SearchResult.Count < sr.NumberOfNeighbours) { KDTreeResult e = new KDTreeResult(indexofi, distance); if (!this.Parent.TakenAlgorithm) { sr.SearchResult.Add(e); if (sr.SearchResult.Count == sr.NumberOfNeighbours) { ballsize = sr.SearchResult[0].Distance; } } else { if (!this.Parent.TreeVectors[Convert.ToInt32(indexofi)].TakenInTree) { this.Parent.TreeVectors[Convert.ToInt32(indexofi)].TakenInTree = true; sr.SearchResult.Add(e); if (sr.SearchResult.Count == sr.NumberOfNeighbours) { ballsize = sr.SearchResult[0].Distance; } } else { } } // Set the ball radius to the largest on the list (maximum priority). } else { // // if we get here then the current node, has a squared // distance smaller // than the last on the list, and belongs on the list. // KDTreeResult e = new KDTreeResult(indexofi, distance); ballsize = sr.SearchResult.ReplaceLast_ReturnFirst(e); } if (distance == 0f) { break; } } // main loop sr.Radius = ballsize; }