Locate the k_closest points to query_point_, and return their distances and data into the given buffers.
| 154 | /// Locate the k_closest points to query_point_, and return their distances and |
| 155 | /// data into the given buffers. |
| 156 | void KDTreeSearch::Search(int *result_count, |
| 157 | FLOAT32 *distances, |
| 158 | void **results) { |
| 159 | if (tree_->Root.Left == NULL) { |
| 160 | *result_count = 0; |
| 161 | } else { |
| 162 | for (int i = 0; i < tree_->KeySize; i++) { |
| 163 | sb_min_[i] = tree_->KeyDesc[i].Min; |
| 164 | sb_max_[i] = tree_->KeyDesc[i].Max; |
| 165 | } |
| 166 | SearchRec(0, tree_->Root.Left); |
| 167 | int count = results_.elements_count(); |
| 168 | *result_count = count; |
| 169 | for (int j = 0; j < count; j++) { |
| 170 | // TODO: why FLOAT64 here? |
| 171 | distances[j] = (FLOAT32) sqrt((FLOAT64)results_.elements()[j].key); |
| 172 | results[j] = results_.elements()[j].value; |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | /*----------------------------------------------------------------------------- |
| 178 | Public Code |
no test coverage detected